buyagainList.vue 11 KB

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