member-product.vue 9.0 KB

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