couponList.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. <u-form ref="form" label-width="80">
  31. <u-form-item label="学员" right-icon="arrow-right" required @click.native="studentShow = true">
  32. <u-input v-model="studentName" placeholder="请选择学员" disabled @click="studentShow = true" />
  33. </u-form-item>
  34. <!-- <u-input v-model="studentName" placeholder="请选择归属场馆" disabled @click="studentShow = true" /> -->
  35. </u-form>
  36. <view class="share-img">
  37. <u-image width="60vw" height="60vw" :src="qrcodeUrl" ></u-image>
  38. <view class="share-class">共{{ classes }}节课</view>
  39. </view>
  40. </view>
  41. </template>
  42. </scroll-view>
  43. </swiper-item>
  44. </swiper>
  45. <u-picker mode="selector" v-model="studentShow" :range="studentList" range-key="childName" @confirm="handleStudentClick"></u-picker>
  46. <u-top-tips ref="uTips"></u-top-tips>
  47. </view>
  48. </template>
  49. <script>
  50. import {
  51. mapGetters
  52. } from 'vuex'
  53. const NET = require('@/utils/request')
  54. const API = require('@/config/api')
  55. export default {
  56. computed: {
  57. ...mapGetters([
  58. 'mainColor',
  59. 'handleCustomStyle',
  60. 'handleDefaultCustomStyle',
  61. ])
  62. },
  63. data() {
  64. return {
  65. triggered: false,
  66. tabList: [{
  67. name: '可用',
  68. isOver: false,
  69. pageIndex: 1,
  70. tableList: [],
  71. }, {
  72. name: '过期',
  73. isOver: false,
  74. pageIndex: 1,
  75. tableList: [],
  76. }, {
  77. name: '使用记录',
  78. isOver: false,
  79. pageIndex: 1,
  80. tableList: [],
  81. },{
  82. name: '赠送课时券',
  83. isOver: false,
  84. pageIndex: 1,
  85. tableList: [],
  86. }],
  87. current: 0,
  88. swiperCurrent: 0,
  89. // 学生id
  90. studentId: '',
  91. // 学生姓名
  92. studentName: '',
  93. studentShow: '',
  94. studentList: [],
  95. // 二维码
  96. qrcodeUrl: '',
  97. // 课时
  98. classes: 0
  99. }
  100. },
  101. onLoad() {
  102. this.getTableList(0)
  103. this.getTableList(1)
  104. this.getTableList(2)
  105. this.getCouponList()
  106. },
  107. onReady() {},
  108. methods: {
  109. // 获取可用优惠券列表
  110. getCouponList() {
  111. NET.request(API.getUserStudent, {
  112. userId: uni.getStorageSync('userData').userId }, 'POST').then( res => {
  113. if(res.status == 10000) {
  114. this.studentList = res.data
  115. if(this.studentList.length) {
  116. this.handleStudentClick(0)
  117. }
  118. }
  119. })
  120. },
  121. // 选择学生
  122. handleStudentClick(args) {
  123. this.studentId = this.studentList[args].studentId
  124. this.studentName = this.studentList[args].childName
  125. this.getInfo()
  126. },
  127. // 根据学员获取二维码和剩余课时
  128. getInfo() {
  129. NET.request(API.studentQRcode, { studentId: this.studentId },'POST').then(res => {
  130. if(res.status == 10000) {
  131. this.qrcodeUrl = res.data
  132. }
  133. })
  134. NET.request(API.getGiveLessons, { studentId: this.studentId },'POST').then(res => {
  135. console.log(res);
  136. if(res.status == 10000) {
  137. console.log(res.data);
  138. this.classes = res.data.length
  139. }
  140. })
  141. },
  142. // tab页面切换
  143. tabsChange(index) {
  144. this.swiperCurrent = index;
  145. },
  146. // swiper-item左右移动,通知tabs的滑块跟随移动
  147. transition(e) {
  148. let dx = e.detail.dx;
  149. this.$refs.uTabs.setDx(dx);
  150. },
  151. // swiper滑动结束,分别设置tabs和swiper的状态
  152. animationfinish(e) {
  153. let current = e.detail.current;
  154. this.$refs.uTabs.setFinishCurrent(current);
  155. this.swiperCurrent = current;
  156. this.current = current;
  157. },
  158. // 下拉刷新
  159. onRefresh() {
  160. if (!this.triggered) {
  161. this.triggered = true
  162. this.tabList[this.current].isOver = false
  163. this.tabList[this.current].pageIndex = 1
  164. this.tabList[this.current].tableList = []
  165. this.getTableList(this.current, 'refresh')
  166. }
  167. },
  168. // 重置下拉刷新状态
  169. onRestore() {
  170. this.triggered = 'restore'
  171. this.triggered = false
  172. },
  173. // 懒加载
  174. handleLoadMore() {
  175. if (!this.tabList[this.current].isOver) {
  176. this.tabList[this.current].pageIndex++
  177. this.getTableList(this.current)
  178. }
  179. },
  180. // 获取列表数据
  181. getTableList(index, refresh) {
  182. NET.request(API.getCouponList, {
  183. status: index,
  184. page: this.tabList[index].pageIndex,
  185. size: 10,
  186. }, 'POST').then(res => {
  187. this.triggered = false
  188. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
  189. this.tabList[index].isOver = res.data.row.length != 10
  190. }).catch(error => {
  191. this.triggered = false
  192. this.$refs.uTips.show({
  193. title: error.message,
  194. type: 'warning',
  195. })
  196. })
  197. }
  198. },
  199. }
  200. </script>
  201. <style>
  202. page {
  203. width: 100%;
  204. height: 100%;
  205. background-color: #f7f7f7;
  206. }
  207. </style>
  208. <style lang="scss" scoped>
  209. @import "@/static/css/themes.scss";
  210. .content {
  211. width: 100%;
  212. float: left;
  213. .swiper-box {
  214. height: calc(100vh - 34px);
  215. .swiper-item {
  216. height: calc(100vh - 34px);
  217. .scroll-box {
  218. width: 100%;
  219. height: calc(100vh - 34px);
  220. padding-bottom: 10px;
  221. box-sizing: border-box;
  222. .class-card {
  223. .class-content {
  224. padding: 10px 15px;
  225. display: flex;
  226. align-items: center;
  227. position: relative;
  228. }
  229. .class-info-img {
  230. width: 60px;
  231. height: 60px;
  232. margin-right: 10px;
  233. }
  234. .class-info-content {
  235. flex: 1;
  236. }
  237. .class-info-label {
  238. font-size: 16px;
  239. color: #000000;
  240. word-break: break-all;
  241. margin-bottom: 5px;
  242. }
  243. .class-info-text {
  244. color: #999999;
  245. margin-bottom: 5px;
  246. }
  247. .card-mask {
  248. width: 100%;
  249. height: 100%;
  250. position: absolute;
  251. left: 0;
  252. top: 0;
  253. background-color: rgba(0, 0, 0, 0.3);
  254. }
  255. .out-date {
  256. font-size: 10px;
  257. color: #ff9900;
  258. margin-bottom: 5px;
  259. position: absolute;
  260. right: 8px;
  261. bottom: 3px;
  262. }
  263. }
  264. }
  265. }
  266. }
  267. }
  268. .content-info {
  269. width: 100%;
  270. height: 100%;
  271. float: left;
  272. position: relative;
  273. .share-img {
  274. top: 40%;
  275. left: 50%;
  276. transform: translate(-50%, -50%);
  277. position: absolute;
  278. .share-class {
  279. margin-top: 20rpx;
  280. text-align: center;
  281. }
  282. }
  283. }
  284. </style>