couponList.vue 7.5 KB

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