index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="pagesCons">
  3. <view class="utabs">
  4. <u-tabs-swiper ref="uTabs" :list="tabList" name="dispName" :current="current" bar-width="150" active-color="#58c4c4" @change="tabsChange" :is-scroll="false"
  5. swiperWidth="750"></u-tabs-swiper>
  6. </view>
  7. <swiper class="check-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
  8. <swiper-item class="swiper-item" v-for="(tabs, index) in tabList" :key="index">
  9. <scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
  10. <view
  11. class="check-order-list"
  12. v-if="index==current"
  13. v-for="(item,sindex) in list"
  14. :key="item.id+'-'+sindex"
  15. >
  16. <view v-if="current==0" class="flex align_center justify_between">
  17. <view class="l_box">{{item.detailName}}</view>
  18. <view class="r_box">剩余{{item.currentQty}}次</view>
  19. </view>
  20. <view v-if="current==1">
  21. <view class="l_box">{{item.detailName}}</view>
  22. <view class="flex align_center justify_between" style="padding-top: 0.2em;">
  23. <view class="r_box">剩余{{item.useQty}}次</view>
  24. <view class="r_box">2022-15-25</view>
  25. </view>
  26. </view>
  27. </view>
  28. <view style="padding: 20upx;">
  29. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
  30. <u-loadmore v-if="list.length" :status="status" />
  31. </view>
  32. </scroll-view>
  33. </swiper-item>
  34. </swiper>
  35. </view>
  36. </template>
  37. <script>
  38. import { getCustomerBundleDetail,getCustomerUseHistory } from '@/api/bundel.js'
  39. export default {
  40. components: {
  41. },
  42. data() {
  43. return {
  44. status: 'loadmore',
  45. noDataText: '暂无数据',
  46. tabList: [
  47. {
  48. dispName: '品项明细',
  49. typeId: 1,
  50. queryLabel: 'WAIT_REFORM' // tab参数
  51. },
  52. {
  53. dispName: '使用记录',
  54. typeId: 2,
  55. queryLabel: 'FINISH_REFORM' // tab参数
  56. }
  57. ],
  58. current: 0,
  59. swiperCurrent: 0,
  60. pageNo: 1,
  61. pageSize: 15,
  62. list: [],
  63. total: 0,
  64. action:'swiperChange', // 操作类型,上划分页,或左右滑动
  65. customerBundleId:''
  66. }
  67. },
  68. onLoad(opts) {
  69. this.customerBundleId = opts.customerBundleId
  70. // 监听整改完成后刷新事件
  71. uni.$on('refreshBL',this.getRow)
  72. this.getRow(1)
  73. },
  74. onUnload() {
  75. uni.$off('refreshBL',this.getRow)
  76. },
  77. methods:{
  78. // tabs通知swiper切换
  79. tabsChange(index) {
  80. this.swiperCurrent = index;
  81. },
  82. swiperChange(event){
  83. this.action = 'swiperChange'
  84. this.status = 'loading'
  85. },
  86. // swiper-item左右移动,通知tabs的滑块跟随移动
  87. transition(e) {
  88. let dx = e.detail.dx;
  89. this.$refs.uTabs.setDx(dx);
  90. },
  91. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  92. // swiper滑动结束,分别设置tabs和swiper的状态
  93. animationfinish(e) {
  94. let current = e.detail.current;
  95. let isCurtab = this.current == current
  96. if(this.status!="nomore"){
  97. let loadData = this.action == 'swiperChange' ? !isCurtab : isCurtab;
  98. if(loadData){
  99. this.$refs.uTabs.setFinishCurrent(current);
  100. this.swiperCurrent = current;
  101. this.current = current;
  102. this.resetPage();
  103. }
  104. }
  105. },
  106. // scroll-view到底部加载更多
  107. onreachBottom() {
  108. this.action = 'onreachBottom'
  109. if(this.list.length < this.total){
  110. this.resetPage()
  111. }else{
  112. this.status = "nomore"
  113. }
  114. },
  115. // 查询列表
  116. getRow (pageNo) {
  117. if (pageNo) {
  118. this.pageNo = pageNo
  119. }
  120. let params = {
  121. pageNo: this.pageNo,
  122. pageSize: this.pageSize,
  123. customerBundleId: this.customerBundleId, // tab分类
  124. }
  125. const url = [getCustomerBundleDetail,getCustomerUseHistory]
  126. this.status = "loading"
  127. url[this.current](params).then(res => {
  128. console.log(params,res.data.list,'+++++++++++')
  129. if (res.status == 200) {
  130. if(this.pageNo>1){
  131. this.list = this.list.concat(res.data.list || [])
  132. }else{
  133. this.list = res.data.list || []
  134. }
  135. this.total = res.data.count || 0
  136. } else {
  137. this.list = []
  138. this.total = 0
  139. this.noDataText = res.message
  140. }
  141. if(this.list.length<this.total){
  142. this.status = "loadmore"
  143. }else{
  144. this.status = "nomore"
  145. }
  146. })
  147. },
  148. resetPage(){
  149. this.status = 'loading';
  150. // 上划分页
  151. if(this.action == 'onreachBottom'){
  152. this.pageNo += 1
  153. this.getRow()
  154. }
  155. // 左右切换tab
  156. if(this.action == 'swiperChange'){
  157. this.list = [];
  158. this.getRow(1);
  159. }
  160. },
  161. }
  162. }
  163. </script>
  164. <style lang="scss">
  165. page {
  166. height: 100%;
  167. }
  168. .pagesCons{
  169. height: 100%;
  170. display: flex;
  171. flex-direction: column;
  172. .text-right {
  173. text-align: right;
  174. }
  175. .utabs{
  176. border-bottom: 1px solid #eee;
  177. }
  178. .check-list{
  179. flex: 1;
  180. .swiper-item{
  181. width: 100%;
  182. height: 100%;
  183. overflow: hidden;
  184. .scroll-view {
  185. width: 100%;
  186. height: 100%;
  187. overflow: auto;
  188. }
  189. }
  190. }
  191. // 列表样式
  192. .check-order-list{
  193. background: #ffffff;
  194. border-bottom: 1px solid #eee;
  195. padding: 1em;
  196. &:active{
  197. background: #f8f8f8;
  198. }
  199. .l_box{
  200. font-size: 1em;
  201. flex-grow: 1;
  202. }
  203. .r_box{
  204. color: #999;
  205. > view{
  206. padding: 0 0.1em;
  207. }
  208. }
  209. }
  210. }
  211. </style>