buyagainList.vue 11 KB

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