jiayubo vor 4 Monaten
Ursprung
Commit
8306509966

+ 9 - 0
api/mine.js

@@ -35,3 +35,12 @@ export function getAccountChangeList(params) {
         params
     })
 }
+
+//查询用户的总收入和总支出
+export function getTotalMoney(params) {
+    return request({
+        url: `/core/client/account-change/totalMoney`,
+        method: 'get',
+        params
+    })
+}

+ 42 - 30
pages/classify.vue

@@ -15,7 +15,7 @@
       >
       </up-tabs>
       <view class="list">
-        <List :data="data" v-if="data && data.length > 0" @refresh="getList" ref="listRef"/>
+        <List :data="data" v-if="data && data.length > 0" @refresh="getList" ref="listRef" :total="pages.total"/>
         <view v-else>
           <NoneView value="您还没有相关订单" />
         </view>
@@ -104,33 +104,40 @@ const column = computed(() => {
   return userType === 1 ? user : admin
 })
 
-async function getList() {
+const pages = ref({
+	current: 1,
+	pageSize: 10,
+	total: 0,
+})
+async function getList(type) {
   try {
-    uni.showLoading({
-      title: '数据加载中...',
-    })
-
+  
+    console.log(data.value.length, pages.value.total);
+    
+    if(type ==='bottom'  ){
+      if(data.value.length < pages.value.total){
+        listRef.value && listRef.value.handleBottom(true);
+        pages.value.current++;
+      }else {
+        listRef.value && listRef.value.handleBottom(false)
+        return;
+      }
+    }else{
+      uni.showLoading({
+        title: '数据加载中...',
+      })
+    }
+  
     const listApi = userType === 1 ? userMainOrderList : getVolunteerOrderList
     const res = await listApi({
       orderStatus: tab.value,
+      pageNum: pages.value.current,
+			pageSize: pages.value.pageSize,
     })
-    data.value =res.rows ||  res.data
+    data.value =[...data.value,...res.rows];
+    pages.value.total = res.total;
 
-    // 判断 userType 来决定调用哪个接口
-    // let res
-    // if (userType === 1) {
-    //   // 如果 userType 是 1,调用 userMainOrderList 接口
-    //   // res = await getListData()
-    //    res = await userMainOrderList({
-    //     orderStatus:  tab.value
-    //   })
-    // } else if (userType === 2) {
-    //   // 如果 userType 是 2,调用 getVolunteerOrderList 接口
-    //   res = await getVolunteerOrderList({
-    //     orderStatus: tab.value,
-    //   })
-    // }
-    // data.value = res.data
+    type ==='bottom'&& listRef.value && listRef.value.handleBottom(false);
   } catch (error) {
     console.log('error', error)
     uni.showToast({
@@ -138,26 +145,26 @@ async function getList() {
       icon: 'error',
     })
   } finally {
-    if(listRef.value && listRef.value.handleRefreshing){
+    if(listRef.value && listRef.value.handleRefreshing && type ==='top'){
       listRef.value.handleRefreshing(false)
     }
-    uni.hideLoading()
+    type !=='bottom' && uni.hideLoading()
   }
 }
 
 /**
  * 1: 查看
  * 2:沟通
- * 3:上传照片
+ * 3:开始或结束服务
  */
 function btnClick(row, type) {
-  if (type === 1 && row.orderStatus === '2') {
+  if (type === 1) {
     uni.navigateTo({
       url: `/pages_classify/pages/order/index?orderId=${row.secondOrderId}`,
     })
     return
   }
-  if (type === 1) {
+  if (type === 3) {
     uni.navigateTo({
       url: `/pages_classify/pages/handle/index?orderId=${row.secondOrderId}`,
     })
@@ -173,17 +180,22 @@ function btnClick(row, type) {
 provide('onClick', btnClick)
 
 function onChange(tabItem) {
-  tab.value = tabItem.value
+  tab.value = tabItem.value;
+  pages.value.current = 1;
+  data.value = [];
   getList()
 }
 
 onMounted(() => {
-  getList()
+  // getList()
 })
 
 onShow(() => {
+  
+  const initIndex = userType === 1? 2:1;//默认选中待服务
+
   const params = getApp().globalData.switchTabParams || {}
-  tabKey.value = params.tabKey || 0
+  tabKey.value = params.tabKey || initIndex;
   onChange(column.value[tabKey.value])
   // 使用后建议清除参数,避免重复读取
   getApp().globalData.switchTabParams = null

+ 22 - 6
pages/common/orderList/index.vue

@@ -1,12 +1,16 @@
 <template>
     <scroll-view refresher-enabled :refresher-triggered="isRefreshing" @refresherrefresh="onCustomRefresh"
-        class="scroll-view-class" scroll-y>
+        class="scroll-view-class" @scrolltolower="scrolltolower" scroll-y>
         <view class="list-page">
             <view v-for="(item, index) in data" :key="index">
                     <ListItem :data="item" v-if="userType === 2"/>
                     <UserItem :data="item" v-else/>
                 </view>
-                <up-loadmore :line="true" status="nomore"></up-loadmore>
+                <!-- <up-loadmore :line="true" status="nomore"></up-loadmore> -->
+
+                <up-loadmore style="margin-top: 40rpx;" :status="loadmoreInfo.status"
+				:loadmoreText="loadmoreInfo.loadingText" :loadingText="loadmoreInfo.loadmoreText"
+				:nomoreText="loadmoreInfo.nomoreText" @loadmore="handleLoadmore" />
         </view>
     </scroll-view>
 </template>
@@ -32,22 +36,34 @@ const userType = uni.getStorageSync('userType') //读取本地存储
 const isRefreshing = ref(false)
 
 
+const loadmoreInfo = ref({
+	status: 'loadmore',
+	loadingText: '努力加载中...',
+	loadmoreText: '点击加载更多~',
+	nomoreText: '已经到底啦~'
+})
 const scrolltolower = () => {
     console.log('底部');
-    // emit('refresh');
+    emit('refresh','bottom');
 };
 
 const onCustomRefresh = () => {
     console.log('下拉刷新');
     isRefreshing.value = true;
-    emit('refresh');
+    emit('refresh','top');
 };
-
+//上拉刷新
 const handleRefreshing = (status) => {
     isRefreshing.value = status;
 }
+
+//下拉刷新
+const handleBottom = (value) => {
+    loadmoreInfo.value.status = value?'loading':'nomore';
+}
 defineExpose({
-    handleRefreshing
+    handleRefreshing,
+    handleBottom
 });
 
 </script>

+ 1 - 1
pages/common/orderList/listItem.vue

@@ -32,7 +32,7 @@
                     <!-- <view class="btn-m" @click="onClick(2)">
                         <text style="margin-left: 8rpx;">沟通</text>
                     </view> -->
-                    <view class="btn-m" @click="onClick(1)"  v-if="['3', '1'].includes(data.orderStatus)">
+                    <view class="btn-m" @click="onClick(3)"  v-if="['3', '1'].includes(data.orderStatus)">
                         <!-- <up-icon name="chat" color="#ffffff" size="20"></up-icon> -->
                        {{ data.orderStatus === '1' ? '开始' : '完成' }}服务
                     </view>

+ 130 - 57
pages_mine/pages/income/index.vue

@@ -1,48 +1,55 @@
 <template>
-    <view class="income-main">
-        <view class="income-header card-box">
-            <text class="income-title" @click="onShows">
-                {{ dataYMD }}
-            </text>
-            <view class="income-header-right">
-                <text>收入: ¥{{ data.totalEarning }}</text>
-                <text class="income-header-right-right">支出: ¥{{ data.totalExpend }}</text>
+   <scroll-view refresher-enabled :refresher-triggered="isRefreshing" @refresherrefresh="onCustomRefresh"
+        class="scroll-view-class" @scrolltolower="scrolltolower" scroll-y>
+        <view class="income-main">
+            <view class="income-header card-box">
+                <text class="income-title" @click="onShows">
+                    {{ dataYMD }}
+                </text>
+                <view class="income-header-right">
+                    <text>收入: ¥{{ data.totalEarning }}</text>
+                    <text class="income-header-right-right">支出: ¥{{ data.totalExpend }}</text>
+                </view>
             </view>
-        </view>
 
-        <view v-if="data.clientAccountChangeVOlist && data.clientAccountChangeVOlist.length > 0">
-            <view class="card-box icome-item" v-for="item in data.clientAccountChangeVOlist" :key="item.code" @click="onClick(item)">
-                <view class="card-left">
-                    <!-- <img :src="baseUrl" alt="" class="income-img"> -->
-                    <view class="card-left-text">
-                        <view class="card-left-name">
-                            <dict-tag :options="jlzj_client_source_type" :value="item.sourceType" />
-                            ({{ item.businessTierName }})
+            <view v-if="data.clientAccountChangeVOlist && data.clientAccountChangeVOlist.length > 0">
+                <view class="card-box icome-item" v-for="item in data.clientAccountChangeVOlist" :key="item.code"
+                    @click="onClick(item)">
+                    <view class="card-left">
+                        <!-- <img :src="baseUrl" alt="" class="income-img"> -->
+                        <view class="card-left-text">
+                            <view class="card-left-name">
+                                <dict-tag :options="jlzj_client_source_type" :value="item.sourceType" />
+                                ({{ item.businessTierName }})
+                            </view>
+                            <view class="card-left-date">{{ item.createTime }}</view>
                         </view>
-                        <view class="card-left-date">{{ item.createTime }}</view>
                     </view>
-                </view>
 
-                <view class="card-rigth"
-                    :style="{ color: item.changeType === '1' ? 'rgba(76, 175, 80, 1)' : 'rgba(244, 67, 54, 1)' }">
-                    {{ item.changeType === '1' ? '+' : '-' }}{{ item.changeMoney }}
+                    <view class="card-rigth"
+                        :style="{ color: item.changeType === '1' ? 'rgba(76, 175, 80, 1)' : 'rgba(244, 67, 54, 1)' }">
+                        {{ item.changeType === '1' ? '+' : '-' }}{{ item.changeMoney }}
+                    </view>
                 </view>
-
+                <up-loadmore style="margin-top: 40rpx;" :status="loadmoreInfo.status"
+                    :loadmoreText="loadmoreInfo.loadingText" :loadingText="loadmoreInfo.loadmoreText"
+                    :nomoreText="loadmoreInfo.nomoreText" @loadmore="handleLoadmore" />
+            </view>
+            <view v-else>
+                <NoneView value="您还没有相关账单" />
             </view>
-        </view>
-        <view v-else>
-            <NoneView value="您还没有相关账单" />
-        </view>
 
 
-        <up-datetime-picker :show="show" v-model="datetime" mode="date" ref="uPickerRef" @confirm="confirm"
-            @cancel="cancel"></up-datetime-picker>
-    </view>
+            <up-datetime-picker :show="show" v-model="datetime" mode="date" ref="uPickerRef" @confirm="confirm"
+                @cancel="cancel"></up-datetime-picker>
+        </view>
+    </scroll-view>
+
 </template>
 
 <script setup>
 import { ref, computed } from 'vue'
-import { getAccountChangeList } from "@/api/mine";
+import { getAccountChangeList, getTotalMoney } from "@/api/mine";
 import {
     onShow
 } from '@dcloudio/uni-app';
@@ -73,42 +80,75 @@ const dataYMD = computed(() => {
 })
 
 const uPickerRef = ref(null)
+const isRefreshing = ref(false)
+
+
+const loadmoreInfo = ref({
+    status: 'loadmore',
+    loadingText: '努力加载中...',
+    loadmoreText: '点击加载更多~',
+    nomoreText: '已经到底啦~'
+})
+const pages = ref({
+    current: 1,
+    pageSize: 10,
+    total: 0,
+})
 const onShows = () => {
     show.value = true;
 };
 
 const confirm = () => {
-    console.log('confirm', datetime.value);
     show.value = false;
-    init();
+    init('top');
+    totalInit();
 };
 
 const cancel = () => {
     show.value = false;
 };
-const onClick = (record) =>{
+const onClick = (record) => {
     record.mainOrderId && uni.navigateTo({
         url: `/pages_classify/pages/orderItem/orderdetails?mainOrderId=${record.mainOrderId}`
     });
 }
+const scrolltolower = () => {
+    init('bottom')
+};
 
-const init = async () => {
+const onCustomRefresh = () => {
+    isRefreshing.value = true;
+    pages.value.current = 1;
+    // data.value.clientAccountChangeVOlist = [];
+    init('top')
+};
+
+const init = async (type) => {
     try {
-        uni.showLoading({
-            title: '数据加载中...'
-        });
 
-        if (userType === 2) {
-            // const res = await getVolunteerAccountInfo();
-            // data.value =res.data;			
-        }
-        if (userType === 1) {
-            const res = await getAccountChangeList({
-                createTime: dayjs(datetime.value).format('YYYY-MM-DD')
-            });
-            console.log(1, res);
-            data.value = res.data;
+
+        if (type === 'bottom') {
+            if (data.value.clientAccountChangeVOlist.length < pages.value.total) {
+                loadmoreInfo.value.status = 'loading';
+                pages.value.current++;
+            } else {
+                loadmoreInfo.value.status = 'nomore';
+                return;
+            }
+        } else {
+            uni.showLoading({
+                title: '数据加载中...',
+            })
         }
+
+        const listApi = userType === 1 ? getAccountChangeList : getAccountChangeList;
+        const res = await listApi({
+            createTime: dayjs(datetime.value).format('YYYY-MM-DD'),
+            pageNum: pages.value.current,
+			pageSize: pages.value.pageSize,
+        });
+        data.value.clientAccountChangeVOlist =type === 'top'? res.rows : [...data.value.clientAccountChangeVOlist, ...res.rows];
+        pages.value.total = res.total;
     } catch (error) {
         console.log('error', error);
         uni.showToast({
@@ -116,11 +156,33 @@ const init = async () => {
             icon: 'error',
         });
     } finally {
-        uni.hideLoading();
+        if (type === 'top') {
+            isRefreshing.value = false;
+            uni.hideLoading();
+        } else {
+            loadmoreInfo.value.status = 'nomore';
+        }
+    }
+}
+
+const totalInit = async () => {
+    try {
+        const res = await getTotalMoney({
+            createTime: dayjs(datetime.value).format('YYYY-MM-DD'),
+        });
+        data.value.totalEarning = res.data.totalEarning;
+        data.value.totalExpend = res.data.totalExpend;
+    } catch (error) {
+        console.log('error', error);
+        uni.showToast({
+            title: error.msg,
+            icon: 'error',
+        });
     }
 }
 onShow(() => {
-    init();
+    init('top');
+    totalInit();
 })
 </script>
 
@@ -133,14 +195,14 @@ onShow(() => {
 }
 
 .income-main {
-    position: fixed;
-    top: 0px;
-    left: 0px;
-    right: 0px;
-    bottom: 0px;
-    background: rgba(245, 245, 245, 1);
+    // position: fixed;
+    // top: 0px;
+    // left: 0px;
+    // right: 0px;
+    // bottom: 0px;
+    
     padding: 12px;
-    overflow: auto;
+    // overflow: auto;
 
     .income-title {
         font-size: 16px;
@@ -220,4 +282,15 @@ onShow(() => {
     }
 
 }
+
+.scroll-view-class {
+    // height: 100%;
+    height: 100vh;
+    background: rgba(245, 245, 245, 1);
+    // position: fixed;
+    // top: 0px;
+    // bottom: 0;
+    // left: 0;
+    // right: 0;
+}
 </style>