allCustomer.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <view class="content">
  3. <view class="filter-box">
  4. <u-search placeholder="请输入关键字" v-model="filterText" @search="setFilterText" @custom="setFilterText"></u-search>
  5. </view>
  6. <u-tabs-swiper ref="uTabs" :active-color="mainColor" :list="tabList" :current="current" @change="tabsChange"
  7. :is-scroll="false"></u-tabs-swiper>
  8. <swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" class="swiper-box">
  9. <swiper-item class="swiper-item" v-for="(item, index1) in tabList" :key="index1">
  10. <scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
  11. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
  12. @refresherrestore="onRestore">
  13. <u-card :show-head="false" :show-foot="false" margin="10px 15px" borderRadius="40" v-for="(site, index2) in item.tableList"
  14. :key="index2" class="card-box" @click="goToOrderList(site)">
  15. <view slot="body" class="card-content">
  16. <view class="student-info">
  17. <view class="info-name">{{site.studentName}}</view>
  18. <view class="info-type" :class="site.status == 1 ? 'info-type-active' : ''">{{site.status == 0 ? '未报名' : '已报名'}}</view>
  19. <view class="info-name" style="clear: left;">{{site.parentName}}</view>
  20. <view class="info-phone">{{site.parentPhone}}</view>
  21. </view>
  22. <u-image width="28px" height="28px" :src="site.type == 1 ? iconPath1 : iconPath2"></u-image>
  23. </view>
  24. </u-card>
  25. <u-divider v-if="item.isOver" bg-color="transparent" :style="{paddingTop : item.tableList.length == 0 ? '10px' : ''}">没有更多了</u-divider>
  26. </scroll-view>
  27. </swiper-item>
  28. </swiper>
  29. <u-top-tips ref="uTips"></u-top-tips>
  30. </view>
  31. </template>
  32. <script>
  33. import {
  34. mapGetters
  35. } from 'vuex'
  36. const NET = require('@/utils/request')
  37. const API = require('@/config/api')
  38. export default {
  39. computed: {
  40. ...mapGetters([
  41. 'mainColor',
  42. 'handleCustomStyle',
  43. 'handleDefaultCustomStyle',
  44. ])
  45. },
  46. data() {
  47. return {
  48. filterText: '',
  49. triggered: false,
  50. tabList: [{
  51. name: '全部',
  52. isOver: false,
  53. pageIndex: 1,
  54. filterText: '',
  55. type: 2,
  56. tableList: [],
  57. }, {
  58. name: '已报名',
  59. isOver: false,
  60. pageIndex: 1,
  61. filterText: '',
  62. type: 1,
  63. tableList: [],
  64. }, {
  65. name: '意向客户',
  66. isOver: false,
  67. pageIndex: 1,
  68. filterText: '',
  69. type: 0,
  70. tableList: [],
  71. }],
  72. current: 0,
  73. swiperCurrent: 0,
  74. iconPath1: API.getServerImg + 'weibaoming.png',
  75. iconPath2: API.getServerImg + 'xianshangkehu.png',
  76. }
  77. },
  78. onLoad() {
  79. this.getTableList(0)
  80. this.getTableList(1)
  81. this.getTableList(2)
  82. },
  83. onReady() {},
  84. methods: {
  85. // 设置过滤字段
  86. setFilterText(value) {
  87. this.tabList[this.current].filterText = value
  88. this.onRefresh()
  89. },
  90. // tab页面切换
  91. tabsChange(index) {
  92. this.swiperCurrent = index;
  93. },
  94. // swiper-item左右移动,通知tabs的滑块跟随移动
  95. transition(e) {
  96. let dx = e.detail.dx;
  97. this.$refs.uTabs.setDx(dx);
  98. },
  99. // swiper滑动结束,分别设置tabs和swiper的状态
  100. animationfinish(e) {
  101. let current = e.detail.current;
  102. this.$refs.uTabs.setFinishCurrent(current);
  103. this.swiperCurrent = current;
  104. this.current = current;
  105. },
  106. // 下拉刷新
  107. onRefresh() {
  108. if (!this.triggered) {
  109. this.triggered = true
  110. this.tabList[this.current].isOver = false
  111. this.tabList[this.current].pageIndex = 1
  112. this.tabList[this.current].tableList = []
  113. this.getTableList(this.current, 'refresh')
  114. }
  115. },
  116. // 重置下拉刷新状态
  117. onRestore() {
  118. this.triggered = 'restore'
  119. this.triggered = false
  120. },
  121. // 懒加载
  122. handleLoadMore() {
  123. if (!this.tabList[this.current].isOver) {
  124. this.tabList[this.current].pageIndex++
  125. this.getTableList(this.current)
  126. }
  127. },
  128. // 获取列表数据
  129. getTableList(index) {
  130. NET.request(API.getCustomerList, {
  131. name: this.tabList[index].filterText,
  132. type: this.tabList[index].type,
  133. page: this.tabList[index].pageIndex,
  134. size: 10,
  135. }, 'POST').then(res => {
  136. this.triggered = false
  137. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
  138. this.tabList[index].isOver = res.data.row.length != 10
  139. }).catch(error => {
  140. this.triggered = false
  141. this.$refs.uTips.show({
  142. title: error.msg,
  143. type: 'warning',
  144. })
  145. })
  146. },
  147. // 跳转订单列表
  148. goToOrderList(item) {
  149. if (item.status == 1) {
  150. uni.navigateTo({
  151. url: '/pagesMain/orderList?id=' + item.id
  152. });
  153. }
  154. if (item.status == 0) {
  155. uni.navigateTo({
  156. url: '/pagesMain/venueList?id=' + item.id
  157. });
  158. }
  159. }
  160. },
  161. }
  162. </script>
  163. <style>
  164. page {
  165. width: 100%;
  166. height: 100%;
  167. background-color: #f7f7f7;
  168. }
  169. </style>
  170. <style lang="scss" scoped>
  171. @import "@/static/css/themes.scss";
  172. .content {
  173. width: 100%;
  174. float: left;
  175. .filter-box {
  176. height: 48px;
  177. padding: 10px 15px;
  178. background-color: #FFFFFF;
  179. }
  180. .swiper-box {
  181. height: calc(100vh - 82px);
  182. .swiper-item {
  183. height: calc(100vh - 82px);
  184. .scroll-box {
  185. width: 100%;
  186. height: calc(100vh - 82px);
  187. .card-box {
  188. .card-content {
  189. display: flex;
  190. align-items: center;
  191. .student-info {
  192. flex: 1;
  193. .info-name {
  194. width: 64px;
  195. float: left;
  196. line-height: 28px;
  197. font-size: 14px;
  198. font-weight: bold;
  199. }
  200. .info-type {
  201. padding: 0 10px;
  202. margin-top: 3px;
  203. border-radius: 20px;
  204. float: left;
  205. line-height: 20px;
  206. font-size: 10px;
  207. color: #FFFFFF;
  208. background-color: #999999;
  209. }
  210. .info-type-active {
  211. background-color: $mainColor;
  212. }
  213. .info-phone {
  214. width: calc(100% - 64px);
  215. float: left;
  216. line-height: 28px;
  217. font-size: 12px;
  218. color: #999999;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. }
  225. }
  226. }
  227. </style>