couponList.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. onPullDownRefresh() {
  92. this['pageIndex' + (this.tabIndex + 1)] = 1
  93. this['couponList' + (this.tabIndex + 1)] = []
  94. this.getList('refresh')
  95. },
  96. methods: {
  97. // 切换tab
  98. changeTabs(index) {
  99. this.tabIndex = index
  100. this['pageIndex' + (index + 1)] = 1
  101. this['couponList' + (index + 1)] = []
  102. this.isOver = false
  103. this.loadingData = false
  104. this.getList()
  105. },
  106. // 懒加载
  107. handleLoadMore() {
  108. if (!this.isOver) {
  109. this['pageIndex' + (this.tabIndex + 1)]++
  110. this.getList()
  111. }
  112. },
  113. // 获取列表数据
  114. getList(refresh) {
  115. this.loadingData = true
  116. NET.request(API.getCouponList, {
  117. isUse: this.tabIndex == 0 ? null : (this.tabIndex == 1 ? 0 : 1),
  118. pageIndex: this['pageIndex' + (this.tabIndex + 1)],
  119. pageSize: 10,
  120. }, 'POST').then(res => {
  121. if (refresh == 'refresh') {
  122. uni.stopPullDownRefresh();
  123. }
  124. if (res.isSuccess) {
  125. if (res.data.list.length) {
  126. this.loadingData = false
  127. this.isOver = res.data.list.length != 10
  128. this['couponList' + (this.tabIndex + 1)] = this['couponList' + (this.tabIndex + 1)].concat(res.data.list)
  129. }
  130. }
  131. }).catch(error => {
  132. this.loadingData = false
  133. this.$refs.uTips.show({
  134. title: error.data.msg,
  135. type: 'warning',
  136. })
  137. })
  138. },
  139. },
  140. }
  141. </script>
  142. <style lang="less" scoped>
  143. page {
  144. width: 100%;
  145. height: 100%;
  146. }
  147. .container {
  148. width: 100%;
  149. height: 100%;
  150. float: left;
  151. background-color: #f7f7f7;
  152. overflow-y: auto;
  153. .coupon-tab {
  154. width: 100%;
  155. height: 45px;
  156. float: left;
  157. background-color: #FFFFFF;
  158. margin-bottom: 16px;
  159. }
  160. .coupon-row {
  161. width: calc(100% - 32px);
  162. height: 105px;
  163. float: left;
  164. margin: 0 16px 10px 16px;
  165. border-radius: 10px;
  166. background: #FFFFFF;
  167. box-shadow: 0px 0px 10px 0px rgba(103, 103, 103, 0.3);
  168. overflow: hidden;
  169. .coupon-left {
  170. width: 107px;
  171. height: 105px;
  172. box-sizing: border-box;
  173. padding-right: 10px;
  174. float: left;
  175. background-size: 107px 105px;
  176. background-position: center;
  177. background-repeat: no-repeat;
  178. background-image: url(@/static/images/couponHead.png);
  179. .coupon-left-price {
  180. width: 100%;
  181. height: 24px;
  182. float: left;
  183. margin: 28px 0 12px 0;
  184. font-size: 24px;
  185. font-family: PingFang SC;
  186. color: #FFFFFF;
  187. line-height: 24px;
  188. text-align: center;
  189. }
  190. .coupon-left-text {
  191. width: 100%;
  192. height: 20px;
  193. float: left;
  194. color: #FFFFFF;
  195. font-size: 12px;
  196. font-family: PingFang SC;
  197. line-height: 20px;
  198. text-align: center;
  199. }
  200. }
  201. .coupon-info {
  202. width: calc(100% - 115px);
  203. height: 100%;
  204. float: right;
  205. box-sizing: border-box;
  206. padding: 16px 0 12px 0;
  207. .coupon-text1 {
  208. width: 100%;
  209. height: 20px;
  210. float: right;
  211. font-size: 15px;
  212. font-family: PingFang SC;
  213. color: #333333;
  214. line-height: 20px;
  215. white-space: nowrap;
  216. text-overflow: ellipsis;
  217. overflow: hidden;
  218. }
  219. .coupon-text2 {
  220. width: 100%;
  221. height: 18px;
  222. float: right;
  223. font-size: 13px;
  224. font-family: PingFang SC;
  225. color: #EB5F2F;
  226. line-height: 18px;
  227. white-space: nowrap;
  228. text-overflow: ellipsis;
  229. overflow: hidden;
  230. }
  231. }
  232. }
  233. }
  234. /deep/.u-divider {
  235. background-color: transparent !important;
  236. }
  237. </style>