coupon.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <view class="container clearfix">
  3. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading="true"
  4. :loadingType="5" />
  5. <view class="container-list" v-else>
  6. <template v-if="coupinList.length > 0">
  7. <view v-for="(coupon, index) in coupinList" :key="index" :id="coupon.id" class="coupon-list">
  8. <view class="list-cell-le">
  9. <view class="coupon-maxMoney"> <text class="small">¥</text> {{ coupon.couponAmount }} </view>
  10. <view class="coupon-minMoney"> 满{{ coupon.touchPrice }}可用 </view>
  11. </view>
  12. <view class="list-cell-ri">
  13. <view class="list-cell-top">
  14. <view class="list-cell-type">
  15. <view class="list-cell-tags">
  16. <template v-if="coupon.moneyCouponFlag == 1">
  17. <text class="tags" v-if="coupon.moneyCouponType == 1"
  18. >意向{{ coupon.couponType | TypeFormat }}</text
  19. >
  20. <text class="tags" v-else>定向{{ coupon.couponType | TypeFormat }}</text>
  21. </template>
  22. <template v-else>
  23. <text class="tags">{{ coupon.couponType | TypeFormat }}</text>
  24. </template>
  25. </view>
  26. <view class="list-cell-texts">
  27. <text v-if="coupon.couponType == 0">
  28. {{
  29. coupon.productType && coupon.productType == 1
  30. ? '全商城商品通用'
  31. : '仅可购买指定商品'
  32. }}
  33. </text>
  34. <text v-if="coupon.couponType == 1">
  35. {{ coupon.categoryType == 1 ? '仅限购买产品类商品' : '仅限购买仪器类商品' }}
  36. </text>
  37. <text v-if="coupon.couponType == 3"
  38. >仅限购买店铺【{{ coupon.shopName }}】的商品</text
  39. >
  40. <text v-if="coupon.couponType == 4 || coupon.couponType == 2">全商城商品通用</text>
  41. </view>
  42. </view>
  43. <view class="list-cell-btn">
  44. <view class="icon-used">
  45. <button open-type="share" class="icon-used-btn receive" :data-coupon="coupon">
  46. 分享
  47. </button>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="list-cell-time">{{ coupon.startDate }} - {{ coupon.endDate }}</view>
  52. </view>
  53. </view>
  54. <!--加载loadding-->
  55. <tui-loadmore :visible="loadding" :index="3" type="black" />
  56. <tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText" />
  57. <!--加载loadding-->
  58. </template>
  59. <view class="empty-container" v-else>
  60. <image class="empty-container-image" :src="StaticUrl + '/icon/icon-coupon-empty@2x.png'"></image>
  61. <text class="error-text">暂无优惠券~</text>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import { mapState, mapMutations } from 'vuex'
  68. import couponTabs from '@/components/cm-module/coupon/tui-tabs.vue'
  69. export default {
  70. components: {
  71. couponTabs
  72. },
  73. data() {
  74. return {
  75. StaticUrl: this.$Static,
  76. isIphoneX: this.$store.state.isIphoneX,
  77. listQuery: {
  78. userId:0,
  79. pageNum: 1,
  80. pageSize: 10
  81. },
  82. coupinList: [],
  83. skeletonShow: true,
  84. nomoreText: '上拉显示更多',
  85. hasNextPage: false,
  86. loadding: false,
  87. pullUpOn: true,
  88. pullFlag: true,
  89. isReceiveLoading: false, //领券操作状态
  90. }
  91. },
  92. onLoad() {
  93. uni.hideShareMenu()
  94. this.initGetStotage()
  95. },
  96. filters: {
  97. TypeFormat(value) {
  98. switch (value) {
  99. case 0:
  100. return '活动券'
  101. break
  102. case 1:
  103. return '品类券'
  104. break
  105. case 2:
  106. return '用户专享券'
  107. break
  108. case 3:
  109. return '店铺券'
  110. break
  111. case 4:
  112. return '新用户券'
  113. break
  114. }
  115. }
  116. },
  117. computed: {
  118. ...mapState(['hasLogin', 'userInfo', 'identity', 'isActivity'])
  119. },
  120. methods: {
  121. async initGetStotage() {
  122. const userInfo = await this.$api.getStorage()
  123. this.spId = userInfo.serviceProviderId
  124. this.QueryCouponList()
  125. setTimeout(()=>{
  126. this.skeletonShow = false
  127. },500)
  128. },
  129. async QueryCouponList() {
  130. // 初始化查询优惠券列表
  131. try{
  132. this.coupinList = []
  133. this.listQuery.pageNum = 1
  134. const res = await this.ProductService.QueryCouponCollarList(this.listQuery)
  135. const data = res.data
  136. if (data.list && data.list.length > 0) {
  137. this.hasNextPage = data.hasNextPage
  138. this.coupinList = data.list
  139. this.pullFlag = false
  140. setTimeout(() => {
  141. this.pullFlag = true
  142. }, 500)
  143. if (this.hasNextPage) {
  144. this.pullUpOn = false
  145. this.nomoreText = '上拉显示更多'
  146. } else {
  147. if (this.coupinList.length < 8) {
  148. this.pullUpOn = true
  149. } else {
  150. this.pullUpOn = false
  151. this.loadding = false
  152. this.nomoreText = '已至底部'
  153. }
  154. }
  155. }
  156. }catch(error){
  157. this.$util.msg(error.msg, 2000)
  158. }
  159. },
  160. async getOnReachBottomData() {
  161. // 上滑加载分页
  162. try{
  163. this.listQuery.pageNum += 1
  164. const res = await this.ProductService.QueryCouponCollarList(this.listQuery)
  165. const data = res.data
  166. if (data.list && data.list.length > 0) {
  167. this.hasNextPage = data.hasNextPage
  168. this.coupinList = this.coupinList.concat(data.list)
  169. this.pullFlag = false // 防上拉暴滑
  170. setTimeout(() => {
  171. this.pullFlag = true
  172. }, 500)
  173. if (this.hasNextPage) {
  174. this.pullUpOn = false
  175. this.nomoreText = '上拉显示更多'
  176. } else {
  177. this.pullUpOn = false
  178. this.loadding = false
  179. this.nomoreText = '已至底部'
  180. }
  181. }
  182. }catch(error){
  183. this.$util.msg(error.msg, 2000)
  184. }
  185. },
  186. navigator(url) {
  187. this.$api.navigateTo(url)
  188. }
  189. },
  190. onShareAppMessage(res) {
  191. //分享购买优惠券
  192. const coupon = res.target.dataset.coupon
  193. if (res.from === 'button') {
  194. // console.log('来自页面内转发按钮')
  195. return {
  196. title: '送您一张优惠券~',
  197. path: `pages/user/coupon/coupon-details?couponId=${coupon.couponId}&spId=${this.spId}`,
  198. imageUrl: 'https://static.caimei365.com/app/img/icon/icon-shareCoupon@2x.png'
  199. }
  200. }
  201. },
  202. onPullDownRefresh() {
  203. setTimeout(() => {
  204. this.QueryCouponList()
  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. onShow() {}
  216. }
  217. </script>
  218. <style lang="scss">
  219. page {
  220. background-color: #f7f7f7;
  221. }
  222. .container {
  223. width: 100%;
  224. height: auto;
  225. }
  226. .container-list {
  227. box-sizing: border-box;
  228. padding: 24rpx;
  229. .empty-container-image {
  230. width: 260rpx;
  231. height: 260rpx;
  232. margin-top: -300rpx;
  233. }
  234. .toIndexPage {
  235. bottom: 390rpx;
  236. }
  237. .coupon-list {
  238. width: 100%;
  239. height: 200rpx;
  240. margin-bottom: 24rpx;
  241. box-sizing: border-box;
  242. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-uesb@2x.png);
  243. background-size: cover;
  244. position: relative;
  245. .list-cell-le {
  246. width: 224rpx;
  247. height: 100%;
  248. box-sizing: border-box;
  249. padding: 37rpx 0;
  250. float: left;
  251. .coupon-maxMoney {
  252. width: 100%;
  253. height: 78rpx;
  254. line-height: 78rpx;
  255. font-size: 56rpx;
  256. color: #ffffff;
  257. text-align: center;
  258. .small {
  259. font-size: $font-size-24;
  260. }
  261. }
  262. .coupon-minMoney {
  263. width: 100%;
  264. height: 33rpx;
  265. line-height: 33rpx;
  266. font-size: $font-size-24;
  267. color: #ffffff;
  268. text-align: center;
  269. }
  270. }
  271. .list-cell-ri {
  272. width: 478rpx;
  273. height: 100%;
  274. box-sizing: border-box;
  275. padding: 20rpx 24rpx 0 24rpx;
  276. float: right;
  277. .list-cell-top {
  278. width: 100%;
  279. height: 121rpx;
  280. float: left;
  281. border-bottom: 1px solid #e1e1e1;
  282. .list-cell-type {
  283. width: 286rpx;
  284. height: 100%;
  285. float: left;
  286. .list-cell-tags {
  287. width: 100%;
  288. height: 32rpx;
  289. margin-bottom: 7rpx;
  290. .tags {
  291. display: inline-block;
  292. padding: 0 10rpx;
  293. height: 32rpx;
  294. line-height: 32rpx;
  295. background-color: #ffdcce;
  296. color: #f94b4b;
  297. font-size: $font-size-20;
  298. border-radius: 8rpx;
  299. text-align: center;
  300. float: left;
  301. }
  302. }
  303. .list-cell-texts {
  304. width: 100%;
  305. height: auto;
  306. line-height: 35rpx;
  307. text-overflow: ellipsis;
  308. display: -webkit-box;
  309. word-break: break-all;
  310. -webkit-box-orient: vertical;
  311. -webkit-line-clamp: 2;
  312. overflow: hidden;
  313. font-size: 26rpx;
  314. color: #333333;
  315. }
  316. }
  317. .list-cell-btn {
  318. width: 128rpx;
  319. height: 100%;
  320. float: right;
  321. .icon-used {
  322. width: 100%;
  323. height: 100%;
  324. box-sizing: border-box;
  325. padding-top: 57rpx;
  326. .icon-used-btn {
  327. width: 128rpx;
  328. height: 48rpx;
  329. border-radius: 28rpx;
  330. line-height: 48rpx;
  331. font-size: $font-size-24;
  332. text-align: center;
  333. &.receive {
  334. background-image: linear-gradient(270deg, #f94b4b 0%, #feb673 100%);
  335. color: #ffffff;
  336. }
  337. &.make {
  338. border: solid 1px #f94b4b;
  339. color: #f94b4b;
  340. }
  341. }
  342. }
  343. }
  344. }
  345. .list-cell-time {
  346. width: 100%;
  347. height: 58rpx;
  348. line-height: 58rpx;
  349. text-align: left;
  350. font-size: $font-size-20;
  351. color: #999999;
  352. }
  353. }
  354. }
  355. }
  356. </style>