good-floor.vue 7.7 KB

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