buyagainList.vue 11 KB

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