coupon.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view>
  3. <uni-popup ref="popupCoupon" type="bottom">
  4. <view class="pop-coupon box-border-box p-24">
  5. <view class="text-align-center fs-36 fw-600 box-title mb-32">
  6. 选择优惠券
  7. <uni-icons @click="closeCoupon" class="box-close" type="closeempty" size="20"></uni-icons>
  8. </view>
  9. <view class="flex-justify-around">
  10. <view @click="setType(1)" class="fs-28 fw-600 mb-24" :class="type == 1?'fc-41ABF5':''">
  11. 可用优惠券({{expressCouponData.coupon.length}})</view>
  12. <view @click="setType(2)" class="fs-28 fw-600 mb-24" :class="type == 2?'fc-41ABF5':''">
  13. 可领优惠券({{expressCouponData.receive.length}})</view>
  14. </view>
  15. <view class="scroll-view-css" v-if="type == 1">
  16. <view v-if="expressCouponData.coupon.length === 0" class="scroll-view-css">
  17. <EnBlank :customSrc='true'>
  18. <template v-slot:blankImg>
  19. <image class="black-custom-img" src="@/static/img/common/no-order.png" mode=""></image>
  20. </template>
  21. </EnBlank>
  22. </view>
  23. <scroll-view v-else :scroll-y="true" class="scroll-view-css">
  24. <view class="item-box display-flex mb-20" v-for="(item,i) in expressCouponData.coupon" :key="i"
  25. @click="setFun(item)">
  26. <view class="item-left flex-direction align-items-center flex-justify-center bgc-FCE7E2">
  27. <view class="align-items-center">
  28. <view class="fs-30 fw-600 fc-FB3D03">¥</view>
  29. <view class="fs-48 fw-600 fc-FB3D03">{{item.money}}</view>
  30. </view>
  31. <view class="fs-24" :class="item.type == 0?'fc-6':'fc-9'">
  32. {{item.desc}}
  33. </view>
  34. <view class="ball"></view>
  35. <view class="ball-two"></view>
  36. </view>
  37. <view class="item-hr"></view>
  38. <view class="item-right flex-1 bgc-f">
  39. <view class="fs-28 fw-600 mb-12 ticket-name text-overflow-ellipsis w382">
  40. {{item.name}}
  41. </view>
  42. <view class="fs-24 mb-12 fc-FB3D03">
  43. {{item.start_time}} - {{item.end_time}}
  44. </view>
  45. </view>
  46. <image v-if="coupon_id==item.id" class="s-icon" src="@/static/img/common/y-select.png"
  47. mode=""></image>
  48. <image v-else class="s-icon" src="@/static/img/common/n-select.png" mode=""></image>
  49. </view>
  50. </scroll-view>
  51. </view>
  52. <view class="scroll-view-css" v-else>
  53. <view v-if="expressCouponData.receive.length === 0" class="scroll-view-css">
  54. <EnBlank :customSrc='true'>
  55. <template v-slot:blankImg>
  56. <image class="black-custom-img" src="@/static/img/common/no-order.png" mode=""></image>
  57. </template>
  58. </EnBlank>
  59. </view>
  60. <view v-else class="scroll-view-css">
  61. <view class=" display-flex mb-20" v-for="(item,i) in expressCouponData.receive" :key="i">
  62. <view class="item-right flex-direction flex-justify-center flex-1 bgc-f">
  63. <view class="fs-28 mb-12 ticket-name text-overflow-ellipsis fc-3 fw-600">
  64. {{item.name}}
  65. </view>
  66. <view class="fs-24 fc-6 mb-12">
  67. 有效时间:{{item.start_time}} - {{item.end_time}}
  68. </view>
  69. <view class="flex-justify-space">
  70. <view class="fs-24 fc-6">
  71. 券类型:{{item.scene == 1?'外卖券':'代取券'}}
  72. </view>
  73. </view>
  74. </view>
  75. <view class="item-hr"></view>
  76. <view class="item-left flex-direction align-items-center flex-justify-center bgc-FCE7E2">
  77. <view class="align-items-center">
  78. <view class="fs-30 fw-600 fc-FB3D03">¥</view>
  79. <view class="fs-48 fw-600 fc-FB3D03">{{item.money}}</view>
  80. </view>
  81. <view class="fs-24 mb-18 fc-6">
  82. {{item.desc}}
  83. </view>
  84. <view class="but-box fs-28 fc-f" @click="getFun(item)">立即领取</view>
  85. <view class="ball"></view>
  86. <view class="ball-two"></view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </uni-popup>
  93. </view>
  94. </template>
  95. <script>
  96. import EnBlank from "@/components/en-utils/en-blank/en-blank";
  97. import {
  98. getExpressCoupon
  99. } from '@/api/express.js';
  100. import {
  101. receiveCoupon
  102. } from '@/api/coupon.js';
  103. import tools from "@/service/tools";
  104. import {
  105. shopOrderCoupon
  106. } from '@/api/shop.js'
  107. export default {
  108. components: {
  109. EnBlank
  110. },
  111. data() {
  112. return {
  113. type: 1, //1可用类型 2可领类型
  114. coupon_id: 1,
  115. dataType: '', //1外卖 2代取 3干洗
  116. isAJAX: false,
  117. // 代取优惠券
  118. expressCouponData: {
  119. coupon: [], //可用
  120. receive: [], //可领
  121. },
  122. }
  123. },
  124. methods: {
  125. getList(e, id, shop_id) {
  126. console.log(e, id);
  127. if (id) {
  128. this.coupon_id = id;
  129. } else {
  130. this.coupon_id = '';
  131. }
  132. this.dataType = Number(e)
  133. if (e == 1) {
  134. this.shopOrderCoupon(shop_id)
  135. } else if (e == 2) {
  136. this.getExpressCoupon()
  137. }
  138. },
  139. // 代取 获取优惠券
  140. getExpressCoupon() {
  141. let operate_id = uni.getStorageSync('operate_id');
  142. getExpressCoupon({
  143. operate_id: operate_id
  144. }).then((res) => {
  145. if (res.code === 1) {
  146. this.expressCouponData = res.data;
  147. this.openPop();
  148. }
  149. })
  150. },
  151. shopOrderCoupon(shop_id) {
  152. // 下单是获取优惠卷
  153. let operate_id = uni.getStorageSync('operate_id');
  154. shopOrderCoupon({
  155. operate_id: operate_id,
  156. shop_id: shop_id
  157. }).then((res) => {
  158. if (res.code === 1) {
  159. this.expressCouponData = res.data;
  160. this.openPop();
  161. }
  162. })
  163. },
  164. setType(type) {
  165. if (type != this.type) {
  166. this.type = type
  167. }
  168. },
  169. openPop() {
  170. this.$refs.popupCoupon.open();
  171. },
  172. closeCoupon() {
  173. this.$refs.popupCoupon.close();
  174. },
  175. setFun(item) {
  176. this.$emit('giveCouPon', item);
  177. this.closeCoupon();
  178. },
  179. getFun(item) {
  180. if (this.isAJAX) {
  181. return
  182. }
  183. this.isAJAX = true;
  184. receiveCoupon({
  185. grant_id: item.grant_id,
  186. coupon_id: item.coupon_id
  187. }).then((res) => {
  188. if (res.code === 1) {
  189. this.isAJAX = false;
  190. tools.success('领取成功');
  191. this.resetList();
  192. } else {
  193. this.isAJAX = false;
  194. tools.success('领取失败');
  195. }
  196. })
  197. },
  198. resetList() {
  199. if (this.dataType == 1) {
  200. } else if (this.dataType == 2) {
  201. this.getExpressCoupon()
  202. }
  203. },
  204. },
  205. }
  206. </script>
  207. <style scoped lang="scss">
  208. .w382 {
  209. width: 382rpx;
  210. }
  211. .item-box {
  212. position: relative;
  213. .s-icon {
  214. width: 32rpx;
  215. height: 32rpx;
  216. position: absolute;
  217. top: 45%;
  218. right: 24rpx;
  219. }
  220. }
  221. .pop-coupon {
  222. width: 100%;
  223. height: 70vh;
  224. background-color: #F5F4F9;
  225. border-radius: 24rpx 24rpx 0rpx 0rpx;
  226. padding-top: 32rpx !important;
  227. display: flex;
  228. flex-direction: column;
  229. .box-title {
  230. position: relative;
  231. .box-close {
  232. position: absolute;
  233. right: 22rpx;
  234. }
  235. }
  236. .item-right {
  237. padding: 24rpx;
  238. box-sizing: border-box;
  239. border-radius: 20rpx 0 0 20rpx;
  240. position: relative;
  241. }
  242. .item-hr {
  243. width: 0px;
  244. height: auto;
  245. border-right: 1rpx dashed #FB7850;
  246. }
  247. .item-hr-two {
  248. width: 0px;
  249. height: auto;
  250. border-right: 1rpx dashed #999;
  251. }
  252. .item-left {
  253. width: 200rpx;
  254. height: auto;
  255. padding: 20rpx 24rpx;
  256. box-sizing: border-box;
  257. position: relative;
  258. border-radius: 0 20rpx 20rpx 0;
  259. }
  260. .but-box {
  261. width: 152rpx;
  262. height: 52rpx;
  263. line-height: 52rpx;
  264. text-align: center;
  265. background: linear-gradient(225deg, #FB3D03 0%, #FF6901 100%);
  266. border-radius: 200rpx;
  267. }
  268. .ball {
  269. width: 24rpx;
  270. height: 24rpx;
  271. border-radius: 50%;
  272. position: absolute;
  273. top: -12rpx;
  274. left: -12rpx;
  275. background: #F5F5F5;
  276. z-index: 2;
  277. }
  278. .ball-two {
  279. width: 24rpx;
  280. height: 24rpx;
  281. border-radius: 50%;
  282. position: absolute;
  283. background: #F5F5F5;
  284. z-index: 10;
  285. bottom: -12rpx;
  286. left: -12rpx;
  287. }
  288. }
  289. </style>