buyagainList.vue 12 KB

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