good-floor.vue 7.5 KB

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