buyagainList.vue 12 KB

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