coupon-details.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <view class="container clearfix" >
  3. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading ="true" :loadingType="5" />
  4. <view class="container-content tui-skeleton" v-else>
  5. <view class="empty-container" v-if="!coupon">
  6. <image class="empty-container-image" :src="StaticUrl + '/icon/icon-coupon-empty@2x.png'"></image>
  7. <text class="error-text">暂无优惠券~</text>
  8. </view>
  9. <template v-else>
  10. <view class="container-list">
  11. <view class="coupon-list">
  12. <view class="list-cell-le">
  13. <view class="coupon-maxMoney"> <text class="small">¥</text> {{ coupon.couponAmount }} </view>
  14. <view class="coupon-minMoney"> 满{{ coupon.touchPrice }}可用 </view>
  15. </view>
  16. <view class="list-cell-ri">
  17. <view class="list-cell-top">
  18. <view class="list-cell-type">
  19. <view class="list-cell-tags">
  20. <template v-if="coupon.moneyCouponFlag == 1">
  21. <text class="tags" v-if="coupon.moneyCouponType == 1"
  22. >意向{{ coupon.couponType | TypeFormat }}</text
  23. >
  24. <text class="tags" v-else>定向{{ coupon.couponType | TypeFormat }}</text>
  25. </template>
  26. <template v-else>
  27. <text class="tags">{{ coupon.couponType | TypeFormat }}</text>
  28. </template>
  29. </view>
  30. <view class="list-cell-texts">
  31. <text v-if="coupon.couponType == 0">
  32. {{
  33. coupon.productType && coupon.productType == 1
  34. ? '全商城商品通用'
  35. : '仅可购买指定商品'
  36. }}
  37. </text>
  38. <text v-if="coupon.couponType == 1">
  39. {{ coupon.categoryType == 1 ? '仅限购买产品类商品' : '仅限购买仪器类商品' }}
  40. </text>
  41. <text v-if="coupon.couponType == 3"
  42. >仅限购买店铺【{{ coupon.shopName }}】的商品</text
  43. >
  44. <text v-if="coupon.couponType == 4 || coupon.couponType == 2">全商城商品通用</text>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="list-cell-time">{{ coupon.startDate }} - {{ coupon.endDate }}</view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="container-button">
  53. <view class="button" @click="handeleReceiveCoupon(coupon)">领取优惠券</view>
  54. </view>
  55. </template>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import { mapState, mapMutations } from 'vuex'
  61. import wxLogin from '@/common/config/wxLogin.js'
  62. import authorize from '@/common/config/authorize.js'
  63. export default {
  64. data() {
  65. return {
  66. StaticUrl: this.$Static,
  67. isIphoneX: this.$store.state.isIphoneX,
  68. coupon: {},
  69. coupinList: [],
  70. payAmount: 100 ,//支付金额
  71. skeletonShow:true,
  72. isReceiveLoading: false ,//领券操作状态
  73. param:{
  74. spId:0,
  75. userId:0,
  76. couponId:0,
  77. source: 1
  78. }
  79. }
  80. },
  81. onLoad(option) {
  82. wxLogin.wxLoginAuthorize()
  83. this.param.spId = option.spId
  84. this.param.couponId = option.couponId
  85. this.initCouponDetail(this.param.couponId)
  86. },
  87. filters: {
  88. TypeFormat(value) {
  89. switch (value) {
  90. case 0:
  91. return '活动券'
  92. break
  93. case 1:
  94. return '品类券'
  95. break
  96. case 2:
  97. return '用户专享券'
  98. break
  99. case 3:
  100. return '店铺券'
  101. break
  102. case 4:
  103. return '新用户券'
  104. break
  105. }
  106. }
  107. },
  108. computed: {
  109. ...mapState(['hasLogin', 'userInfo',])
  110. },
  111. methods: {
  112. async initCouponDetail(couponId) {
  113. // 初始化优惠券信息
  114. try{
  115. const res = await this.ProductService.QueryCouponDetail({ couponId: couponId })
  116. this.coupon = res.data
  117. setTimeout(()=>{
  118. this.skeletonShow = false
  119. },500)
  120. }catch(e){
  121. console.log('初始化优惠券信息异常~')
  122. }
  123. },
  124. async handeleReceiveCoupon(coupon){
  125. // 点击优惠券领取按钮,
  126. if (this.hasLogin) {
  127. if (this.isReceiveLoading) {
  128. return
  129. }
  130. const userInfo = await this.$api.getStorage()
  131. this.param.userId = userInfo.userId
  132. this.getRceiveCoupon(this.param)
  133. } else {
  134. const pages = getCurrentPages()
  135. const page = pages[pages.length - 1]
  136. uni.setStorageSync('LOGIN_REDIRECT_URL', page.$page.fullPath)
  137. this.$api.redirectTo('/pages/login/login')
  138. }
  139. },
  140. // 执行领取优惠券
  141. async getRceiveCoupon(params){
  142. try{
  143. await this.ProductService.ReceiveCoupon(params)
  144. this.isReceiveLoading = true
  145. this.$util.msg('领取成功', 1500, true, 'success')
  146. setTimeout(() => {
  147. this.isReceiveLoading = false
  148. this.$api.reLaunch('/pages/user/coupon/coupon')
  149. }, 1500)
  150. }catch(error){
  151. this.$util.msg(error.msg, 2000)
  152. this.isReceiveLoading = false
  153. }
  154. }
  155. },
  156. onShow() {
  157. }
  158. }
  159. </script>
  160. <style lang="scss">
  161. page {
  162. background-color: #FFFFFF;
  163. }
  164. .container {
  165. width: 100%;
  166. height: auto;
  167. }
  168. .empty-container-image {
  169. width: 260rpx;
  170. height: 260rpx;
  171. margin-top: -300rpx;
  172. }
  173. .container-list {
  174. box-sizing: border-box;
  175. padding: 24rpx;
  176. .toIndexPage {
  177. bottom: 390rpx;
  178. }
  179. .coupon-list {
  180. width: 100%;
  181. height: 200rpx;
  182. margin-bottom: 24rpx;
  183. box-sizing: border-box;
  184. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-uesb@2x.png);
  185. background-size: cover;
  186. position: relative;
  187. .list-cell-le {
  188. width: 224rpx;
  189. height: 100%;
  190. box-sizing: border-box;
  191. padding: 37rpx 0;
  192. float: left;
  193. .coupon-maxMoney {
  194. width: 100%;
  195. height: 78rpx;
  196. line-height: 78rpx;
  197. font-size: 56rpx;
  198. color: #ffffff;
  199. text-align: center;
  200. .small {
  201. font-size: $font-size-24;
  202. }
  203. }
  204. .coupon-minMoney {
  205. width: 100%;
  206. height: 33rpx;
  207. line-height: 33rpx;
  208. font-size: $font-size-24;
  209. color: #ffffff;
  210. text-align: center;
  211. }
  212. }
  213. .list-cell-ri {
  214. width: 478rpx;
  215. height: 100%;
  216. box-sizing: border-box;
  217. padding: 20rpx 24rpx 0 24rpx;
  218. float: right;
  219. .list-cell-top {
  220. width: 100%;
  221. height: 121rpx;
  222. float: left;
  223. border-bottom: 1px solid #e1e1e1;
  224. .list-cell-type {
  225. width: 286rpx;
  226. height: 100%;
  227. float: left;
  228. .list-cell-tags {
  229. width: 100%;
  230. height: 32rpx;
  231. margin-bottom: 7rpx;
  232. .tags {
  233. display: inline-block;
  234. padding: 0 10rpx;
  235. height: 32rpx;
  236. line-height: 32rpx;
  237. background-color: #ffdcce;
  238. color: #f94b4b;
  239. font-size: $font-size-20;
  240. border-radius: 8rpx;
  241. text-align: center;
  242. float: left;
  243. }
  244. }
  245. .list-cell-texts {
  246. width: 100%;
  247. height: auto;
  248. line-height: 35rpx;
  249. text-overflow: ellipsis;
  250. display: -webkit-box;
  251. word-break: break-all;
  252. -webkit-box-orient: vertical;
  253. -webkit-line-clamp: 2;
  254. overflow: hidden;
  255. font-size: 26rpx;
  256. color: #333333;
  257. }
  258. }
  259. .list-cell-btn {
  260. width: 128rpx;
  261. height: 100%;
  262. float: right;
  263. .icon-used {
  264. width: 100%;
  265. height: 100%;
  266. box-sizing: border-box;
  267. padding-top: 57rpx;
  268. .icon-used-btn {
  269. width: 128rpx;
  270. height: 48rpx;
  271. border-radius: 28rpx;
  272. line-height: 48rpx;
  273. font-size: $font-size-24;
  274. text-align: center;
  275. &.receive {
  276. background-image: linear-gradient(270deg, #f94b4b 0%, #feb673 100%);
  277. color: #ffffff;
  278. }
  279. &.make {
  280. border: solid 1px #f94b4b;
  281. color: #f94b4b;
  282. }
  283. }
  284. }
  285. }
  286. }
  287. .list-cell-time {
  288. width: 100%;
  289. height: 58rpx;
  290. line-height: 58rpx;
  291. text-align: left;
  292. font-size: $font-size-20;
  293. color: #999999;
  294. }
  295. }
  296. }
  297. }
  298. .container-button {
  299. width: 100%;
  300. height: 90rpx;
  301. margin-top: 190rpx;
  302. .button {
  303. width: 600rpx;
  304. height: 90rpx;
  305. text-align: center;
  306. background: $btn-confirm;
  307. line-height: 90rpx;
  308. font-size: $font-size-30;
  309. color: #ffffff;
  310. margin: 0 auto;
  311. border-radius: 45rpx;
  312. }
  313. }
  314. </style>