cyl/master-0804
jscyl13849007907 3 months ago
commit 5db7686772

@ -16,6 +16,37 @@ export default {
onLaunch() {
let that = this;
uni.removeStorageSync("selectedCity");
//
// uni.onBeforeAppRoute((res) => {
// console.log("setNavStyle", res);
// try {
// that.G.Post("/common/user/browsing/history/addRecord", { browsingUrl: res.path }, (res) => {});
// } catch (error) {
// console.log("error", error);
// }
// });
//
uni.addInterceptor("navigateTo", {
//
invoke(args) {
console.log("navigateTo 跳转前", args);
that.G.watchUserPage(args.url);
},
});
uni.addInterceptor("reLaunch", {
//
invoke(args) {
console.log("reLaunch 跳转前", args);
that.G.watchUserPage(args.url);
},
});
uni.addInterceptor("redirectTo", {
//
invoke(args) {
console.log("redirectTo 跳转前", args);
that.G.watchUserPage(args.url);
},
});
},
onShow: function (options) {
let that = this;
@ -47,14 +78,10 @@ export default {
this.G.checkToken();
}
if (!that.globalData.timer) {
if (uni.getStorageSync("apply-token")) {
that.checkNum();
}
that.checkNum();
that.globalData.timer = setInterval(() => {
console.log("inner++++++++++++++++++++ +++++++++++++++++++++++++++");
if (uni.getStorageSync("apply-token")) {
that.checkNum();
}
console.log("inner+++++++++++++++++++++++++++++++++++++++++++++++");
that.checkNum();
}, 30 * 1000);
}

@ -352,6 +352,7 @@ export default {
this.agencyInfo = uni.getStorageSync("agencyInfo");
this.userInfo = uni.getStorageSync("apply-userinfo");
that.loadSelectedCityFromCache();
that.G.watchUserPage("pages/home/index");
}
},
@ -442,7 +443,7 @@ export default {
// res.recordList = [];
// if (res.recordCount == 0) {
that.loading = false;
that.loading = false;
// } else {
// that.loading = true;
// }

@ -352,6 +352,7 @@ export default {
this.getCompanyInfo();
}
});
that.G.watchUserPage("pages/person/index");
// that.userInfo = uni.getStorageSync("apply-userinfo");
} else {
that.waitNum_ups = 0;
@ -375,7 +376,7 @@ export default {
getNewApplyNum() {
let that = this;
this.G.Get(this.api.order_getNewApplyNumNotViewed, {}, (res) => {
console.log(res, "getNewApplyNum");
console.log(res, "getNewApplyNum");
that.applyNum = res;
});
},

@ -203,6 +203,7 @@ export default {
this.getList();
}
this.getGZHInfo();
that.G.watchUserPage("pages/workBench/index");
},
onReachBottom() {
let that = this;

@ -1,236 +1,227 @@
// let ajaxUrl = "http://192.168.3.83:8001";
let ajaxUrl = "https://daotian.matripe.com.cn";
let requestTask;
let data = {
ajaxUrl: ajaxUrl,
startAbort($bool = 0) {
if ($bool == 1) {
requestTask.abort();
}
},
Get($url = '', $parmas = {}, callback = () => {}, failback = () => {}) {
let that = this,
params = {};
let promise = new Promise((resolve, reject) => {
params = $parmas;
resolve();
});
promise.then(() => {
that.postData($url, params, callback, failback, 'GET');
}).catch();
},
Post($url = '', $parmas = {}, callback = () => {}, failback = () => {}) {
let that = this,
params = {};
let promise = new Promise((resolve, reject) => {
params = $parmas;
resolve();
});
promise.then(() => {
that.postData($url, params, callback, failback, 'POST');
}).catch();
},
Put($url = '', $parmas = {}, callback = () => {}, failback = () => {}) {
let that = this,
params = {};
let promise = new Promise((resolve, reject) => {
params = $parmas;
resolve();
});
promise.then(() => {
that.postData($url, params, callback, failback, 'PUT');
}).catch();
},
ajaxUrl: ajaxUrl,
Get ($url = '', $parmas = {}, callback = () => { }, failback = () => { }) {
let that = this,
params = {};
let promise = new Promise((resolve, reject) => {
params = $parmas;
resolve();
});
promise.then(() => {
that.postData($url, params, callback, failback, 'GET');
}).catch();
},
Post ($url = '', $parmas = {}, callback = () => { }, failback = () => { }) {
let that = this,
params = {};
let promise = new Promise((resolve, reject) => {
params = $parmas;
resolve();
});
promise.then(() => {
that.postData($url, params, callback, failback, 'POST');
}).catch();
},
Put ($url = '', $parmas = {}, callback = () => { }, failback = () => { }) {
let that = this,
params = {};
let promise = new Promise((resolve, reject) => {
params = $parmas;
resolve();
});
promise.then(() => {
that.postData($url, params, callback, failback, 'PUT');
}).catch();
},
setPublicParams() {
let that = this,
params = {};
let uuid_new = "";
// #ifdef APP-PLUS
if (uni.getSystemInfoSync().osName == "android") {
uuid_new = "from_android_applyAssistantUniapp"
} else {
uuid_new = "from_ios_applyAssistantUniapp"
}
// #endif
params = {
'requestComeFrom': 'assistant_miniapp',
// #ifdef APP-PLUS
'g-open-env': 'APP-PLUS',
appId: uuid_new,
// 请求来源标识 1.小程序 2.app 3.网页
appClassify: 2,
appName: encodeURIComponent('报名助手')
// #endif
// #ifdef H5
'g-open-env': 'H5',
appId: '',
appClassify: 3,
appName: encodeURIComponent('报名助手')
// #endif
// #ifdef MP-WEIXIN
'g-open-env': 'MP-MINI',
appId: uni.getAccountInfoSync().miniProgram.appId,
appClassify: 1,
appName: encodeURIComponent('报名助手')
// #endif
// #ifdef MP-TOUTIAO
'g-open-env': 'MP-TOUTIAO',
appId: tt.getEnvInfoSync().microapp.appId,
subAppId: uni.getStorageSync('subAppId'),
appClassify: 1,
appName: encodeURIComponent('报名助手')
// #endif
// #ifdef MP-KUAISHOU
'g-open-env': 'MP-KUAISHOU',
appId: "",
appClassify: 1,
appName: encodeURIComponent('报名助手')
// #endif
}
return params
},
// 发送请求
postData($url = '', $parmas = {}, callback = () => {}, failback = () => {}, $method) {
let that = this,
$header = {};
if (uni.getStorageSync("apply-token")) {
$header.Authorization = 'Bearer ' + uni.getStorageSync("apply-token");
}
if (uni.getStorageSync("apply-agencyId")) {
// console.log('uni.getStorageSync("apply-agencyId")', uni.getStorageSync("apply-agencyId"));
$header.Agencyid = uni.getStorageSync("apply-agencyId");
}
if ($parmas == '') {
$parmas = {};
}
if ($parmas.formdata || $method == "POST" || $method == "PUT") {
$header['content-type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
}
for (const k in $parmas) {
if ($parmas[k] == undefined || $parmas[k] == 'undefined') {
$parmas[k] = ''
}
}
console.log("公共参数,+++++", Object.assign($parmas, that.setPublicParams()));
uni.getNetworkType({
success: function(res) {
// console.log(res);
if (res.networkType != 'none') {
requestTask = uni.request({
url: ajaxUrl + $url,
data: Object.assign($parmas, that.setPublicParams()),
header: Object.assign($header, that.setPublicParams()),
method: $method,
success: (res) => {
// console.log('测试报错123123123123123123',res);
// console.log('测试报错123123123123123123$url',$url);
let resData = res.data;
setPublicParams () {
let that = this,
params = {};
let uuid_new = "";
// #ifdef APP-PLUS
if (uni.getSystemInfoSync().osName == "android") {
uuid_new = "from_android_applyAssistantUniapp"
} else {
uuid_new = "from_ios_applyAssistantUniapp"
}
// #endif
params = {
'requestComeFrom': 'assistant_miniapp',
// #ifdef APP-PLUS
'g-open-env': 'APP-PLUS',
appId: uuid_new,
// 请求来源标识 1.小程序 2.app 3.网页
appClassify: 2,
appName: encodeURIComponent('报名助手')
// #endif
// #ifdef H5
'g-open-env': 'H5',
appId: '',
appClassify: 3,
appName: encodeURIComponent('报名助手')
// #endif
// #ifdef MP-WEIXIN
'g-open-env': 'MP-MINI',
appId: uni.getAccountInfoSync().miniProgram.appId,
appClassify: 1,
appName: encodeURIComponent('报名助手')
// #endif
// #ifdef MP-TOUTIAO
'g-open-env': 'MP-TOUTIAO',
appId: tt.getEnvInfoSync().microapp.appId,
subAppId: uni.getStorageSync('subAppId'),
appClassify: 1,
appName: encodeURIComponent('报名助手')
// #endif
// #ifdef MP-KUAISHOU
'g-open-env': 'MP-KUAISHOU',
appId: "",
appClassify: 1,
appName: encodeURIComponent('报名助手')
// #endif
}
return params
},
// 发送请求
postData ($url = '', $parmas = {}, callback = () => { }, failback = () => { }, $method) {
let that = this,
$header = {};
if (uni.getStorageSync("apply-token")) {
$header.Authorization = 'Bearer ' + uni.getStorageSync("apply-token");
}
if (uni.getStorageSync("apply-agencyId")) {
// console.log('uni.getStorageSync("apply-agencyId")', uni.getStorageSync("apply-agencyId"));
$header.Agencyid = uni.getStorageSync("apply-agencyId");
}
if ($parmas == '') {
$parmas = {};
}
if ($parmas.formdata || $method == "POST" || $method == "PUT") {
$header['content-type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
}
for (const k in $parmas) {
if ($parmas[k] == undefined || $parmas[k] == 'undefined') {
$parmas[k] = ''
}
}
console.log("公共参数,+++++", Object.assign($parmas, that.setPublicParams()));
uni.request({
url: ajaxUrl + $url,
data: Object.assign($parmas, that.setPublicParams()),
header: Object.assign($header, that.setPublicParams()),
method: $method,
success: (res) => {
// console.log('测试报错123123123123123123',res);
// console.log('测试报错123123123123123123$url',$url);
let resData = res.data;
if (resData.status == 200) { // 正常
callback(resData.data, resData.msg);
} else if (resData.status == 9999) { // 登录过期或者身份变动等需要登录的场景
uni.showToast({
title: resData.msg,
icon: "none"
});
failback(resData);
setTimeout(() => {
uni.reLaunch({
url: '/root/person/loginIndex?path=/' + that.getPathCopy().path + '&level=' +
that.getPathCopy().level
});
}, 1500);
} else if (resData.status == 500 || resData.status == 502) { // 某种原因导致接口提示该状态码
// if (resData.msg == '系统异常,请稍后') {
// uni.reLaunch({
// url: '/root/other/error'
// });
// } else {
uni.showToast({
title: resData.msg,
// title:'系统异常,请稍后',
icon: "none"
});
failback(resData.msg);
// }
} else if (resData.status == 2002) {
uni.showToast({
title: '已切换团队,需要重新登录',
icon: "none"
});
setTimeout(() => {
uni.reLaunch({
url: '/root/person/loginIndex?path=/pages/home/index&level=' + that
.getPathCopy().level
});
}, 1500);
} else { // 其他异常
if ($url == '/yishoudan/user/apply/order/V2/details') {
if (resData.status == 200) {// 正常
callback(resData.data, resData.msg);
} else if (resData.status == 9999) {// 登录过期或者身份变动等需要登录的场景
uni.showToast({
title: resData.msg,
icon: "none"
});
failback(resData);
setTimeout(() => {
uni.reLaunch({
url: '/root/person/loginIndex?path=/' + that.getPathCopy().path + '&level=' + that.getPathCopy().level
});
}, 1500);
} else if (resData.status == 500 || resData.status == 502) {// 某种原因导致接口提示该状态码
// if (resData.msg == '系统异常,请稍后') {
// uni.reLaunch({
// url: '/root/other/error'
// });
// } else {
uni.showToast({
title: resData.msg,
// title:'系统异常,请稍后',
icon: "none"
});
failback(resData.msg);
// }
} else if (resData.status == 2002) {
uni.showToast({
title: '已切换团队,需要重新登录',
icon: "none"
});
setTimeout(() => {
uni.reLaunch({
url: '/root/person/loginIndex?path=/pages/home/index&level=' + that.getPathCopy().level
});
}, 1500);
} else {// 其他异常
if ($url == '/yishoudan/user/apply/order/V2/details') {
} else {
uni.showToast({
title: resData.msg,
icon: "none"
});
}
} else {
uni.showToast({
title: resData.msg,
icon: "none"
});
}
failback(resData.msg);
}
},
fail(error) {
uni.showToast({
// title: error.errMsg,
title: '系统异常,请稍后',
icon: "none"
})
failback(error);
}
});
} else {
uni.showToast({
title: '网络异常,请检查网络',
icon: "none"
})
}
},
});
},
failback(resData.msg);
}
},
fail (error) {
uni.showToast({
// title: error.errMsg,
title: '系统异常,请稍后',
icon: "none"
})
failback(error);
}
});
},
// 头像上传
uploadFile($file, callback = () => {}) {
let that = this;
uni.uploadFile({
url: ajaxUrl + '/user/changeUserImgsrc',
filePath: $file,
name: 'uploadFile',
header: Object.assign({
Authorization: 'Bearer ' + uni.getStorageSync("apply-token")
}, that.setPublicParams()),
formData: that.setPublicParams(),
success: (uploadFileRes) => {
callback(JSON.parse(uploadFileRes.data).data.url);
}
});
},
/* path
*/
getPathCopy() {
const pages = getCurrentPages();
if (pages.length > 0) {
let _path = pages[pages.length - 1].route;
return {
path: _path,
level: _path.slice(0, 4)
}
} else {
return {
path: '',
level: ''
};
}
},
// 头像上传
uploadFile ($file, callback = () => { }) {
let that = this;
uni.uploadFile({
url: ajaxUrl + '/user/changeUserImgsrc',
filePath: $file,
name: 'uploadFile',
header: Object.assign({
Authorization: 'Bearer ' + uni.getStorageSync("apply-token")
}, that.setPublicParams()),
formData: that.setPublicParams(),
success: (uploadFileRes) => {
callback(JSON.parse(uploadFileRes.data).data.url);
}
});
},
/* path
*/
getPathCopy () {
const pages = getCurrentPages();
if (pages.length > 0) {
let _path = pages[pages.length - 1].route;
return {
path: _path,
level: _path.slice(0, 4)
}
} else {
return {
path: '',
level: ''
};
}
},
//监听用户的页面点击
watchUserPage (path) {
let that = this;
try {
if (uni.getStorageSync("apply-userinfo")) {
that.Post("/common/user/browsing/history/addRecord", { browsingUrl: path }, (res) => { });
}
} catch (error) {
console.log("error", error);
}
},
};
export default data;

@ -161,6 +161,8 @@ let data = {
/*
*/
setNavStyle ($form = 'default') {
console.log('into setNavStyle');
if ($form == 'home') {
uni.setNavigationBarColor({
backgroundColor: "#fff",
@ -1573,6 +1575,7 @@ let data = {
}
return str;
},
}
export default data;

Loading…
Cancel
Save