wangguoyu 6 maanden geleden
bovenliggende
commit
87b799c2e0

+ 0 - 10
common/prototype.js

@@ -1,10 +0,0 @@
-/**
- * @全局挂载
- * @API 全局事件
- */
-import global from '../utils/global'
-export default {
-    install(app) {
-        app.config.globalProperties.$global = global
-    }
-}

+ 0 - 4
main.js

@@ -3,13 +3,9 @@ import App from './App.vue'
 //import plugins from './plugins' // plugins
 //import './permission' // permission
 import { createPinia } from 'pinia'
-import uviewPlus from 'uview-plus'
-import prototype from './common/prototype.js'//全局挂载
-const pinia = createPinia()
 // 创建Vue应用实例
 const app = createApp(App)
 //app.use(plugins)
 app.use(createPinia())
-app.use(uviewPlus)
 // 挂载Vue应用实例
 app.mount('#app')

+ 20 - 49
package.json

@@ -1,51 +1,22 @@
 {
-	"name": "hbproject",
-	"version": "1.0.0",
-	"description": "",
-	"main": "main.js",
-	"dependencies": {
-		"axios": "^1.7.2",
-		"jsencrypt": "^3.3.2",
-		"pinia": "^2.1.7",
-		"ts-md5": "^1.3.1",
-		"uview-plus": "^3.3.42",
-		"vue": "^3.5.13"
-	},
-	"devDependencies": {},
-	"uni-app": {
-		"scripts": {
-			"dev-h5": {
-				"title": "开发环境H5",
-				"BROWSER": "chrome",
-				"env": {
-					"UNI_PLATFORM": "h5",
-					"UNI_APP_URL": "https://www.wgy.com",
-					"UNI_BASE_URL": "https://www.wgy.com"
-				},
-				"define": {
-					"DEV-H5": true
-				}
-			},
-			"prod-h5": {
-				"title": "生产环境H5",
-				"BROWSER": "chrome",
-				"env": {
-					"UNI_PLATFORM": "h5",
-					"UNI_APP_URL": "https://www.wgy.com"
-				},
-				"define": {
-					"PROD-H5": true
-				}
-			}
-		}
-	},
-	"scripts": {
-		"dev:h5": "uni"
-	},
-	"repository": {
-		"type": "git",
-		"url": "https://gogs.mtavip.com/wangguoyu/uniProject.git"
-	},
-	"author": "",
-	"license": "ISC"
+  "name": "hbproject",
+  "version": "1.0.0",
+  "description": "",
+  "main": "main.js",
+  "dependencies": {
+    "axios": "^1.7.2",
+    "jsencrypt": "^3.3.2",
+    "pinia": "^2.1.7",
+    "ts-md5": "^1.3.1"
+  },
+  "devDependencies": {},
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1112"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://gogs.mtavip.com/wangguoyu/uniProject.git"
+  },
+  "author": "",
+  "license": "ISC"
 }

+ 0 - 22
pages/course/index.vue

@@ -1,22 +0,0 @@
-<template>
-	<view class="lli-develop-expect-page">
-		开发中,敬请期侍!
-	</view>
-</template>
-
-<script>
-	export default {
-		data() {
-			return {
-				
-			}
-		},
-		methods: {
-			
-		}
-	}
-</script>
-
-<style>
-
-</style>

+ 0 - 66
pages/demo/index.vue

