项目初始化
This commit is contained in:
parent
20d0d4e051
commit
3741868735
|
|
@ -1 +1,2 @@
|
|||
*/uni_modules/
|
||||
*/uni_modules/
|
||||
/unpackage/
|
||||
|
|
@ -10,6 +10,10 @@
|
|||
{
|
||||
"launchtype" : "local"
|
||||
},
|
||||
"h5" :
|
||||
{
|
||||
"launchtype" : "local"
|
||||
},
|
||||
"type" : "uniCloud"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
3
App.vue
3
App.vue
|
|
@ -4,7 +4,8 @@
|
|||
console.log('App Launch')
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
const envInfo = process.env.VUE_APP_BASE_URL
|
||||
console.log('App ShowenvInfo',envInfo)
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
export default{
|
||||
// 主题色
|
||||
mainColor:'',
|
||||
//默认头像
|
||||
userHead:",
|
||||
//默认用户名
|
||||
userName:"",
|
||||
// 社群默认头像
|
||||
groupHead:"",
|
||||
// 默认用户资质
|
||||
credentials: "",
|
||||
// 分享地址域名
|
||||
shareOriginUrl: "",
|
||||
// 分享logo图
|
||||
shareImageUrl: ""
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
let baseUrl
|
||||
let wsUrl
|
||||
let domain
|
||||
let headUrl
|
||||
// #ifdef APP-PLUS
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
//app 开发环境
|
||||
baseUrl = '';
|
||||
wsUrl = '';
|
||||
domain = '';
|
||||
} else {
|
||||
//app 生产环境
|
||||
baseUrl = '';
|
||||
wsUrl = '';
|
||||
domain = '';
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifndef APP-PLUS
|
||||
baseUrl = process.env.VUE_APP_BASE_URL;
|
||||
wsUrl = process.env.VUE_APP_WS_URL;
|
||||
domain = process.env.VUE_APP_DOMAIN_URL;
|
||||
// #endif
|
||||
export default {
|
||||
baseUrl,
|
||||
wsUrl,
|
||||
domain,
|
||||
headUrl,
|
||||
}
|
||||
|
|
@ -0,0 +1,262 @@
|
|||
import base from "@/common/config/domain.js"
|
||||
class websocketUtil {
|
||||
constructor(token, time) {
|
||||
this.token = token;
|
||||
this.is_open_socket = false; //避免重复连接
|
||||
// this.url = url; //地址
|
||||
// this.data = null;
|
||||
this.reconnect_time=6000;//意外断开超过多少秒重连
|
||||
//心跳检测
|
||||
this.timeout = time; //多少秒执行检测
|
||||
this.sendheartInterval = null; //心跳发送计时器
|
||||
this.reconnectTimeOut = null; //重连之后多久再次重连计时器
|
||||
this.onHeartInterval = null; //心跳检测计时器
|
||||
this.heart_nownum=0;//心跳最新
|
||||
this.heart_oldnum=0;//上次心跳
|
||||
this.offline_time=0;//断开的毫秒数
|
||||
this.need_reconnect=false;//监听到关闭后,是否需要重连
|
||||
this.ac_close=false;//是否主动关闭 如果是主动断开不会自动重连,需要手动调用connectSocketInit
|
||||
this.is_reconnect=false;//是否正在重连
|
||||
|
||||
try {
|
||||
return this.connectSocketInit();
|
||||
} catch (e) {
|
||||
// console.log("catch");
|
||||
this.is_open_socket = false;
|
||||
this.socketReconnect();
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化websocket链接
|
||||
connectSocketInit() {
|
||||
this.heart_nownum=0;//心跳最新
|
||||
this.heart_oldnum=0;//上次心跳
|
||||
this.offline_time=0;
|
||||
// console.log("this.sendheartInterval",this.sendheartInterval);
|
||||
|
||||
if(this.reconnectTimeOut){
|
||||
clearTimeout(this.reconnectTimeOut);
|
||||
this.reconnectTimeOut=null;
|
||||
}
|
||||
//停止发送心跳
|
||||
if(this.sendheartInterval){
|
||||
clearInterval(this.sendheartInterval);
|
||||
this.sendheartInterval=null;
|
||||
}
|
||||
//停止监听心跳
|
||||
if(this.onHeartInterval){
|
||||
clearInterval(this.onHeartInterval);
|
||||
this.onHeartInterval=null;
|
||||
}
|
||||
|
||||
if(this.socketTask){
|
||||
this.socketTask=null;
|
||||
}
|
||||
let url = `${base.wsUrl}/websocket/socketServer.do?token=${this.token}`; //地址
|
||||
// console.log("链接地址",url);
|
||||
this.socketTask = uni.connectSocket({
|
||||
url: url,
|
||||
success: () => {
|
||||
console.log("正准备建立websocket中...");
|
||||
// uni.showLoading({
|
||||
// title:"创建连接中..."
|
||||
// })
|
||||
// 返回实例
|
||||
return this.socketTask;
|
||||
},
|
||||
fail:(res)=>{
|
||||
console.log("创建websocket失败...",res);
|
||||
}
|
||||
});
|
||||
this.socketTask.onOpen((res) => {
|
||||
console.log("WebSocket连接成功!");
|
||||
uni.hideLoading();
|
||||
this.is_open_socket = true;
|
||||
this.need_reconnect=false;//监听到关闭后,是否需要重连
|
||||
this.ac_close=false;//是否主动关闭
|
||||
this.is_reconnect = false;
|
||||
//开始发送心跳
|
||||
this.start();
|
||||
// 开启检测心跳
|
||||
this.onHeart();
|
||||
|
||||
//监听接受消息
|
||||
this.socketTask.onMessage((res) => {
|
||||
// console.log('websocket接受到的消息',res);
|
||||
let dJson = res.data;
|
||||
|
||||
let data = JSON.parse(dJson);
|
||||
// console.log('websocket接受res.data',data);
|
||||
// data.msg = data.msg ? JSON.parse(data.msg) : data.msg;
|
||||
data.msg = data.msg;
|
||||
|
||||
if(data.opt == 'HEALTH'){
|
||||
//接受心跳
|
||||
// console.log('接受心跳成功');
|
||||
this.heart_nownum++;
|
||||
}else{
|
||||
// console.log("接受到的数据", data);
|
||||
// 发射事件到页面
|
||||
// console.log("data--------------",data,data.opt);
|
||||
uni.$emit(data.opt, data.msg);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// 监听关闭链接
|
||||
this.socketTask.onClose((res) => {
|
||||
console.log("WebSocket关闭链接!",res);
|
||||
this.is_reconnect = false;
|
||||
|
||||
//服务器重启导致websocket关闭
|
||||
this.socketTask=null;
|
||||
// if(!this.ac_close || this.need_reconnect){
|
||||
// //监听到不是主动断开 或者 需要主动重连的
|
||||
// this.is_open_socket = false;
|
||||
// this.socketReconnect();
|
||||
// }
|
||||
|
||||
});
|
||||
//监听链接错误
|
||||
this.socketTask.onError((err) => {
|
||||
console.log("WebSocket错误!",err);
|
||||
// console.log("this.ac_close",this.ac_close);
|
||||
// console.log("this.need_reconnect",this.need_reconnect);
|
||||
|
||||
if(!this.ac_close || this.need_reconnect){
|
||||
//监听到不是主动断开 或者 需要主动重连的
|
||||
this.is_open_socket = false;
|
||||
this.is_reconnect = false;
|
||||
this.socketReconnect();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//发送消息
|
||||
send(value) {
|
||||
// console.log("value",value);
|
||||
// 注:只有连接正常打开中 ,才能正常成功发送消息
|
||||
this.socketTask.send({
|
||||
data: value,
|
||||
success:(res)=> {
|
||||
// console.log("消息发送成功",res);
|
||||
},
|
||||
fail:(res)=>{
|
||||
// console.log("消息发送失败",res);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
//重新连接
|
||||
socketReconnect() {
|
||||
if(this.is_reconnect || this.is_open_socket) return;//正在重连 或者已连接 截断
|
||||
this.is_reconnect=true;
|
||||
this.ac_close=false;//重置是否主动断开,方便重连后判断
|
||||
// console.log("开始重连")
|
||||
// console.log('is_open_socket',this.is_open_socket);
|
||||
//停止发送心跳
|
||||
if(this.sendheartInterval){
|
||||
clearInterval(this.sendheartInterval);
|
||||
this.sendheartInterval=null;
|
||||
}
|
||||
//停止监听心跳
|
||||
if(this.onHeartInterval){
|
||||
clearInterval(this.onHeartInterval);
|
||||
this.onHeartInterval=null;
|
||||
}
|
||||
//链接是关闭状态下
|
||||
if (!this.is_open_socket) {
|
||||
// uni.showLoading({
|
||||
// title:"重接中..."
|
||||
// })
|
||||
this.reconnectTimeOut = setTimeout(() => {
|
||||
this.connectSocketInit();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
//关闭websocket
|
||||
close(ac_close=true){
|
||||
if(!this.is_open_socket) return;//链接未链接成功下,不能主动关闭
|
||||
// console.log("主动断开")
|
||||
//停止发送心跳
|
||||
if(this.sendheartInterval){
|
||||
clearInterval(this.sendheartInterval);
|
||||
this.sendheartInterval=null;
|
||||
}
|
||||
//停止监听心跳
|
||||
if(this.onHeartInterval){
|
||||
clearInterval(this.onHeartInterval);
|
||||
this.sendheartInterval=null;
|
||||
}
|
||||
//是否主动断开
|
||||
this.ac_close=ac_close;
|
||||
// console.log("主动关闭",this.ac_close)
|
||||
if(this.socketTask){
|
||||
this.socketTask.close({
|
||||
success:(res)=>{
|
||||
console.log('主动关闭返回1',res)
|
||||
this.is_open_socket = false;
|
||||
if(!this.ac_close || this.need_reconnect){
|
||||
// console.log("主动关闭")
|
||||
//监听到不是主动断开 或者 需要主动重连的
|
||||
this.socketReconnect();
|
||||
}
|
||||
},
|
||||
fail:(res)=>{
|
||||
// console.log('主动关闭返回2')
|
||||
}
|
||||
});
|
||||
}else{
|
||||
//服务器关闭导致没有websocket
|
||||
this.reconnectTimeOut = setTimeout(() => {
|
||||
this.connectSocketInit();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
//开启心跳检测
|
||||
start() {
|
||||
this.sendheartInterval = setInterval(() => {
|
||||
// let data = { healthCheck:'Y'};
|
||||
let data = {
|
||||
"opt":"HEALTH",
|
||||
"msg":{"healthCheck":"Y"}
|
||||
};
|
||||
|
||||
// console.log(this.data);
|
||||
// console.log('发送心跳');
|
||||
this.send(JSON.stringify(data));
|
||||
}, this.timeout);
|
||||
}
|
||||
//监听心跳
|
||||
onHeart(){
|
||||
this.onHeartInterval = setInterval(() => {
|
||||
if(this.heart_nownum>this.heart_oldnum){
|
||||
// console.log("websocket正常",this.heart_nownum,this.heart_oldnum);
|
||||
//正常连接中
|
||||
this.heart_oldnum=this.heart_nownum;
|
||||
// console.log("websocket正常",this.heart_oldnum);
|
||||
|
||||
|
||||
// //测试
|
||||
// if(this.heart_oldnum>5){
|
||||
// this.close();
|
||||
// }
|
||||
}else{
|
||||
console.log("心跳检测到websocket断开",this.heart_nownum,this.heart_oldnum);
|
||||
this.offline_time+=this.timeout*2;
|
||||
|
||||
if(this.offline_time>=this.reconnect_time){
|
||||
//开始重连
|
||||
// console.log("需要重连-------");
|
||||
this.need_reconnect=true;
|
||||
this.close(false);
|
||||
// this.socketReconnect();
|
||||
}
|
||||
}
|
||||
}, this.timeout*2);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = websocketUtil;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
//test
|
||||
import {
|
||||
post,
|
||||
get
|
||||
} from "../request.js"
|
||||
export function apiTest(params){
|
||||
return post("/api/content/edit", params)
|
||||
}
|
||||
|
|
@ -0,0 +1,824 @@
|
|||
import base from "@/common/config/domain.js"
|
||||
import {md5} from "@/common/js/md5.js"
|
||||
|
||||
const baseUrl = base.baseUrl
|
||||
const wsUrl = base.wsUrl
|
||||
|
||||
let ajaxTimes = 0;
|
||||
|
||||
//需要跳转到登录页的接口
|
||||
let login_list=[
|
||||
'/game/app/question/queryTrainQuest',
|
||||
'/game/operate/joinGame',
|
||||
'/user/app/feat/getAllFeatInfo'
|
||||
];
|
||||
|
||||
|
||||
/*
|
||||
url接口地址
|
||||
data数据
|
||||
needtoken是否需要令牌
|
||||
domain请求域名
|
||||
*/
|
||||
export const get = (url, data = {}, needtoken = true, domain) => {
|
||||
|
||||
|
||||
let header = defaultHeader();
|
||||
// let header = {
|
||||
// // "content-type": "application/json",
|
||||
// Authorization: handleToken(),
|
||||
// };
|
||||
let token = handleToken();
|
||||
let http_base = {
|
||||
url: domain ? domain + url : baseUrl + url,
|
||||
data: data,
|
||||
method: "GET",
|
||||
header:{
|
||||
...header
|
||||
}
|
||||
}
|
||||
|
||||
// console.log("domain",domain)
|
||||
if (needtoken) {
|
||||
//拦截需要登录的名单跳转到登录页面
|
||||
// console.log("login_list.indexOf(url)",login_list.indexOf(url));
|
||||
if(login_list.indexOf(url)>=0 && !token){
|
||||
//需要登录
|
||||
uni.navigateTo({
|
||||
url:'/pages/login/index'
|
||||
})
|
||||
return ;
|
||||
// return new Promise((resolve, reject) => {
|
||||
// reject('需要先登录');
|
||||
// });
|
||||
}
|
||||
http_base.header.Authorization =token;
|
||||
} else {
|
||||
if (token) {
|
||||
http_base.header.Authorization =token;
|
||||
}
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
...http_base,
|
||||
success: (res) => {
|
||||
// console.log("getres",res);
|
||||
if (res.statusCode == 200) {
|
||||
if (typeof res.data == "string") {
|
||||
res.data = JSON.parse(res.data);
|
||||
}
|
||||
if (res.data.code == "1000") {
|
||||
resolve(res.data);
|
||||
} else {
|
||||
authCase(res.data, url)
|
||||
reject(res);
|
||||
}
|
||||
} else {
|
||||
reject(res);
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log("请求失败",err);
|
||||
uni.showToast({
|
||||
title:"网络异常,请检查网络",
|
||||
icon:"none",
|
||||
duration:2000,
|
||||
})
|
||||
reject(err);
|
||||
},
|
||||
complete: (com) => {
|
||||
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
url接口地址
|
||||
data数据
|
||||
needtoken是否需要令牌
|
||||
domain请求域名
|
||||
*/
|
||||
export const post = (url, data = {}, needtoken = true, domain) => {
|
||||
let header = defaultHeader();
|
||||
let token = handleToken();
|
||||
let http_base = {
|
||||
url: domain ? domain + url : baseUrl + url,
|
||||
data: data,
|
||||
method: "POST",
|
||||
header:{
|
||||
...header,
|
||||
"content-type": "application/json",
|
||||
}
|
||||
}
|
||||
|
||||
if (needtoken) {
|
||||
console.log("login_list.indexOf(url)",url,login_list.indexOf(url));
|
||||
//拦截需要登录的名单跳转到登录页面
|
||||
if(login_list.indexOf(url)>=0 && !token){
|
||||
console.log(1)
|
||||
//需要登录
|
||||
uni.navigateTo({
|
||||
url:'/pages/login/index'
|
||||
})
|
||||
return ;
|
||||
// return new Promise((resolve, reject) => {
|
||||
// reject('需要先登录');
|
||||
// });
|
||||
}
|
||||
http_base.header.Authorization =token;
|
||||
} else {
|
||||
if (token) {
|
||||
http_base.header.Authorization =token;
|
||||
}
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
...http_base,
|
||||
success: (res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (typeof res.data == "string") {
|
||||
res.data = JSON.parse(res.data);
|
||||
}
|
||||
if (res.data.code == "1000") {
|
||||
resolve(res.data);
|
||||
} else {
|
||||
authCase(res.data, url)
|
||||
reject(res);
|
||||
}
|
||||
} else {
|
||||
reject(res);
|
||||
}
|
||||
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log("请求失败",err);
|
||||
uni.showToast({
|
||||
title:"网络异常,请检查网络",
|
||||
icon:"none",
|
||||
duration:2000,
|
||||
})
|
||||
reject(err);
|
||||
},
|
||||
complete: (com) => {
|
||||
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
function handleToken() {
|
||||
let tokenC = uni.getStorageSync('token');
|
||||
// tokenC = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NTEwMzY5MjcsInVzZXJJZCI6Ijk5MjYzODg2Nzg4MDI4NDE2MF8xNjUwOTUwNTI3NTc3In0.ID2vAMfd2AYb6h5Ir9l-dcH9RBF0hrtkn4en8w8kL2U'
|
||||
// let tokenC = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NTQ4NzMzOTUsInVzZXJJZCI6ImFwcF8xMCJ9.S6sI9wmo3JlU5W-HD1b4fULUqKN7LpYhFVj0O9EZjuU"
|
||||
|
||||
return tokenC
|
||||
}
|
||||
|
||||
/*
|
||||
@param上传文件
|
||||
file uniapp的choosefile获取到的文件临时信息
|
||||
url 上传的url地址
|
||||
name 上传给服务器端的字段名称默认file
|
||||
type_set上传的文件类型 默认['.pdf','.doc','.ppt','.pptx','.png','.jpg','.jpeg']
|
||||
filekey 储存的路径,更新原有文件
|
||||
success 成功
|
||||
fail 失败
|
||||
max_size 文件最大的大小,单位mb
|
||||
onProgress获取上传进度信息
|
||||
|
||||
*/
|
||||
export const uploadFile = (param, needtoken = true) => {
|
||||
console.log("param.file",param.file);
|
||||
let header = defaultHeader();
|
||||
let file_name = param.file.tempFiles[0].name;
|
||||
let file_size = param.file.tempFiles[0].size / 1024 / 1024;
|
||||
let type_list = file_name.split('.');
|
||||
let file_type = null;
|
||||
if (type_list.length > 0) {
|
||||
file_type = type_list[type_list.length - 1];
|
||||
// console.log("file_type",file_type);
|
||||
|
||||
//截取文件名140字内
|
||||
let name_list = JSON.parse(JSON.stringify(type_list));
|
||||
name_list.pop();
|
||||
let full_name=name_list.join('.');
|
||||
full_name=full_name.slice(0,140);
|
||||
file_name=`${full_name}.${file_type}`;
|
||||
}
|
||||
//查找是否在范围内的
|
||||
let can_upload = false;
|
||||
let type_set = param.type_set ? param.type_set : ['pdf', 'doc', 'ppt', 'pptx', 'png', 'jpg', 'jpeg'];
|
||||
// console.log(file_size,file_type);
|
||||
// console.log('type_set',type_set);
|
||||
if (file_type) {
|
||||
console.log("type_set.indexOf('.' + file_type)",type_set.indexOf(file_type));
|
||||
if (type_set.indexOf(file_type) >= 0) {
|
||||
can_upload = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let max_size=param && param.max_size?param.max_size:10;
|
||||
// console.log("max_size",max_size);
|
||||
if (can_upload && file_size <= max_size) {
|
||||
//可以上传的类型
|
||||
let nowTime = new Date();
|
||||
let year = nowTime.getFullYear();
|
||||
let month = nowTime.getMonth() + 1;
|
||||
let day = nowTime.getDate();
|
||||
let time = nowTime.getTime();
|
||||
|
||||
let filekey = param.filekey ? param.filekey :
|
||||
`/${year}/${month}/${day}/${time}_${Math.floor(Math.random()*100)}.${file_type}`;
|
||||
|
||||
console.log("filekey",filekey);
|
||||
// console.log(year,month,day,time,filekey)
|
||||
// console.log('url',baseUrl+param.url);
|
||||
let http_base = {
|
||||
url: baseUrl + param.url, //仅为示例,非真实的接口地址
|
||||
filePath: param.file.tempFiles[0].path,
|
||||
name: param.name ? param.name : 'file',
|
||||
formData: {
|
||||
'fileKey': filekey,
|
||||
},
|
||||
header:{
|
||||
...header
|
||||
}
|
||||
}
|
||||
if (needtoken) {
|
||||
http_base.header.Authorization =handleToken();
|
||||
}
|
||||
const uploadTask = uni.uploadFile({
|
||||
// url:baseUrl+param.url, //仅为示例,非真实的接口地址
|
||||
// filePath: param.file.tempFilePaths[0],
|
||||
// name: param.name?param.name:'file',
|
||||
// header:{Authorization: handleToken()},
|
||||
// formData: {
|
||||
// 'fileKey': filekey
|
||||
// },
|
||||
...http_base,
|
||||
success: (res) => {
|
||||
console.log('提交返回', res);
|
||||
if (typeof res.data == "string") {
|
||||
res.data = JSON.parse(res.data)
|
||||
}
|
||||
if (res.data.code == 1000) {
|
||||
res.data.data.fileName = file_name;
|
||||
res.data.data.file_type = file_type;
|
||||
res.data.data.resumeName = res.data.data.fileName;
|
||||
res.data.data.resumeFileKey = filekey;
|
||||
|
||||
var update = new Date();
|
||||
res.data.data.updateTime = update.toLocaleString('zh',{hour12:false});
|
||||
// console.log('res',res);
|
||||
param.success && param.success(res)
|
||||
} else {
|
||||
param.fail && param.fail(res)
|
||||
}
|
||||
},
|
||||
fail: (res) => {
|
||||
param.fail && param.fail(res)
|
||||
}
|
||||
});
|
||||
|
||||
if (param.onProgress) {
|
||||
uploadTask.onProgressUpdate((res) => {
|
||||
// console.log('上传进度' + res.progress);
|
||||
// console.log('已经上传的数据长度' + res.totalBytesSent);
|
||||
// console.log('预期需要上传的数据总长度' + res.totalBytesExpectedToSend);
|
||||
param.onProgress(res);
|
||||
// 测试条件,取消上传任务。
|
||||
// if (res.progress > 50) {
|
||||
// uploadTask.abort();
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
//不可以上传
|
||||
let msg
|
||||
if (!can_upload) {
|
||||
let type_str=type_set.join("、");
|
||||
msg = `仅支持${type_str}类型文件`;
|
||||
}
|
||||
if (file_size > max_size) {
|
||||
msg = `大小不能超过${max_size}MB`;
|
||||
}
|
||||
param.fail && param.fail({
|
||||
msg: msg
|
||||
})
|
||||
uni.showToast({
|
||||
title: msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
setCvDetail上传附件简历
|
||||
@param上传文件
|
||||
file uniapp的choosefile获取到的文件临时信息
|
||||
url 上传的url地址
|
||||
name 上传给服务器端的字段名称默认file
|
||||
type_set上传的文件类型 默认['.pdf','.doc','.ppt','.pptx','.png','.jpg','.jpeg']
|
||||
filekey 储存的路径,更新原有文件
|
||||
success 成功
|
||||
fail 失败
|
||||
max_size 文件最大的大小,单位mb
|
||||
onProgress获取上传进度信息
|
||||
cvId 简历id
|
||||
|
||||
*/
|
||||
export const setCvDetail = (param, needtoken = true) => {
|
||||
console.log("param.file",param.file);
|
||||
let header = defaultHeader();
|
||||
let file_name = param.file.tempFiles[0].name;
|
||||
let file_size = param.file.tempFiles[0].size / 1024 / 1024;
|
||||
let type_list = file_name.split('.');
|
||||
let file_type = null;
|
||||
if (type_list.length > 0) {
|
||||
file_type = type_list[type_list.length - 1];
|
||||
// console.log("file_type",file_type);
|
||||
|
||||
//截取文件名140字内
|
||||
let name_list = JSON.parse(JSON.stringify(type_list));
|
||||
name_list.pop();
|
||||
let full_name=name_list.join('.');
|
||||
full_name=full_name.slice(0,140);
|
||||
file_name=`${full_name}.${file_type}`;
|
||||
}
|
||||
//查找是否在范围内的
|
||||
let can_upload = false;
|
||||
let type_set = param.type_set ? param.type_set : ['pdf', 'doc', 'ppt', 'pptx', 'png', 'jpg', 'jpeg'];
|
||||
// console.log(file_size,file_type);
|
||||
// console.log('type_set',type_set);
|
||||
if (file_type) {
|
||||
console.log("type_set.indexOf('.' + file_type)",type_set.indexOf(file_type));
|
||||
if (type_set.indexOf(file_type) >= 0) {
|
||||
can_upload = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let max_size=param && param.max_size?param.max_size:10;
|
||||
// console.log("max_size",max_size);
|
||||
if (can_upload && file_size <= max_size) {
|
||||
//可以上传的类型
|
||||
let nowTime = new Date();
|
||||
let year = nowTime.getFullYear();
|
||||
let month = nowTime.getMonth() + 1;
|
||||
let day = nowTime.getDate();
|
||||
let time = nowTime.getTime();
|
||||
|
||||
let filekey = param.filekey ? param.filekey :
|
||||
`/${year}/${month}/${day}/${time}_${Math.floor(Math.random()*100)}.${file_type}`;
|
||||
|
||||
console.log("filekey",filekey);
|
||||
// console.log(year,month,day,time,filekey)
|
||||
// console.log('url',baseUrl+param.url);
|
||||
let formData={
|
||||
'cvName':file_name,
|
||||
'cvPath': filekey,
|
||||
}
|
||||
if(param.cvId){
|
||||
formData.cvId=param.cvId;
|
||||
}
|
||||
let http_base = {
|
||||
url: baseUrl + param.url, //仅为示例,非真实的接口地址
|
||||
filePath: param.file.tempFiles[0].path,
|
||||
name: param.name ? param.name : 'cvFile',
|
||||
formData: formData,
|
||||
header:{
|
||||
...header
|
||||
}
|
||||
}
|
||||
if (needtoken) {
|
||||
http_base.header.Authorization =handleToken();
|
||||
}
|
||||
console.log("formData",formData);
|
||||
const uploadTask = uni.uploadFile({
|
||||
// url:baseUrl+param.url, //仅为示例,非真实的接口地址
|
||||
// filePath: param.file.tempFilePaths[0],
|
||||
// name: param.name?param.name:'file',
|
||||
// header:{Authorization: handleToken()},
|
||||
// formData: {
|
||||
// 'fileKey': filekey
|
||||
// },
|
||||
...http_base,
|
||||
success: (res) => {
|
||||
console.log('提交返回', res);
|
||||
if (typeof res.data == "string") {
|
||||
res.data = JSON.parse(res.data)
|
||||
}
|
||||
if (res.data.code == 1000) {
|
||||
let file_info={};
|
||||
file_info.fileName = file_name;
|
||||
file_info.file_type = file_type;
|
||||
file_info.resumeName = file_name;
|
||||
file_info.resumeFileKey = filekey;
|
||||
file_info.cvId = res.data.data;
|
||||
|
||||
var update = new Date();
|
||||
file_info.updateTime = update.toLocaleString('zh',{hour12:false});
|
||||
// console.log('res',res);
|
||||
res.data.data=file_info;
|
||||
param.success && param.success(res)
|
||||
} else {
|
||||
param.fail && param.fail(res)
|
||||
}
|
||||
},
|
||||
fail: (res) => {
|
||||
uni.showToast({
|
||||
title:"网络异常,请检查网络",
|
||||
icon:"none",
|
||||
duration:2000,
|
||||
})
|
||||
param.fail && param.fail(res)
|
||||
}
|
||||
});
|
||||
|
||||
if (param.onProgress) {
|
||||
uploadTask.onProgressUpdate((res) => {
|
||||
// console.log('上传进度' + res.progress);
|
||||
// console.log('已经上传的数据长度' + res.totalBytesSent);
|
||||
// console.log('预期需要上传的数据总长度' + res.totalBytesExpectedToSend);
|
||||
param.onProgress(res);
|
||||
// 测试条件,取消上传任务。
|
||||
// if (res.progress > 50) {
|
||||
// uploadTask.abort();
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
//不可以上传
|
||||
let msg
|
||||
if (!can_upload) {
|
||||
let type_str=type_set.join("、");
|
||||
msg = `仅支持${type_str}类型文件`;
|
||||
}
|
||||
if (file_size > max_size) {
|
||||
msg = `大小不能超过${max_size}MB`;
|
||||
}
|
||||
param.fail && param.fail({
|
||||
msg: msg
|
||||
})
|
||||
uni.showToast({
|
||||
title: msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const uploadFileMore = (param, needtoken = true) => {
|
||||
let header = defaultHeader();
|
||||
if (param.index >= param.file.tempFiles.length) {
|
||||
return
|
||||
}
|
||||
let file_name = param.file.tempFiles[param.index].path;
|
||||
console.log("file_name", file_name);
|
||||
let file_size = param.file.tempFiles[param.index].size / 1024 / 1024;
|
||||
let type_list = file_name.split('.');
|
||||
//兼容h5
|
||||
if (type_list.length == 1) {
|
||||
type_list.push('png');
|
||||
}
|
||||
console.log("type_list", type_list);
|
||||
let file_type = null;
|
||||
if (type_list.length > 0) {
|
||||
file_type = type_list[type_list.length - 1];
|
||||
}
|
||||
console.log("file_type", file_type);
|
||||
//查找是否在范围内的
|
||||
let can_upload = false;
|
||||
let type_set = param.type_set ? param.type_set : ['.pdf', '.doc', '.ppt', '.pptx', '.PNG', '.JPG', '.JPEG'];
|
||||
// console.log(file_size,file_type);
|
||||
// console.log('type_set',type_set);
|
||||
console.log("type_set", type_set, file_type)
|
||||
if (file_type) {
|
||||
if (type_set.indexOf('.' + file_type) >= 0) {
|
||||
can_upload = true;
|
||||
}
|
||||
}
|
||||
console.log("can_upload", can_upload);
|
||||
if (can_upload && file_size < 10) {
|
||||
//可以上传的类型
|
||||
|
||||
let nowTime = new Date();
|
||||
let year = nowTime.getFullYear();
|
||||
let month = nowTime.getMonth() + 1;
|
||||
let day = nowTime.getDate();
|
||||
let time = nowTime.getTime();
|
||||
let filekey
|
||||
if (param.fileType) {//新增的fileType 参数 兼容到没有传 fileType的 各位大佬看见了自己改下自己的代码
|
||||
filekey = param.filekey ? param.filekey :
|
||||
`/${param.fileType}/${year}/${month}/${day}/${time}_${Math.floor(Math.random()*100)}.${file_type}`;
|
||||
} else {
|
||||
filekey = param.filekey ? param.filekey :
|
||||
`/${year}/${month}/${day}/${time}_${Math.floor(Math.random()*100)}.${file_type}`;
|
||||
}
|
||||
// console.log(year,month,day,time,filekey)
|
||||
// console.log('url',baseUrl+param.url);
|
||||
|
||||
let http_base = {
|
||||
url: baseUrl + param.url, //仅为示例,非真实的接口地址
|
||||
filePath: param.file.tempFilePaths[param.index],
|
||||
name: param.name ? param.name : 'file',
|
||||
formData: {
|
||||
'fileKey': filekey,
|
||||
},
|
||||
header:{
|
||||
...header
|
||||
}
|
||||
}
|
||||
if (needtoken) {
|
||||
http_base.header.Authorization =handleToken();
|
||||
}
|
||||
console.log("http_base", http_base)
|
||||
const uploadTask = uni.uploadFile({
|
||||
// url:baseUrl+param.url, //仅为示例,非真实的接口地址
|
||||
// filePath: param.file.tempFilePaths[0],
|
||||
// name: param.name?param.name:'file',
|
||||
// header:{Authorization: handleToken()},
|
||||
// formData: {
|
||||
// 'fileKey': filekey
|
||||
// },
|
||||
...http_base,
|
||||
success: (res) => {
|
||||
console.log('提交返回', res);
|
||||
if (typeof res.data == "string") {
|
||||
res.data = JSON.parse(res.data)
|
||||
}
|
||||
if (res.data.code == 1000) {
|
||||
res.data.data.file_type = file_type;
|
||||
res.data.data.resumeName = res.data.data.fileName;
|
||||
res.data.data.resumeFileKey = filekey;
|
||||
|
||||
var update = new Date();
|
||||
res.data.data.updateTime = update.toLocaleString();
|
||||
// console.log('res',res);
|
||||
|
||||
param.success && param.success(res)
|
||||
param.index++
|
||||
uploadFileMore(param, true)
|
||||
} else {
|
||||
param.fail && param.fail(res)
|
||||
}
|
||||
},
|
||||
fail: (res) => {
|
||||
param.fail && param.fail(res)
|
||||
}
|
||||
});
|
||||
|
||||
if (param.onProgress) {
|
||||
uploadTask.onProgressUpdate((res) => {
|
||||
// console.log('上传进度' + res.progress);
|
||||
// console.log('已经上传的数据长度' + res.totalBytesSent);
|
||||
// console.log('预期需要上传的数据总长度' + res.totalBytesExpectedToSend);
|
||||
param.onProgress(res);
|
||||
// 测试条件,取消上传任务。
|
||||
// if (res.progress > 50) {
|
||||
// uploadTask.abort();
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
//不可以上传
|
||||
let msg
|
||||
if (!can_upload) {
|
||||
msg = "不支持该类型"
|
||||
}
|
||||
if (file_size >= 10) {
|
||||
msg = "只支持10MB内的文件"
|
||||
}
|
||||
param.fail && param.fail({
|
||||
msg: msg
|
||||
})
|
||||
uni.showToast({
|
||||
title: msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const uploadVideo = (param, needtoken = true) => {
|
||||
let header = defaultHeader();
|
||||
let file_name = param.file.tempFilePath
|
||||
console.log("file_name", file_name);
|
||||
let file_size = param.file.size / 1024 / 1024;
|
||||
let type_list = file_name.split('.');
|
||||
console.log("type_list", type_list);
|
||||
let file_type = null;
|
||||
if (type_list.length > 0) {
|
||||
file_type = type_list[type_list.length - 1];
|
||||
}
|
||||
console.log("file_type", file_type);
|
||||
//查找是否在范围内的
|
||||
let can_upload = false;
|
||||
let type_set = param.type_set ? param.type_set : ['.mp4'];
|
||||
// console.log(file_size,file_type);
|
||||
// console.log('type_set',type_set);
|
||||
console.log("type_set", type_set, file_type)
|
||||
if (file_type) {
|
||||
if (type_set.indexOf('.' + file_type) >= 0) {
|
||||
can_upload = true;
|
||||
}
|
||||
}
|
||||
console.log("can_upload", can_upload);
|
||||
if (can_upload && file_size < 10) {
|
||||
//可以上传的类型
|
||||
|
||||
let nowTime = new Date();
|
||||
let year = nowTime.getFullYear();
|
||||
let month = nowTime.getMonth() + 1;
|
||||
let day = nowTime.getDate();
|
||||
let time = nowTime.getTime();
|
||||
|
||||
let filekey
|
||||
if (param.fileType) {//新增的fileType 参数 兼容到没有传 fileType的 各位大佬看见了自己改下自己的代码
|
||||
filekey = param.filekey ? param.filekey :
|
||||
`/${param.fileType}/${year}/${month}/${day}/${time}_${Math.floor(Math.random()*100)}.${file_type}`;
|
||||
} else {
|
||||
filekey = param.filekey ? param.filekey :
|
||||
`/${year}/${month}/${day}/${time}_${Math.floor(Math.random()*100)}.${file_type}`;
|
||||
}
|
||||
|
||||
// console.log(year,month,day,time,filekey)
|
||||
// console.log('url',baseUrl+param.url);
|
||||
|
||||
let http_base = {
|
||||
url: baseUrl + param.url, //仅为示例,非真实的接口地址
|
||||
filePath: param.file.tempFilePath,
|
||||
name: param.name ? param.name : 'file',
|
||||
formData: {
|
||||
'fileKey': filekey,
|
||||
},
|
||||
header:{
|
||||
...header
|
||||
}
|
||||
}
|
||||
if (needtoken) {
|
||||
http_base.header.Authorization =handleToken();
|
||||
}
|
||||
console.log("http_base", http_base)
|
||||
const uploadTask = uni.uploadFile({
|
||||
// url:baseUrl+param.url, //仅为示例,非真实的接口地址
|
||||
// filePath: param.file.tempFilePaths[0],
|
||||
// name: param.name?param.name:'file',
|
||||
// header:{Authorization: handleToken()},
|
||||
// formData: {
|
||||
// 'fileKey': filekey
|
||||
// },
|
||||
...http_base,
|
||||
success: (res) => {
|
||||
console.log('提交返回', res);
|
||||
if (typeof res.data == "string") {
|
||||
res.data = JSON.parse(res.data)
|
||||
}
|
||||
if (res.data.code == 1000) {
|
||||
res.data.data.file_type = file_type;
|
||||
res.data.data.resumeName = res.data.data.fileName;
|
||||
res.data.data.resumeFileKey = filekey;
|
||||
|
||||
var update = new Date();
|
||||
res.data.data.updateTime = update.toLocaleString();
|
||||
// console.log('res',res);
|
||||
|
||||
param.success && param.success(res)
|
||||
} else {
|
||||
param.fail && param.fail(res)
|
||||
}
|
||||
},
|
||||
fail: (res) => {
|
||||
param.fail && param.fail(res)
|
||||
}
|
||||
});
|
||||
|
||||
if (param.onProgress) {
|
||||
uploadTask.onProgressUpdate((res) => {
|
||||
// console.log('上传进度' + res.progress);
|
||||
// console.log('已经上传的数据长度' + res.totalBytesSent);
|
||||
// console.log('预期需要上传的数据总长度' + res.totalBytesExpectedToSend);
|
||||
param.onProgress(res);
|
||||
// 测试条件,取消上传任务。
|
||||
// if (res.progress > 50) {
|
||||
// uploadTask.abort();
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
//不可以上传
|
||||
let msg
|
||||
if (!can_upload) {
|
||||
msg = "不支持该类型"
|
||||
}
|
||||
if (file_size >= 10) {
|
||||
msg = "只支持10MB内的文件"
|
||||
}
|
||||
param.fail && param.fail({
|
||||
msg: msg
|
||||
})
|
||||
uni.showToast({
|
||||
title: msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const upload = (url, data = {}, needtoken = false) => {
|
||||
let header = defaultHeader();
|
||||
let http_base = {
|
||||
url: baseUrl + url,
|
||||
name: data.name || 'file',
|
||||
filePath: data.file.path,
|
||||
formData: {
|
||||
fileKey: data.fileKey
|
||||
},
|
||||
header:{
|
||||
...header
|
||||
}
|
||||
}
|
||||
if (needtoken) {
|
||||
http_base.header.Authorization =handleToken();
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
...http_base,
|
||||
success: (res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (typeof res.data == "string") {
|
||||
res.data = JSON.parse(res.data);
|
||||
}
|
||||
if (res.data.code == "1000") {
|
||||
resolve(res.data);
|
||||
} else {
|
||||
authCase(res.data, url)
|
||||
reject(res);
|
||||
}
|
||||
} else {
|
||||
reject(res);
|
||||
}
|
||||
},
|
||||
fail: (res) => {
|
||||
reject(res.data);
|
||||
},
|
||||
complete: (com) => {
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
//设置请求头
|
||||
function defaultHeader(){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 通过errorcode的拦截提示
|
||||
function authCase(res, url) {
|
||||
const {code, msg, data} = res
|
||||
switch (code) {
|
||||
case 6001: // 您已将该用户拉黑,无法对TA进行该操作
|
||||
case 6002: // 由于对方的隐私设置,您无法对TA进行该操作
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: msg,
|
||||
duration: 1500
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// switch (code) {
|
||||
// case 1004: //签名有误
|
||||
// break;
|
||||
// case 4000: //请求参数有误
|
||||
// break;
|
||||
// case 4001: //请求参数有误
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
28
main.js
28
main.js
|
|
@ -1,29 +1,31 @@
|
|||
import App from './App'
|
||||
import {
|
||||
router,
|
||||
RouterMount
|
||||
} from './router.js'
|
||||
|
||||
// vuex
|
||||
import store from './store'
|
||||
Vue.prototype.$store = store
|
||||
import sidsocket from "@/common/websocket/websocket.js"
|
||||
// #ifndef VUE3
|
||||
import Vue from 'vue'
|
||||
import uView from '@/uni_modules/uview-ui'
|
||||
import './uni.promisify.adaptor'
|
||||
//websocket
|
||||
Vue.prototype.$socket = sidsocket;
|
||||
Vue.config.productionTip = false
|
||||
Vue.use(router)
|
||||
.use(uView)
|
||||
Vue.use(uView)
|
||||
App.mpType = 'app'
|
||||
const app = new Vue({
|
||||
...App
|
||||
...App
|
||||
})
|
||||
app.$mount()
|
||||
// #endif
|
||||
|
||||
// #ifdef VUE3
|
||||
import { createSSRApp } from 'vue'
|
||||
import {
|
||||
createSSRApp
|
||||
} from 'vue'
|
||||
export function createApp() {
|
||||
const app = createSSRApp(App)
|
||||
return {
|
||||
app
|
||||
}
|
||||
const app = createSSRApp(App)
|
||||
return {
|
||||
app
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
85
package.json
85
package.json
|
|
@ -1,6 +1,81 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"uni-read-pages": "^1.0.5",
|
||||
"uni-simple-router": "^2.0.8-beta.4"
|
||||
}
|
||||
}
|
||||
"name": "uniuiTemplate",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"uni-read-pages": "^1.0.5",
|
||||
"uni-simple-router": "^2.0.8-beta.4"
|
||||
},
|
||||
"uni-app": {
|
||||
"scripts": {
|
||||
"h5dev":{
|
||||
"title":"h5开发版",
|
||||
"browser":"chrome",
|
||||
"env": {
|
||||
"UNI_PLATFORM": "h5",
|
||||
"VUE_APP_BASE_URL":"",
|
||||
"VUE_APP_WS_URL":""
|
||||
},
|
||||
"define":{
|
||||
"H5-DEV":true
|
||||
}
|
||||
},
|
||||
"h5test":{
|
||||
"title":"h5测试版",
|
||||
"browser":"chrome",
|
||||
"env": {
|
||||
"UNI_PLATFORM": "h5",
|
||||
"VUE_APP_BASE_URL":"",
|
||||
"VUE_APP_WS_URL":""
|
||||
},
|
||||
"define":{
|
||||
"H5-TEST":true
|
||||
}
|
||||
},
|
||||
"h5prod":{
|
||||
"title":"h5生产版",
|
||||
"browser":"chrome",
|
||||
"env": {
|
||||
"UNI_PLATFORM": "h5",
|
||||
"VUE_APP_BASE_URL":"",
|
||||
"VUE_APP_WS_URL":""
|
||||
},
|
||||
"define":{
|
||||
"H5-PROD":true
|
||||
}
|
||||
},
|
||||
"mp-weixin-dev":{
|
||||
"title":"微信开发版",
|
||||
"env": {
|
||||
"UNI_PLATFORM": "mp-weixin",
|
||||
"VUE_APP_BASE_URL":"",
|
||||
"VUE_APP_WS_URL":""
|
||||
},
|
||||
"define":{
|
||||
"MP-WEIXIN-DEV":true
|
||||
}
|
||||
},
|
||||
"mp-weixin-test":{
|
||||
"title":"微信测试版",
|
||||
"env": {
|
||||
"UNI_PLATFORM": "mp-weixin",
|
||||
"VUE_APP_BASE_URL":"",
|
||||
"VUE_APP_WS_URL":""
|
||||
},
|
||||
"define":{
|
||||
"MP-WEIXIN-TEST":true
|
||||
}
|
||||
},
|
||||
"mp-weixin-prod":{
|
||||
"title":"微信生产版",
|
||||
"env": {
|
||||
"UNI_PLATFORM": "mp-weixin",
|
||||
"VUE_APP_BASE_URL":"",
|
||||
"VUE_APP_WS_URL":""
|
||||
},
|
||||
"define":{
|
||||
"MP-WEIXIN-PROD":true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -214,7 +214,8 @@
|
|||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "uni-app",
|
||||
"navigationBarBackgroundColor": "#F8F8F8",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
"backgroundColor": "#F8F8F8",
|
||||
"maxWidth": 750
|
||||
},
|
||||
"uniIdRouter": {}
|
||||
}
|
||||
|
|
|
|||
159
router.js
159
router.js
|
|
@ -1,159 +0,0 @@
|
|||
import { RouterMount, createRouter } from 'uni-simple-router'
|
||||
|
||||
const router = createRouter({
|
||||
platform: process.env.VUE_APP_PLATFORM,
|
||||
routes: [
|
||||
{
|
||||
"path": "/pages/index/index",
|
||||
"name": 'index',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/specialInfo/specialInfo",
|
||||
"name": 'specialInfo',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/pages/user/user",
|
||||
"name": 'user',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/message/message",
|
||||
"name": 'message',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/login/login",
|
||||
"name": 'login',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/setting/setting",
|
||||
"name": 'setting',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/deviceIn/deviceIn",
|
||||
"name": 'deviceIn',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/addDriver/addDriver",
|
||||
"name": 'addDriver',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/search/search",
|
||||
"name": 'search',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/personalInfo/personalInfo",
|
||||
"name": 'personalInfo',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/accountSafety/accountSafety",
|
||||
"name": 'accountSafety',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/compAuthInfo/compAuthInfo",
|
||||
"name": 'compAuthInfo',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/deviceDetail/deviceDetail",
|
||||
"name": 'deviceDetail',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/subLoanInfo/subLoanInfo",
|
||||
"name": 'subLoanInfo',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/myLoan/myLoan",
|
||||
"name": 'myLoan',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/myOffer/myOffer",
|
||||
"name": 'myOffer',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/continueLoan/continueLoan",
|
||||
"name": 'continueLoan',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/offLoan/offLoan",
|
||||
"name": 'offLoan',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/myFavorite/myFavorite",
|
||||
"name": 'myFavorite',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/myItem/myItem",
|
||||
"name": 'myItem',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "/pages/myDriver/myDriver",
|
||||
"name": 'myDriver',
|
||||
"meta": {
|
||||
"needAuth": "true"
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
export {
|
||||
router,
|
||||
RouterMount
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
Vue.use(Vuex)
|
||||
|
||||
const modulesFiles = require.context('./module', true, /\.js$/)
|
||||
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
|
||||
const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
|
||||
const value = modulesFiles(modulePath)
|
||||
modules[moduleName] = value.default
|
||||
return modules
|
||||
}, {})
|
||||
const state = {}
|
||||
const getters = {}
|
||||
const mutations = {}
|
||||
const actions = {}
|
||||
|
||||
export default new Vuex.Store({
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations,
|
||||
modules
|
||||
})
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// 用户基本信息
|
||||
export default{
|
||||
namespaced: true,
|
||||
state:{
|
||||
userInfo:{}
|
||||
},
|
||||
getters:{
|
||||
|
||||
},
|
||||
mutations:{
|
||||
},
|
||||
actions:{
|
||||
|
||||
}
|
||||
}
|
||||
2
uni.scss
2
uni.scss
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
@import '@/uni_modules/uview-ui/theme.scss';
|
||||
|
||||
$main-color:#37C690;//主题色
|
||||
|
||||
/* 行为相关颜色 */
|
||||
$uni-color-primary: #007aff;
|
||||
$uni-color-success: #4cd964;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
//vue.config.js
|
||||
const TransformPages = require('uni-read-pages')
|
||||
const {webpack} = new TransformPages()
|
||||
const {
|
||||
webpack
|
||||
} = new TransformPages()
|
||||
const consoleDebuggerFlag = process.env.NODE_ENV == 'production'
|
||||
module.exports = {
|
||||
configureWebpack: {
|
||||
configureWebpack: config => {
|
||||
// console.log("config",config)
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
ROUTES: webpack.DefinePlugin.runtimeValue(() => {
|
||||
|
|
@ -10,8 +14,15 @@ module.exports = {
|
|||
includes: ['path', 'name', 'aliasPath']
|
||||
});
|
||||
return JSON.stringify(tfPages.routes)
|
||||
}, true )
|
||||
}, true)
|
||||
})
|
||||
]
|
||||
];
|
||||
if (consoleDebuggerFlag) {
|
||||
config.optimization.minimizer[0].options.terserOptions.compress.warnings = false
|
||||
config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
|
||||
config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true
|
||||
config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log']
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue