good-floor.vue 7.5 KB

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