index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="page" :style="{'height':windowHeight}">
  3. <view class="flex-row">
  4. <view class="flex-col justify-center" @click="noUseChange">
  5. <u-icon v-if="noUse" name="checkmark-circle-fill" color="#38db38" size="25" ></u-icon>
  6. <u-icon v-else name="/static/order/ud9.png" color="green" size="25"></u-icon>
  7. </view>
  8. <view class="noUse">
  9. <text>不使用优惠券</text>
  10. </view>
  11. </view>
  12. <view :style="{'height':scrollViewHeight}">
  13. <scroll-view class="scroll " :style="{'height':scrollViewHeight}" scroll-y>
  14. <view class="row-list flex-row justify-start" :class="{'grayscale' : item.discountsPrice>standardPrice }" v-for="(item,index) in countsList" @click="clickCoupons(item,index)" :key="index">
  15. <view class="h-text flex-col justify-center ">
  16. <view class="money">
  17. <text>¥{{item.discountsPrice}}</text>
  18. </view>
  19. <view class="desc">
  20. <text>{{item.name}}</text>
  21. </view>
  22. </view>
  23. <view class="h-center-content flex-col ">
  24. <view class="h-value">
  25. <text>门店通用</text>
  26. </view>
  27. <view class="title">
  28. 使用平台:<text v-if="item.strategyType == '0'">全平台</text>
  29. <text v-else-if="item.strategyType == '1'">个人优惠卷</text>
  30. </view>
  31. <view class="title">
  32. 使用次数:{{item.degree}}
  33. </view>
  34. <view class="title">
  35. 到期时间:{{item.endTime.substring(0,10)}}
  36. </view>
  37. </view>
  38. <view class="h-right-content flex-col justify-center">
  39. <view class="flex-row justify-center" v-if="item.discountsPrice>standardPrice">
  40. <view class="h-btn-img">
  41. <image class="h-btn-img" src="/static/coupon/u2110.png" mode=""></image>
  42. </view>
  43. </view>
  44. <view class="flex-row justify-center" v-else>
  45. <u-icon v-if="item.isUse " name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  46. <u-icon v-else name="/static/order/ud9.png" color="green" size="25"></u-icon>
  47. </view>
  48. </view>
  49. </view>
  50. </scroll-view>
  51. </view>
  52. <view>
  53. <view class="btn" @click="useCoupons">
  54. <text>确定</text>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. export default {
  61. data() {
  62. return {
  63. countsList:[],
  64. noUse:true,
  65. windowHeight:'',
  66. scrollViewHeight:'',
  67. standardPrice:0,
  68. };
  69. },
  70. onLoad(e) {
  71. let sysInfo = uni.getSystemInfoSync()
  72. this.windowHeight =sysInfo.windowHeight +'px'
  73. this.scrollViewHeight =sysInfo.windowHeight -(sysInfo.windowWidth/750)*252 +'px'
  74. this.getMyCouponList()
  75. if (e.standardPrice){
  76. console.log('++++++++++++++', e.standardPrice)
  77. this.standardPrice = e.standardPrice
  78. }
  79. },
  80. computed: {
  81. },
  82. methods: {
  83. useCoupons(){
  84. let useCoupons = []
  85. for (const useCoupon of this.countsList) {
  86. if (useCoupon.isUse){
  87. useCoupons.push(useCoupon)
  88. }
  89. }
  90. uni.$emit('getUseCoupons',useCoupons)
  91. uni.navigateBack({
  92. data:1
  93. })
  94. },
  95. noUseChange(){
  96. this.noUse = !this.noUse
  97. if (this.noUse){
  98. this.countsList.forEach(item=>{
  99. item.isUse = false
  100. })
  101. }
  102. },
  103. clickCoupons(item,index){
  104. if (item.discountsPrice > this.standardPrice){
  105. return
  106. }
  107. //关闭多选开始
  108. this.countsList.forEach(item=>{
  109. item.isUse = false
  110. })
  111. //关闭多选结束
  112. console.log(item)
  113. this.noUse = false
  114. item.isUse = !item.isUse
  115. this.$set(this.countsList,index,item)
  116. let flag = true
  117. this.countsList.forEach(item=>{
  118. if (item.isUse){
  119. flag = false
  120. }
  121. })
  122. this.noUse = flag
  123. },
  124. // 查询可领取的优惠劵
  125. getMyCouponList(){
  126. let that = this;
  127. // 用户绑定门店
  128. this.$api.getMyCouponList({
  129. type:0,
  130. pageNum: 1,
  131. pageSize: 1000,
  132. }).then((res)=>{
  133. console.log(res)
  134. this.countsList = res.data.rows;
  135. }).catch(() =>{
  136. uni.showToast({
  137. title: "操作失败"
  138. })
  139. })
  140. },
  141. },
  142. };
  143. </script>
  144. <style lang="scss" scoped>
  145. @import '/common/css/common.css';
  146. @import './index.rpx.scss';
  147. </style>