mescrollUni-item.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <!--
  3. swiper中的transfrom会使fixed失效,此时用height固定高度;
  4. swiper中无法触发mescroll-mixins.js的onPageScroll和onReachBottom方法,只能用mescroll-uni,不能用mescroll-body
  5. -->
  6. <!-- ref动态生成: 字节跳动小程序编辑器不支持一个页面存在相同的ref (如不考虑字节跳动小程序可固定值为 ref="mescrollRef") -->
  7. <!-- top的高度等于悬浮菜单tabs的高度 -->
  8. <mescroll-uni :ref="'mescrollRef' + i" @init="mescrollInit" :height="height" :down="downOption" @down="downCallback"
  9. :up="upOption" @up="upCallback" @emptyclick="emptyClick">
  10. <view class="flex-row item " v-for="(item ,index) in list" :key="index">
  11. <view class="flex-col avatarView">
  12. <view class="flex-row justify-center">
  13. <image :src="item.avatar || '/static/ud4.png'" class="avatar"></image>
  14. </view>
  15. <view class="flex-row justify-center">
  16. <text class="name">{{item.serviceObjectName}}</text>
  17. </view>
  18. </view>
  19. <view class="flex-col justify-around msg ">
  20. <view>
  21. <text>服务项目:</text>
  22. <text class="value">{{item.serviceProject}}</text>
  23. </view>
  24. <view>
  25. <text>服务金额:</text>
  26. <text class="value">¥{{item.serviceFee}}</text>
  27. </view>
  28. <view>
  29. <text>服务时间:</text>
  30. <text class="value">{{item.time}}</text>
  31. </view>
  32. </view>
  33. </view>
  34. </mescroll-uni>
  35. </template>
  36. <script>
  37. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  38. import MescrollMoreItemMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more-item.js"
  39. export default {
  40. mixins: [MescrollMixin, MescrollMoreItemMixin], // 注意此处还需使用MescrollMoreItemMixin (必须写在MescrollMixin后面)
  41. components: {},
  42. data() {
  43. return {
  44. downOption: {
  45. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  46. },
  47. upOption: {
  48. auto: false, // 不自动加载
  49. // page: {
  50. // num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  51. // size: 10 // 每页数据的数量
  52. // },
  53. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  54. empty: {
  55. icon: '',
  56. tip: '暂无内容', // 提示
  57. // btnText: '去看看'
  58. },
  59. textNoMore: '没有更多了'
  60. },
  61. list: [],
  62. }
  63. },
  64. props: {
  65. i: Number, // 每个tab页的专属下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  66. index: { // 当前tab的下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  67. type: Number,
  68. default () {
  69. return 0
  70. }
  71. },
  72. dataTime: {
  73. type: String,
  74. default () {
  75. return ''
  76. }
  77. },
  78. tabs: { // 为了请求数据,演示用,可根据自己的项目判断是否要传
  79. type: Array,
  80. default () {
  81. return []
  82. }
  83. },
  84. height: [Number, String], // mescroll的高度
  85. selectStartDate:{
  86. type:String,
  87. default () {
  88. return ''
  89. }
  90. },
  91. selectEndDate:{
  92. type:String,
  93. default () {
  94. return ''
  95. }
  96. },
  97. selectServiceId:{
  98. type:String,
  99. default () {
  100. return ''
  101. }
  102. }
  103. },
  104. watch: {
  105. },
  106. created() {
  107. this.userInfo = uni.getStorageSync('userInfo')
  108. },
  109. methods: {
  110. orderFinish(item){
  111. this.$api.orderFinish(item.orderNo).then((res)=>{
  112. uni.$u.toast('操作成功')
  113. this.downCallback()
  114. })
  115. },
  116. getOrderSign(order){
  117. this.$emit('serialNumber',order)
  118. },
  119. appointment(order){
  120. this.$emit('openPayAppointment',order,2)
  121. },
  122. oneClickPay(order){
  123. this.$emit('openPay',order,1)
  124. },
  125. /*下拉刷新的回调 */
  126. downCallback() {
  127. // 这里加载你想下拉刷新的数据, 比如刷新轮播数据
  128. // loadSwiper();
  129. // 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  130. this.mescroll.resetUpScroll()
  131. },
  132. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  133. upCallback(page) {
  134. let status = this.index
  135. if (this.index === 3){
  136. status = 4
  137. }
  138. //联网加载数据
  139. this.$api.service.performanceList({
  140. pageNum: page.num,
  141. pageSize: 10,
  142. type:this.index,
  143. startTime:this.selectStartDate,
  144. endTime:this.selectEndDate,
  145. serviceProjectId:this.selectServiceId
  146. }).then((res) => {
  147. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  148. this.mescroll.endSuccess(res.data.data.records.length, res.data.data.records.length === 10);
  149. //设置列表数据
  150. if (page.num === 1) this.list = []; //如果是第一页需手动制空列表
  151. res.data.data.records.forEach(i=>{
  152. if (i.avatar){
  153. i.avatar = i.avatar.replace(/^http:/, "https:")
  154. }
  155. })
  156. this.list = this.list.concat(res.data.data.records); //追加新数据
  157. // 通知父组件更新统计总数
  158. if (page.num === 1) {
  159. this.$emit('updateTotal', res.data.data.total || 0)
  160. }
  161. console.log(this.list)
  162. }).catch((err) => {
  163. //联网失败, 结束加载
  164. this.mescroll.endErr();
  165. })
  166. },
  167. //点击空布局按钮的回调
  168. emptyClick() {
  169. uni.showToast({
  170. title: '点击了按钮,具体逻辑自行实现'
  171. })
  172. },
  173. // 搜索
  174. doSearch() {
  175. this.list = []; // 先清空列表,显示加载进度
  176. this.mescroll.resetUpScroll();
  177. },
  178. }
  179. }
  180. </script>
  181. <style scoped lang="scss">
  182. @import './index.rpx.css';
  183. </style>