联调接口
This commit is contained in:
@@ -59,11 +59,16 @@ export function logout(data) {
|
||||
|
||||
// 获取用户信息
|
||||
export function getUserInfo(data) {
|
||||
return request.post({
|
||||
url: '/api/getUserInfo',
|
||||
return request.get({
|
||||
url: '/acc/profile/userInfo',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 查询当前用户常用功能
|
||||
export function getUserFavorite(data) {
|
||||
return request.post({
|
||||
url: '/acc/profile/favorite',
|
||||
data
|
||||
})
|
||||
}
|
||||
@@ -8,18 +8,18 @@ export function search(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 业务列表
|
||||
// 查询当前用户业务列表
|
||||
export function businessList(data) {
|
||||
return request.post({
|
||||
url: '/api/businessList',
|
||||
url: '/acc/profile/bizList',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 企业日常
|
||||
export function businessDaily(data) {
|
||||
// 设置常用服务
|
||||
export function bizFavoriteSetting(data) {
|
||||
return request.post({
|
||||
url: '/api/businessDaily',
|
||||
url: '/acc/biz/favoriteSetting',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
import request from "@/utils/request"
|
||||
|
||||
// 待办数据查询
|
||||
export function backBlogCount(data) {
|
||||
// 待办数据查询 获取用户消息的待阅和已阅数量
|
||||
export function messageNotifyCount(data) {
|
||||
return request.get({
|
||||
url: '/acc/message/notify/count',
|
||||
data
|
||||
})
|
||||
}
|
||||
// 获取用户审批的待办和已办数量
|
||||
export function messageFlowCount(data) {
|
||||
return request.get({
|
||||
url: '/acc/message/flow/count',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 常用服务
|
||||
export function getUserFavorite(data) {
|
||||
return request.post({
|
||||
url: '/api/backBlogCount',
|
||||
url: '/acc/profile/favorite',
|
||||
data
|
||||
})
|
||||
}
|
||||
@@ -32,13 +47,7 @@ export function salesTask(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 常用服务
|
||||
export function commonServices(data) {
|
||||
return request.post({
|
||||
url: '/api/commonServices',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 新闻公告
|
||||
export function newsQueryList(data) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import request from "@/utils/request"
|
||||
// 查询通知列表
|
||||
export function noticeList(data) {
|
||||
return request.post({
|
||||
url: '/api/noticeList',
|
||||
url: '/acc/message/notify/detail',
|
||||
data
|
||||
})
|
||||
}
|
||||
@@ -132,6 +132,12 @@
|
||||
"style": {
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/h5-webview/h5-webview",
|
||||
"style": {
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
|
||||
@@ -149,7 +149,62 @@ const getVisitorReportList = (pageIndex, pageSize) => {
|
||||
pageSize
|
||||
}
|
||||
|
||||
let res = await visitorReportList(param);
|
||||
// let res = await visitorReportList(param);
|
||||
let res = {
|
||||
list:[
|
||||
{
|
||||
id:1,title:'客户:北京中科睿信科技有限公司',name:'YS-VR2025091515',
|
||||
reportType:1,reportTypeName:'I 类活动 (走访)',statusName:'待胡本华审核',
|
||||
reportPeople:'管理员',dateStr:'2025-09-15'
|
||||
},
|
||||
{
|
||||
id:2,title:'客户:中国船舶集团有限公司第七一 七研究所',name:'YS-VR2025091307',
|
||||
reportType:1,reportTypeName:'I 类活动 (走访)',statusName:'待胡本华审核',
|
||||
reportPeople:'管理员',dateStr:'2025-09-15'
|
||||
},
|
||||
{
|
||||
id:3,title:'客户:旭日阳(北京)科技有限公司',name:'YS-VR2025090902',
|
||||
reportType:1,reportTypeName:'I 类活动 (走访)',statusName:'待审核',
|
||||
reportPeople:'管理员',dateStr:'2025-09-15'
|
||||
},
|
||||
{
|
||||
id:4,title:'客户:北京中科睿信科技有限公司',name:'YS-VR2025091515',
|
||||
reportType:1,reportTypeName:'I 类活动 (走访)',statusName:'待胡本华审核',
|
||||
reportPeople:'管理员',dateStr:'2025-09-15'
|
||||
},
|
||||
{
|
||||
id:5,title:'客户:北京中科睿信科技有限公司',name:'YS-VR2025091515',
|
||||
reportType:1,reportTypeName:'I 类活动 (走访)',statusName:'待胡本华审核',
|
||||
reportPeople:'管理员',dateStr:'2025-09-15'
|
||||
},
|
||||
{
|
||||
id:6,title:'客户:北京中科睿信科技有限公司',name:'YS-VR2025091515',
|
||||
reportType:1,reportTypeName:'I 类活动 (走访)',statusName:'待胡本华审核',
|
||||
reportPeople:'管理员',dateStr:'2025-09-15'
|
||||
},
|
||||
{
|
||||
id:7,title:'客户:北京中科睿信科技有限公司',name:'YS-VR2025091515',
|
||||
reportType:1,reportTypeName:'I 类活动 (走访)',statusName:'待胡本华审核',
|
||||
reportPeople:'管理员',dateStr:'2025-09-15'
|
||||
},
|
||||
{
|
||||
id:8,title:'客户:北京中科睿信科技有限公司',name:'YS-VR2025091515',
|
||||
reportType:1,reportTypeName:'I 类活动 (走访)',statusName:'待胡本华审核',
|
||||
reportPeople:'管理员',dateStr:'2025-09-15'
|
||||
},
|
||||
{
|
||||
id:9,title:'客户:北京中科睿信科技有限公司',name:'YS-VR2025091515',
|
||||
reportType:1,reportTypeName:'I 类活动 (走访)',statusName:'待胡本华审核',
|
||||
reportPeople:'管理员',dateStr:'2025-09-15'
|
||||
},
|
||||
{
|
||||
id:10,title:'客户:北京中科睿信科技有限公司',name:'YS-VR2025091515',
|
||||
reportType:1,reportTypeName:'I 类活动 (走访)',statusName:'待胡本华审核',
|
||||
reportPeople:'管理员',dateStr:'2025-09-15'
|
||||
}
|
||||
],
|
||||
totalCount:14
|
||||
}
|
||||
resolve({
|
||||
list: res.list,
|
||||
total: res.totalCount
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
<block v-if="!item.expandFlag">
|
||||
<view class="logo-list" v-if="item.children&&item.children.length>0">
|
||||
<block v-for="(item2,index2) in item.children">
|
||||
<view class="l-l-item" :key="index2"
|
||||
@click="handleJump(item2.bizUrl)" v-if="item2.status==1">
|
||||
<img :src="item2.icon" />
|
||||
<view class="l-l-item"
|
||||
@click="handleJump(item2.bizUrl)">
|
||||
<img :src="'static/images/business/'+item2.icon+'.png'" />
|
||||
<text class="font-gray">{{ item2.bizName }}</text>
|
||||
</view>
|
||||
</block>
|
||||
@@ -63,27 +63,37 @@ import customHeader from '@/components/customHeader.vue'
|
||||
import MescrollUni from 'mescroll-uni/mescroll-uni.vue';
|
||||
import { getNavBarPaddingTop} from '@/utils/system.js'
|
||||
import { businessList } from '@/api/business.js';
|
||||
import {showLoading,hideLoading} from '@/utils/message.js'
|
||||
import { initTree } from '@/utils/common.js'
|
||||
|
||||
onLoad(async(opt) => {
|
||||
uni.setStorageSync('page_cache',true);
|
||||
try {
|
||||
showLoading("加载中...")
|
||||
getList();
|
||||
hideLoading();
|
||||
} catch (error) {
|
||||
hideLoading();
|
||||
}
|
||||
})
|
||||
|
||||
// 获取导航栏高度用于内容区域padding
|
||||
const navBarPaddingTop = ref(0);
|
||||
onMounted(() => {
|
||||
navBarPaddingTop.value = getNavBarPaddingTop()*2;
|
||||
getList();
|
||||
})
|
||||
|
||||
// 查询列表
|
||||
let list = ref([]);
|
||||
let getList = async()=>{
|
||||
let res = await businessList({});
|
||||
let arr = res.list || [];
|
||||
arr.forEach(item => {
|
||||
|
||||
let res = await businessList({});//查询所有业务
|
||||
let arr = res || [];
|
||||
let bizList = initTree(arr,0,'bizId');//递归获取数组处理
|
||||
bizList.forEach(item => {
|
||||
item.expandFlag = false;
|
||||
});
|
||||
list.value = arr;
|
||||
list.value = bizList;
|
||||
}
|
||||
|
||||
// 右侧展开
|
||||
@@ -116,9 +126,10 @@ const downOption = ref({
|
||||
// 下拉刷新
|
||||
const downCallback = async (mescroll) => {
|
||||
try {
|
||||
setTimeout(async ()=>{
|
||||
// mescroll.resetUpScroll();
|
||||
},500);
|
||||
getList();
|
||||
// setTimeout(async ()=>{
|
||||
// // mescroll.resetUpScroll();
|
||||
// },500);
|
||||
} catch (error) {
|
||||
mescroll.endErr();
|
||||
} finally {
|
||||
|
||||
@@ -46,25 +46,58 @@ import { onLoad } from '@dcloudio/uni-app';
|
||||
import customHeader from '@/components/customHeader.vue'
|
||||
import MescrollUni from 'mescroll-uni/mescroll-uni.vue';
|
||||
import { getNavBarPaddingTop} from '@/utils/system.js'
|
||||
import { businessList } from '@/api/business.js';
|
||||
import { businessList,bizFavoriteSetting } from '@/api/business.js';
|
||||
import { getUserFavorite } from '@/api/home.js';
|
||||
import {showLoading,hideLoading,showAlert} from '@/utils/message.js'
|
||||
import { initTree } from '@/utils/common.js'
|
||||
|
||||
// 初始化加载
|
||||
onLoad(async(opt) => {
|
||||
uni.setStorageSync('page_cache',true);
|
||||
try {
|
||||
showLoading("加载中...")
|
||||
getList();
|
||||
hideLoading();
|
||||
} catch (error) {
|
||||
hideLoading();
|
||||
}
|
||||
})
|
||||
|
||||
// 获取导航栏高度用于内容区域padding
|
||||
const navBarPaddingTop = ref(0);
|
||||
onMounted(() => {
|
||||
navBarPaddingTop.value = getNavBarPaddingTop()*2;
|
||||
getList();
|
||||
})
|
||||
|
||||
// 查询列表
|
||||
let list = ref([]);
|
||||
let count = ref(7);
|
||||
let count = ref(0);
|
||||
let getList = async()=>{
|
||||
let res = await businessList({});
|
||||
let arr = res.list || [];
|
||||
let arrNew = [];
|
||||
let res = await businessList({});//查询所有业务
|
||||
let arr = res || [];
|
||||
|
||||
let res2 = await getUserFavorite({});//查询当前用户的常用服务
|
||||
let bizIdListStr = res2.bizIdList || '';
|
||||
let arr2 = bizIdListStr.split(",");
|
||||
count.value = arr2.length;
|
||||
|
||||
arr.forEach(item=>{
|
||||
item.isDaily=false;
|
||||
arr2.forEach(item2=>{
|
||||
if(item2==item.bizId){
|
||||
item.isDaily=true;
|
||||
}
|
||||
})
|
||||
arrNew.push(item)
|
||||
})
|
||||
|
||||
let bizList = initTree(arrNew,0,'bizId');//递归获取数组处理
|
||||
bizList.forEach(item => {
|
||||
item.expandFlag = false;
|
||||
});
|
||||
list.value = arr;
|
||||
list.value = bizList;
|
||||
console.log("list=>",list.value)
|
||||
}
|
||||
|
||||
// 下拉刷新
|
||||
@@ -94,20 +127,35 @@ const downCallback = async (mescroll) => {
|
||||
}
|
||||
}
|
||||
|
||||
let bizIds = ref([]);
|
||||
// 选择常用
|
||||
const handleCheck=(item)=>{
|
||||
item.isDaily = !item.isDaily;
|
||||
if(item.isDaily){
|
||||
count.value++;
|
||||
bizIds.value.push(item.bizId);
|
||||
}else{
|
||||
count.value--;
|
||||
const index = bizIds.value.findIndex(item2 => item2.bizId === item.bizId);
|
||||
if (index !== -1) {
|
||||
bizIds.value.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("bizIds=>",bizIds.value)
|
||||
}
|
||||
|
||||
// 提交
|
||||
const handleSubmit=(item)=>{
|
||||
|
||||
const handleSubmit= async()=>{
|
||||
try {
|
||||
showLoading("加载中...")
|
||||
console.log("bizIds=>",bizIds.value)
|
||||
await bizFavoriteSetting({bizIds:bizIds.value.join(",")});
|
||||
showAlert("操作成功")
|
||||
hideLoading();
|
||||
} catch (error) {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="container" :style="{ height: `100vh` }">
|
||||
<view class="container">
|
||||
<view class="bg"></view>
|
||||
<view class="bg-con">
|
||||
<view :style="{height: navBarPaddingTop + 'px'}"></view>
|
||||
@@ -46,24 +46,18 @@
|
||||
<view class="login-form approval" style="padding:110rpx 55rpx 150rpx;">
|
||||
<view class="approval-title">审核通过,请输入授权码</view>
|
||||
<view class="auth-code">
|
||||
<input password type="number" v-model="num1" auto-complete="off" :focus="pass1"
|
||||
maxlength="1" @blur="handleBlur(1)" @input="handleInput($event,1)"
|
||||
<input v-for="(item, index) in codes"
|
||||
password
|
||||
:key="index"
|
||||
v-model="codes[index]"
|
||||
type="number"
|
||||
maxlength="1"
|
||||
:ref="el => { if (el) inputRefs[index] = el }"
|
||||
@input="handleInput(index, $event)"
|
||||
@keydown.delete="handleDelete(index, $event)"
|
||||
:focus="activeIndex==index"
|
||||
@blur="handleBlur(index,codes[index])"
|
||||
/>
|
||||
<input password type="number" v-model="num2" auto-complete="off" :focus="pass2"
|
||||
maxlength="1" @blur="handleBlur(2)" @input="handleInput($event,2)"
|
||||
>
|
||||
<input password type="number" v-model="num3" auto-complete="off" :focus="pass3"
|
||||
maxlength="1" @blur="handleBlur(3)" @input="handleInput($event,3)"
|
||||
>
|
||||
<input password type="number" v-model="num4" auto-complete="off" :focus="pass4"
|
||||
maxlength="1" @blur="handleBlur(4)" @input="handleInput($event,4)"
|
||||
>
|
||||
<input password type="number" v-model="num5" auto-complete="off" :focus="pass5"
|
||||
maxlength="1" @blur="handleBlur(5)" @input="handleInput($event,5)"
|
||||
>
|
||||
<input password type="number" v-model="num6" auto-complete="off" :focus="pass6"
|
||||
maxlength="1" @blur="handleBlur(6)" @input="handleInput($event,6)"
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
<button type="primary" class="btn-submit" @click="handleSubmit" :loading="subLoading" :disabled="subLoading">提交</button>
|
||||
@@ -94,10 +88,19 @@ import { useUserStore } from '@/stores/user';
|
||||
const userStore = useUserStore();
|
||||
|
||||
onLoad(async(opt) => {
|
||||
console.log("onLoad");
|
||||
console.log("deviceAuth=>onLoad");
|
||||
uni.setStorageSync('page_cache',true);
|
||||
// uni.preloadPage({url: "/pages/login/login"});
|
||||
// uni.preloadPage({url: "/pages/home/home"});
|
||||
|
||||
deviceId.value = uni.getStorageSync('app_device_id');// 本地设备ID
|
||||
await selectBindStatus();
|
||||
if(bindStatus.value==2){
|
||||
// bindStatus=2-----到等待页面(定时任务查询 10秒查询一次)
|
||||
timer = setInterval(()=>{
|
||||
refreshBindStatus()
|
||||
},1000*10)//10秒刷新一次
|
||||
}
|
||||
})
|
||||
|
||||
// 绑定状态(1=已提交、2=等待审核、3=审核通过、4=绑定成功、5=审核拒绝)
|
||||
@@ -108,14 +111,6 @@ let timer = null;
|
||||
const navBarPaddingTop = ref(0);
|
||||
onMounted(async () => {
|
||||
navBarPaddingTop.value = getNavBarPaddingTop();
|
||||
deviceId.value = uni.getStorageSync('app_device_id');// 本地设备ID
|
||||
await selectBindStatus();
|
||||
if(bindStatus.value==2){
|
||||
// bindStatus=2-----到等待页面(定时任务查询 10秒查询一次)
|
||||
timer = setInterval(()=>{
|
||||
refreshBindStatus()
|
||||
},1000*10)//10秒刷新一次
|
||||
}
|
||||
})
|
||||
|
||||
// 组件卸载时清除定时器
|
||||
@@ -247,77 +242,44 @@ const handleRefresh = ()=>{
|
||||
selectBindStatus();
|
||||
}
|
||||
|
||||
// 输入授权码内容
|
||||
let num1=ref(''),num2=ref(''),num3=ref(''),num4=ref(''),num5=ref(''),num6=ref('');
|
||||
let pass1=ref(false),pass2=ref(false),pass3=ref(false),pass4=ref(false),pass5=ref(false),pass6=ref(false);
|
||||
// 获取值
|
||||
const getValue=(num,value)=>{
|
||||
let flag = false;
|
||||
num = value.replace(/[^\d]/g, '');
|
||||
if(num!=''){
|
||||
flag=true
|
||||
}
|
||||
return {num,flag}
|
||||
}
|
||||
// input事件
|
||||
const handleInput=(e,type)=>{
|
||||
let value = e.detail.value;
|
||||
if(type==6){
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case 1:
|
||||
let obj = getValue(num1.value,value);
|
||||
num1.value = obj.num;
|
||||
nextTick(() => {
|
||||
pass2.value = true;
|
||||
})
|
||||
break;
|
||||
case 2:
|
||||
let obj2 = getValue(num2.value,value);
|
||||
num2.value = obj2.num;
|
||||
nextTick(() => {
|
||||
pass3.value = true;
|
||||
})
|
||||
break;
|
||||
case 3:
|
||||
let obj3 = getValue(num3.value,value);
|
||||
num3.value = obj3.num;
|
||||
nextTick(() => {
|
||||
pass4.value = true;
|
||||
})
|
||||
break;
|
||||
case 4:
|
||||
let obj4 = getValue(num4.value,value);
|
||||
num4.value = obj4.num;
|
||||
nextTick(() => {
|
||||
pass5.value = true;
|
||||
})
|
||||
break;
|
||||
case 5:
|
||||
let obj5 = getValue(num5.value,value);
|
||||
num5.value = obj5.num;
|
||||
nextTick(() => {
|
||||
pass6.value = true;
|
||||
})
|
||||
break;
|
||||
case 6:
|
||||
let obj6 = getValue(num6.value,value);
|
||||
num6.value = obj6.num;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const codes = ref(Array(6).fill(''))
|
||||
const inputRefs = ref([]);
|
||||
const activeIndex = ref(0);//初始化焦点
|
||||
let authCode = ref('')
|
||||
const handleBlur = ()=>{
|
||||
let pass1 = num1.value?num1.value:'';
|
||||
let pass2 = num2.value?num2.value:'';
|
||||
let pass3 = num3.value?num3.value:'';
|
||||
let pass4 = num4.value?num4.value:'';
|
||||
let pass5 = num5.value?num5.value:'';
|
||||
let pass6 = num6.value?num6.value:'';
|
||||
authCode.value = pass1+pass2+pass3+pass4+pass5+pass6;
|
||||
const handleInput = (index, event) => {
|
||||
// 只允许数字输入
|
||||
const value = event.detail.value.replace(/\D/g, '')
|
||||
codes.value[index] = value
|
||||
|
||||
// 自动跳转到下一个输入框
|
||||
if (value && index < 5) {
|
||||
nextTick(() => {
|
||||
activeIndex.value = index+1;
|
||||
})
|
||||
}
|
||||
|
||||
// 输入最后一个框时获取值
|
||||
// if (index === 5 && value) {
|
||||
// authCode.value = codes.value.join('')
|
||||
// console.log('输入完成:', authCode.value)
|
||||
// }
|
||||
}
|
||||
|
||||
// 鼠标离开
|
||||
const handleBlur = (index,value)=>{
|
||||
codes.value[index] = value;
|
||||
authCode.value = codes.value.join('');
|
||||
// console.log('鼠标离开:', authCode.value)
|
||||
}
|
||||
|
||||
const handleDelete = (index, event) => {
|
||||
// 如果当前框为空且按下删除键,跳转到上一个输入框
|
||||
if (!codes.value[index] && index > 0) {
|
||||
event.preventDefault() // 阻止默认删除行为
|
||||
nextTick(() => {
|
||||
activeIndex.value = index-1;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 执行设备绑定
|
||||
|
||||
74
src/pages/h5-webview/h5-webview.vue
Normal file
74
src/pages/h5-webview/h5-webview.vue
Normal file
@@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<view>
|
||||
<web-view :src="url"></web-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref,onMounted,getCurrentInstance } from 'vue';
|
||||
import { onLoad,onReady } from '@dcloudio/uni-app';
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
let windowInfo = ref(null);
|
||||
let url = ref('');
|
||||
let title = ref('');
|
||||
//将要创建的webview对象
|
||||
let wv;
|
||||
onLoad(async(opt) => {
|
||||
// console.log(opt)
|
||||
url.value = 'http://www.baidu.com'//opt.url;
|
||||
title.value = opt.title;
|
||||
|
||||
})
|
||||
|
||||
onReady(()=>{
|
||||
setTimeout(()=>{
|
||||
uni.setNavigationBarTitle({
|
||||
title:'app中要设置的标题'
|
||||
})
|
||||
},2000)
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
uni.getSystemInfo({
|
||||
success: (res)=> {
|
||||
windowInfo.value = res;
|
||||
createWvAndLoadUrl(url.value);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
/*创建web-view并加载url*/
|
||||
const createWvAndLoadUrl=(url)=>{
|
||||
// #ifdef APP-PLUS
|
||||
wv = plus.webview.create(url,"webview",{
|
||||
// plusrequire:"none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
|
||||
top: 0,//this.windowInfo.statusBarHeight + 126, //放置在titleNView下方。如果还想在webview上方加个地址栏的什么的,可以继续降低TOP值
|
||||
scalable: true,
|
||||
height: windowInfo.value.windowHeight - windowInfo.value.statusBarHeight //- 126
|
||||
})
|
||||
wv.addEventListener('loading', () => {
|
||||
plus.nativeUI.showWaiting("loading...",{
|
||||
width:'110px',
|
||||
padding:'10px'
|
||||
})
|
||||
}, false);
|
||||
//plus.nativeUI.showWaiting()
|
||||
wv.addEventListener('loaded', () => {
|
||||
plus.nativeUI.closeWaiting();
|
||||
}, false);
|
||||
|
||||
//wv.loadURL(url)
|
||||
let currentWebview = proxy.$scope.$getAppWebview();
|
||||
currentWebview = wv;
|
||||
// console.log(wv)
|
||||
// setTimeout(()=> {
|
||||
// console.log(wv.getStyle())
|
||||
// }, 1000);
|
||||
// #endif
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -105,7 +105,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 常用服务 -->
|
||||
<view class="white-bg">
|
||||
<view class="white-bg" v-if="commonServiceList.length>0">
|
||||
<view class="w-b-title">常用服务</view>
|
||||
<view class="logo-list">
|
||||
<view v-for="(item,index) in commonServiceList" class="l-l-item" :key="index">
|
||||
@@ -147,23 +147,31 @@ import { onLoad } from '@dcloudio/uni-app';
|
||||
import MescrollUni from 'mescroll-uni/mescroll-uni.vue';
|
||||
import customSteps from '@/components/customSteps.vue'
|
||||
import { getNavBarPaddingTop} from '@/utils/system.js'
|
||||
import { backBlogCount,swiperList,stepData,salesTask,commonServices,newsQueryList } from '@/api/home.js';
|
||||
// ,swiperList,stepData,salesTask,commonServices,newsQueryList
|
||||
import { messageNotifyCount,messageFlowCount,getUserFavorite} from '@/api/home.js';
|
||||
import { getWeekStr,formatTimestamp } from '@/utils/datetime.js'
|
||||
import { formatMoney } from '@/utils/formatter.js'
|
||||
import {showLoading,hideLoading} from '@/utils/message.js'
|
||||
|
||||
onLoad(async(opt) => {
|
||||
uni.setStorageSync('page_cache',true);
|
||||
initLoad();
|
||||
// initLoad();
|
||||
})
|
||||
|
||||
// 初始化调用方法
|
||||
const initLoad =()=>{
|
||||
try {
|
||||
showLoading("加载中...")
|
||||
getBackBlogCount();
|
||||
getSwiperList();
|
||||
getStepData();
|
||||
getSalesTask();
|
||||
getCommonServices();
|
||||
getNewsList();
|
||||
hideLoading();
|
||||
} catch (error) {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
// 下拉刷新
|
||||
@@ -209,20 +217,30 @@ let handleSearch = ()=>{
|
||||
|
||||
}
|
||||
|
||||
|
||||
let backBlogObj = ref({
|
||||
count1:0,
|
||||
count2:0,
|
||||
count3:0,
|
||||
count4: 0
|
||||
})
|
||||
// 获取待办数据
|
||||
const getBackBlogCount = async () =>{
|
||||
let res = await messageNotifyCount();
|
||||
let res2 = await messageFlowCount();
|
||||
backBlogObj.value.count1= res.todoCount || 0//消息待阅
|
||||
backBlogObj.value.count2= res2.todoCount || 0//审核待办
|
||||
// tabar 增加消息数量
|
||||
try {
|
||||
if(backBlogObj.value.count1>0){
|
||||
wx.setTabBarBadge({
|
||||
index: 2, // TabBar的索引,从0开始计数
|
||||
text: '3' // 徽章的文本
|
||||
text: res.todoCount+'' // 徽章的文本
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('设置TabBar Badge失败:', error);
|
||||
}
|
||||
|
||||
let backBlogObj = ref({})
|
||||
// 获取待办数据
|
||||
let getBackBlogCount = async () =>{
|
||||
backBlogObj.value = await backBlogCount();
|
||||
}
|
||||
|
||||
|
||||
@@ -287,17 +305,8 @@ const getSalesTask = async ()=>{
|
||||
// 常用服务
|
||||
let commonServiceList = ref([])
|
||||
const getCommonServices = async ()=>{
|
||||
// let res = await commonServices({});
|
||||
let res = {
|
||||
list:[
|
||||
{id:1,name:'设备管理',imgSrc:'static/images/business/icon-sbgl.png'},
|
||||
{id:2,name:'目标管理',imgSrc:'static/images/business/icon-mbgl.png'},
|
||||
{id:3,name:'科研工艺',imgSrc:'static/images/business/icon-kygy.png'},
|
||||
{id:4,name:'工艺攻关',imgSrc:'static/images/business/icon-gygg.png'},
|
||||
{id:5,name:'数据采集',imgSrc:'static/images/business/icon-sjcj.png'}
|
||||
],
|
||||
}
|
||||
commonServiceList.value = res.list
|
||||
let res = await getUserFavorite({});
|
||||
commonServiceList.value = res.list || []
|
||||
}
|
||||
|
||||
// 添加常用服务
|
||||
|
||||
@@ -246,7 +246,7 @@ const submitForm = () => {
|
||||
let clientId = `${CLIENT_ID || "2"}`;
|
||||
let password = encryptObj.Encrypt(param.username + clientId + "," + param.password);
|
||||
param.password = password;
|
||||
param.uniqCode = 'bf52f71a-a951-43c3-a63d-0927d7854955'// uni.getStorageSync('app_device_id');//先从缓存取之后处理
|
||||
param.uniqCode = uni.getStorageSync('app_device_id');//先从缓存取之后处理 '7f47cfb4-59e2-4cb9-ac46-9da5e23c4de2'//
|
||||
param.clientId = clientId;
|
||||
let res = await login(param);
|
||||
userStore.login(res);
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<!-- 头部 -->
|
||||
<customHeader ref="customHeaderRef" :title="'消息'" :leftFlag="false" :rightFlag="true">
|
||||
<template #right>
|
||||
<view class="head-right" @click="handleReady">
|
||||
<img :src="'static/images/notice/icon-clean@2x.png'" />清除未读
|
||||
<view class="head-right" @click="handleRead">
|
||||
<img :src="'static/images/icon-clean@2x.png'" />清除未读
|
||||
</view>
|
||||
</template>
|
||||
</customHeader>
|
||||
@@ -24,13 +24,14 @@
|
||||
<!-- 消息列表 -->
|
||||
<mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
|
||||
:up="upOption" :down="downOption" :fixed="false" class="scroll-h" :class="{'loading-scroll':cssFlag}">
|
||||
<view class="white-bg" v-if="list.length">
|
||||
<view class="notice-list" v-for="(item, index) in list" :key="index">
|
||||
<img :src="item.imgSrc" />
|
||||
<view class="white-bg" v-if="list.length>0" :class="{'bg-height':list.length<5}">
|
||||
<view class="notice-list" v-for="(item, index) in list" :key="index" @click="handleJump(item)">
|
||||
<img :src="'static/images/notice/'+item.imgSrc" class="img-w" />
|
||||
<!-- <image :src="item.imgSrc" mode="aspectFit" class="img-w"></image> -->
|
||||
<view class="notice-item">
|
||||
<view :class="{ 'notice-title': true, bold: item.isReady }">{{ item.title }}</view>
|
||||
<view class="notice-date">{{ formatDateStr(item.date) }}</view>
|
||||
<view class="dot" v-if="item.isReady"></view>
|
||||
<view :class="{ 'notice-title': true, bold: item.isRead }">{{ item.subject }}</view>
|
||||
<view class="notice-date">{{ formatDateStr(item.createTime) }}</view>
|
||||
<view class="dot" v-if="item.isRead"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -40,7 +41,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref, onMounted,computed } from 'vue'
|
||||
import customHeader from '@/components/customHeader.vue'
|
||||
import { getNavBarPaddingTop } from '@/utils/system.js'
|
||||
import { noticeList } from '@/api/notice.js'
|
||||
@@ -68,12 +69,21 @@ const formatDateStr = (times) => {
|
||||
}
|
||||
|
||||
// 清除未读
|
||||
const handleReady = () => {
|
||||
const handleRead = () => {
|
||||
list.value.forEach(item => {
|
||||
item.isReady = false;
|
||||
item.isRead = false;
|
||||
})
|
||||
}
|
||||
|
||||
// 随机图片数组
|
||||
const images = [
|
||||
'icon-TiXing@2x.png',
|
||||
'icon-RiCheng@2x.png',
|
||||
'icon-DaiBan@2x.png',
|
||||
'icon-TongZhi@2x.png',
|
||||
'icon-TiXing@2x.png'
|
||||
]
|
||||
|
||||
// 查询通知列表
|
||||
let list = ref([]);
|
||||
const mescrollRef = ref(null);
|
||||
@@ -86,7 +96,7 @@ const upOption = ref({
|
||||
});
|
||||
|
||||
const downOption = ref({
|
||||
auto: true,
|
||||
auto: false,
|
||||
textInOffset: '下拉刷新',
|
||||
textOutOffset: '释放更新',
|
||||
textLoading: '刷新中...'
|
||||
@@ -101,12 +111,11 @@ const mescrollInit = (mescroll) => {
|
||||
// 下拉刷新
|
||||
const downCallback = async (mescroll) => {
|
||||
try {
|
||||
setTimeout(async ()=>{
|
||||
console.log("下拉刷新")
|
||||
const res = await getNoticeList(1, upOption.value.page.size);
|
||||
cssFlag.value = false;
|
||||
list.value = res.list;
|
||||
mescroll.resetUpScroll();
|
||||
},500);
|
||||
} catch (error) {
|
||||
mescroll.endErr();
|
||||
} finally {
|
||||
@@ -118,15 +127,14 @@ const downCallback = async (mescroll) => {
|
||||
// 上拉加载更多
|
||||
const upCallback = async (mescroll) => {
|
||||
try {
|
||||
setTimeout(async ()=>{
|
||||
const res = await getNoticeList(mescroll.num, mescroll.size);
|
||||
console.log("上拉加载更多")
|
||||
let res = await getNoticeList(mescroll.num, mescroll.size);
|
||||
if (mescroll.num === 1) {
|
||||
list.value = res.list;
|
||||
} else {
|
||||
list.value.push(...res.list);
|
||||
}
|
||||
mescroll.endBySize(res.list.length, res.total);
|
||||
},500);
|
||||
} catch (error) {
|
||||
mescroll.endErr();
|
||||
}
|
||||
@@ -140,33 +148,26 @@ const getNoticeList = (pageIndex, pageSize) => {
|
||||
pageSize
|
||||
}
|
||||
|
||||
// let res = await noticeList(param);
|
||||
let res = {
|
||||
list:[
|
||||
{id:1,date:'2025-06-30',isReady:true,title:'临时调整本周工作时间的通知',imgSrc:'static/images/notice/icon-TiXing@2x.png'},
|
||||
{id:2,date:'2025-06-27',isReady:false,title:'8月个税扣缴申报已完成',imgSrc:'static/images/notice/icon-RiCheng@2x.png'},
|
||||
{id:3,date:'2025-09-10 17:29:00',isReady:true,title:'公司班车北五环线路调整的通知',imgSrc:'static/images/notice/icon-DaiBan@2x.png'},
|
||||
{id:4,date:'2025-09-09 15:36:00',isReady:true,title:'祝贺“友晟夏季封装外壳发布会”圆满成功',imgSrc:'static/images/notice/icon-TongZhi@2x.png'},
|
||||
{id:5,date:'2025-09-07 08:41:00',isReady:false,title:'研发部采购验收流程【2025】修改版',imgSrc:'static/images/notice/icon-FuWu@2x.png'},
|
||||
{id:6,date:'2025-09-07 08:08:00',isReady:false,title:'加强公司安全管理 迎接全市年度检查',imgSrc:'static/images/notice/icon-TongZhi@2x.png'},
|
||||
{id:7,date:'2025-09-05 13:18:00',isReady:false,title:'2025年国庆节放假安排通知',imgSrc:'static/images/notice/icon-TiXing@2x.png'},
|
||||
{id:8,date:'2025-06-30',isReady:true,title:'临时调整本周工作时间的通知',imgSrc:'static/images/notice/icon-TiXing@2x.png'},
|
||||
{id:9,date:'2025-06-27',isReady:false,title:'8月个税扣缴申报已完成',imgSrc:'static/images/notice/icon-RiCheng@2x.png'},
|
||||
{id:10,date:'2025-09-10 17:29:00',isReady:true,title:'公司班车北五环线路调整的通知',imgSrc:'static/images/notice/icon-DaiBan@2x.png'},
|
||||
// {id:11,date:'2025-09-09 15:36:00',isReady:true,title:'祝贺“友晟夏季封装外壳发布会”圆满成功',imgSrc:'static/images/notice/icon-TongZhi@2x.png'},
|
||||
// {id:12,date:'2025-09-07 08:41:00',isReady:false,title:'研发部采购验收流程【2025】修改版',imgSrc:'static/images/notice/icon-FuWu@2x.png'},
|
||||
// {id:13,date:'2025-09-07 08:08:00',isReady:false,title:'加强公司安全管理 迎接全市年度检查',imgSrc:'static/images/notice/icon-TongZhi@2x.png'},
|
||||
// {id:14,date:'2025-09-05 13:18:00',isReady:false,title:'2025年国庆节放假安排通知',imgSrc:'static/images/notice/icon-TiXing@2x.png'},
|
||||
],
|
||||
totalCount:14
|
||||
}
|
||||
let res = await noticeList(param);
|
||||
let list = res.list || [];
|
||||
list.forEach(item=>{
|
||||
const randomIndex = Math.floor(Math.random() * images.length)
|
||||
item.imgSrc = images[randomIndex];
|
||||
})
|
||||
resolve({
|
||||
list: res.list,
|
||||
total: res.totalCount
|
||||
list,
|
||||
total: res.recordCount || 0
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 跳转webview
|
||||
const handleJump = (item)=>{
|
||||
uni.navigateTo({
|
||||
url: '/pages/h5-webview/h5-webview?url=' + item.mobileLink+"&title="+item.subject
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -195,16 +196,24 @@ const getNoticeList = (pageIndex, pageSize) => {
|
||||
|
||||
.white-bg {
|
||||
width: 750rpx;
|
||||
padding: 40rpx 0 ;
|
||||
padding: 40rpx 0 20rpx;
|
||||
margin-bottom:0;
|
||||
border-radius: 8px 8px 0 0;
|
||||
}
|
||||
.white-bg.bg-height{
|
||||
/* #ifdef APP-PLUS */
|
||||
height: calc(100vh - 145px);
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
height: calc(100vh - 175px);
|
||||
/* #endif */
|
||||
}
|
||||
.scroll-h{
|
||||
/* #ifdef APP-PLUS */
|
||||
height: calc(100vh - 120px);
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
height: calc(100vh - 140px);
|
||||
height: calc(100vh - 160px);
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
@@ -214,7 +223,7 @@ const getNoticeList = (pageIndex, pageSize) => {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.white-bg .notice-list img {
|
||||
.white-bg .notice-list .img-w{
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
margin-right: 30rpx;
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
<img class="pic-img" :src="'static/images/userinfo/icon-userinfo.png'" />
|
||||
<view class="head-name">
|
||||
<view class="nick">
|
||||
<view class="nick-text">{{ userObj.name }}</view>
|
||||
<view class="nick-text">{{ userObj.realname }}</view>
|
||||
<img :src="`static/images/userinfo/num-${userObj.level}@2x.png`" class="level" />
|
||||
</view>
|
||||
<view class="dept">{{ userObj.deptName }} {{ userObj.jobName }}</view>
|
||||
<view class="dept">{{ userObj.deptName }} {{ userObj.postName }}</view>
|
||||
</view>
|
||||
<view class="head-right">
|
||||
<view class="font-ruzhi">已入职{{userObj.joinDay}}天</view>
|
||||
@@ -27,12 +27,12 @@
|
||||
</view>
|
||||
|
||||
<!-- 日常 -->
|
||||
<view class="backlog-bg">
|
||||
<view class="backlog-b-item">
|
||||
<img :src="'static/images/business/icon-rwjh.png'" />
|
||||
<view class="font-title">任务计划</view>
|
||||
</view>
|
||||
<view class="backlog-b-item">
|
||||
<!-- <view class="backlog-bg">
|
||||
<view class="backlog-b-item" v-for="(item,index) in bizListFavorite" :key="index">
|
||||
<img :src="'static/images/business/'+item.icon+'.png'" />
|
||||
<view class="font-title">{{item.bizName}}</view>
|
||||
</view> -->
|
||||
<!-- <view class="backlog-b-item">
|
||||
<img :src="'static/images/business/icon-rb.png'" />
|
||||
<view class="font-title">日报</view>
|
||||
</view>
|
||||
@@ -43,11 +43,11 @@
|
||||
<view class="backlog-b-item">
|
||||
<img :src="'static/images/business/icon-jxgl.png'" />
|
||||
<view class="font-title">绩效管理</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<!-- </view> -->
|
||||
|
||||
<!-- 头像块 -->
|
||||
<view class="white-bg">
|
||||
<view class="white-bg" style="margin-top:20rpx;">
|
||||
<view class="list-item">
|
||||
<img :src="'static/images/userinfo/icon-tx@2x.png'" class="l-icon" />
|
||||
<text>头像</text>
|
||||
@@ -78,9 +78,9 @@
|
||||
<view class="item-border"></view>
|
||||
<view class="list-item item-padding" @click="handleVersion">
|
||||
<img :src="'static/images/userinfo/icon-bbgx@2x.png'" class="l-icon" />
|
||||
<view class="item-text">版本更新 <view class="dot"></view></view>
|
||||
<view class="item-text">版本更新 <view class="dot" v-if="isCurrent==2"></view></view>
|
||||
<view class="list-right">
|
||||
<text class="item-gray">Version 1.0.0</text>
|
||||
<text class="item-gray">Version {{ appVersion }}</text>
|
||||
<uni-icons type="right" size="20" color="#A0A0A0"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
@@ -99,21 +99,27 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
// import customHeader from '@/components/customHeader.vue'
|
||||
import MescrollUni from 'mescroll-uni/mescroll-uni.vue';
|
||||
import { getNavBarPaddingTop } from '@/utils/system.js'
|
||||
import { getUserInfo } from '@/api/auth.js'
|
||||
import { getUserInfo,versionCheck } from '@/api/auth.js'
|
||||
import { formatIOS } from '@/utils/status.js'
|
||||
import { useUserStore } from '@/stores/user';
|
||||
const userStore = useUserStore()
|
||||
|
||||
onLoad(async(opt) => {
|
||||
uni.setStorageSync('page_cache',true);
|
||||
})
|
||||
|
||||
// 1.头部导航栏
|
||||
const navBarPaddingTop = ref(0);
|
||||
let appVersion = ref("1.0.0");//当前版本号
|
||||
|
||||
let isCurrent = ref(undefined);//是否是当前版本 1-是 2-否
|
||||
let systemInfo = uni.getSystemInfoSync();
|
||||
onLoad(async(opt) => {
|
||||
uni.setStorageSync('page_cache',true);
|
||||
// #ifdef APP-PLUS
|
||||
appVersion.value=systemInfo.appWgtVersion; //当前版本号
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
appVersion.value=systemInfo.appVersion;
|
||||
// #endif
|
||||
})
|
||||
|
||||
// 下拉刷新
|
||||
const mescrollRef = ref(null);
|
||||
@@ -127,26 +133,63 @@ const downOption = ref({
|
||||
textLoading: '刷新中...'
|
||||
});
|
||||
|
||||
// 2.获取用户基本信息
|
||||
let userObj = ref({});
|
||||
let bizListFavorite = ref([]);
|
||||
const selectUserInfo = async ()=>{
|
||||
let data = await getUserInfo({});
|
||||
|
||||
// 查询常用业务
|
||||
// let favoriteBizListStr = data.favoriteBizList || '';
|
||||
// let favoriteBizList = favoriteBizListStr.split(",");//常用业务
|
||||
// let list = [];
|
||||
// let bizList = data.bizList;//所有业务
|
||||
// bizList.forEach(item => {
|
||||
// favoriteBizList.forEach(item2=>{
|
||||
// if(item.bizId == item2){
|
||||
// list.push(item);
|
||||
// }
|
||||
// })
|
||||
// });
|
||||
// bizListFavorite.value = list;
|
||||
|
||||
// 岗位名称,取第0个显示
|
||||
let postName = data.postList[0]?data.postList[0].postName:'';
|
||||
userObj.value = {
|
||||
...data,
|
||||
postName,
|
||||
level:5,//默认搞个5
|
||||
joinDay:1000,//默认1000天
|
||||
};
|
||||
}
|
||||
|
||||
// 下拉刷新
|
||||
const downCallback = async (mescroll) => {
|
||||
try {
|
||||
setTimeout(async ()=>{
|
||||
// mescroll.resetUpScroll();
|
||||
},500);
|
||||
selectUserInfo();
|
||||
getVersion();
|
||||
} catch (error) {
|
||||
mescroll.endErr();
|
||||
} finally {
|
||||
setTimeout(async ()=>{
|
||||
mescroll.endSuccess();
|
||||
},500);
|
||||
}
|
||||
}
|
||||
|
||||
// 2.获取用户基本信息
|
||||
let userObj = ref({});
|
||||
const selectUserInfo = async ()=>{
|
||||
let data = await getUserInfo({});
|
||||
userObj.value = data;
|
||||
// 3.查询是否有更新的版本显示点
|
||||
const getVersion = async ()=>{
|
||||
let param = {
|
||||
// #ifdef APP-PLUS
|
||||
verNumber:systemInfo.appWgtVersion,//当前版本号
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
verNumber : systemInfo.appVersion,
|
||||
// #endif
|
||||
os: formatIOS(systemInfo.osName),//操作系统 Android IOS
|
||||
}
|
||||
// 当前手机版本
|
||||
appVersion.value = param.appVersion;
|
||||
let data = await versionCheck(param);
|
||||
isCurrent.value = data.isCurrent;
|
||||
}
|
||||
|
||||
// 3.退出登录
|
||||
@@ -164,16 +207,6 @@ const handleVersion=()=>{
|
||||
|
||||
onMounted(() => {
|
||||
navBarPaddingTop.value = getNavBarPaddingTop() * 2;
|
||||
|
||||
let systemInfo = uni.getSystemInfoSync();
|
||||
// #ifdef APP-PLUS
|
||||
appVersion.value=systemInfo.appWgtVersion; //当前版本号
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
appVersion.value=systemInfo.appVersion;
|
||||
// #endif
|
||||
|
||||
selectUserInfo()
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -26,10 +26,10 @@ const cache = {
|
||||
return null
|
||||
}
|
||||
const { value, expire } = JSON.parse(data)
|
||||
if (expire && expire < this.time()) {
|
||||
uni.removeStorageSync(key)
|
||||
return null
|
||||
}
|
||||
// if (expire && expire < this.time()) {
|
||||
// uni.removeStorageSync(key)
|
||||
// return null
|
||||
// }
|
||||
return value
|
||||
} catch (e) {
|
||||
return null
|
||||
|
||||
12
src/utils/common.js
Normal file
12
src/utils/common.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// 递归算法
|
||||
export const initTree = (arr, parentId='0',id) => {
|
||||
const tree = [];
|
||||
arr.filter(item => item.parentId === parentId).forEach(item => {
|
||||
const children = initTree(arr, item[id]);
|
||||
if (children.length > 0) {
|
||||
item.children = children;
|
||||
}
|
||||
tree.push(item);
|
||||
});
|
||||
return tree;
|
||||
}
|
||||
@@ -3,16 +3,14 @@ import { merge } from 'lodash-es';
|
||||
import { getToken } from '../auth';
|
||||
import { CLIENT_ID } from '@/enums/cacheEnums';
|
||||
import { RequestCodeEnum, RequestMethodsEnum } from '@/enums/requestEnums';
|
||||
import { clearToken } from '@/utils/auth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useMessage } from '../message';
|
||||
|
||||
const message = useMessage();
|
||||
|
||||
const requestHooks = {
|
||||
// 请求拦截器
|
||||
requestInterceptorsHook(options, config) {
|
||||
console.log("request=>",options);
|
||||
// console.log("request=>config=>",config)
|
||||
const { urlPrefix, baseUrl, withToken, isAuth } = config;
|
||||
options.header = options.header ?? {};
|
||||
if (urlPrefix) {
|
||||
@@ -22,9 +20,11 @@ const requestHooks = {
|
||||
options.url = `${baseUrl}${options.url}`;
|
||||
}
|
||||
const token = getToken(); //console.log("token=>",token)
|
||||
if (withToken && !options.header.token) {
|
||||
options.header.token = token;
|
||||
}
|
||||
// if (withToken && !options.header.token) {
|
||||
options.header.token = "Bearer "+ token;
|
||||
options.header.Authorization = "Bearer "+ token;
|
||||
// }
|
||||
console.log("request=>",options)
|
||||
return options;
|
||||
},
|
||||
// 响应拦截器
|
||||
@@ -39,7 +39,7 @@ const requestHooks = {
|
||||
if (!isTransformResponse) {
|
||||
return response.data;
|
||||
}
|
||||
const { logout, isLogin } = useUserStore();
|
||||
// const { logout, isLogin } = useUserStore();
|
||||
const { code, data, msg, show } = response.data;
|
||||
// console.log(code,data,msg,show)
|
||||
switch (code) {
|
||||
@@ -50,9 +50,12 @@ const requestHooks = {
|
||||
message.toast(msg);
|
||||
return Promise.reject(msg);
|
||||
case RequestCodeEnum.TOKEN_INVALID:
|
||||
if (isAuth && isLogin) {
|
||||
|
||||
}
|
||||
message.toast('登录状态已过期,请重新登录!');
|
||||
// console.log(isAuth,isLogin)
|
||||
// if (isAuth && isLogin) {
|
||||
clearToken();
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
// }
|
||||
|
||||
return Promise.reject();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user