2026-05-11 07:36:26 +08:00
|
|
|
|
// app.js
|
2026-05-21 00:56:17 +08:00
|
|
|
|
const config = require('./utils/config')
|
|
|
|
|
|
|
2026-05-11 07:36:26 +08:00
|
|
|
|
App({
|
|
|
|
|
|
onLaunch() {
|
|
|
|
|
|
const uid = wx.getStorageSync('uid')
|
|
|
|
|
|
const token = wx.getStorageSync('token')
|
2026-10-12 00:09:45 +08:00
|
|
|
|
const userType = wx.getStorageSync('userType')
|
2026-05-11 07:36:26 +08:00
|
|
|
|
if (uid) {
|
|
|
|
|
|
this.globalData.uid = uid
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token) {
|
|
|
|
|
|
this.globalData.token = token
|
|
|
|
|
|
}
|
2026-10-12 00:09:45 +08:00
|
|
|
|
if (userType) {
|
|
|
|
|
|
this.globalData.userType = userType
|
|
|
|
|
|
}
|
2026-05-11 07:36:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
globalData: {
|
|
|
|
|
|
userInfo: null,
|
|
|
|
|
|
encryptedData: '',
|
|
|
|
|
|
iv: '',
|
|
|
|
|
|
code: '',
|
|
|
|
|
|
|
2026-05-21 00:56:17 +08:00
|
|
|
|
url: config.baseUrl,
|
|
|
|
|
|
domain: config.baseUrl,
|
|
|
|
|
|
domaintwo: config.baseUrl,
|
2026-06-07 11:34:33 +08:00
|
|
|
|
imageBaseUrl: config.imageBaseUrl,
|
2026-05-11 07:36:26 +08:00
|
|
|
|
|
|
|
|
|
|
phone: '',
|
|
|
|
|
|
uid: '',
|
2026-10-12 00:09:45 +08:00
|
|
|
|
userType: 'C', // 当前角色: C=患者 B=陪诊师 06=推广员 05=调度 04=客服 03=运营 00=超管
|
2026-05-11 07:36:26 +08:00
|
|
|
|
sessionKey: '',
|
|
|
|
|
|
version_number: '1.0.0',
|
2026-06-07 11:29:35 +08:00
|
|
|
|
|
2026-10-12 00:09:45 +08:00
|
|
|
|
// 角色 TabBar 配置
|
|
|
|
|
|
ROLE_TABS: {
|
|
|
|
|
|
'C': [
|
|
|
|
|
|
{ text: '首页', icon: '/pages/image/income.png', selIcon: '/pages/image/income_a.png' },
|
|
|
|
|
|
{ text: '服务', icon: '/pages/image/service.png', selIcon: '/pages/image/service.png' },
|
|
|
|
|
|
{ text: '订单', icon: '/pages/image/dingdan.png', selIcon: '/pages/image/dingdanl.png' },
|
|
|
|
|
|
{ text: '我的', icon: '/pages/image/my.png', selIcon: '/pages/image/my_a.png' }
|
|
|
|
|
|
],
|
|
|
|
|
|
'B': [
|
|
|
|
|
|
{ text: '待接单', icon: '/pages/image/income.png', selIcon: '/pages/image/income_a.png' },
|
|
|
|
|
|
{ text: '进行中', icon: '/pages/image/service.png', selIcon: '/pages/image/service.png' },
|
|
|
|
|
|
{ text: '已完成', icon: '/pages/image/dingdan.png', selIcon: '/pages/image/dingdanl.png' },
|
|
|
|
|
|
{ text: '我的', icon: '/pages/image/my.png', selIcon: '/pages/image/my_a.png' }
|
|
|
|
|
|
],
|
|
|
|
|
|
'06': [
|
|
|
|
|
|
{ text: '推广数据', icon: '/pages/image/income.png', selIcon: '/pages/image/income_a.png' },
|
|
|
|
|
|
{ text: '我的团队', icon: '/pages/image/service.png', selIcon: '/pages/image/service.png' },
|
|
|
|
|
|
{ text: '佣金', icon: '/pages/image/dingdan.png', selIcon: '/pages/image/dingdanl.png' },
|
|
|
|
|
|
{ text: '我的', icon: '/pages/image/my.png', selIcon: '/pages/image/my_a.png' }
|
|
|
|
|
|
],
|
|
|
|
|
|
'03': [
|
|
|
|
|
|
{ text: '待处理', icon: '/pages/image/income.png', selIcon: '/pages/image/income_a.png' },
|
|
|
|
|
|
{ text: '全部订单', icon: '/pages/image/dingdan.png', selIcon: '/pages/image/dingdanl.png' },
|
|
|
|
|
|
{ text: '收益', icon: '/pages/image/service.png', selIcon: '/pages/image/service.png' },
|
|
|
|
|
|
{ text: '我的', icon: '/pages/image/my.png', selIcon: '/pages/image/my_a.png' }
|
|
|
|
|
|
],
|
|
|
|
|
|
'04': [
|
|
|
|
|
|
{ text: '待处理', icon: '/pages/image/income.png', selIcon: '/pages/image/income_a.png' },
|
|
|
|
|
|
{ text: '全部订单', icon: '/pages/image/dingdan.png', selIcon: '/pages/image/dingdanl.png' },
|
|
|
|
|
|
{ text: '收益', icon: '/pages/image/service.png', selIcon: '/pages/image/service.png' },
|
|
|
|
|
|
{ text: '我的', icon: '/pages/image/my.png', selIcon: '/pages/image/my_a.png' }
|
|
|
|
|
|
],
|
|
|
|
|
|
'05': [
|
|
|
|
|
|
{ text: '待派单', icon: '/pages/image/income.png', selIcon: '/pages/image/income_a.png' },
|
|
|
|
|
|
{ text: '全部订单', icon: '/pages/image/dingdan.png', selIcon: '/pages/image/dingdanl.png' },
|
|
|
|
|
|
{ text: '收益', icon: '/pages/image/service.png', selIcon: '/pages/image/service.png' },
|
|
|
|
|
|
{ text: '我的', icon: '/pages/image/my.png', selIcon: '/pages/image/my_a.png' }
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 角色中文名映射
|
|
|
|
|
|
ROLE_LABELS: {
|
|
|
|
|
|
'00': '超级管理员',
|
|
|
|
|
|
'03': '运营经理',
|
|
|
|
|
|
'04': '客服专员',
|
|
|
|
|
|
'05': '调度员',
|
|
|
|
|
|
'06': '推广员',
|
|
|
|
|
|
'B': '陪诊师',
|
|
|
|
|
|
'C': '患者'
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 可自助切换的角色对
|
|
|
|
|
|
ROLE_SWITCHABLE: ['C', '06', 'B'],
|
|
|
|
|
|
|
2026-06-07 11:29:35 +08:00
|
|
|
|
// 订单状态映射(订单状态:-2:已取消 -1:拒绝接单 0:待接单 1:已接单
|
|
|
|
|
|
// 2:待服务 3:服务中 4:已完成 5:退款中 6:退款中 7:已退款 8:已结算)
|
|
|
|
|
|
STATUS_MAP: {
|
|
|
|
|
|
'-2': '已取消', '-1': '拒绝接单', '0': '待接单',
|
|
|
|
|
|
'1': '已接单', '2': '服务中', '3': '待支付',
|
|
|
|
|
|
'4': '已完成', '5': '申请退款', '6': '退款中',
|
|
|
|
|
|
'7': '已退款', '8': '已结算'
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 退款原因列表(全局公用,避免每页重复定义)
|
|
|
|
|
|
REFUND_REASONS: [
|
|
|
|
|
|
{ text: '不喜欢/不想要' },
|
|
|
|
|
|
{ text: '商品信息与描述不符' },
|
|
|
|
|
|
{ text: '买多/买错/计划有变' },
|
|
|
|
|
|
{ text: '更换其他项目、购买了其他项目' },
|
|
|
|
|
|
{ text: '没有时间/个人原因' },
|
|
|
|
|
|
{ text: '其他原因' }
|
|
|
|
|
|
],
|
2026-05-11 07:36:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
console: function (msg) {
|
|
|
|
|
|
console.log(msg);
|
|
|
|
|
|
},
|
|
|
|
|
|
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;
|
|
|
|
|
|
},
|
2026-06-07 11:29:35 +08:00
|
|
|
|
// 公共导航栏高度,避免每个页面重复计算
|
|
|
|
|
|
getNavBarHeight: function () {
|
2026-10-12 00:09:45 +08:00
|
|
|
|
var statusBarHeight = (wx.getWindowInfo && wx.getWindowInfo().statusBarHeight) || wx.getSystemInfoSync().statusBarHeight;
|
2026-06-07 11:29:35 +08:00
|
|
|
|
return {
|
|
|
|
|
|
statusBarHeight: statusBarHeight,
|
|
|
|
|
|
height: 46 + statusBarHeight
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-06-07 11:53:49 +08:00
|
|
|
|
// 修复图片路径:相对路径补全 baseUrl,绝对 URL 或空值原样返回
|
2026-06-07 11:29:35 +08:00
|
|
|
|
fixImageUrl: function (path) {
|
|
|
|
|
|
if (!path) return '';
|
|
|
|
|
|
if (path.indexOf('http') === 0) return path;
|
2026-06-07 11:53:49 +08:00
|
|
|
|
return this.globalData.url + path;
|
2026-06-07 11:29:35 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 获取订单状态文案
|
|
|
|
|
|
getStatusLabel: function (status) {
|
|
|
|
|
|
return this.globalData.STATUS_MAP[String(status)] || '';
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-05-11 07:36:26 +08:00
|
|
|
|
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
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|