coupon.vue 7.1 KB

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