couponList.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="container">
  3. <view class="coupon-tab">
  4. <u-tabs :list="tabList" :is-scroll="false" :current="tabIndex" @change="changeTabs" font-size="30" active-color="#52A63A"
  5. inactive-color="#666666" :bold="false" height="90" bar-width="120"></u-tabs>
  6. </view>
  7. <view class="coupon-box" v-if="tabIndex == 0">
  8. <view class="coupon-row" v-for="(site, index2) in couponList1" :key="index2">
  9. <view class="coupon-left">
  10. <view class="coupon-left-price"><text style="font-size: 16px;">¥</text>{{site.discountAmount}}</view>
  11. <view class="coupon-left-text">满减金额</view>
  12. </view>
  13. <view class="coupon-info">
  14. <view class="coupon-text1">{{site.couponName}}</view>
  15. <view class="coupon-text1" style="margin-bottom: 4px;">满{{site.fullAmount}}减{{site.discountAmount}}</view>
  16. <view class="coupon-text2">{{site.couponType == 1 ? '仅限用于' + site.name + '的店铺' : ''}}</view>
  17. <view class="coupon-text2" style="color: #999999;">有效期:{{site.term}}</view>
  18. </view>
  19. </view>
  20. <u-divider :color="isOver ? '#909399' : '#51A539'" :border-color="isOver ? '#909399' : '#51A539'" @click="handleLoadMore()">
  21. <u-loading mode="circle" v-if="loadingData"></u-loading>{{loadingData ? '加载中' : (isOver ? '没有更多了' : '点击加载更多')}}
  22. </u-divider>
  23. </view>
  24. <view class="coupon-box" v-if="tabIndex == 1">
  25. <view class="coupon-row" v-for="(site, index2) in couponList2" :key="index2">
  26. <view class="coupon-left">
  27. <view class="coupon-left-price"><text style="font-size: 16px;">¥</text>{{site.discountAmount}}</view>
  28. <view class="coupon-left-text">满减金额</view>
  29. </view>
  30. <view class="coupon-info">
  31. <view class="coupon-text1">{{site.couponName}}</view>
  32. <view class="coupon-text1" style="margin-bottom: 4px;">满{{site.fullAmount}}减{{site.discountAmount}}</view>
  33. <view class="coupon-text2">{{site.couponType == 1 ? '仅限用于' + site.name + '的店铺' : ''}}</view>
  34. <view class="coupon-text2" style="color: #999999;">有效期:{{site.term}}</view>
  35. </view>
  36. </view>
  37. <u-divider :color="isOver ? '#909399' : '#51A539'" :border-color="isOver ? '#909399' : '#51A539'" @click="handleLoadMore()">
  38. <u-loading mode="circle" v-if="loadingData"></u-loading>{{loadingData ? '加载中' : (isOver ? '没有更多了' : '点击加载更多')}}
  39. </u-divider>
  40. </view>
  41. <view class="coupon-box" v-if="tabIndex == 2">
  42. <view class="coupon-row" v-for="(site, index2) in couponList3" :key="index2">
  43. <view class="coupon-left">
  44. <view class="coupon-left-price"><text style="font-size: 16px;">¥</text>{{site.discountAmount}}</view>
  45. <view class="coupon-left-text">满减金额</view>
  46. </view>
  47. <view class="coupon-info">
  48. <view class="coupon-text1">{{site.couponName}}</view>
  49. <view class="coupon-text1" style="margin-bottom: 4px;">满{{site.fullAmount}}减{{site.discountAmount}}</view>
  50. <view class="coupon-text2">{{site.couponType == 1 ? '仅限用于' + site.name + '的店铺' : ''}}</view>
  51. <view class="coupon-text2" style="color: #999999;">有效期:{{site.term}}</view>
  52. </view>
  53. </view>
  54. <u-divider :color="isOver ? '#909399' : '#51A539'" :border-color="isOver ? '#909399' : '#51A539'" @click="handleLoadMore()">
  55. <u-loading mode="circle" v-if="loadingData"></u-loading>{{loadingData ? '加载中' : (isOver ? '没有更多了' : '点击加载更多')}}
  56. </u-divider>
  57. </view>
  58. <u-top-tips ref="uTips"></u-top-tips>
  59. </view>
  60. </template>
  61. <script>
  62. const NET = require('@/utils/request')
  63. const API = require('@/config/api')
  64. export default {
  65. data() {
  66. return {
  67. tabIndex: 0,
  68. tabList: [{
  69. name: '我的券'
  70. },
  71. {
  72. name: '未使用'
  73. },
  74. {
  75. name: '已使用'
  76. }
  77. ],
  78. loadingData: false,
  79. isOver: false,
  80. pageIndex1: 1,
  81. couponList1: [],
  82. pageIndex2: 1,
  83. couponList2: [],
  84. pageIndex3: 1,
  85. couponList3: [],
  86. }
  87. },
  88. onLoad() {
  89. this.getList()
  90. },
  91. methods: {
  92. // 切换tab
  93. changeTabs(index) {
  94. this.tabIndex = index
  95. this['pageIndex' + (index + 1)] = 1
  96. this['couponList' + (index + 1)] = []
  97. this.isOver = false
  98. this.loadingData = false
  99. this.getList()
  100. },
  101. // 懒加载
  102. handleLoadMore() {
  103. if (!this.isOver) {
  104. this['pageIndex' + (this.tabIndex + 1)]++
  105. this.getList()
  106. }
  107. },
  108. // 获取列表数据
  109. getList() {
  110. this.loadingData = true
  111. NET.request(API.getCouponList, {
  112. isUse: this.tabIndex == 0 ? null : (this.tabIndex == 1 ? 0 : 1),
  113. pageIndex: this['pageIndex' + (this.tabIndex + 1)],
  114. pageSize: 10,
  115. }, 'POST').then(res => {
  116. this.loadingData = false
  117. this.isOver = res.data.list.length != 10
  118. this['couponList' + (this.tabIndex + 1)] = this['couponList' + (this.tabIndex + 1)].concat(res.data.list)
  119. }).catch(error => {
  120. this.loadingData = false
  121. this.$refs.uTips.show({
  122. title: error.data.msg,
  123. type: 'warning',
  124. })
  125. })
  126. },
  127. },
  128. }
  129. </script>
  130. <style lang="less" scoped>
  131. page {
  132. width: 100%;
  133. height: 100%;
  134. }
  135. .container {
  136. width: 100%;
  137. height: 100%;
  138. float: left;
  139. background-color: #f7f7f7;
  140. overflow-y: auto;
  141. .coupon-tab {
  142. width: 100%;
  143. height: 45px;
  144. float: left;
  145. background-color: #FFFFFF;
  146. margin-bottom: 16px;
  147. }
  148. .coupon-row {
  149. width: calc(100% - 32px);
  150. height: 105px;
  151. float: left;
  152. margin: 0 16px 10px 16px;
  153. border-radius: 10px;
  154. background: #FFFFFF;
  155. box-shadow: 0px 0px 10px 0px rgba(103, 103, 103, 0.3);
  156. overflow: hidden;
  157. .coupon-left {
  158. width: 107px;
  159. height: 105px;
  160. box-sizing: border-box;
  161. padding-right: 10px;
  162. float: left;
  163. background-size: 107px 105px;
  164. background-position: center;
  165. background-repeat: no-repeat;
  166. background-image: url(@/static/images/couponHead.png);
  167. .coupon-left-price {
  168. width: 100%;
  169. height: 24px;
  170. float: left;
  171. margin: 28px 0 12px 0;
  172. font-size: 24px;
  173. font-family: PingFang SC;
  174. color: #FFFFFF;
  175. line-height: 24px;
  176. text-align: center;
  177. }
  178. .coupon-left-text {
  179. width: 100%;
  180. height: 20px;
  181. float: left;
  182. color: #FFFFFF;
  183. font-size: 12px;
  184. font-family: PingFang SC;
  185. line-height: 20px;
  186. text-align: center;
  187. }
  188. }
  189. .coupon-info {
  190. width: calc(100% - 115px);
  191. height: 100%;
  192. float: right;
  193. box-sizing: border-box;
  194. padding: 16px 0 12px 0;
  195. .coupon-text1 {
  196. width: 100%;
  197. height: 20px;
  198. float: right;
  199. font-size: 15px;
  200. font-family: PingFang SC;
  201. color: #333333;
  202. line-height: 20px;
  203. white-space: nowrap;
  204. text-overflow: ellipsis;
  205. overflow: hidden;
  206. }
  207. .coupon-text2 {
  208. width: 100%;
  209. height: 18px;
  210. float: right;
  211. font-size: 13px;
  212. font-family: PingFang SC;
  213. color: #EB5F2F;
  214. line-height: 18px;
  215. white-space: nowrap;
  216. text-overflow: ellipsis;
  217. overflow: hidden;
  218. }
  219. }
  220. }
  221. }
  222. /deep/.u-divider {
  223. background-color: transparent !important;
  224. }
  225. </style>