dryClean-coupon.vue 7.5 KB

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