details.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <app-layout>
  3. <view class="page">
  4. <view>
  5. <!-- 优惠券信息 -->
  6. <view class="info-top">
  7. <view class="name">{{list.name}}</view>
  8. <template v-if="list.type == 2">
  9. <view class="price">¥{{list.sub_price | reservedNum}}</view>
  10. </template>
  11. <template v-else>
  12. <view class="price">{{list.discount | reservedNum}}折</view>
  13. </template>
  14. <view v-if="list.min_price > 0">满{{list.min_price | reservedNum}}可用</view>
  15. <view v-else>无门槛使用</view>
  16. <view v-if="list.discount_limit">优惠上限:¥{{list.discount_limit | reservedNum}}</view>
  17. <view v-if="!person">
  18. <view @click="toGoods" v-if="list.receive_count === '1'">
  19. <button style="background-color: #fff;" :class="[`btn`,`${theme}-color`,`${theme}-border`]">
  20. 立即使用
  21. </button>
  22. </view>
  23. <view @click="receive(list.id)" v-if="list.receive_count === '0'">
  24. <button style="color:#fff;" :class="[`btn`,`${theme}-background`,`${theme}-border`]">立即领取
  25. </button>
  26. </view>
  27. </view>
  28. <view v-else>
  29. <view v-if="list.appoint_type == 4">
  30. <view class="scan-code">仅限当面付活动使用</view>
  31. </view>
  32. <view @click="toGoods" v-else-if="list.is_use == 0 && list.is_expired == 0">
  33. <button style="background-color: #fff;" :class="[`btn`,`${theme}-color`,`${theme}-border`]">
  34. 立即使用
  35. </button>
  36. </view>
  37. <button class="btn used" v-else-if="list.is_use == 1">已使用</button>
  38. <button class="btn used" v-else-if="list.is_expired == 1 && list.is_use == 0">已过期</button>
  39. </view>
  40. </view>
  41. <!-- 分割线 -->
  42. <view class="line">
  43. <image src="./../image/line.png"></image>
  44. </view>
  45. <!-- 优惠券使用信息 -->
  46. <view class="details">
  47. <view class="title">有效期</view>
  48. <view v-if="list.expire_type == '2' || person">{{person ? list.start_time : list.begin_time + " 00:00"}} - {{list.end_time + ' '}}
  49. <text v-if="!person"> 23:59</text>
  50. </view>
  51. <view v-if="list.expire_type !== '2' && !person">领取后{{list.expire_day}}天内有效</view>
  52. <view class="title">使用规则</view>
  53. <view v-if="list.appoint_type == '1'">本券仅限购买
  54. <text v-for="(cat,index) in list.cat" :key="cat.id">{{cat.name}}
  55. <text v-if="index !== list.cat.length -1">、</text>
  56. </text>
  57. 分类下的商品。
  58. </view>
  59. <view v-if="list.appoint_type == '2'">本券仅限购买
  60. <text v-for="(good,index) in list.goods" :key="good.id">{{good.name}}
  61. <text v-if="index !== list.goods.length -1">、</text>
  62. </text>
  63. </view>
  64. <view v-if="list.appoint_type == '3'">本券全场通用。</view>
  65. <view v-if="list.appoint_type == '4'">本券仅限当面付活动使用。</view>
  66. <view class="title">使用说明</view>
  67. <view>
  68. <text style="word-break: break-all;">{{list.rule}}</text>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </app-layout>
  74. </template>
  75. <script>
  76. import {mapState} from "vuex";
  77. export default {
  78. data() {
  79. return {
  80. list: {
  81. name: '',
  82. start_time: '',
  83. begin_time: '',
  84. end_time: '',
  85. sub_price: 0,
  86. min_price: 0,
  87. expire_day: '',
  88. discount: 10,
  89. },
  90. person: false
  91. }
  92. },
  93. computed: {
  94. ...mapState({
  95. theme: state => state.mallConfig.theme,
  96. })
  97. },
  98. methods: {
  99. getList(id, person) {
  100. let that = this;
  101. that.$showLoading({
  102. type: 'global',
  103. text: '加载中...'
  104. });
  105. let url = that.$api.coupon.detail;
  106. let para = {
  107. coupon_id: id
  108. };
  109. if (person == 1) {
  110. url = that.$api.coupon.user_coupon_detail;
  111. para = {
  112. user_coupon_id: id
  113. };
  114. that.person = true;
  115. }
  116. that.$request({
  117. url: url,
  118. data: para
  119. }).then(response => {
  120. that.$hideLoading();
  121. if (response.code === 0) {
  122. that.list = response.data.list;
  123. } else {
  124. uni.showToast({
  125. title: response.msg,
  126. icon: 'none',
  127. duration: 1000
  128. });
  129. }
  130. }).catch(() => {
  131. that.$hideLoading();
  132. });
  133. },
  134. toGoods() {
  135. uni.navigateTo({
  136. url: this.list.page_url
  137. });
  138. },
  139. receive(id) {
  140. let that = this;
  141. uni.showLoading({
  142. title: '领取中...'
  143. });
  144. that.$request({
  145. url: that.$api.coupon.receive,
  146. data: {
  147. coupon_id: id
  148. },
  149. }).then(response => {
  150. uni.hideLoading();
  151. if (response.code === 0) {
  152. uni.showToast({
  153. title: response.msg,
  154. duration: 1000
  155. });
  156. this.getList(id);
  157. } else {
  158. uni.showToast({
  159. title: response.msg,
  160. icon: 'none',
  161. duration: 1000
  162. });
  163. this.getList(id);
  164. }
  165. }).catch(() => {
  166. uni.hideLoading();
  167. that.$event.on(that.$const.EVENT_USER_LOGIN).then(() => {
  168. that.receive(id);
  169. });
  170. });
  171. },
  172. },
  173. onLoad(option) {
  174. this.getList(option.id, option.person);
  175. },
  176. filters: {
  177. reservedNum(data) {
  178. return Number(data);
  179. }
  180. }
  181. }
  182. </script>
  183. <style scoped lang="scss">
  184. .page {
  185. height: 100%;
  186. background-color: #d6b985;
  187. width: 100%;
  188. padding: #{20rpx} 0;
  189. position: absolute;
  190. }
  191. .info-top {
  192. background-color: #fff;
  193. margin: 0 #{25rpx};
  194. text-align: center;
  195. padding-top: #{60rpx};
  196. border-top-left-radius: #{25rpx};
  197. border-top-right-radius: #{25rpx};
  198. color: #353535;
  199. font-size: #{32rpx};
  200. }
  201. .name {
  202. font-size: #{28rpx};
  203. color: #666;
  204. }
  205. .price {
  206. font-size: #{56rpx};
  207. margin-top: #{28rpx};
  208. margin-bottom: #{10rpx};
  209. }
  210. .scan-code {
  211. height: #{56rpx};
  212. line-height: #{52rpx};
  213. margin: #{35rpx} auto 0;
  214. color: #ff4544;
  215. font-size: #{30rpx};
  216. border: none;
  217. }
  218. .btn {
  219. height: #{56rpx};
  220. line-height: #{52rpx};
  221. width: #{240rpx};
  222. margin: #{35rpx} auto 0;
  223. font-size: #{30rpx};
  224. border-radius: #{28rpx};
  225. border: #{2rpx} solid;
  226. }
  227. .btn.used {
  228. background-color: #f7f7f7;
  229. color: #acacac;
  230. border: #{2rpx} solid #f7f7f7;
  231. }
  232. .btn::after {
  233. border: 0;
  234. }
  235. .line {
  236. height: #{50rpx};
  237. margin: #{-1rpx} #{25rpx};
  238. background-color: #fff;
  239. }
  240. .line image {
  241. height: 100%;
  242. width: 100%;
  243. }
  244. .details {
  245. background-color: #fff;
  246. margin: #{-2rpx} #{25rpx} 0;
  247. font-size: #{28rpx};
  248. padding: #{25rpx} #{40rpx} #{65rpx};
  249. border-bottom-left-radius: #{25rpx};
  250. border-bottom-right-radius: #{25rpx};
  251. }
  252. .details .title {
  253. color: #b0b0b0;
  254. font-size: #{26rpx};
  255. margin-bottom: #{25rpx};
  256. margin-top: #{50rpx};
  257. }
  258. .scan-code {
  259. height: #{56rpx};
  260. line-height: #{52rpx};
  261. margin: #{35rpx} auto 0;
  262. color: #ff4544;
  263. font-size: #{30rpx};
  264. border: none;
  265. }
  266. </style>