xiaohaizhao 2 months ago
parent
commit
28f3b92ed1
8 changed files with 118 additions and 25 deletions
  1. 7 1
      App.vue
  2. 9 0
      pages.json
  3. 53 13
      pages/index/home.vue
  4. 3 1
      pages/index/index.vue
  5. 11 0
      pages/workOrder/finish.vue
  6. 11 0
      pages/workOrder/my.vue
  7. 11 0
      pages/workOrder/saloon.vue
  8. 13 10
      utils/Http.js

+ 7 - 1
App.vue

@@ -1,8 +1,15 @@
 <script>
+import { ref, getCurrentInstance } from 'vue'
 export default {
 	onLaunch: function () {
 	},
 	onShow: function () {
+		try {
+			const { $Http } = getCurrentInstance().proxy;
+			$Http.uploadNumber && $Http.uploadNumber();
+		} catch (error) {
+
+		}
 	},
 	onHide: function () {
 	}
@@ -13,5 +20,4 @@ export default {
 /* 注意要写在第一行,注意不能引入至uni.scss,同时给style标签加入lang="scss"属性 */
 @import "@/uni_modules/uview-plus/index.scss";
 @import '/static/iconfont.css';
-
 </style>

+ 9 - 0
pages.json

@@ -14,6 +14,15 @@
 		},
 		{
 			"path": "pages/index/index"
+		},
+		{
+			"path": "pages/workOrder/finish"
+		},
+		{
+			"path": "pages/workOrder/my"
+		},
+		{
+			"path": "pages/workOrder/saloon"
 		}
 	],
 	"globalStyle": {

+ 53 - 13
pages/index/home.vue

@@ -6,11 +6,11 @@
 			服务
 		</view>
 		<view class="name">
-			美大基础服务
+			{{ welcomeText }}
 		</view>
 
 		<view class="list">
-			<view class="item" v-for="item in itemList" :key="item.label" hover-class="navigator-hover">
+			<navigator :url="item.path" class="item" v-for="item in itemList" :key="item.label">
 				<view class="icon">
 					<image class="image" :src="item.icon" />
 				</view>
@@ -20,16 +20,36 @@
 				<view class="text">
 					{{ item.text }}
 				</view>
-			</view>
+				<view class="badge" v-if="item.badge">
+					<up-badge type="error" max="999" :value="item.badge"></up-badge>
+				</view>
+			</navigator>
 		</view>
 	</view>
 </template>
 
 <script setup>
-import { ref, getCurrentInstance } from 'vue'
+import { ref, getCurrentInstance, computed } from 'vue'
 import { onLoad } from '@dcloudio/uni-app';
 const { $Http } = getCurrentInstance().proxy;
-const banner = ref([])
+const banner = ref([]);
+const welcomeText = computed(() => {
+	return getTimeGreeting() + ',' + (uni.getStorageSync('userMsg').name);
+});
+function getTimeGreeting() {
+	const hour = new Date().getHours();
+
+	if (hour >= 5 && hour < 12) {
+		return '早上好';
+	} else if (hour >= 12 && hour < 14) {
+		return '中午好';
+	} else if (hour >= 14 && hour < 18) {
+		return '下午好';
+	} else {
+		return '晚上好';
+	}
+}
+
 onLoad(() => {
 	$Http.basic({
 		"classname": "common.adspace.adspace",
@@ -53,8 +73,22 @@ onLoad(() => {
 			}) || [];
 		}
 	})
+	uploadNumber()
+	$Http.uploadNumber = uploadNumber;
 });
 
+function uploadNumber() {
+	itemList.value.forEach((item) => {
+		$Http.basic({ "id": "20230208140203", "content": { "pageNumber": 1, "pageSize": 0, "where": { "status": item.label, "condition": "" } } }).then(res => {
+			if (res.code !== 0) {
+				item.badge = res.total;
+			} else {
+				item.badge = 0;
+			}
+		})
+	});
+	welcomeText.getter()
+}
 function onClickSwiper(e) {
 	let item = banner.value[e]
 	if (item.hyperlink) {
@@ -75,24 +109,22 @@ function onClickSwiper(e) {
 		})
 	}
 }
-const showPage = ref('home');
 const itemList = ref([{
 	label: '待接单',
 	icon: '/static/image/djd.png',
-	text: "故障维修排除"
+	text: "故障维修排除",
+	path: "/pages/workOrder/saloon",
 }, {
 	label: '进行中',
 	icon: '/static/image/jxz.png',
-	text: "专业上门安装"
+	text: "专业上门安装",
+	path: "/pages/workOrder/my",
 }, {
 	label: '已完结',
 	icon: '/static/image/ywj.png',
-	text: "精心维护保养"
+	text: "精心维护保养",
+	path: "/pages/workOrder/finish",
 }]);
-function change1(value) {
-	showPage.value = value;
-}
-
 </script>
 
 <style lang="scss" scoped>
@@ -123,6 +155,7 @@ function change1(value) {
 		margin-top: 40rpx;
 
 		.item {
+			position: relative;
 			width: 334rpx;
 			height: 260rpx;
 			background: #FFFFFF;
@@ -153,6 +186,13 @@ function change1(value) {
 				color: #999999;
 				margin-top: 10rpx;
 			}
+
+			.badge {
+				position: absolute;
+				top: 20rpx;
+				right: 20rpx;
+				transform: scale(1.3);
+			}
 		}
 
 	}

+ 3 - 1
pages/index/index.vue

@@ -22,10 +22,12 @@
 
 <script setup>
 import home from './home.vue';
-import { ref } from 'vue';
+import { ref, getCurrentInstance } from 'vue'
+const { $Http } = getCurrentInstance().proxy;
 
 const showPage = ref('home');
 function change1(value) {
+	if (value == 'home') $Http.uploadNumber && $Http.uploadNumber();
 	showPage.value = value;
 }
 

+ 11 - 0
pages/workOrder/finish.vue

@@ -0,0 +1,11 @@
+<template>
+    <view>
+        已完成
+    </view>
+</template>
+
+<script setup>
+
+</script>
+
+<style lang="scss" scoped></style>

+ 11 - 0
pages/workOrder/my.vue

@@ -0,0 +1,11 @@
+<template>
+    <view>
+        进行中
+    </view>
+</template>
+
+<script setup>
+
+</script>
+
+<style lang="scss" scoped></style>

+ 11 - 0
pages/workOrder/saloon.vue

@@ -0,0 +1,11 @@
+<template>
+    <view>
+        待接单
+    </view>
+</template>
+
+<script setup>
+
+</script>
+
+<style lang="scss" scoped></style>

+ 13 - 10
utils/Http.js

@@ -76,16 +76,19 @@ class HTTP {
                     // 清除过期会话ID
                     this.jsessionid = '';
                     wx.removeStorageSync('JSESSIONID');
-
-                    uni.redirectTo({
-                        url: '/pages/login/login',
-                        success: () => {
-                            uni.showToast({
-                                title: res.data.msg,
-                                icon: "none"
-                            });
-                        }
-                    });
+                   let currentPages = getCurrentPages()[getCurrentPages().length - 1];
+                    // 如果当前页面不是登录页面,则跳转到登录页面
+                    if (currentPages.route !== 'pages/login/login') {
+                        uni.showModal({
+                            title: '提示',
+                            content: '您的登录状态已过期,请重新登录。',
+                            showCancel: false,
+                            success: () => {
+                                // 跳转到登录页面
+                                this._redirectToLogin(res);
+                            }
+                        });
+                    }
                 }
             }
         });