classifyProductList.vue 11 KB

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