productList.vue 15 KB

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