Files
szjs/app.js

109 lines
2.7 KiB
JavaScript
Raw Normal View History

2025-03-07 22:27:18 +08:00
// app.js
App({
onLaunch() {
const uid = wx.getStorageSync('uid')
const token = wx.getStorageSync('token')
if (uid) {
this.globalData.uid = uid
}
if (token) {
this.globalData.token = token
}
},
globalData: {
userInfo: null,
encryptedData: '',
iv: '',
code: '',
encryptedData: '',
iv: '',
// url: 'http://101.43.95.130/',
url: 'https://ruilaizipj.com/',
2026-01-30 10:14:02 +08:00
// url: 'https://www.ruilaizipj.com/',
2025-03-07 22:27:18 +08:00
phone: '',
uid: '',
sessionKey: '',
version_number: '1.0.0',
},
console: function (msg) {
2026-01-06 15:59:20 +08:00
// 日志输出已隐藏
2025-03-07 22:27:18 +08:00
},
tip: function (params) {
var that = this;
var title = params.hasOwnProperty('title') ? params['title'] : '提示您';
var content = params.hasOwnProperty('content') ? params['content'] : '';
wx.showModal({
title: title,
content: content,
success: function (res) {
if (res.confirm) { //点击确定
if (params.hasOwnProperty('cb_confirm') && typeof (params.cb_confirm) == "function") {
params.cb_confirm();
}
} else { //点击否
if (params.hasOwnProperty('cb_cancel') && typeof (params.cb_cancel) == "function") {
params.cb_cancel();
}
}
}
})
},
getRequestHeader: function () {
return {
'content-type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer ' + this.getCache("token")
}
},
buildUrl: function (path, params) {
var url = this.globalData.domain + path;
var _paramUrl = "";
if (params) {
_paramUrl = Object.keys(params).map(function (k) {
return [encodeURIComponent(k), encodeURIComponent(params[k])].join("=");
}).join("&");
_paramUrl = "?" + _paramUrl;
}
return url + _paramUrl;
},
buildUrltwo: function (path, params) {
var url = this.globalData.domaintwo + path;
var _paramUrl = "";
if (params) {
_paramUrl = Object.keys(params).map(function (k) {
return [encodeURIComponent(k), encodeURIComponent(params[k])].join("=");
}).join("&");
_paramUrl = "?" + _paramUrl;
}
return url + _paramUrl;
},
getCache: function (key) {
var value = undefined;
try {
value = wx.getStorageSync(key);
} catch (e) {}
return value;
},
setCache: function (key, value) {
wx.setStorage({
key: key,
data: value
});
},
//是否登录
isdenglu() {
wx.showModal({
title: '提示',
content: '请先登录',
success(res) {
if (res.confirm) {
2026-01-06 15:59:20 +08:00
// 用户点击确定
2025-03-07 22:27:18 +08:00
wx.switchTab({
url: '/pages/my/my'
})
} else if (res.cancel) {
2026-01-06 15:59:20 +08:00
// 用户点击取消
2025-03-07 22:27:18 +08:00
}
}
})
},
})