classifyProductList.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <view class="container commodity-list-wrapper" :style="{'overflow':(showSkeleton? 'hidden' : 'auto'),'height': (showSkeleton? windowHeight + 'px' : 'auto')}">
  3. <list-skeleton v-if="showSkeleton" :listType='0'></list-skeleton>
  4. <scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="toLower" scroll-y v-if="listData.length > 0">
  5. <view v-for="(item,index) in listData" :key="index" :id="item.id" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.productID)">
  6. <image mode='widthFix' :src="item.mainImage" class="list-img" alt="list-img"></image>
  7. <view class="list-details-info">
  8. <text class="list-details-title">{{item.name}}</text>
  9. <text class="list-details-specs">规格:{{item.unit}}</text>
  10. <view class="list-details-specs" v-if="item.productCode!=''&&item.productCode!=null">商品编码:{{item.productCode}}</view>
  11. <view class="list-details-price">
  12. <view v-if="hasLogin" class="list-price">
  13. <view v-if="userIdentity == 1">
  14. <text>¥<text class="price-larger">{{item.retailPrice ? item.retailPrice.toFixed(2) : '0.00'}}</text></text>
  15. </view>
  16. <view v-if="userIdentity == 4">
  17. <view class="price-larger" v-if="item.price1TextFlag == '1'">
  18. <text class="txt">未公开价格</text>
  19. </view>
  20. <view v-else>
  21. <view class="price-larger" v-if="item.price1TextFlag == '2'">
  22. <text class="txt">价格仅会员可见</text>
  23. <text class="btn" @click.stop="this.$api.navigateTo(`/pages/login/apply?clubStatus=${clubStatus}`)">去升级</text>
  24. </view>
  25. <text v-else>¥<text class="price-larger">{{item.retailPrice ? item.retailPrice.toFixed(2) :'0.00'}}</text></text>
  26. </view>
  27. </view>
  28. <view v-if="userIdentity == 2">
  29. <view class="price-larger" v-if="item.price1TextFlag == '1'">
  30. <text class="txt">未公开价格</text>
  31. </view>
  32. <text>¥<text class="price-larger">{{item.retailPrice ? item.retailPrice.toFixed(2) :'0.00'}}</text></text>
  33. </view>
  34. </view>
  35. <view v-else class="list-login-now">
  36. <text class="p-no">价格:</text>
  37. <uni-stars :stars="parseInt(item.price1Grade)" :font-size='36' :width-info="180"></uni-stars>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view v-if="showLoading && listData.length > 4">
  43. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
  44. <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
  45. </view>
  46. </scroll-view>
  47. <view class="empty-container" v-if="showEmpty">
  48. <image class="empty-container-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AY2ZjAABpmnBICH4247.png"></image>
  49. <text class="error-text">{{emptyText}}</text>
  50. </view>
  51. <!-- 透明模态层 -->
  52. <modal-layer v-if='isModallayer'></modal-layer>
  53. </view>
  54. </template>
  55. <script>
  56. import listSkeleton from '@/components/cm-module/listTemplate/listSkeleton'
  57. import modalLayer from "@/components/modal-layer"
  58. import uniStars from '@/components/uni-stars/uni-stars.vue'
  59. import { searchQueryTinyType,querySearchProductPrice} from "@/api/product.js"
  60. import { mapState,mapMutations } from 'vuex';
  61. export default{
  62. name:'CommodityList',
  63. components:{
  64. listSkeleton,
  65. modalLayer,
  66. uniStars
  67. },
  68. props: {
  69. emptyText: {
  70. type: String
  71. },
  72. serverUrl: {
  73. type: String
  74. },
  75. classifyID: {
  76. type:Number
  77. }
  78. },
  79. data(){
  80. return{
  81. clubStatus:'',
  82. isModallayer:false,
  83. windowHeight: '',
  84. showSkeleton: true,
  85. showEmpty: false,
  86. userID: '',
  87. userIdentity:'',
  88. scrollHeight: '',
  89. listData: [],
  90. showLoading: false,
  91. loadingNow: true,
  92. loadingText: '上拉加载更多',
  93. pageSize: 20,
  94. pageNum: 1,
  95. totalPage: 1,
  96. hasNextPage:false,
  97. pullFlag: true,
  98. cartNum: 0,
  99. }
  100. },
  101. created() {
  102. // console.log(this.typeId)
  103. this.setScrollHeight();
  104. this.$api.getComStorage('userInfo').then((resolve) =>{
  105. this.clubStatus = resolve.clubStatus
  106. this.userID = resolve.userID ? resolve.userID : '';
  107. this.userIdentity = resolve.userIdentity
  108. console.log(this.clubStatus)
  109. console.log(this.userID)
  110. console.log(this.userIdentity)
  111. this.getListFromServer();
  112. }).catch(error =>{
  113. this.getListFromServer();
  114. })
  115. },
  116. computed: {
  117. ...mapState(['hasLogin','userInfo'])
  118. },
  119. methods:{
  120. toLower() {
  121. if(this.totalPage>this.listData.length && this.pullFlag) {
  122. this.getListFromServer(true);
  123. }
  124. },
  125. setScrollHeight() {
  126. const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
  127. this.windowHeight = windowHeight - 1;
  128. this.scrollHeight = windowHeight - 1;
  129. },
  130. getListFromServer(loadMore) {
  131. this.getQueryGoodslist(loadMore)
  132. },
  133. getQueryGoodslist(loadMore){
  134. this.showLoading = true;
  135. this.loadingNow = true;
  136. this.loadingText = '加载中';
  137. if(loadMore) { this.pageNum += 1; }
  138. let params ={
  139. classifyId:this.classifyID,
  140. userId:this.userID,
  141. pageNum:this.pageNum,
  142. pageSize:this.pageSize,
  143. }
  144. this.CommonService.GetHomeClassify(params).then(response =>{
  145. const resList = response.data.results;
  146. if(resList && resList.length > 0){
  147. this.showEmpty = false
  148. this.hasNextPage = response.data.hasNextPage;
  149. if(loadMore) {
  150. this.listData = [...this.listData,...resList];
  151. this.showSkeleton = false
  152. } else {
  153. this.listData = [...resList];
  154. this.showSkeleton = false
  155. }
  156. // 防上拉暴滑
  157. this.pullFlag = false;
  158. setTimeout(()=>{ this.pullFlag = true; },500)
  159. // 底部提示文案
  160. if(this.hasNextPage) {
  161. this.loadingText = '上拉加载更多';
  162. } else {
  163. this.showLoading = true;
  164. this.loadingNow = false;
  165. }
  166. } else {
  167. if(!loadMore) { this.showEmpty = true; }
  168. }
  169. }).catch(error =>{
  170. this.$util.msg(error.msg,2000);
  171. })
  172. },
  173. navToDetailPage(id) {
  174. this.isModallayer = true;
  175. this.$api.navigateTo(`/pages/goods/product?id=${id}`);
  176. this.isModallayer = false;
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss">
  182. .commodity-list-wrapper {
  183. scroll-view {
  184. height: 100%;
  185. border-top: 2rpx solid rgba(0,0,0,0.07);
  186. }
  187. .empty-container-image {
  188. margin-top: -300rpx;
  189. }
  190. .toIndexPage {
  191. bottom: 390rpx;
  192. }
  193. .show-more-btn {
  194. width: 276rpx;
  195. height: 52rpx;
  196. line-height: 52rpx;
  197. border: 2rpx solid #D8D8D8;
  198. background: #F7F7F7;
  199. font-size: 26rpx;
  200. margin: 26rpx 0;
  201. position: absolute;
  202. left: 50%;
  203. margin-left: -138rpx;
  204. }
  205. }
  206. .all-type-list-content {
  207. height: 216rpx;
  208. padding: 24rpx;
  209. background: #fff;
  210. margin-bottom: 2rpx;
  211. display: flex;
  212. flex-direction: row;
  213. box-sizing: content-box;
  214. .list-img {
  215. width: 210rpx;
  216. height: 218rpx !important;
  217. margin-right: 26rpx;
  218. border-radius: 10rpx;
  219. border: 2rpx solid #f3f3f3;
  220. }
  221. }
  222. .list-details-info {
  223. width: 466rpx;
  224. display: flex;
  225. flex-direction: column;
  226. font-size: 26rpx;
  227. position: relative;
  228. .list-details-title {
  229. line-height: 38rpx;
  230. text-overflow: ellipsis;
  231. overflow: hidden;
  232. display: -webkit-box;
  233. -webkit-line-clamp: 2;
  234. line-clamp: 2;
  235. -webkit-box-orient: vertical;
  236. }
  237. .list-details-specs {
  238. margin-top: 8rpx;
  239. color: #666666;
  240. }
  241. .list-details-miniQuantity {
  242. margin-top: 7rpx;
  243. }
  244. }
  245. .list-details-price {
  246. width: 100%;
  247. display: flex;
  248. flex-direction: row;
  249. justify-content: space-between;
  250. position: absolute;
  251. bottom: 0;
  252. right: 0;
  253. .price-icon {
  254. width: 22rpx;
  255. height: 28rpx;
  256. vertical-align: middle;
  257. margin-right: 10rpx;
  258. }
  259. .price-icon + text {
  260. font-size: 25rpx;
  261. vertical-align: middle;
  262. }
  263. .list-login-now {
  264. width: 375rpx;
  265. color: #F8C499;
  266. position: absolute;
  267. bottom: 0;
  268. .p-no{
  269. float: left;
  270. font-size: $font-size-24;
  271. color: $color-system;
  272. margin-right: 10rpx;
  273. }
  274. }
  275. .login-now {
  276. padding: 10rpx 10rpx 10rpx 0;
  277. }
  278. .list-price {
  279. color: #FF2A2A;
  280. width: 100%;
  281. height: 44rpx;
  282. .price-larger {
  283. width: 100%;
  284. height: 44rpx;
  285. font-size: 32rpx;
  286. &.small{
  287. font-size: $font-size-24;
  288. }
  289. .txt{
  290. font-size: $font-size-24;
  291. display: inline-block;
  292. line-height: 44rpx;
  293. text-align: left;
  294. float: left;
  295. }
  296. .btn{
  297. width: 112rpx;
  298. height: 44rpx;
  299. display: inline-block;
  300. float: right;
  301. background: $btn-confirm;
  302. line-height: 44rpx;
  303. text-align: center;
  304. color: #FFFFFF;
  305. font-size: $font-size-24;
  306. border-radius: 22rpx;
  307. }
  308. }
  309. }
  310. .add-cart-btn {
  311. width: 156rpx;
  312. height: 64rpx;
  313. line-height: 64rpx;
  314. border-radius: 32rpx;
  315. color: #fff;
  316. font-size: 26rpx;
  317. margin-right: 0;
  318. background:linear-gradient(45deg,rgba(255,41,41,1) 0%,rgba(255,109,27,1) 100%);
  319. }
  320. }
  321. .cart-icon {
  322. width: 92rpx;
  323. height: 92rpx;
  324. border-radius: 50%;
  325. background: rgba(255, 147, 0, 0.5);
  326. position: fixed;
  327. right: 24rpx;
  328. bottom: 30%;
  329. display: flex;
  330. align-items: center;
  331. justify-content: center;
  332. cursor: pointer;
  333. image {
  334. width: 58rpx;
  335. height: 58rpx;
  336. }
  337. text {
  338. font-size: 28rpx;
  339. position: absolute;
  340. top: -10rpx;
  341. right: 0;
  342. }
  343. }
  344. </style>