couponList.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view class="content">
  3. <u-tabs-swiper ref="uTabs" :active-color="mainColor" :list="tabList" :current="current" @change="tabsChange"
  4. :is-scroll="false"></u-tabs-swiper>
  5. <swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" class="swiper-box">
  6. <swiper-item class="swiper-item" v-for="(item, index1) in tabList" :key="index1">
  7. <scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
  8. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
  9. @refresherrestore="onRestore">
  10. <template v-if="current != 3">
  11. <u-card :show-head="false" :show-foot="false" padding="0px" margin="10px" borderRadius="40" v-for="(site, index2) in item.tableList"
  12. :key="index2" class="class-card">
  13. <view class="class-content" slot="body">
  14. <view class="class-info-img">
  15. <u-image width="60px" height="60px" :src="site.url" shape="circle"></u-image>
  16. </view>
  17. <view class="class-info-content">
  18. <view class="class-info-label">{{site.name}}¥{{site.amount}}</view>
  19. <view class="class-info-text">{{site.typeValue}}&nbsp;&nbsp;{{site.content}}</view>
  20. <view class="class-info-text">{{site.endDate}}&nbsp;&nbsp;到期</view>
  21. </view>
  22. <view class="card-mask" v-if="index1 == 1"></view>
  23. <view class="out-date" v-if="index1 == 2">已用</view>
  24. </view>
  25. </u-card>
  26. <u-divider v-if="item.isOver" bg-color="transparent">没有更多了</u-divider>
  27. </template>
  28. <template v-else>
  29. <view class="content-info">
  30. <view class="share-img">
  31. <u-image width="60vw" height="60vw" :src="shareUrl" ></u-image>
  32. <view class="share-class">共5节课</view>
  33. </view>
  34. </view>
  35. </template>
  36. </scroll-view>
  37. </swiper-item>
  38. </swiper>
  39. <u-top-tips ref="uTips"></u-top-tips>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. mapGetters
  45. } from 'vuex'
  46. const NET = require('@/utils/request')
  47. const API = require('@/config/api')
  48. export default {
  49. computed: {
  50. ...mapGetters([
  51. 'mainColor',
  52. 'handleCustomStyle',
  53. 'handleDefaultCustomStyle',
  54. ])
  55. },
  56. data() {
  57. return {
  58. triggered: false,
  59. tabList: [{
  60. name: '可用',
  61. isOver: false,
  62. pageIndex: 1,
  63. tableList: [],
  64. }, {
  65. name: '过期',
  66. isOver: false,
  67. pageIndex: 1,
  68. tableList: [],
  69. }, {
  70. name: '使用记录',
  71. isOver: false,
  72. pageIndex: 1,
  73. tableList: [],
  74. },{
  75. name: '赠送课时券',
  76. isOver: false,
  77. pageIndex: 1,
  78. tableList: [],
  79. }],
  80. current: 0,
  81. swiperCurrent: 0,
  82. }
  83. },
  84. onLoad() {
  85. this.getTableList(0)
  86. this.getTableList(1)
  87. this.getTableList(2)
  88. },
  89. onReady() {},
  90. methods: {
  91. // tab页面切换
  92. tabsChange(index) {
  93. this.swiperCurrent = index;
  94. },
  95. // swiper-item左右移动,通知tabs的滑块跟随移动
  96. transition(e) {
  97. let dx = e.detail.dx;
  98. this.$refs.uTabs.setDx(dx);
  99. },
  100. // swiper滑动结束,分别设置tabs和swiper的状态
  101. animationfinish(e) {
  102. let current = e.detail.current;
  103. this.$refs.uTabs.setFinishCurrent(current);
  104. this.swiperCurrent = current;
  105. this.current = current;
  106. console.log(this.current);
  107. },
  108. // 下拉刷新
  109. onRefresh() {
  110. if (!this.triggered) {
  111. this.triggered = true
  112. this.tabList[this.current].isOver = false
  113. this.tabList[this.current].pageIndex = 1
  114. this.tabList[this.current].tableList = []
  115. this.getTableList(this.current, 'refresh')
  116. }
  117. },
  118. // 重置下拉刷新状态
  119. onRestore() {
  120. this.triggered = 'restore'
  121. this.triggered = false
  122. },
  123. // 懒加载
  124. handleLoadMore() {
  125. if (!this.tabList[this.current].isOver) {
  126. this.tabList[this.current].pageIndex++
  127. this.getTableList(this.current)
  128. }
  129. },
  130. // 获取列表数据
  131. getTableList(index, refresh) {
  132. NET.request(API.getCouponList, {
  133. status: index,
  134. page: this.tabList[index].pageIndex,
  135. size: 10,
  136. }, 'POST').then(res => {
  137. this.triggered = false
  138. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
  139. this.tabList[index].isOver = res.data.row.length != 10
  140. }).catch(error => {
  141. this.triggered = false
  142. this.$refs.uTips.show({
  143. title: error.message,
  144. type: 'warning',
  145. })
  146. })
  147. }
  148. },
  149. }
  150. </script>
  151. <style>
  152. page {
  153. width: 100%;
  154. height: 100%;
  155. background-color: #f7f7f7;
  156. }
  157. </style>
  158. <style lang="scss" scoped>
  159. @import "@/static/css/themes.scss";
  160. .content {
  161. width: 100%;
  162. float: left;
  163. .swiper-box {
  164. height: calc(100vh - 34px);
  165. .swiper-item {
  166. height: calc(100vh - 34px);
  167. .scroll-box {
  168. width: 100%;
  169. height: calc(100vh - 34px);
  170. padding-bottom: 10px;
  171. box-sizing: border-box;
  172. .class-card {
  173. .class-content {
  174. padding: 10px 15px;
  175. display: flex;
  176. align-items: center;
  177. position: relative;
  178. }
  179. .class-info-img {
  180. width: 60px;
  181. height: 60px;
  182. margin-right: 10px;
  183. }
  184. .class-info-content {
  185. flex: 1;
  186. }
  187. .class-info-label {
  188. font-size: 16px;
  189. color: #000000;
  190. word-break: break-all;
  191. margin-bottom: 5px;
  192. }
  193. .class-info-text {
  194. color: #999999;
  195. margin-bottom: 5px;
  196. }
  197. .card-mask {
  198. width: 100%;
  199. height: 100%;
  200. position: absolute;
  201. left: 0;
  202. top: 0;
  203. background-color: rgba(0, 0, 0, 0.3);
  204. }
  205. .out-date {
  206. font-size: 10px;
  207. color: #ff9900;
  208. margin-bottom: 5px;
  209. position: absolute;
  210. right: 8px;
  211. bottom: 3px;
  212. }
  213. }
  214. }
  215. }
  216. }
  217. }
  218. .content-info {
  219. width: 100%;
  220. height: 100%;
  221. float: left;
  222. position: relative;
  223. .share-img {
  224. top: 40%;
  225. left: 50%;
  226. transform: translate(-50%, -50%);
  227. position: absolute;
  228. .share-class {
  229. margin-top: 20rpx;
  230. text-align: center;
  231. }
  232. }
  233. }
  234. </style>