myCoupon.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view ref="container">
  3. <view>
  4. <u-tabs :list="listCoupon" @click="selcoupon" lineColor='#ff0000'></u-tabs>
  5. </view>
  6. <view class="coupon-list" v-if="couponsList.length > 0">
  7. <view class="item acea-row row-center-wrapper" v-for="(item, index) in couponsList" :key="index">
  8. <view class="money" >
  9. <image v-if="item.status==0" class="img" src="https://bjczwh.oss-cn-beijing.aliyuncs.com/app/shop/images/coupon1.png" mode="widthFix"></image>
  10. <image v-if="item.status!=0" class="img" src="https://bjczwh.oss-cn-beijing.aliyuncs.com/app/shop/images/coupon2.png" mode="widthFix"></image>
  11. <view style="z-index: 999;">
  12. ¥<text class="num">{{ item.couponPrice }}</text>
  13. </view>
  14. <view class="pic-num" >满{{ item.useMinPrice }}元可用</view>
  15. </view>
  16. <view class="text">
  17. <view class="condition line1 justify-between align-center">
  18. <view>{{ item.couponTitle }}</view>
  19. <view class="base-color-red bor-red h50 lh50 plr20 radius40 fs24"
  20. v-if="tabsact==3&&item.status==0" @click="refund(item,index)">可退款</view>
  21. <view class="base-color-red bor-red h50 lh50 plr20 radius40 fs24"
  22. v-if="tabsact==3&&item.status==4">退款中</view>
  23. </view>
  24. <view class="data acea-row row-between-wrapper">
  25. <view v-if="item.limitTime!=null">{{ item.limitTime }}到期</view>
  26. <view v-else>永久使用期限</view>
  27. <view class="bnt gray" v-if="item.status==1" >已使用</view>
  28. <view class="bnt gray" v-if="item.status==-1" >已过期</view>
  29. <view class="bnt bg-color-red" v-if="item.status==0">可使用</view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view v-if="couponsList.length == 0" class="no-data-box" @click="getMyCouponList()">
  35. <image src="https://bjczwh.oss-cn-beijing.aliyuncs.com/app/shop/images/no_data.png" mode="aspectFit"></image>
  36. <view class="empty-title">暂无数据</view>
  37. </view>
  38. <view>
  39. <u-modal :show="showRefund" title="退款" content='确认是否退款立减金'
  40. :showCancelButton='true' @cancel='showRefund=false' @confirm='confirmRefund()'></u-modal>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import { getMyCouponList,refundCashCoupon } from '@/api/coupon'
  46. export default {
  47. name: 'UserCoupon',
  48. props: {},
  49. data: function() {
  50. return {
  51. couponsList: [],
  52. listCoupon:[
  53. {
  54. name:'优惠卷',
  55. value:0
  56. },
  57. {
  58. name:'立减金',
  59. value:3
  60. }
  61. ],
  62. tabsact:0,
  63. showRefund:false,
  64. refundId:null,
  65. delIndex:null
  66. }
  67. },
  68. watch: {
  69. },
  70. onLoad(option) {
  71. if(option.tabsact){
  72. this.tabsact=option.tabsact
  73. }
  74. this.getUseCoupons()
  75. },
  76. mounted() {
  77. },
  78. methods: {
  79. refund(item,index){
  80. this.refundId=item
  81. this.showRefund=true
  82. this.delIndex=index
  83. },
  84. confirmRefund(){
  85. const user=JSON.parse(uni.getStorageSync('userInfo'))
  86. const data={
  87. couponId:this.refundId.couponId,
  88. id:this.refundId.id,
  89. userId:user.userId,
  90. couponType:this.tabsact
  91. }
  92. refundCashCoupon(data).then(res=>{
  93. if(res.code==200){
  94. uni.showToast({
  95. icon:'success',
  96. title: res.msg,
  97. });
  98. this.showRefund=false
  99. this.couponsList.splice(this.delIndex,1);
  100. console.log(this.couponsList)
  101. }else{
  102. uni.showToast({
  103. icon:'none',
  104. title: res.msg,
  105. });
  106. }
  107. })
  108. },
  109. selcoupon(e){
  110. this.tabsact=e.value
  111. this.getUseCoupons()
  112. console.log(e)
  113. },
  114. getUseCoupons(){
  115. var data={
  116. couponType:this.tabsact,
  117. }
  118. getMyCouponList(data).then(res => {
  119. if(res.code==200){
  120. this.couponsList = res.data
  121. }else{
  122. uni.showToast({
  123. icon:'none',
  124. title: res.msg,
  125. });
  126. }
  127. })
  128. },
  129. },
  130. }
  131. </script>
  132. <style lang="less" scoped>
  133. .container {
  134. height: 100%;
  135. }
  136. /*优惠券列表公共*/
  137. .coupon-list {
  138. padding: 0 0.3 * 100rpx;
  139. margin-top: 0.25 * 100rpx;
  140. box-sizing: border-box;
  141. }
  142. .coupon-list .item {
  143. width: 100%;
  144. height: 1.7 * 100rpx;
  145. margin-bottom: 0.16 * 100rpx;
  146. }
  147. .coupon-list .item .money {
  148. background-size: 100% 100%;
  149. width: 2.4 * 100rpx;
  150. height: 100%;
  151. color: #fff;
  152. font-size: 0.36 * 100rpx;
  153. font-weight: bold;
  154. text-align: center;
  155. display: flex;
  156. flex-direction: column;
  157. align-items: center;
  158. justify-content: center;
  159. position: relative;
  160. }
  161. .coupon-list .item .money .img{
  162. position: absolute;
  163. width: 2.4 * 100rpx;
  164. height: 100%;
  165. color: #fff;
  166. }
  167. .coupon-list .item .money .num {
  168. font-size: 0.6 * 100rpx;
  169. }
  170. .coupon-list .item .money .pic-num {
  171. font-size: 20rpx;
  172. z-index: 99;
  173. }
  174. .coupon-list .item .text {
  175. width: 4.5 * 100rpx;
  176. padding: 0 0.17 * 100rpx 0 0.24 * 100rpx;
  177. background-color: #fff;
  178. box-sizing: border-box;
  179. }
  180. .coupon-list .item .text .condition {
  181. font-size: 0.3 * 100rpx;
  182. color: #282828;
  183. height: 0.93 * 100rpx;
  184. line-height: 0.93 * 100rpx;
  185. border-bottom: 1px solid #f0f0f0;
  186. }
  187. .coupon-list .item .text .data {
  188. font-size: 0.2 * 100rpx;
  189. color: #999;
  190. height: 0.76 * 100rpx;
  191. }
  192. .coupon-list .item .text .data .bnt {
  193. width: 1.36 * 100rpx;
  194. height: 0.44 * 100rpx;
  195. border-radius: 0.22 * 100rpx;
  196. font-size: 0.22 * 100rpx;
  197. color: #fff;
  198. text-align: center;
  199. line-height: 0.44 * 100rpx;
  200. background-color: red;
  201. }
  202. .coupon-list .item .text .data .bnt.gray {
  203. background-color: #ccc;
  204. }
  205. </style>