index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view>
  3. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="选择优惠券"></u-navbar>
  4. <view class="coupon-title">可用优惠券:{{listNum}}</view>
  5. <view class="coupon-list">
  6. <view class="flex coupon-list-item" v-for="(item,index) in list" :key="index">
  7. <view class="flex coupon-list-item-info">
  8. <view class="money">
  9. <view class="">¥<text>{{item.discount}}</text></view>
  10. </view>
  11. <view class="flex content">
  12. <view class="txt title">{{item.title}}</view>
  13. <view class="txt">使用期限:{{ $parseTime(item.validStart, '{y}.{m}.{d}')}}-{{$parseTime(item.validEnd, '{y}.{m}.{d}')}}</view>
  14. <view class="txt">适用范围:{{item.useAreaDesc || '-'}}</view>
  15. </view>
  16. </view>
  17. <view class="checked">
  18. <view class="flex circle">
  19. <view class="action" v-if="actionIndex == 0"></view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="flex empty" v-if="!list.length">
  25. <u-empty text="数据为空" mode="order" />
  26. </view>
  27. <view class="footer-fixed">
  28. <view class="flex btn">
  29. <button type="default" @click="exchange">确认</button>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import env from '../../config/env.js'
  36. import $http from '@/utils/request.js'
  37. export default {
  38. data() {
  39. return {
  40. checked: false,
  41. actionIndex: 0,
  42. pageNum: 1,
  43. total: 0,
  44. list: [],
  45. listNum:'',
  46. };
  47. },
  48. onShow(){
  49. this.getList()
  50. },
  51. methods:{
  52. getList(){
  53. uni.showLoading({
  54. title: '加载中'
  55. });
  56. $http.post('/api/v1/mp/user/ticket/order/coupon/list', {}).then(
  57. res => {
  58. uni.hideLoading();
  59. console.log(res)
  60. if (res.code == 0) {
  61. this.listNum = res.data.length
  62. res.data.forEach(item =>{
  63. let useAreaDesc = JSON.parse(item.useArea)
  64. item.useAreaDesc = useAreaDesc.desc
  65. })
  66. this.list = this.list.concat(res.data)
  67. console.log(this.list)
  68. }
  69. }).catch(() => {
  70. uni.hideLoading();
  71. })
  72. },
  73. changeChecked(e){
  74. console.log(e);
  75. },
  76. exchange(){
  77. // 获取所选项
  78. // 返回立即支付位置
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .coupon {
  85. &-title {
  86. position: fixed;
  87. width: 100%;
  88. padding: 24rpx 32rpx;
  89. background-color: #FFFFFF;
  90. }
  91. &-list {
  92. margin-top: 100rpx;
  93. padding: 0 20rpx 100rpx;
  94. &-item {
  95. justify-content: space-between;
  96. padding: 20rpx;
  97. background-color: #FFFFFF;
  98. margin-bottom: 20rpx;
  99. &-info{
  100. flex: 1;
  101. justify-content: flex-start;
  102. height: 170rpx;
  103. image{
  104. width: 84rpx;
  105. height: 132rpx;
  106. margin-right: 20rpx;
  107. }
  108. .content{
  109. height: 132rpx;
  110. flex-direction: column;
  111. align-items: flex-start;
  112. justify-content: space-between;
  113. }
  114. .content .title{
  115. font-size: 32rpx;
  116. line-height: 50rpx;
  117. }
  118. .money{
  119. padding-right: 30rpx;
  120. font-weight: bold;
  121. text{
  122. font-size: 50rpx;
  123. }
  124. }
  125. }
  126. .circle{
  127. width: 40rpx;
  128. height: 40rpx;
  129. border-radius: 50%;
  130. border: 1px solid;
  131. }
  132. .action{
  133. width: 30rpx;
  134. height: 30rpx;
  135. border-radius: 50%;
  136. background-color: $uni-bg-color;
  137. }
  138. }
  139. }
  140. }
  141. .empty{
  142. height: 60vh;
  143. }
  144. .footer-fixed {
  145. position: fixed;
  146. bottom: var(--window-bottom);
  147. left: 0;
  148. right: 0;
  149. z-index: 11;
  150. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  151. background: #fff;
  152. // 设置ios刘海屏底部横线安全区域
  153. padding-bottom: constant(safe-area-inset-bottom);
  154. padding-bottom: env(safe-area-inset-bottom);
  155. .btn {
  156. padding: 20rpx 0;
  157. /deep/ button {
  158. width: 640rpx;
  159. height: 90rpx;
  160. line-height: 90rpx;
  161. font-size: 36rpx;
  162. color: #fff;
  163. background-color: $uni-bg-color;
  164. border: none;
  165. border-radius: 20rpx;
  166. }
  167. }
  168. }
  169. </style>