buyagainList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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"></list-skeleton>
  4. <view class="product-container" v-if="!isShowEmpty" :style="{paddingTop:searchStatus?'112rpx':''}">
  5. <scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="scrolltolower" scroll-y v-if="productList.length > 0">
  6. <view v-for="(item,index) in productList" :key="index" :id="item.productId" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.productId)">
  7. <image mode='widthFix' :src="item.image" 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 !=null ? item.unit : ''}}</text>
  11. <text class="list-details-miniQuantity">起订量:{{item.ladderPriceFlag == 1 ? item.maxBuyNumber : item.minBuyNumber}}</text>
  12. <view class="list-details-price">
  13. <view class="list-shop">
  14. <view class="list-price-none" v-if="item.repurchaseFlag == 1">
  15. <text class="price-none">¥{{item.originalPrice}}</text>
  16. <text class="iconfont icon-wenhao" @click.stop="repurchModel"></text>
  17. </view>
  18. <view class="list-price" v-else>
  19. <text class="price-larger" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  20. ¥{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price) | NumFormat }}
  21. </text>
  22. </view>
  23. </view>
  24. <button class="add-cart-btn" @click.stop="operationHanld(item)">数量</button>
  25. </view>
  26. <view class="list-details-price">
  27. <view class="floor-item-act">
  28. <view class="coupon-tags" v-if="item.couponsLogo">优惠券</view>
  29. <template v-if="item.actStatus==1">
  30. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  31. {{item.promotions.name}}<text>:¥{{ item.price | NumFormat }}</text>
  32. </view>
  33. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  34. </template>
  35. </view>
  36. <view class="floor-item-act">
  37. <view class="coupon-tags" v-if="item.couponsLogo">优惠券</view>
  38. <view class="floor-tags" v-if="item.actStatus ==0 && item.ladderPriceFlag==1">阶梯价格</view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view v-if="showLoading && productList.length > 4 && !showRegularBtn">
  44. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
  45. <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
  46. </view>
  47. </scroll-view>
  48. </view>
  49. <view class="empty-container" v-else>
  50. <image class="empty-container-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AWdWzAAGlgAP0das422.png" mode="aspectFit"></image>
  51. <text class="error-text">您还没有购买过任何商品哟~</text>
  52. </view>
  53. <!-- 可拖动悬浮按钮 -->
  54. <cm-drag :cartNum="cartQuantity"
  55. :isDock="true"
  56. :existTabBar="true"
  57. @btnClick="btnClick"
  58. @btnTouchstart="btnTouchstart"
  59. @btnTouchend="btnTouchend">
  60. </cm-drag>
  61. <!-- 透明模态层 -->
  62. <modal-layer v-if='isModallayer'></modal-layer>
  63. </view>
  64. </template>
  65. <script>
  66. import listSkeleton from '@/components/cm-module/listTemplate/listSkeleton'
  67. import modalLayer from "@/components/modal-layer"
  68. import uniStars from '@/components/uni-stars/uni-stars.vue'
  69. import cmDrag from '@/components/cm-custom/cm-drag.vue'
  70. import { mapState,mapMutations } from 'vuex';
  71. export default{
  72. name:'productList',
  73. components:{
  74. listSkeleton,
  75. modalLayer,
  76. uniStars,
  77. cmDrag
  78. },
  79. data(){
  80. return{
  81. isShowClose:false,
  82. searchInputVal:'',
  83. isModallayer:false,
  84. windowHeight: '',
  85. showSkeleton: true,
  86. isShowEmpty: false,
  87. userId: '',
  88. scrollHeight: '',
  89. productList: [],
  90. showLoading: false,
  91. loadingNow: true,
  92. loadingText: '上拉加载更多',
  93. pageSize: 10,
  94. pageNum: 1,
  95. hasNextPage: false,
  96. pullFlag: true,
  97. fromRegularPurchasePage: false,
  98. cartQuantity: 0,
  99. showRegularBtn: false,
  100. isPrecedence:false,
  101. windowWidth:'',
  102. windowHeight:'',
  103. }
  104. },
  105. created() {
  106. this.setScrollHeight();
  107. this.$parent.getClubProductNum()
  108. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  109. this.userId = resolve.userID
  110. this.getProductAgainInfo(false)
  111. })
  112. },
  113. filters: {
  114. NumFormat:function(text) {//处理金额
  115. return Number(text).toFixed(2);
  116. },
  117. },
  118. computed: {
  119. ...mapState(['hasLogin','userInfo'])
  120. },
  121. methods:{
  122. scrolltolower() {
  123. if(this.hasNextPage && this.pullFlag) {
  124. this.getProductAgainInfo(true);
  125. }
  126. },
  127. setScrollHeight() {
  128. const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
  129. this.windowHeight = windowHeight - 1;
  130. this.scrollHeight = windowHeight - 1;
  131. },
  132. getProductAgainInfo(loadMore) {
  133. this.showLoading = true;
  134. this.loadingNow = true;
  135. this.loadingText = '加载中';
  136. this.isShowEmpty = false;
  137. if(loadMore) {this.pageNum += 1;}
  138. this.ProductService.GetRepeatBuyAgainProductList(
  139. {
  140. userId:this.userId,
  141. pageNum:this.pageNum,
  142. pageSize:this.pageSize,
  143. }
  144. )
  145. .then(response =>{
  146. this.isShowWrapper = true
  147. this.showSkeleton = false;
  148. const listData = response.data.results;
  149. if(listData && listData.length > 0){
  150. this.hasNextPage = response.data.hasNextPage;
  151. this.isShowEmpty = false;
  152. if(loadMore) {
  153. this.productList = [...this.productList,...listData];
  154. } else {
  155. this.productList = listData;
  156. console.log(this.productList)
  157. }
  158. //价格显示处理
  159. let isActFlg,newProductList=[];
  160. this.productList.map((item, index)=> {
  161. console.log(item)
  162. if(item.actStatus == 1){
  163. isActFlg = true
  164. }else if(item.actStatus == 1 && item.ladderPriceFlag == 1){
  165. isActFlg = true
  166. }else{
  167. isActFlg = false
  168. }
  169. newProductList.push(Object.assign({},item,{isShowActFlg:isActFlg}))
  170. })
  171. this.productList = newProductList
  172. console.log(this.productList)
  173. // 防上拉暴滑
  174. this.pullFlag = false;
  175. setTimeout(()=>{
  176. this.pullFlag = true;
  177. },500)
  178. // 底部提示文案
  179. if(this.hasNextPage) {
  180. this.loadingText = '上拉加载更多';
  181. } else {
  182. this.showLoading = true;
  183. this.loadingNow = false;
  184. }
  185. } else {
  186. if(!loadMore) {
  187. this.isShowEmpty = true;
  188. }
  189. }
  190. })
  191. .catch(error =>{
  192. this.$util.msg(error.msg,2000);
  193. })
  194. },
  195. operationHanld(prop){
  196. this.$emit('operationConfim',prop)
  197. },
  198. navToDetailPage(id) {
  199. this.isModallayer = true;
  200. this.$api.navigateTo(`/pages/goods/product?id=${id}`);
  201. this.isModallayer = false;
  202. },
  203. repurchModel(){
  204. this.$util.modal('','此商品的价格有变化,原来的购买价已不适用','知道了','',false,() =>{})
  205. },
  206. PromotionsFormat(promo){//促销活动类型数据处理
  207. if(promo!=null){
  208. if(promo.type == 1 && promo.mode == 1){
  209. return true
  210. }else{
  211. return false
  212. }
  213. }
  214. return false
  215. },
  216. onShowClose () {//输入框失去焦点时触发
  217. if(this.searchInputVal != ''){
  218. this.isShowClose = true
  219. }else{
  220. this.isShowClose = false
  221. }
  222. },
  223. delInputText(){//清除输入框内容
  224. this.searchInputVal = ''
  225. this.isShowClose = false
  226. },
  227. btnClick() {
  228. this.$emit('goCartPage')
  229. },
  230. btnTouchstart() {
  231. // console.log('btnTouchstart');
  232. },
  233. btnTouchend() {
  234. // console.log('btnTouchend');
  235. }
  236. }
  237. }
  238. </script>
  239. <style lang="scss">
  240. .commodity-list-wrapper {
  241. scroll-view {
  242. height: 100%;
  243. }
  244. .empty-container-image {
  245. margin-top: -300rpx;
  246. }
  247. .toIndexPage {
  248. bottom: 390rpx;
  249. }
  250. .show-more-btn {
  251. width: 276rpx;
  252. height: 52rpx;
  253. line-height: 52rpx;
  254. border: 2rpx solid #D8D8D8;
  255. background: #F7F7F7;
  256. font-size: 26rpx;
  257. margin: 26rpx 0;
  258. position: absolute;
  259. left: 50%;
  260. margin-left: -138rpx;
  261. }
  262. }
  263. .all-type-list-content {
  264. height: auto;
  265. padding: 24rpx;
  266. background: #fff;
  267. margin-bottom: 2rpx;
  268. display: flex;
  269. flex-direction: row;
  270. box-sizing: content-box;
  271. .list-img {
  272. width: 240rpx;
  273. height: 240rpx !important;
  274. margin-right: 26rpx;
  275. border-radius: 10rpx;
  276. border: 2rpx solid #f3f3f3;
  277. }
  278. }
  279. .list-details-info {
  280. width: 442rpx;
  281. flex-direction: column;
  282. font-size: 26rpx;
  283. position: relative;
  284. .list-details-title {
  285. line-height: 38rpx;
  286. text-overflow: ellipsis;
  287. overflow: hidden;
  288. display: -webkit-box;
  289. -webkit-line-clamp: 2;
  290. line-clamp: 2;
  291. -webkit-box-orient: vertical;
  292. }
  293. .list-details-specs {
  294. width: 100%;
  295. display: inline-block;
  296. margin-top: 8rpx;
  297. color: #999999;
  298. }
  299. .list-details-miniQuantity {
  300. width: 100%;
  301. display: inline-block;
  302. margin-top: 7rpx;
  303. }
  304. }
  305. .list-details-price {
  306. width: 100%;
  307. float: left;
  308. line-height: 54rpx;
  309. .floor-item-act{
  310. height: 54rpx;
  311. text-align: center;
  312. box-sizing: border-box;
  313. float: left;
  314. padding: 11rpx 0;
  315. .coupon-tags{
  316. height: 32rpx;
  317. box-sizing: border-box;
  318. border-radius: 8rpx;
  319. background-color: #fff1eb;
  320. line-height: 28rpx;
  321. color: #f94b4b;
  322. text-align: center;
  323. display: inline-block;
  324. padding:0 10rpx;
  325. font-size: $font-size-20;
  326. border: 1px solid #f94b4b;
  327. float: left;
  328. margin-right: 12rpx;
  329. }
  330. .floor-tags{
  331. height: 32rpx;
  332. box-sizing: border-box;
  333. border-radius: 8rpx;
  334. background-color: #FFFFFF;
  335. line-height: 28rpx;
  336. color: $color-system;
  337. text-align: center;
  338. display: inline-block;
  339. padding:0 16rpx;
  340. font-size: $font-size-20;
  341. border: 1px solid #E15616;
  342. float: left;
  343. }
  344. }
  345. .price-icon {
  346. width: 22rpx;
  347. height: 28rpx;
  348. vertical-align: middle;
  349. margin-right: 10rpx;
  350. }
  351. .price-icon + text {
  352. font-size: 25rpx;
  353. vertical-align: middle;
  354. }
  355. .list-login-now {
  356. width: 375rpx;
  357. color: #F8C499;
  358. .p-no{
  359. float: left;
  360. font-size: $font-size-24;
  361. color: $color-system;
  362. margin-right: 10rpx;
  363. }
  364. }
  365. .login-now {
  366. padding: 10rpx 10rpx 10rpx 0;
  367. }
  368. .list-none{
  369. margin-top: 15rpx;
  370. .price-small{
  371. font-size:$font-size-24;
  372. line-height: 40rpx;
  373. color: #FF2A2A;
  374. }
  375. }
  376. .list-shop{
  377. height: auto;
  378. float: left;
  379. .list-price {
  380. width: 100%;
  381. color: #FF2A2A;
  382. float: left;
  383. line-height:54rpx ;
  384. align-items: center;
  385. justify-content: center;
  386. .price-larger {
  387. font-size: $font-size-30;
  388. display: inline-block;
  389. &.none{
  390. text-decoration: line-through;
  391. color: #999999;
  392. }
  393. }
  394. }
  395. .list-price-none{
  396. width: 100%;
  397. .price-none{
  398. text-decoration: line-through;
  399. color: #999999;
  400. display: inline-block;
  401. }
  402. .icon-wenhao{
  403. font-size: $font-size-32;
  404. color: #0091FF;
  405. margin-left: 6rpx;
  406. }
  407. }
  408. }
  409. .add-cart-btn {
  410. float: right;
  411. width: 140rpx;
  412. height: 54rpx;
  413. line-height: 54rpx;
  414. border-radius: 27rpx;
  415. color: #fff;
  416. font-size: 24rpx;
  417. margin-right: 0;
  418. background:#FFFFFF;
  419. border: 1px solid #C9C9C9;
  420. color: $text-color;
  421. }
  422. }
  423. .cart-icon {
  424. width: 92rpx;
  425. height: 92rpx;
  426. border-radius: 50%;
  427. background: rgba(255, 147, 0, 0.5);
  428. position: fixed;
  429. right: 24rpx;
  430. bottom: 28%;
  431. display: flex;
  432. align-items: center;
  433. justify-content: center;
  434. cursor: pointer;
  435. image {
  436. width: 58rpx;
  437. height: 58rpx;
  438. }
  439. text {
  440. font-size: 28rpx;
  441. position: absolute;
  442. top: -10rpx;
  443. right: 0;
  444. }
  445. }
  446. </style>