coupon-product.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <view class="container floor clearfix">
  3. <tui-skeleton
  4. v-if="skeletonShow"
  5. backgroundColor="#fafafa"
  6. borderRadius="10rpx"
  7. :isLoading="true"
  8. :loadingType="5"
  9. ></tui-skeleton>
  10. <!-- 楼层 -->
  11. <view class="container-section tui-skeleton">
  12. <view class="floor-item-banner ad_01" v-if="appletsBanner">
  13. <image class="item-img-gg" :src="appletsBanner"></image>
  14. </view>
  15. <view class="section_page_main clearfix">
  16. <view
  17. class="floor-item clearfix"
  18. v-for="(pros, idx) in productList"
  19. :key="idx"
  20. @click.stop="navToDetailPage(pros.productId)"
  21. >
  22. <image class="item-img tui-skeleton-fillet" :src="pros.image" mode="aspectFill"></image>
  23. <view class="floor-item-content">
  24. <view class="title tui-skeleton-rect">
  25. <text class="mclap-tag" v-if="pros.beautyActFlag == '1'">美博会</text>
  26. <text class="mclap" :class="pros.beautyActFlag == '1' ? 'indent' : ''"
  27. >{{ pros.name }}
  28. </text>
  29. </view>
  30. <view class="floor-item-price">
  31. <view class="floor-item-act">
  32. <view class="coupon-tags">优惠券</view>
  33. <template v-if="pros.actStatus === 1">
  34. <view class="floor-tags" v-if="PromotionsFormat(pros.promotions)">
  35. {{ pros.promotions.name }}
  36. <text v-if="pros.priceFlag != 1">:¥{{ pros.price | NumFormat }}</text>
  37. </view>
  38. <view class="floor-tags" v-else>{{ pros.promotions.name }}</view>
  39. </template>
  40. <template v-if="pros.svipProductFlag == 1">
  41. <view class="svip-tags">
  42. <view class="tags" :class="{ none: vipFlag != 1 }">SVIP</view>
  43. <view class="price" v-if="isShowVipFlag(pros)">{{ pros.svipPriceTag }}</view>
  44. </view>
  45. </template>
  46. </view>
  47. <view>
  48. <template v-if="userIdentity === 4 && vipFlag != 1">
  49. <view class="title-none" v-if="pros.priceFlag === 1">
  50. <text class="p big">¥未公开价格</text>
  51. </view>
  52. <view class="title-none" v-if="pros.priceFlag === 2">
  53. <text class="p big">¥价格仅会员可见</text>
  54. </view>
  55. <view
  56. class="price tui-skeleton-rect"
  57. v-if="pros.priceFlag === 0"
  58. :class="PromotionsFormat(pros.promotions) ? 'none' : ''"
  59. >
  60. <text class="p sm">¥</text>
  61. <text class="p big">
  62. {{
  63. (PromotionsFormat(pros.promotions) ? pros.originalPrice : pros.price)
  64. | NumFormat
  65. }}
  66. </text>
  67. </view>
  68. </template>
  69. <template v-else>
  70. <view class="title-none" v-if="pros.priceFlag === 1">
  71. <text class="p big">¥未公开价格</text>
  72. </view>
  73. <view
  74. class="price tui-skeleton-rect"
  75. v-else
  76. :class="
  77. PromotionsFormat(pros.promotions) || pros.svipProductFlag == 1 ? 'none' : ''
  78. "
  79. >
  80. <text class="p sm">¥</text>
  81. <text class="p big">
  82. {{
  83. (PromotionsFormat(pros.promotions) || pros.svipProductFlag == 1
  84. ? pros.originalPrice
  85. : pros.price) | NumFormat
  86. }}
  87. </text>
  88. </view>
  89. </template>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. <!--加载loadding-->
  96. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  97. <tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText"></tui-nomore>
  98. <!--加载loadding-->
  99. </view>
  100. </view>
  101. </template>
  102. <script>
  103. import { mapState, mapMutations } from 'vuex'
  104. export default {
  105. data() {
  106. return {
  107. vipFlag: 0,
  108. userIdentity: 0,
  109. productList: [],
  110. appletsBanner: '',
  111. listQuery: {
  112. userId: 0,
  113. couponId: 0,
  114. pageSize: 10,
  115. pageNum: 1,
  116. source: 2
  117. },
  118. NavigationBarTitle: '',
  119. nomoreText: '上拉显示更多',
  120. hasNextPage: false,
  121. loadding: false,
  122. pullUpOn: true,
  123. pullFlag: true
  124. }
  125. },
  126. onLoad(option) {
  127. this.listQuery.couponId = option.couponId
  128. this.initGetStotage()
  129. },
  130. filters: {
  131. NumFormat: function(text) {
  132. //处理金额
  133. return Number(text).toFixed(2)
  134. }
  135. },
  136. computed: {
  137. ...mapState(['hasLogin', 'userInfo', 'identity'])
  138. },
  139. methods: {
  140. async initGetStotage() {
  141. // 初始化
  142. const userInfo = await this.$api.getStorage()
  143. this.listQuery.userId = userInfo.userId ? userInfo.userId : 0
  144. this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
  145. this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
  146. this.QueryCouponActivityList()
  147. },
  148. QueryCouponActivityList() {
  149. //楼层查看更多
  150. this.ProductService.QueryCouponActivityList(this.listQuery)
  151. .then(response => {
  152. let data = response.data
  153. uni.setNavigationBarTitle({ title: data.coupon.name })
  154. this.appletsBanner = data.coupon.appletsBanner
  155. this.productList = data.pageInfo.list
  156. this.hasNextPage = data.pageInfo.hasNextPage
  157. this.skeletonShow = false
  158. if (this.hasNextPage) {
  159. this.pullUpOn = false
  160. this.nomoreText = '上拉显示更多'
  161. } else {
  162. if (this.productList.length <6) {
  163. this.pullUpOn = true
  164. } else {
  165. this.pullUpOn = false
  166. this.loadding = false
  167. this.nomoreText = '已至底部'
  168. }
  169. }
  170. })
  171. .catch(error => {
  172. this.$util.msg(error.msg, 2000)
  173. })
  174. },
  175. OnReachBottomData() {
  176. // 上滑加载
  177. this.listQuery.pageNum += 1
  178. this.ProductService.QueryCouponActivityList(this.listQuery)
  179. .then(response => {
  180. let data = response.data
  181. uni.setNavigationBarTitle({ title: data.coupon.name })
  182. this.hasNextPage = data.pageInfo.hasNextPage
  183. this.productList = this.productList.concat(data.pageInfo.list)
  184. this.skeletonShow = false
  185. if (this.hasNextPage) {
  186. this.pullUpOn = false
  187. this.nomoreText = '上拉显示更多'
  188. } else {
  189. this.pullUpOn = false
  190. this.loadding = false
  191. this.nomoreText = '已至底部'
  192. }
  193. })
  194. .catch(error => {
  195. this.$util.msg(error.msg, 2000)
  196. })
  197. },
  198. PromotionsFormat(promo) {
  199. //促销活动类型数据处理
  200. if (promo != null) {
  201. if (promo.type == 1 && promo.mode == 1) {
  202. return true
  203. } else {
  204. return false
  205. }
  206. }
  207. return false
  208. },
  209. navToDetailPage(productId) {
  210. //跳转商品详情页
  211. this.$api.navigateTo(`/pages/goods/product?id=${productId}`)
  212. },
  213. isShowVipFlag(pros) {
  214. // 超级会员价格显示控制
  215. if (this.hasLogin && pros.priceFlag != 1) {
  216. if (this.userIdentity == 4 && this.vipFlag == 1) {
  217. return true
  218. } else if (this.userIdentity == 2) {
  219. return true
  220. }
  221. }
  222. }
  223. },
  224. onPullDownRefresh() {
  225. setTimeout(() => {
  226. this.productList = []
  227. this.listQuery.pageNum = 1
  228. this.QueryCouponActivityList()
  229. uni.stopPullDownRefresh()
  230. }, 200)
  231. },
  232. onReachBottom() {
  233. if (this.hasNextPage) {
  234. this.loadding = true
  235. this.pullUpOn = true
  236. this.OnReachBottomData()
  237. }
  238. },
  239. onShow() {}
  240. }
  241. </script>
  242. <style lang="scss">
  243. page {
  244. background-color: #f7f7f7;
  245. }
  246. .container-home {
  247. width: 100%;
  248. height: auto;
  249. }
  250. .container-section {
  251. width: 100%;
  252. height: auto;
  253. background-color: #f7f7f7;
  254. box-sizing: border-box;
  255. padding: 24rpx;
  256. }
  257. .floor-item-banner {
  258. width: 100%;
  259. height: 240rpx;
  260. margin-bottom: 20rpx;
  261. .item-img-gg {
  262. width: 100%;
  263. height: 240rpx;
  264. display: block;
  265. border-radius: 16rpx;
  266. }
  267. }
  268. .section_page_main {
  269. width: 100%;
  270. height: auto;
  271. box-sizing: border-box;
  272. .floor-item {
  273. width: 339rpx;
  274. height: 516rpx;
  275. margin-right: 20rpx;
  276. font-size: $font-size-24;
  277. color: $text-color;
  278. background: #ffffff;
  279. line-height: 36rpx;
  280. border-radius: 16rpx;
  281. margin-bottom: 20rpx;
  282. float: left;
  283. box-sizing: border-box;
  284. position: relative;
  285. &:nth-child(2n) {
  286. margin-right: 0;
  287. }
  288. .item-img {
  289. width: 339rpx;
  290. height: 339rpx;
  291. border-radius: 16rpx 16rpx 0 0;
  292. display: block;
  293. margin-bottom: 8rpx;
  294. }
  295. .floor-item-content {
  296. width: 100%;
  297. padding: 0 20rpx;
  298. box-sizing: border-box;
  299. }
  300. .floor-item-act {
  301. display: block;
  302. width: 100%;
  303. height: 32rpx;
  304. text-align: center;
  305. box-sizing: border-box;
  306. }
  307. .title-none {
  308. font-size: $font-size-26;
  309. color: #ff2a2a;
  310. line-height: 54rpx;
  311. }
  312. .title {
  313. width: 100%;
  314. height: 70rpx;
  315. display: flex;
  316. line-height: 35rpx;
  317. flex-direction: column;
  318. margin: 8rpx 0;
  319. padding: 0;
  320. position: relative;
  321. .mclap {
  322. width: 100%;
  323. line-height: 35rpx;
  324. text-overflow: ellipsis;
  325. display: -webkit-box;
  326. word-break: break-all;
  327. -webkit-box-orient: vertical;
  328. -webkit-line-clamp: 2;
  329. overflow: hidden;
  330. font-size: 26rpx;
  331. &.indent {
  332. text-indent: 95rpx;
  333. }
  334. }
  335. .mclap-tag {
  336. display: block;
  337. width: 84rpx;
  338. height: 32rpx;
  339. background-image: linear-gradient(270deg, #f9c023 0%, #f83600 100%);
  340. border-radius: 4rpx 48rpx 4px 4px;
  341. line-height: 32rpx;
  342. font-size: $font-size-22;
  343. color: #ffffff;
  344. text-align: center;
  345. position: absolute;
  346. left: 0;
  347. top: 0;
  348. }
  349. }
  350. .price {
  351. color: #ff2a2a;
  352. line-height: 54rpx;
  353. &.none {
  354. text-decoration: line-through;
  355. color: #999999;
  356. }
  357. .sm {
  358. font-size: $font-size-24;
  359. }
  360. .big {
  361. font-size: $font-size-28;
  362. }
  363. }
  364. }
  365. }
  366. </style>