You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
4.6 KiB

1 week ago
  1. <template>
  2. <view class="personal-coupon" >
  3. <u-subsection :list="list"
  4. active-color="#ffaa48"
  5. bg-color="#fff"
  6. inactive-color="#aaaaaa"
  7. font-size="16"
  8. :current="curNow"
  9. @change="sectionChange" ></u-subsection>
  10. <view v-if="curNow==0">
  11. <view v-for="(item,index) in sendedList" style="padding:14px 18px 0;" :key="index">
  12. <view class="card">
  13. <view class="card-left">{{switchType(item.stockType)}}</view>
  14. <view class="card-right">
  15. <view class="card-content">
  16. <view class="card-info">{{item.stockName}}</view>
  17. <view class="card-time">有效期限: {{item.expireTime.slice(0, 10)}}截止</view>
  18. </view>
  19. <view style="width: 20%;">
  20. <u-button shape="circle" size="mini" color="#ffaa48" text="去使用" @click="useCoupon()"></u-button>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view v-if="curNow==1">
  27. <view v-for="(item,index) in usedList" style="padding:14px 18px 0;" :key="index">
  28. <view class="card">
  29. <view class="card-left" style="color: #aaaaaa;">{{switchType(item.stockType)}}</view>
  30. <view class="card-right">
  31. <view class="card-content">
  32. <view class="card-info" style="color: #aaaaaa;">{{item.stockName}}</view>
  33. <view class="card-time" style="color: #aaaaaa;">有效期限: {{item.expireTime.slice(0, 10)}}截止</view>
  34. </view>
  35. <view class="card-icon">
  36. <image src="./../../static/images/personal/used.png" alt="used" style="width: 60px;height: 60px;"/>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view v-if="curNow==2">
  43. <view v-for="(item,index) in exporedList" style="padding:14px 18px 0;" :key="index">
  44. <view class="card">
  45. <view class="card-left" style="color: #aaaaaa;">{{switchType(item.stockType)}}</view>
  46. <view class="card-right">
  47. <view class="card-content" >
  48. <view class="card-info" style="color: #aaaaaa;">{{item.stockName}}</view>
  49. <view class="card-time" style="color: #aaaaaa;">有效期限: {{item.expireTime.slice(0, 10)}}截止</view>
  50. </view>
  51. <view class="card-icon">
  52. <image src="./../../static/images/personal/invalid.png" alt="invalid" style="width: 60px;height: 60px;"/>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import {getCouponList} from "@/api/system/personal.js"
  62. export default{
  63. data(){
  64. return{
  65. list: ['未使用', '已使用', '已失效'],
  66. curNow: 0,
  67. sendedList:[],
  68. usedList:[],
  69. exporedList:[]
  70. }
  71. },
  72. onLoad() {
  73. // this.openIdStr = this.$globalData.openIdStr;
  74. this.getCouponList()
  75. },
  76. methods: {
  77. sectionChange(index) {
  78. this.curNow = index;
  79. },
  80. getCouponList() {
  81. getCouponList().then(res=>{
  82. let rows = res.rows
  83. console.log(rows)
  84. this.sendedList=rows.filter(item=>item.couponState=="SENDED")
  85. this.usedList=rows.filter(item=>item.couponState=="USED")
  86. this.exporedList=rows.filter(item=>item.couponState=="EXPORED")
  87. })
  88. },
  89. switchType(type){
  90. if(type=='PNORMAL'){
  91. return '满减券'
  92. }
  93. if(type=='PDISCOUNT'){
  94. return '折扣券'
  95. }
  96. if(type=='PTRAIL'){
  97. return '体验券'
  98. }
  99. return '优惠券'
  100. },
  101. useCoupon(){
  102. this.$globalData.newOrderData={
  103. currentAddress:{},
  104. currentPets:[],
  105. totalPrice:0,
  106. needPreFamiliarize:[]
  107. }
  108. uni.navigateTo({
  109. url: `/pages/newOrder/serviceNew`
  110. });
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss">
  116. .personal-coupon{
  117. .card{
  118. display: flex;
  119. align-items: center;
  120. width: 100%;
  121. padding: 10px 0;
  122. background: #fff;
  123. border-radius: 8px;
  124. -webkit-mask-image: radial-gradient(circle at 88px 4px, transparent 4px, #d8d8d8 4.5px),radial-gradient(closest-side circle at 50%, #d8d8d8 99%, transparent 100%);
  125. -webkit-mask-size: 100%, 2px 4px;
  126. -webkit-mask-repeat: repeat, repeat-y;
  127. -webkit-mask-position: 0 -4px, 87px;
  128. -webkit-mask-composite: source-out;
  129. mask-composite: subtract;
  130. // background: linear-gradient(45deg, orange, red);
  131. }
  132. .card-left{
  133. width: 88px;
  134. text-align: center;
  135. font-size: 18px;
  136. color: #333333;
  137. }
  138. .card-right{
  139. padding: 0px 12px;
  140. display: flex;
  141. flex: 1;
  142. /* flex-direction: column; */
  143. justify-content: space-between;
  144. align-items: center;
  145. height: 60px;s
  146. .card-content {
  147. width: 80%;
  148. }
  149. .card-icon{
  150. position: relative;
  151. right: -10px;
  152. top: -10px;
  153. }
  154. }
  155. .card-info{
  156. margin: 0;
  157. font-size: 14px;
  158. line-height: 20px;
  159. color:#333333;
  160. }
  161. .card-time{
  162. font-size: 12px;
  163. line-height: 16px;
  164. font-weight: normal;
  165. color: #aaaaaa;
  166. margin-top: 4px;
  167. }
  168. }
  169. </style>