@@ -1,66 +0,0 @@
-<template>
-	<view class="lli-demo-page">
-		<uni-search-bar class="uni-mt-10" radius="100" placeholder="请输入考试名称" bgColor="#F3F3F4" clearButton="auto" cancelButton="none" @confirm="search"/>
-		<view class="lli-status-box">
-		    <text class="status-item click">可以考试</text><text class="status-item">已结束</text>
-		</view>
-		<scroll-view class="demo-scroll-view" scroll-y="true">
-			<view class="content-view">
-				
-				<view class="lli-tc demo-title">------------咱们要用的默认按钮↓-------------</view>
-				<button class="lli-btn">页面次要操作 Normal</button>
-				<button class="lli-btn" loading="true" >页面主操作 Loading</button>
-				<button class="lli-btn" disabled="true" >页面次要操作 Disabled</button>
-				<view class="lli-tc demo-title">---------咱们要用的按钮plain(线性)↓----------</view>
-				<button class="lli-btn" plain="true">页面次要操作 Normal</button>
-				<button class="lli-btn" loading="true" plain="true">页面主操作 Loading</button>
-				<button class="lli-btn" disabled="true" plain="true">页面次要操作 Disabled</button>
-				<view class="lli-tc demo-title">------------其他组件定义color="#0550e5"-------------</view>	
-					<checkbox-group>
-						<label>
-							<checkbox value="cb" checked="true" color="#0550e5"/>选中
-						</label>
-						<label>
-							<checkbox value="cb" />未选中
-						</label>
-					</checkbox-group>
-					<view class="lli-tc demo-title">------------扩展组件-------------</view>
-						
-					<uni-section title="自定义样式" subTitle="使用 styles 属性 ,可以自定义输入框样式" type="line" padding>
-								<uni-easyinput v-model="value" placeholder="请输入内容"@input="input"></uni-easyinput>
-							</uni-section>
-			</view>
-		</scroll-view>
-	</view>
-</template>
-
-<script>
-	export default {
-		data() {
-			return {
-				value:'',
-			}
-		},
-		methods: {
-			search:function(){},
-		}
-	}
-</script>
-<style lang="scss">
-	.lli-demo-page{
-		display: flex;flex-direction: column;
-		height: 100vh;padding-bottom: 60rpx;box-sizing: border-box;
-		.demo-scroll-view{
-			overflow-y: auto;flex: 1;
-		}
-		.content-view{padding: 24px;box-sizing: border-box;}
-		.demo-title{margin: 24px 0 10px;}
-	}
-	/* 小程序UI开发规范 */
-	/*  1.第一版没有UI,用手机单机版的UI开发,尽可能保持一致
-		2.页面中样式第一版都先写到底部style中
-		2.扩展组件:已重置样式,可以直接用
-		3.内置组件:如果是有颜色的,需要添加color="#0550e5"(后期会改成动态的,第一版先这么加),btn也可以用demo写好的
-		4.自己写的样式尽量只用view,text标签,使用类选择器不要使用标签选择器 */
-</style>
-

+ 0 - 36
pages/exam/index.vue

@@ -1,36 +0,0 @@
-<template>
-	<custom-scroll-list :refreshFn="getExamList" :tabList="tabData" :defaultTab="1">
-		<template #default="{list}">
-			<scroll-list-card  v-for="(item,index) in list" :key="item.ksId" :data="item" ></scroll-list-card>
-		</template>
-	</custom-scroll-list>
-</template>
-
-<script setup>
-	import {
-		getExamList
-	} from "@/api/exam.js";
-	import {
-		// onLoad,
-		onReady,
-		
-	} from "@dcloudio/uni-app"
-	import {
-		reactive,
-		ref
-	} from "vue";
-
-	const tabData = [{
-			label: "可以考试",
-			value: 1,
-		},
-		{
-			label: "已结束",
-			value: 4,
-		}
-	]
-</script>
-
-<style lang="scss">
-
-</style>

+ 0 - 227
pages/index/index.vue

