index.vue 5.6 KB

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