微信

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <div class="mainPage">
  3. <nav class="flex-h" v-if='false'>
  4. <a class="flex-item" v-for="(item,index) in nav" :key="index" :class="{'active':index==active}" @click="change(item,index)">{{item}}</a>
  5. </nav>
  6. <div style="background:#fff;">
  7. <!-- <scroll ref='scroll' :isloading='isloading' class='wrapper' :data='data[active].list' :pullUpLoad='pullUpLoadObj' :startY='parseInt(startY)' @pullingUp='getList'> -->
  8. <div class="box">
  9. <div v-if="active == 0">
  10. <discounts v-for="(item,index) in data[0].list" :key='index' @toUse='toUse' :data='item' @toDetail="toCardDetail(item)"></discounts>
  11. <noMore v-if="data[active].hasPic"></noMore>
  12. </div>
  13. <div v-if="active == 1">
  14. <div class="fitness-card" v-for="(item,index) in data[1].list" :key='index'>
  15. <div :class="{'opacity' : item.CardStatus == 'expire' || item.CardStatus == 'used', 'gray': item.CardStatus == 'used'}" @click="toGymCardDetail(item)">
  16. <div class="card-top">
  17. <div class="top-left">
  18. <img :src="logo" alt="">
  19. <div class="price">
  20. <span>¥</span>
  21. <h1>{{parseInt(item.Price)}}</h1>
  22. <span>元</span>
  23. </div>
  24. </div>
  25. <div class="top-right">
  26. <img :src="Line3" alt="">
  27. <div>{{item.CustomerGymName}}</div>
  28. <div>{{item.CardShareInfo}}</div>
  29. </div>
  30. </div>
  31. <div class="card-bottom">
  32. <img :src="line" alt="">
  33. <div class="time">有效期:{{toolClass.dateFormat(item.EndDate,'yyyy-MM-dd')}}</div>
  34. <div class="status" :class="{'gray-location' : item.CardStatus == 'used'}">
  35. <span v-if="item.GymType == 'year'">年卡</span>
  36. <span v-if="item.GymType == 'quarter'">季卡</span>
  37. <span v-if="item.GymType == 'month'">月卡</span>
  38. <span v-if="item.GymType == 'once'">次卡</span>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="useType">
  43. <img :src="used" alt="已使用" v-if="item.CardStatus == 'used'" width="100%" height="100%">
  44. <img :src="failure" alt="已失效" v-if="item.CardStatus == 'expire'" width="100%" height="100%">
  45. </div>
  46. </div>
  47. <noMore v-if="data[active].hasPic"></noMore>
  48. </div>
  49. </div>
  50. </div>
  51. <!-- </scroll> -->
  52. </div>
  53. </template>
  54. <script>
  55. import line from '../../../common/icon/cicyle.png'
  56. import logo from '../../../common/icon/logo-t.png'
  57. import Line3 from '../../../common/icon/Line3.png'
  58. import used from '../../../common/icon/already.png'
  59. import failure from '../../../common/icon/inv.png'
  60. // 上拉加载组件
  61. import scroll from '../../../components/scroll/scroll'
  62. import noMore from '../../../components/noMore/noMore'
  63. import discounts from '../../../components/discounts/discounts'
  64. import { createNamespacedHelpers } from 'vuex'
  65. const { mapState: mapCardState, mapActions: mapCardActions } = createNamespacedHelpers('card')
  66. export default {
  67. data () {
  68. return {
  69. nav: ['课程体验卡', '健身卡'],
  70. active: 0,
  71. logo,
  72. Line3,
  73. used,
  74. failure,
  75. pullUpLoad: true,
  76. pullUpLoadThreshold: 40,
  77. startY: 0,
  78. isloading: true,
  79. data: [
  80. {
  81. hasPic: false,
  82. hasMore: true,
  83. page: 1,
  84. pagesize: 1,
  85. list: []
  86. },
  87. {
  88. hasPic: false,
  89. hasMore: true,
  90. page: 0,
  91. pagesize: 10000,
  92. list: []
  93. }
  94. ],
  95. line
  96. }
  97. },
  98. components: {
  99. scroll,
  100. noMore,
  101. discounts
  102. },
  103. computed: {
  104. pullUpLoadObj: function () {
  105. return this.pullUpLoad
  106. ? {
  107. threshold: parseInt(this.pullUpLoadThreshold),
  108. txt: {
  109. more: this.pullUpLoadMoreTxt,
  110. noMore: this.pullUpLoadNoMoreTxt
  111. }
  112. }
  113. : false
  114. },
  115. ...mapCardState({
  116. gymCardList: x => x.gymCardList
  117. })
  118. },
  119. created () {
  120. this.change('', 0)
  121. this.getCardList().then((res) => {
  122. if (res) {
  123. for (var n = 0; n < res.length; n++) {
  124. let useType = '已使用'
  125. let nowDate = new Date().valueOf()
  126. let endDate = new Date(res[n].EndDate).valueOf()
  127. // if (res[n].Status === 2) {
  128. // useType = '已使用'
  129. // } else if (res[n].Status === 1 && nowDate > endDate) {
  130. // useType = '已失效'
  131. // } else {
  132. // useType = '未使用'
  133. // }
  134. this.data[0].list.push({
  135. title: res[n].CustomerCardName,
  136. desc: res[n].Share.CardUseRule,
  137. time: this.toolClass.dateFormat(res[n].EndDate, 'yyyy-MM-dd'),
  138. useType: useType,
  139. tag: '共享',
  140. CustomerCourseId: res[n].CustomerCourseId,
  141. CustomerCardId: res[n].CustomerCardId
  142. })
  143. }
  144. } else {
  145. this.data[this.active].hasPic = true
  146. }
  147. })
  148. },
  149. methods: {
  150. ...mapCardActions([
  151. 'getgymCardList',
  152. 'getCardList',
  153. ]),
  154. change (item, index) {
  155. this.active = index
  156. this.getList('change')
  157. },
  158. toUse (item) {
  159. console.log(item)
  160. this.$router.push({ name: 'lessonDetail', query: { id: item.CustomerCourseId } })
  161. },
  162. getList (param) {
  163. if (this.active === 0) {
  164. } else {
  165. if (param === 'change') {
  166. this.data[this.active].page = 0
  167. }
  168. if (this.data[this.active].hasMore) {
  169. this.getgymCardList({ page: this.data[this.active].page, pagesize: this.data[this.active].pagesize }).then((res) => {
  170. this.data[this.active].list = this.data[this.active].list.concat(this.gymCardList)
  171. this.data[this.active].page++
  172. if (this.gymCardList.length < this.data[this.active].pagesize) {
  173. this.data[this.active].hasMore = false
  174. }
  175. if (this.data[this.active].list.length <= 0) {
  176. this.data[this.active].hasPic = true
  177. }
  178. })
  179. } else {
  180. this.$refs.scroll.forceUpdate()
  181. }
  182. }
  183. },
  184. toGymCardDetail (item) {
  185. this.$router.push({ name: 'gymCardDetail', query: { CustomerGymId: item.CustomerGymId } })
  186. },
  187. toCardDetail (item) {
  188. this.$router.push({ name: 'cardDetail', query: { id: item.CustomerCardId } })
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang="scss" scoped>
  194. @import 'page.scss';
  195. </style>