@@ -1,227 +0,0 @@
-<template>
-	<view class="lli-index-page">
-		<!-- banner -->
-		<view class="index-imgbox">
-		    <img :src="banners||defaultbanners" class="index-banner-img"/>
-		</view>
-		<!-- meul-box -->
-		<view class="index-meul-box">
-			<uni-grid :column="4" :show-border="false" :square="false" @change="gridClick">
-				<uni-grid-item v-for="(item ,index) in menuList" :index="index" :key="index">
-					<view class="lli-grid-item">
-						<image class="grid-item-image" :src="item.url" mode="aspectFill" />
-						<text class="grid-item-text">{{item.text}}</text>
-						<view v-if="item.badge" class="grid-dot">
-							<uni-badge :text="item.badge" :type="item.type" :customStyle="{background: '#FF5551'}" />
-						</view>
-					</view>
-				</uni-grid-item>
-			</uni-grid>
-		</view>
-		
-		<!-- 课程list -->
-		<view class="lli-index-title-box">
-			<text class="index-title">最热课程</text>
-			<text class="index-sub-title" @click="developClick">查看更多 ></text>
-		</view>
-		<view class="lli-card-box">
-			<uni-card padding="0" margin="0" spacing="0" :is-shadow="false" :border="false" 
-			v-for="(item ,index) in courseCardList" :index="index" :key="index" class="lli-card-item" @click="developClick(index)">
-				<view class="custom-cover">
-					<image class="lli-card-image" mode="aspectFill" :src="item.pic || defultKcImg"></image>
-					<view class="cover-content" v-if="item.status">
-						<text>{{statusCodeKc[item.status]}}</text>
-					</view>
-				</view>
-				<text class="lli-card-name">{{item.name}}</text>
-			</uni-card>
-		</view>
-		<!-- 考试list -->
-		<view class="lli-index-title-box">
-			<text class="index-title">最热考试</text>
-			<text class="index-sub-title" @click="developClick">查看更多 ></text>
-		</view>
-		<view class="lli-card-box">
-			<uni-card padding="0" margin="0" spacing="0" :is-shadow="false" :border="false" 
-			v-for="(item ,index) in examCardList" :index="index" :key="index" class="lli-card-item" @click="developClick(index)">
-				<view class="custom-cover">
-					<image class="lli-card-image" mode="aspectFill" :src="item.pic || defultKsImg"></image>
-					<view class="cover-content" v-if="item.status">
-						<text>{{statusCodeKs[item.status]}}</text>
-					</view>
-				</view>
-				<text class="lli-card-name">{{item.ksName}}</text>
-			</uni-card>
-		</view>
-		
-	</view>
-</template>
-
-<script setup>
-	import {ref,reactive} from "vue";
-	import {getCourseList, getNoticeCount,getExamList} from '@/api/index.js';
-	import {onLoad} from "@dcloudio/uni-app"
-	const banners= ref('');
-	const defaultbanners= ref('/static/images/index/index-banner.png');
-	const defultKsImg= ref('/static/images/index/index-ks-default.png');
-	const defultKcImg= ref('/static/images/index/index-kc-default.png');
-	const statusCodeKc= ref(['未开始', '可以学习', '已学完', '学习中', '已结束']);
-	const statusCodeKs= ref(['未开始', '可以考试', '再次考试', '考试中', '已结束', '未报名', '报名审核中', '审核未通过', '等待人工评分']);
-	let menuList = ref([{
-	      		url: '/static/images/index/index-kc-img.png',
-	      		text: '我的课程',
-	      	},
-	      	{
-	      		url: '/static/images/index/index-ks-img.png',
-	      		text: '我的考试',
-	      	},
-	      	{
-	      		url: '/static/images/index/index-lx-img.png',
-	      		text: '每日一练',
-	      	},
-	      	{
-	      		url: '/static/images/index/index-gg-img.png',
-	      		text: '公告',
-				badge:0,
-	      	},
-	      ]);
-	let courseCardList = ref([]);
-	let examCardList = ref([]);
-	let noticeCount = ref(0);
-	
-	onLoad(() => {
-		getNoticeCountData();
-		getCourseListData();
-		getExamListData();
-	});
-	
-	function getNoticeCountData() {
-		let req = {
-		          'page': 1,
-		          'size': 4,
-		          'status': 1,
-		        };
-		getNoticeCount(req).then(res => {
-		    menuList.value[3].badge = res.data.noticeCount || 0;
-		});
-	};
-	
-	function getCourseListData() {
-		let req = {
-		          'page': 1,
-		          'size': 4,
-		          'status': 1,
-		        };
-		getCourseList(req).then(res => {
-		          courseCardList.value = res.data.data || [];
-		});
-	};
-	
-	function getExamListData() {
-		let req = {
-		          'page': 1,
-		          'size': 4,
-		          'status': 1,
-		        };
-		getExamList(req).then(res => {
-		          examCardList.value = res.data.data || [];
-		});
-	};
-	
-	function gridClick(e){
-		let {index} = e.detail;
-		switch (index) {
-			case 0:
-			    uni.switchTab({
-			    	url: '/pages/course/index'
-			    });
-			    break;
-			case 1:
-			    uni.switchTab({
-			    	url: '/pages/exam/index'
-			    });
-			    break;
-			case 2:
-			    uni.showToast({
-					icon: 'none',
-			    	title: '开发中,敬请期侍!',
-			    });
-			    break;
-			case 3:
-			    uni.showToast({
-					icon: 'none',
-			    	title: '开发中,敬请期侍!',
-			    });
-			    break;
-				}
-	}
-	function developClick(){
-		uni.showToast({
-			icon: 'none',
-			title: '开发中,敬请期侍!',
-		});
-	}
-	
-	
-</script>
-
-<style lang="scss">
-.lli-index-page{
-	padding: 24rpx;
-	background: #FCFBFC;
-	min-height: 100vh;
-	// banner
-	.index-imgbox {
-	    text-align: center;width: 100%;
-	    .index-banner-img {
-	      width: 702rpx;
-	      height: 242rpx;
-	      display: inline-block;
-	      border-radius: 4px;
-	    }
-	}
-	
-	//meul-box
-	.index-meul-box{
-		.lli-grid-item {
-				flex: 1;
-				/* #ifndef APP-NVUE */
-				display: flex;
-				/* #endif */
-				flex-direction: column;
-				align-items: center;
-				justify-content: center;
-				padding: 15px 0;
-			}
-		.grid-item-image {width: 99rpx;height: 113rpx;}
-		.grid-item-text {font-size: 24rpx;color: $uni-text-color;}
-		.grid-dot {position: absolute;top: 5px;right: 15px;}
-	}
-	
-	// title-box
-	.lli-index-title-box{
-		margin: 44rpx 0 32rpx;display: flex;justify-content: space-between;align-items: center;
-		.index-title{font-size: 32rpx;color: #333;font-weight: 800;display: inline-flex;align-items: center;}
-		.index-title:before{content:'';width: 3px;height: 30rpx;margin-right: 8px;display: block;}
-		.index-sub-title{font-size: 24rpx;color: #9c9c9c;font-weight: normal;cursor: pointer;}
-	}
-	
-	// card
-	.lli-card-box{width: 100%;display: flex;justify-content: space-between;flex-wrap: wrap;margin-bottom: 8px;cursor: pointer;}
-	.lli-card-item{
-		width: 49%;flex: unset;border-radius: 20rpx;background-color: #ffffff;
-		padding: 12rpx 12rpx 0;box-sizing: border-box;margin-bottom: 20rpx;
-		.lli-card-image{max-width: 100%;height: 180rpx;border-radius: 8rpx;}
-		.custom-cover {max-width: 100%;height: 180rpx;border-radius: 8rpx;overflow: hidden;position: relative;}
-		.cover-content {
-			position: absolute;bottom: 0;left: 0;padding: 4rpx 12rpx;background: rgba(0, 0, 0, 0.29);
-			color: #fff;font-size: 22rpx;border-radius: 0 10rpx 0 10rpx;
-		}
-		.lli-card-name{
-			font-size: 28rpx;line-height: 36rpx;color: #565656;margin: 20rpx 0;
-			display: -webkit-box;-webkit-line-clamp: 2;overflow: hidden;
-			text-overflow: ellipsis;-webkit-box-orient: vertical;
-		}
-	}
-}
-</style>

+ 0 - 81
pages/my/index.vue

@@ -1,81 +0,0 @@
-<template>
-	<view class="lli-develop-expect-page">
-			<button class="lli-btn" @click="quit">退出登录</button>
-	</view>
-</template>
-
-<script setup>
-	import {
-		logout
-	} from '@/api/login.js'
-	
-	
-	const quitClick = ()=>{
-		uni.showModal({
-		        title: '提示',
-		        content: '你确定要执行这个操作吗?',
-		        success: (res) => {
-		          if (res.confirm) {
-		            // 用户点击了确定按钮,执行你的操作
-		            console.log('用户点击了确定');
-		           quit()
-		          } else if (res.cancel) {
-		            // 用户点击了取消按钮
-		            console.log('用户点击了取消');
-		          }
-		        }
-		      });
-		
-		 }
-	const quit = ()=>{
-		uni.navigateTo({
-			url: '/pages/login'
-		});
-			/* logout().then(res=>{
-				uni.removeStorage({
-					key: 'Mta-Auth',
-					success: function (res) {
-						console.log('success');
-						uni.navigateTo({
-							url: '/pages/login'
-						});
-					}
-				});
-			}) */
-		
-		 }
-		 
-	// import { ref, onMounted } from 'vue';
-	//
-	// const listData = ref([]);
-	// const page = ref(1);
-	// const pageSize = ref(10);
-	// const isLoading = ref(false);
-	// const noMoreData = ref(false);
-	//
-	// // 加载
-	// const loadData = async () => {
-	// 	if (isLoading.value || noMoreData.value) return;
-	// 	isLoading.value = true;
-	// 	const newData = await fetchData(page.value, pageSize.value); // 假设 fetchData 是你的请求函数
-	// 	if (newData.length > 0) {
-	// 		listData.value = listData.value.concat(newData);
-	// 		page.value++;
-	// 	} else {
-	// 		noMoreData.value = true;
-	// 	}
-	// 	isLoading.value = false;
-	// };
-	// onMounted(() => {
-	// 	loadData();
-	// });
-	//
-	// // 下拉加载更多
-	// const loadMore = () => {
-	// 	loadData();
-	// };
-</script>
-
-<style>
-
-</style>

+ 0 - 44
pages/score/index.vue

@@ -1,44 +0,0 @@
-<template>
-	<view class="lli-develop-expect-page">
-		<!-- 这里状态栏 -->
-		<view class="ezy-status-bar"></view>
-		<view class="ezy-title-bar">
-		    <!-- 导航栏内容 -->
-		    <view class="title">页面标题</view>
-		  </view>
-		  <text class="page-content">开发中,敬请期侍!</text>
-		
-		<view class="bottom-word">底部文字测试!</view>
-	</view>
-</template>
-
-<script>
-	export default {
-		data() {
-			return {
-				
-			}
-		},
-		methods: {
-			
-		}
-	}
-</script>
-
-<style>
-  .ezy-title-bar {
-    position: fixed;
-    top: var(--status-bar-height);
-    left: var(--window-left);
-    right: var(--window-right);
-    height: calc(44px + env(safe-area-inset-top));
-    background-color: rgb(248, 248, 248);
-    color: rgb(0, 0, 0);
-	box-sizing: border-box;
-	z-index: 998;
-	display: flex;
-	overflow: hidden;
-	align-items: center;
-	justify-content: center;
-  }
-</style>

+ 5 - 21
unpackage/dist/cache/.vite/deps/_metadata.json

@@ -1,31 +1,15 @@
 {
-  "hash": "2a404f3e",
-  "configHash": "088a760f",
+  "hash": "88503f0e",
+  "configHash": "ea4e468c",
   "lockfileHash": "e3b0c442",
-  "browserHash": "ffd0a475",
+  "browserHash": "38e76d38",
   "optimized": {
-    "jsencrypt": {
-      "src": "../../../../../node_modules/jsencrypt/lib/index.js",
-      "file": "jsencrypt.js",
-      "fileHash": "03d4dde8",
-      "needsInterop": false
-    },
     "ts-md5/dist/md5": {
       "src": "../../../../../node_modules/ts-md5/dist/md5.js",
       "file": "ts-md5_dist_md5.js",
-      "fileHash": "edc4dd39",
+      "fileHash": "c0f874e9",
       "needsInterop": true
-    },
-    "uview-plus": {
-      "src": "../../../../../node_modules/uview-plus/index.js",
-      "file": "uview-plus.js",
-      "fileHash": "111ff084",
-      "needsInterop": false
     }
   },
-  "chunks": {
-    "chunk-Y2F7D3TJ": {
-      "file": "chunk-Y2F7D3TJ.js"
-    }
-  }
+  "chunks": {}
 }

+ 0 - 4
utils/global.js

@@ -1,4 +0,0 @@
-export default {
-
-
-}

+ 178 - 0
utils/request copy 1.js

@@ -0,0 +1,178 @@
+import axios     from 'axios';
+import { Md5 }   from 'ts-md5/dist/md5';
+import config from '@/config'
+let noTimeoutLimitArr = [
+
+];
+
+// create an axios instance
+const service = axios.create({
+                                 baseURL:         config.baseUrl, // url = base url + request url
+                                 withCredentials: false, // send cookies when cross-domain requests
+                                 timeout:         20000, // request timeout
+                             });
+
+export let needLoadingRequestCount = 0;
+export function showFullScreenLoading(config) {
+    if (needLoadingRequestCount === 0) {
+        store.state.isLoading = true
+    }
+    needLoadingRequestCount++;
+}
+
+export function tryHideFullScreenLoading() {
+    if (needLoadingRequestCount <= 0) {
+        return;
+    }
+
+    needLoadingRequestCount--;
+    if (needLoadingRequestCount === 0) {
+        store.state.isLoading = false
+    }
+}
+// request interceptor
+service.interceptors.request.use(
+    config => {
+        // do something before request is sent
+        // console.log(config);
+
+        function setTimeoutunlimit(config) {
+            // if (_.indexOf(noTimeoutLimitArr, config.url) > -1) {
+            //     config.timeout = 9999999999;
+            // }
+        }
+
+        function mixSignAndToken(config) {
+		//	debugger
+            // console.log(config.data, process.env.VUE_APP_BASE_API, process.env.VUE_APP_SECRET_KEY);
+            const checkurl = function (url) {
+                if (url === '/common/active') {
+                    return false;
+                }
+                // 用户端白名单
+                if (url.indexOf('/common') > -1) {
+                    return true;
+                }
+                // 管理端白名单
+                if (url === '/admin/user/auth') {
+                    return true;
+                }
+                // 短信服务白名单
+                if (url === 'sms/sendCode') {
+                    return true;
+                }
+                return false;
+            };
+			
+            if (checkurl(config.url)) {
+                if(config.url.indexOf('/open' >-1)){
+                }else {
+                    config.headers['X-AUTH-SIGN'] = Md5.hashStr(JSON.stringify(config.data) + '123');
+                }
+            } else {
+                if (store.state.auth) {
+                    config.headers['X-AUTH-SIGN'] = Md5.hashStr(JSON.stringify(config.data) + store.state.auth.secret);
+                    config.headers['X-AUTH-TOKEN'] = store.state.auth.token;
+                } else {
+                    // 非登录操作,但没有auth,跳转登录
+                    router.push('/' + store.state.tenantCode + '/login');
+                }
+            }
+
+        }
+        // if (!JSON.stringify(config.data.customLoadingSwitch)) {
+        //     //  如不需要在data中 LoadingSwitch:false
+        //     console.log('有loading');
+        //     showFullScreenLoading(config);
+        // }
+        mixSignAndToken(config);
+        setTimeoutunlimit(config);
+
+        /*if (store.getters.token) {
+            // let each request carry token
+            // ['X-Token'] is a custom headers key
+            // please modify it according to the actual situation
+            config.headers['X-Token'] = getToken();
+        }*/
+        return config;
+    },
+    error => {
+        // do something with request error
+        // console.log(error); // for debug
+        return Promise.reject(error);
+    },
+);
+
+
+
+// response interceptor
+service.interceptors.response.use(
+    /**
+     * If you want to get http information such as headers or status
+     * Please return  response => response
+     */
+
+    /**
+     * Determine the request status by custom code
+     * Here is just an example
+     * You can also judge the status by HTTP Status Code
+     */
+    response => {
+        const res = response.data;
+
+        // if the custom code is not 20000, it is judged as an error.
+        if (res.code !== 0) {
+    
+            // 401:登录超时
+            if (res.code === 401) {
+                setTimeout(function () {
+                    if (window.loading) {
+                        window.loading.close();
+                    }
+                    // console.log(router);
+                    /*if (router.app.$route.path.indexOf('/c/') === 0) {
+                        router.push('/c/' + store.state.tenantCode + '/login');
+                    } else {
+                        router.push('/a/' + store.state.tenantCode + '/login');
+                    }*/
+                    store.state.showBottomNav = true;
+                    router.push('/login');
+                }, 2000);
+            }
+            if (res.code === 405) {
+                setTimeout(function () {
+                    if (window.loading) {
+                        window.loading.close();
+                    }
+                    store.state.showBottomNav = true;
+                    router.push('/login');
+                }, 2000);
+            }
+
+            if (res.code === 502) {
+            //    Toast.fail('bad gateway');
+            }
+            if (res.code === 500 || res.code === 1001|| res.code ===1002) {
+                tryHideFullScreenLoading();
+                return Promise.reject('error' + res.code + '-' + (res.message === undefined ? 'nomessage': res.message));
+            }
+            tryHideFullScreenLoading();
+            return Promise.reject(res.message || 'error');
+        } else {
+            tryHideFullScreenLoading();
+            return res;
+        }
+    },
+    error => {
+
+        if (error == 'Error: Network Error') {
+        //    Toast.fail('网络断开,请检查网络');
+        } else {
+         //   Toast.fail('其他错误,请联系管理员');
+        }
+        tryHideFullScreenLoading();
+        return Promise.reject(error);
+    },
+);
+
+export default service;

+ 73 - 0
utils/request copy.js

@@ -0,0 +1,73 @@
+import store from '@/store'
+import config from '@/config'
+import { getToken } from '@/utils/auth'
+import errorCode from '@/utils/errorCode'
+import { toast, showConfirm, tansParams } from '@/utils/common'
+
+let timeout = 10000
+const baseUrl = config.baseUrl
+
+const request = config => {
+  // 是否需要设置 token
+  const isToken = (config.headers || {}).isToken === false
+  config.header = config.header || {}
+  if (getToken() && !isToken) {
+    config.header['Authorization'] = 'Bearer ' + getToken()
+  }
+  // get请求映射params参数
+  if (config.params) {
+    let url = config.url + '?' + tansParams(config.params)
+    url = url.slice(0, -1)
+    config.url = url
+  }
+  return new Promise((resolve, reject) => {
+    uni.request({
+        method: config.method || 'get',
+        timeout: config.timeout ||  timeout,
+        url: config.baseUrl || baseUrl + config.url,
+        data: config.data,
+        header: config.header,
+        dataType: 'json'
+      }).then(response => {
+        let [error, res] = response
+        if (error) {
+          toast('后端接口连接异常')
+          reject('后端接口连接异常')
+          return
+        }
+        const code = res.data.code || 200
+        const msg = errorCode[code] || res.data.msg || errorCode['default']
+        if (code === 401) {
+          showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
+            if (res.confirm) {
+              store.dispatch('LogOut').then(res => {
+                uni.reLaunch({ url: '/pages/login' })
+              })
+            }
+          })
+          reject('无效的会话,或者会话已过期,请重新登录。')
+        } else if (code === 500) {
+          toast(msg)
+          reject('500')
+        } else if (code !== 200) {
+          toast(msg)
+          reject(code)
+        }
+        resolve(res.data)
+      })
+      .catch(error => {
+        let { message } = error
+        if (message === 'Network Error') {
+          message = '后端接口连接异常'
+        } else if (message.includes('timeout')) {
+          message = '系统接口请求超时'
+        } else if (message.includes('Request failed with status code')) {
+          message = '系统接口' + message.substr(message.length - 3) + '异常'
+        }
+        toast(message)
+        reject(error)
+      })
+  })
+}
+
+export default request