member-product.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <view class="container clearfix" v-if="isRequest">
  3. <view class="cm-member-top"> <image class="banner" :src="banner" mode=""></image> </view>
  4. <view class="cm-member-main ">
  5. <view class="cm-member-product clearfix">
  6. <view
  7. v-for="(pro, index) in productList"
  8. :key="index"
  9. :id="pro.productId"
  10. class="product-list"
  11. @click="productDetail(pro.productId)"
  12. >
  13. <view class="product-image"> <image :src="pro.image" mode=""></image> </view>
  14. <view class="product-mains">
  15. <view class="product-name"> {{ pro.name }} </view>
  16. <view class="product-tags">
  17. <view class="floor-item-act">
  18. <view class="coupon-tags" v-if="pro.couponsLogo">优惠券</view>
  19. <template v-if="pro.actStatus == 1">
  20. <view class="floor-tags" v-if="PromotionsFormat(pro.promotions)">
  21. {{ pro.promotions.name }}
  22. <text v-if="pro.priceFlag != 1">:¥{{ pro.price | NumFormat }}</text>
  23. </view>
  24. <view class="floor-tags" v-else>{{ pro.promotions.name }}</view>
  25. </template>
  26. <template v-if="pro.svipProductFlag == 1">
  27. <view class="svip-tags">
  28. <view class="tags" :class="{ none: !isShowVipFlag }">SVIP</view>
  29. <view class="price" v-if="isShowVipFlag(pro)">{{ pro.svipPriceTag }}</view>
  30. </view>
  31. </template>
  32. </view>
  33. </view>
  34. <view class="product-price" v-if="hasLogin">
  35. <!-- 价格未公开 -->
  36. <view class="list-none" v-if="pro.priceFlag == 1">¥未公开价格</view>
  37. <!-- 价格公开 -->
  38. <template v-else>
  39. <!-- 个人机构且不是超级会员 -->
  40. <template v-if="userIdentity == 4 && vipFlag != 1">
  41. <!-- 价格仅会员可见 -->
  42. <view class="list-none" v-if="pro.priceFlag == 2"
  43. >¥价格仅会员可见</view
  44. >
  45. <!-- 价格仅医美机构可见 -->
  46. <view class="list-none" v-else-if="pro.priceFlag == 3"
  47. >¥仅医美机构可见</view
  48. >
  49. <view class="list-none-price" v-else>¥{{ pro.originalPrice | NumFormat }}</view>
  50. </template>
  51. <!-- 资质机构 || 个人机构且是超级会员 -->
  52. <template v-else>
  53. <!-- 价格仅医美机构可见 -->
  54. <view class="list-none" v-if="pro.priceFlag == 3 && firstClubType!=1"
  55. >¥仅医美机构可见</view
  56. >
  57. <view class="list-none-price" v-else>¥{{ pro.originalPrice | NumFormat }}</view>
  58. </template>
  59. </template>
  60. </view>
  61. <view v-else class="product-price-none">
  62. <text class="p-no">¥</text>
  63. <uni-grader :grade="Number(pro.priceGrade)"></uni-grader>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. <!--加载loadding-->
  69. <tui-loadmore :visible="loadding" :index="3" type="black" />
  70. <tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText" />
  71. <!--加载loadding-->
  72. </view>
  73. <!-- 透明模态层 -->
  74. <modal-layer v-if="isModallayer" />
  75. </view>
  76. </template>
  77. <script>
  78. import { mapState, mapMutations } from 'vuex'
  79. import modalLayer from '@/components/modal-layer'
  80. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  81. export default {
  82. components: {
  83. modalLayer,
  84. uniGrader
  85. },
  86. data() {
  87. return {
  88. StaticUrl: this.$Static,
  89. isModallayer: false,
  90. banner: '',
  91. listQuery: {
  92. userId: 0,
  93. source: 2,
  94. pageNum: 1,
  95. pageSize: 10
  96. },
  97. vipFlag: 0,
  98. userIdentity: 0,
  99. firstClubType:0,
  100. productList: [],
  101. nomoreText: '上拉显示更多',
  102. hasNextPage: false,
  103. loadding: false,
  104. pullUpOn: true,
  105. pullFlag: true,
  106. isRequest: false
  107. }
  108. },
  109. onLoad() {
  110. this.initGetStotage()
  111. },
  112. filters: {
  113. NumFormat: function(text) {
  114. //处理金额
  115. return Number(text).toFixed(2)
  116. }
  117. },
  118. computed: {
  119. ...mapState(['hasLogin', 'clubType'])
  120. },
  121. methods: {
  122. async initGetStotage() {
  123. const userInfo = await this.$api.getStorage()
  124. this.listQuery.userId = userInfo.userId ? userInfo.userId : 0
  125. this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
  126. this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
  127. this.firstClubType = this.clubType
  128. this.getSvipProductPage()
  129. },
  130. getSvipProductPage() {
  131. // 获取会员优惠商品列表
  132. this.coupinList = []
  133. this.listQuery.pageNum = 1
  134. this.ProductService.getSvipProductPage(this.listQuery)
  135. .then(response => {
  136. let data = response.data.svipProductPage
  137. this.banner = response.data.adsImage
  138. if (data.results && data.results.length > 0) {
  139. this.showEmpty = false
  140. this.hasNextPage = data.hasNextPage
  141. this.productList = data.results
  142. this.pullFlag = false
  143. setTimeout(() => {
  144. this.pullFlag = true
  145. }, 500)
  146. if (this.hasNextPage) {
  147. this.pullUpOn = false
  148. this.nomoreText = '上拉显示更多'
  149. } else {
  150. if (this.coupinList.length < 8) {
  151. this.pullUpOn = true
  152. } else {
  153. this.pullUpOn = false
  154. this.loadding = false
  155. this.nomoreText = '已至底部'
  156. }
  157. }
  158. } else {
  159. this.showEmpty = true
  160. }
  161. this.isRequest = true
  162. })
  163. .catch(error => {
  164. this.$util.msg(error.msg, 2000)
  165. })
  166. },
  167. getOnReachBottomData() {
  168. // 上滑加载分页
  169. this.listQuery.pageNum += 1
  170. this.ProductService.getSvipProductPage(this.listQuery)
  171. .then(response => {
  172. let data = response.data.svipProductPage
  173. if (data.results && data.results.length > 0) {
  174. this.hasNextPage = data.hasNextPage
  175. this.productList = this.productList.concat(data.results)
  176. this.pullFlag = false // 防上拉暴滑
  177. setTimeout(() => {
  178. this.pullFlag = true
  179. }, 500)
  180. if (this.hasNextPage) {
  181. this.pullUpOn = false
  182. this.nomoreText = '上拉显示更多'
  183. } else {
  184. this.pullUpOn = false
  185. this.loadding = false
  186. this.nomoreText = '已至底部'
  187. }
  188. }
  189. })
  190. .catch(error => {
  191. this.$util.msg(error.msg, 2000)
  192. })
  193. },
  194. PromotionsFormat(promo) {
  195. //促销活动类型数据处理
  196. if (promo != null) {
  197. if (promo.type == 1 && promo.mode == 1) {
  198. return true
  199. } else {
  200. return false
  201. }
  202. }
  203. return false
  204. },
  205. productDetail(productId) {
  206. // 跳转商品详情
  207. this.isModallayer = true
  208. this.$api.navigateTo(`/pages/goods/product?id=${productId}`)
  209. this.isModallayer = false
  210. },
  211. isShowVipFlag(pros) {
  212. /**
  213. *显示SVIP和超级会员价格:
  214. * 个人机构(不是超级会员,但价格所有机构可见),
  215. * 资质机构(不是超级会员,但价格所有机构可见或仅会员可见),
  216. * 超级会员(价格所有机构可见或仅会员可见),超级会员(是医美机构,价格仅医美可见)
  217. *商品价格是否可见:priceFlag 0:所有机构可见 1:未公开价格 2:仅会员可见 3:仅医美机构可见
  218. * 普通机构
  219. * 超级会员 && priceFlag === 0
  220. * 资质机构
  221. * priceFlag !== 1 ||
  222. * 超级会员
  223. * 商品priceFlag === 3 && 是否是医美机构
  224. */
  225. // 未登录 || 非会员
  226. if(!this.hasLogin || !this.vipFlag === 1) return false
  227. // 商品所有机构可见
  228. if(pros.priceFlag === 0 ) return true
  229. // 商品价格仅资质机构可见
  230. if(pros.priceFlag === 2 && this.userIdentity === 2) return true
  231. // 商品价格仅医美机构可见
  232. if(pros.priceFlag === 3 && this.userIdentity === 2 && this.firstClubType == 1) return true
  233. // 其它
  234. return false
  235. },
  236. },
  237. onPullDownRefresh() {
  238. setTimeout(() => {
  239. this.getSvipProductPage()
  240. uni.stopPullDownRefresh()
  241. }, 200)
  242. },
  243. onReachBottom() {
  244. if (this.hasNextPage) {
  245. this.loadding = true
  246. this.pullUpOn = true
  247. this.getOnReachBottomData()
  248. }
  249. },
  250. onShareAppMessage(res) {
  251. //分享转发
  252. if (res.from === 'button') {
  253. // 来自页面内转发按钮
  254. }
  255. return {
  256. title: '采美超级会员,巨量优惠享不停',
  257. path: '/pages/user/member/member-product',
  258. imageUrl: 'https://static.caimei365.com/app/img/icon/icon-member-share@2x.png'
  259. }
  260. },
  261. onShow() {}
  262. }
  263. </script>
  264. <style lang="scss">
  265. page {
  266. background-color: #f7f7f7;
  267. }
  268. .container {
  269. width: 100%;
  270. height: auto;
  271. }
  272. .cm-member-top {
  273. width: 100%;
  274. height: 340rpx;
  275. box-sizing: border-box;
  276. padding: 0 24rpx;
  277. margin: 24rpx 0 0 0;
  278. .banner {
  279. width: 100%;
  280. height: 340rpx;
  281. display: block;
  282. border-radius: 16rpx;
  283. }
  284. }
  285. .cm-member-main {
  286. width: 100%;
  287. box-sizing: border-box;
  288. padding: 0 24rpx 24rpx 24rpx;
  289. background-color: #f7f7f7;
  290. .cm-member-product {
  291. width: 100%;
  292. margin-top: 24rpx;
  293. .product-list {
  294. width: 339rpx;
  295. height: 516rpx;
  296. border-radius: 16rpx;
  297. float: left;
  298. margin-right: 24rpx;
  299. margin-bottom: 24rpx;
  300. background-color: #ffffff;
  301. &:nth-child(2n) {
  302. margin-right: 0;
  303. }
  304. .product-image {
  305. width: 339rpx;
  306. height: 339rpx;
  307. image {
  308. width: 339rpx;
  309. height: 339rpx;
  310. display: block;
  311. border-radius: 16rpx 16rpx 0 0;
  312. }
  313. }
  314. .product-mains {
  315. width: 100%;
  316. height: auto;
  317. box-sizing: border-box;
  318. padding: 0 24rpx;
  319. margin-top: 8rpx;
  320. .product-name {
  321. height: 72rpx;
  322. line-height: 36rpx;
  323. text-overflow: ellipsis;
  324. overflow: hidden;
  325. display: -webkit-box;
  326. -webkit-line-clamp: 2;
  327. line-clamp: 2;
  328. -webkit-box-orient: vertical;
  329. font-size: $font-size-26;
  330. color: #333333;
  331. text-align: justify;
  332. }
  333. .product-tags {
  334. width: 100%;
  335. height: 32rpx;
  336. margin-top: 6rpx;
  337. .floor-item-act {
  338. width: 100%;
  339. height: 32rpx;
  340. text-align: center;
  341. box-sizing: border-box;
  342. float: left;
  343. }
  344. }
  345. .product-price {
  346. width: 100%;
  347. line-height: 37rpx;
  348. font-size: $font-size-26;
  349. color: #f94b4b;
  350. margin-top: 8rpx;
  351. .list-none-price {
  352. text-decoration: line-through;
  353. color: #999999;
  354. }
  355. }
  356. .product-price-none {
  357. color: #f8c499;
  358. float: left;
  359. line-height: 54rpx;
  360. .p-no {
  361. float: left;
  362. font-size: $font-size-24;
  363. color: $text-color;
  364. }
  365. }
  366. .product-svip {
  367. width: 100%;
  368. height: 32rpx;
  369. margin-top: 10rpx;
  370. .svip {
  371. padding-left: 44rpx;
  372. height: 32rpx;
  373. position: relative;
  374. .tags {
  375. width: 60rpx;
  376. height: 32rpx;
  377. background-color: #333333;
  378. text-align: center;
  379. line-height: 32rpx;
  380. font-size: $font-size-22;
  381. color: #f0cb72;
  382. position: absolute;
  383. left: 0;
  384. top: 0;
  385. border-radius: 8rpx 16rpx 8rpx 8rpx;
  386. }
  387. .price {
  388. height: 32rpx;
  389. box-sizing: border-box;
  390. border-radius: 0 8rpx 8rpx 0;
  391. background-color: #f0cb72;
  392. line-height: 32rpx;
  393. color: #333333;
  394. text-align: center;
  395. padding: 0 9rpx 0 25rpx;
  396. font-size: $font-size-26;
  397. float: left;
  398. }
  399. }
  400. }
  401. }
  402. }
  403. }
  404. }
  405. </style>