buyagainList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  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. }
  139. },
  140. created() {
  141. this.setScrollHeight()
  142. this.$parent.getClubProductNum()
  143. this.initGetStotage()
  144. },
  145. filters: {
  146. NumFormat: function(text) {
  147. //处理金额
  148. return Number(text).toFixed(2)
  149. }
  150. },
  151. computed: {
  152. ...mapState(['hasLogin', 'userInfo'])
  153. },
  154. methods: {
  155. async initGetStotage() {
  156. // 初始化
  157. const userInfo = await this.$api.getStorage()
  158. const clubInfo = await this.$api.getComStorage('orderUserInfo')
  159. this.userId = clubInfo.userId ? clubInfo.userId : 0
  160. this.getProductAgainInfo(false)
  161. },
  162. scrolltolower() {
  163. if (this.hasNextPage && this.pullFlag) {
  164. this.getProductAgainInfo(true)
  165. }
  166. },
  167. setScrollHeight() {
  168. const { windowHeight, pixelRatio } = wx.getSystemInfoSync()
  169. this.windowHeight = windowHeight - 1
  170. this.scrollHeight = windowHeight - 1
  171. },
  172. getProductAgainInfo(loadMore) {
  173. this.showLoading = true
  174. this.loadingNow = true
  175. this.loadingText = '加载中'
  176. this.isShowEmpty = false
  177. if (loadMore) {
  178. this.pageNum += 1
  179. }
  180. this.ProductService.GetRepeatBuyAgainProductList({
  181. userId: this.userId,
  182. pageNum: this.pageNum,
  183. pageSize: this.pageSize
  184. })
  185. .then(response => {
  186. this.isShowWrapper = true
  187. this.showSkeleton = false
  188. const listData = response.data.results
  189. if (listData && listData.length > 0) {
  190. this.hasNextPage = response.data.hasNextPage
  191. this.isShowEmpty = false
  192. if (loadMore) {
  193. this.productList = [...this.productList, ...listData]
  194. } else {
  195. this.productList = listData
  196. console.log(this.productList)
  197. }
  198. //价格显示处理
  199. let isActFlg,
  200. newProductList = []
  201. this.productList.map((item, index) => {
  202. console.log(item)
  203. if (item.actStatus == 1) {
  204. isActFlg = true
  205. } else if (item.actStatus == 1 && item.ladderPriceFlag == 1) {
  206. isActFlg = true
  207. } else {
  208. isActFlg = false
  209. }
  210. newProductList.push(Object.assign({}, item, { isShowActFlg: isActFlg }))
  211. })
  212. this.productList = newProductList
  213. console.log(this.productList)
  214. // 防上拉暴滑
  215. this.pullFlag = false
  216. setTimeout(() => {
  217. this.pullFlag = true
  218. }, 500)
  219. // 底部提示文案
  220. if (this.hasNextPage) {
  221. this.loadingText = '上拉加载更多'
  222. } else {
  223. this.showLoading = true
  224. this.loadingNow = false
  225. }
  226. } else {
  227. if (!loadMore) {
  228. this.isShowEmpty = true
  229. }
  230. }
  231. })
  232. .catch(error => {
  233. this.$util.msg(error.msg, 2000)
  234. })
  235. },
  236. operationHanld(prop) {
  237. this.$emit('operationConfim', prop)
  238. },
  239. navToDetailPage(id) {
  240. this.isModallayer = true
  241. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  242. this.isModallayer = false
  243. },
  244. repurchModel() {
  245. this.$util.modal('', '此商品的价格有变化,原来的购买价已不适用', '知道了', '', false, () => {})
  246. },
  247. PromotionsFormat(promo) {
  248. //促销活动类型数据处理
  249. if (promo != null) {
  250. if (promo.type == 1 && promo.mode == 1) {
  251. return true
  252. } else {
  253. return false
  254. }
  255. }
  256. return false
  257. },
  258. onShowClose() {
  259. //输入框失去焦点时触发
  260. if (this.searchInputVal != '') {
  261. this.isShowClose = true
  262. } else {
  263. this.isShowClose = false
  264. }
  265. },
  266. delInputText() {
  267. //清除输入框内容
  268. this.searchInputVal = ''
  269. this.isShowClose = false
  270. },
  271. btnClick() {
  272. this.$emit('goCartPage')
  273. },
  274. btnTouchstart() {
  275. // console.log('btnTouchstart');
  276. },
  277. btnTouchend() {
  278. // console.log('btnTouchend');
  279. }
  280. }
  281. }
  282. </script>
  283. <style lang="scss">
  284. .commodity-list-wrapper {
  285. scroll-view {
  286. height: 100%;
  287. }
  288. .empty-container-image {
  289. margin-top: -300rpx;
  290. }
  291. .toIndexPage {
  292. bottom: 390rpx;
  293. }
  294. .show-more-btn {
  295. width: 276rpx;
  296. height: 52rpx;
  297. line-height: 52rpx;
  298. border: 2rpx solid #d8d8d8;
  299. background: #f7f7f7;
  300. font-size: 26rpx;
  301. margin: 26rpx 0;
  302. position: absolute;
  303. left: 50%;
  304. margin-left: -138rpx;
  305. }
  306. }
  307. .all-type-list-content {
  308. height: auto;
  309. padding: 24rpx;
  310. background: #fff;
  311. margin-bottom: 2rpx;
  312. display: flex;
  313. flex-direction: row;
  314. box-sizing: content-box;
  315. .list-img {
  316. width: 240rpx;
  317. height: 240rpx !important;
  318. margin-right: 26rpx;
  319. border-radius: 10rpx;
  320. border: 2rpx solid #f3f3f3;
  321. }
  322. }
  323. .list-details-info {
  324. width: 442rpx;
  325. flex-direction: column;
  326. font-size: 26rpx;
  327. position: relative;
  328. .list-details-title {
  329. line-height: 38rpx;
  330. text-overflow: ellipsis;
  331. overflow: hidden;
  332. display: -webkit-box;
  333. -webkit-line-clamp: 2;
  334. line-clamp: 2;
  335. -webkit-box-orient: vertical;
  336. }
  337. .list-details-specs {
  338. width: 100%;
  339. display: inline-block;
  340. margin-top: 8rpx;
  341. color: #999999;
  342. }
  343. .list-details-miniQuantity {
  344. width: 100%;
  345. display: inline-block;
  346. margin-top: 7rpx;
  347. }
  348. }
  349. .list-details-price {
  350. width: 100%;
  351. float: left;
  352. line-height: 54rpx;
  353. .floor-item-act {
  354. height: 54rpx;
  355. text-align: center;
  356. box-sizing: border-box;
  357. float: left;
  358. padding: 11rpx 0;
  359. }
  360. .price-icon {
  361. width: 22rpx;
  362. height: 28rpx;
  363. vertical-align: middle;
  364. margin-right: 10rpx;
  365. }
  366. .price-icon + text {
  367. font-size: 25rpx;
  368. vertical-align: middle;
  369. }
  370. .list-login-now {
  371. width: 375rpx;
  372. color: #f8c499;
  373. .p-no {
  374. float: left;
  375. font-size: $font-size-24;
  376. color: $color-system;
  377. margin-right: 10rpx;
  378. }
  379. }
  380. .login-now {
  381. padding: 10rpx 10rpx 10rpx 0;
  382. }
  383. .list-none {
  384. margin-top: 15rpx;
  385. .price-small {
  386. font-size: $font-size-24;
  387. line-height: 40rpx;
  388. color: #ff2a2a;
  389. }
  390. }
  391. .list-shop {
  392. height: auto;
  393. float: left;
  394. .list-price {
  395. width: 100%;
  396. color: #ff2a2a;
  397. float: left;
  398. line-height: 54rpx;
  399. align-items: center;
  400. justify-content: center;
  401. .price-larger {
  402. font-size: $font-size-30;
  403. display: inline-block;
  404. &.none {
  405. text-decoration: line-through;
  406. color: #999999;
  407. }
  408. }
  409. }
  410. .list-price-none {
  411. width: 100%;
  412. .price-none {
  413. text-decoration: line-through;
  414. color: #999999;
  415. display: inline-block;
  416. }
  417. .icon-wenhao {
  418. font-size: $font-size-32;
  419. color: #0091ff;
  420. margin-left: 6rpx;
  421. }
  422. }
  423. }
  424. .add-cart-btn {
  425. float: right;
  426. width: 140rpx;
  427. height: 54rpx;
  428. line-height: 54rpx;
  429. border-radius: 27rpx;
  430. color: #fff;
  431. font-size: 24rpx;
  432. margin-right: 0;
  433. background: #ffffff;
  434. border: 1px solid #c9c9c9;
  435. color: $text-color;
  436. }
  437. }
  438. .cart-icon {
  439. width: 92rpx;
  440. height: 92rpx;
  441. border-radius: 50%;
  442. background: rgba(255, 147, 0, 0.5);
  443. position: fixed;
  444. right: 24rpx;
  445. bottom: 28%;
  446. display: flex;
  447. align-items: center;
  448. justify-content: center;
  449. cursor: pointer;
  450. image {
  451. width: 58rpx;
  452. height: 58rpx;
  453. }
  454. text {
  455. font-size: 28rpx;
  456. position: absolute;
  457. top: -10rpx;
  458. right: 0;
  459. }
  460. }
  461. </style>