detail.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <!-- 优惠劵详情 -->
  2. <template>
  3. <view class="page_box">
  4. <!-- 标题栏 -->
  5. <shopro-navbar back-icon-color="#fff" :background="{}" :backTextStyle="{ color: '#fff', fontSize: '36rpx', fontWeight: '500' }" backText="优惠券详情"></shopro-navbar>
  6. <view class="content_box">
  7. <scroll-view class="scroll-box" scroll-y="true" scroll-with-animation enable-back-to-top :scroll-into-view="scrollId" @scroll="onScroll">
  8. <!-- 详情卡片 -->
  9. <view class="coupon-box">
  10. <view class="top u-flex-col u-col-center">
  11. <view class="img-box u-flex u-row-center u-col-center"><image class="coupon-img" :src="$IMG_URL + '/imgs/coupon.png'" mode=""></image></view>
  12. <view class="title">{{ couponDetail.amount || '0.00' }}元优惠券</view>
  13. <view class="tip">满{{ couponDetail.enough || '0.00' }}元可用</view>
  14. <button class="u-reset-button" :class="['can_use', 'can_get'].includes(btnStataus) || !btnStataus ? 'use-btn' : 'fail-btn'" @tap="goScroll">
  15. {{ btnStatusText[btnStataus] || '立即领取' }}
  16. </button>
  17. <view class="time" v-if="couponDetail.usetime && couponDetail.usetime.start">
  18. 有效期:{{ $u.timeFormat(couponDetail.usetime.start, 'yyyy-mm-dd') }} 至 {{ $u.timeFormat(couponDetail.usetime.end, 'yyyy-mm-dd') }}
  19. </view>
  20. <view class="coupon-line"></view>
  21. </view>
  22. <view class="bottom">
  23. <view class="notice-item">
  24. <view class="notice-title">优惠券说明</view>
  25. <view class="notice-detail">{{ couponDetail.description || '暂无说明~' }}</view>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- 适用商品 -->
  30. <view class="coupon-goods u-p-30" v-if="couponGoods.length">
  31. <view class="coupon-goods-title" id="couponGoods">适用商品</view>
  32. <view class="goods-list u-m-b-20 u-p-20" v-for="goods in couponGoods" :key="goods.id">
  33. <shopro-mini-card
  34. :image="goods.image"
  35. :title="goods.title"
  36. :subtitle="goods.subtitle"
  37. :price="goods.price"
  38. :originPrice="goods.original_price"
  39. @click="$Router.push({ path: '/pages/goods/detail', query: { id: goods.id } })"
  40. ></shopro-mini-card>
  41. </view>
  42. </view>
  43. </scroll-view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. components: {},
  50. data() {
  51. return {
  52. couponDetail: {},
  53. couponGoods: [],
  54. scrollId: '',
  55. nowTime: new Date().getTime(),
  56. options: {},
  57. btnStatusText: {
  58. can_use: '立即使用',
  59. used: '已使用',
  60. expired: '已失效',
  61. cannot_use: '暂不可用',
  62. can_get: '立即领取',
  63. cannot_get: '不可领取'
  64. },
  65. btnStataus: ''
  66. };
  67. },
  68. computed: {},
  69. onLoad() {
  70. this.options = this.$Route.query;
  71. this.getCouponDetail();
  72. this.getCouponGoods();
  73. },
  74. methods: {
  75. // 领取优惠劵
  76. getCoupon() {
  77. let that = this;
  78. that.$http(
  79. 'coupons.get',
  80. {
  81. id: that.$Route.query.id
  82. },
  83. '领取中...'
  84. ).then(res => {
  85. if (res.code === 1) {
  86. this.options.userCouponId = res.data.id;
  87. that.getCouponDetail();
  88. that.$u.toast('领取成功')
  89. }
  90. });
  91. },
  92. // 优惠券详情
  93. getCouponDetail() {
  94. let that = this;
  95. that.$http('coupons.detail', {
  96. id: that.$Route.query.id,
  97. user_coupons_id: that.options.userCouponId
  98. }).then(res => {
  99. if (res.code === 1) {
  100. that.couponDetail = res.data;
  101. if (res.data.status_code) {
  102. this.btnStataus = res.data.status_code;
  103. }
  104. }
  105. });
  106. },
  107. // 适用商品
  108. getCouponGoods() {
  109. let that = this;
  110. that.$http('coupons.goods', {
  111. id: that.$Route.query.id
  112. }).then(res => {
  113. if (res.code === 1) {
  114. that.couponGoods = res.data.data;
  115. }
  116. });
  117. },
  118. onScroll() {
  119. this.scrollId = '';
  120. },
  121. goScroll() {
  122. if (!this.options.userCouponId) {
  123. this.getCoupon();
  124. } else {
  125. if (this.couponDetail.goods_ids === '0' && this.btnStataus == 'can_use') {
  126. this.$Router.push({
  127. path: '/pages/goods/list'
  128. });
  129. }
  130. this.scrollId = 'couponGoods';
  131. }
  132. }
  133. }
  134. };
  135. </script>
  136. <style lang="scss">
  137. .page_box {
  138. background: linear-gradient(180deg, rgba(240, 199, 133, 1), rgba(246, 214, 157, 1));
  139. }
  140. .coupon-box {
  141. margin: 100rpx 30rpx 0;
  142. border-radius: 20rpx;
  143. background-color: #fff;
  144. .top {
  145. border-radius: 20rpx 20rpx 0 0;
  146. background-image: radial-gradient(circle at bottom left, #f6d69d, #f6d69d 16rpx, transparent 17rpx),
  147. radial-gradient(circle at bottom right, #f6d69d, #f6d69d 16rpx, transparent 17rpx);
  148. padding: 110rpx 0 40rpx 0;
  149. position: relative;
  150. z-index: 5;
  151. .coupon-line {
  152. width: 95%;
  153. border-bottom: 2rpx dashed #f3ce90;
  154. position: absolute;
  155. bottom: 0;
  156. left: 50%;
  157. transform: translateX(-50%);
  158. z-index: 6;
  159. }
  160. .img-box {
  161. width: 140rpx;
  162. height: 140rpx;
  163. border-radius: 50%;
  164. background: #fff;
  165. position: absolute;
  166. left: 50%;
  167. transform: translateX(-50%);
  168. top: -70rpx;
  169. .coupon-img {
  170. width: 100rpx;
  171. height: 100rpx;
  172. }
  173. }
  174. .title {
  175. font-size: 40rpx;
  176. font-weight: bold;
  177. line-height: 40rpx;
  178. margin-bottom: 30rpx;
  179. }
  180. .tip {
  181. font-size: 28rpx;
  182. font-weight: 500;
  183. margin-bottom: 50rpx;
  184. }
  185. .use-btn {
  186. width: 386rpx;
  187. line-height: 80rpx;
  188. background: linear-gradient(90deg, rgba(240, 199, 133, 1), rgba(246, 214, 157, 1));
  189. border-radius: 40rpx;
  190. color: rgba(#fff, 0.9);
  191. margin-bottom: 30rpx;
  192. }
  193. .fail-btn {
  194. width: 386rpx;
  195. line-height: 80rpx;
  196. background: rgba(245, 245, 245, 1);
  197. border-radius: 40rpx;
  198. font-size: 30rpx;
  199. font-weight: 500;
  200. color: rgba(188, 188, 188, 1);
  201. margin-bottom: 30rpx;
  202. }
  203. .time {
  204. color: #999;
  205. font-size: 26rpx;
  206. }
  207. }
  208. .bottom {
  209. border-radius: 0 0 20rpx 20rpx;
  210. background-image: radial-gradient(circle at top left, #f6d69d, #f6d69d 16rpx, transparent 17rpx),
  211. radial-gradient(circle at top right, #f6d69d, #f6d69d 16rpx, transparent 17rpx);
  212. padding: 40rpx 30rpx;
  213. .notice-item {
  214. border-bottom: 1rpx solid #eeeeee;
  215. min-height: 90rpx;
  216. width: 100%;
  217. .notice-title {
  218. font-weight: 500;
  219. font-size: 26rpx;
  220. }
  221. .notice-detail {
  222. font-size: 24rpx;
  223. color: #666;
  224. margin-top: 10rpx;
  225. padding-bottom: 10rpx;
  226. text-indent: 30rpx;
  227. }
  228. }
  229. }
  230. }
  231. // 优惠券商品
  232. .coupon-goods {
  233. .coupon-goods-title {
  234. font-size: 30rpx;
  235. font-weight: bold;
  236. height: 80rpx;
  237. }
  238. .goods-list {
  239. background: #fff;
  240. border-radius: 20rpx;
  241. }
  242. }
  243. </style>