member-product.vue 9.1 KB

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