|
|
|
import component from "@/utils/component";
|
|
|
|
import relativeTime from "@/utils/dayjs/relativeTime.js";
|
|
|
|
import page from "@/utils/page";
|
|
|
|
import { request } from "@/utils/request";
|
|
|
|
import { parseScene } from "./utils/util";
|
|
|
|
|
|
|
|
wx.WebIM = require("@/utils/webIM/WebIM.js").default;
|
|
|
|
|
|
|
|
const dayjs = require("dayjs");
|
|
|
|
const licia = require("miniprogram-licia");
|
|
|
|
|
|
|
|
require("/utils/dayjs/day-zh-cn.js");
|
|
|
|
|
|
|
|
dayjs.locale("zh-cn"); // 全局使用
|
|
|
|
dayjs.extend(relativeTime);
|
|
|
|
|
|
|
|
App<IAppOption>({
|
|
|
|
globalData: {
|
|
|
|
// 测试号 wx2b0bb13edf717c1d
|
|
|
|
// dev
|
|
|
|
// appid:wxaae50c206446a964
|
|
|
|
url: "https://m.takeda.hbraas.com",
|
|
|
|
upFileUrl: "https://m.takeda.hbraas.com/",
|
|
|
|
imageUrl: "https://m.takeda.hbraas.com/wt/",
|
|
|
|
// pro
|
|
|
|
// appid:wx96f45ca4f1fa36ec
|
|
|
|
// url: 'https://m.takeda.hbraas.com',
|
|
|
|
// upFileUrl: 'https://m.takeda.hbraas.com/',
|
|
|
|
// imageUrl: 'https://m.takeda.hbraas.com/zd/',
|
|
|
|
|
|
|
|
loginState: "",
|
|
|
|
isLogin: 0,
|
|
|
|
doctorId: null,
|
|
|
|
|
|
|
|
scene: null,
|
|
|
|
},
|
|
|
|
onLaunch() {
|
|
|
|
Page = page as WechatMiniprogram.Page.Constructor;
|
|
|
|
Component = component as WechatMiniprogram.Component.Constructor;
|
|
|
|
|
|
|
|
wx.ajax = licia.curry(request)({ gUrl: this.globalData.url });
|
|
|
|
|
|
|
|
wx.login({
|
|
|
|
success: (res) => {
|
|
|
|
wx.ajax({
|
|
|
|
method: "GET",
|
|
|
|
url: "?r=takeda/user/init-login",
|
|
|
|
data: {
|
|
|
|
code: res.code,
|
|
|
|
},
|
|
|
|
}).then((res) => {
|
|
|
|
this.globalData.loginState = res.loginState;
|
|
|
|
this.globalData.isLogin = res.isLogin;
|
|
|
|
this.globalData.doctorId = res.doctorId;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onShow(options) {
|
|
|
|
if (options.query.scene) {
|
|
|
|
this.globalData.scene = parseScene(options.query.scene);
|
|
|
|
}
|
|
|
|
// this.startLogin();
|
|
|
|
},
|
|
|
|
waitLogin(waitLoginState = false) {
|
|
|
|
let time: number;
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
time = setInterval(() => {
|
|
|
|
if (this.globalData.loginState) {
|
|
|
|
clearInterval(time);
|
|
|
|
if (waitLoginState) {
|
|
|
|
resolve(true);
|
|
|
|
} else if (this.globalData.isLogin === 0) {
|
|
|
|
reject(new Error("未登录"));
|
|
|
|
wx.reLaunch({ url: "/module1/pages/login/index" });
|
|
|
|
} else if (this.globalData.doctorId === null) {
|
|
|
|
this.getApplyDoctor().then((applyDoctorInfo) => {
|
|
|
|
if (applyDoctorInfo.AuditStatus === 0) {
|
|
|
|
wx.reLaunch({ url: "/module1/pages/setInfoResult/index" });
|
|
|
|
reject(new Error("还在审核中"));
|
|
|
|
} else {
|
|
|
|
wx.reLaunch({ url: "/module1/pages/setInfo/index" });
|
|
|
|
reject(new Error("还不是医生"));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
resolve(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 500);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
getApplyDoctor() {
|
|
|
|
return wx.ajax({
|
|
|
|
method: "GET",
|
|
|
|
url: "?r=takeda/reg/get-apply-doctor",
|
|
|
|
});
|
|
|
|
},
|
|
|
|
getUserInfo(self: WechatMiniprogram.Page.Instance<any, any>, callback?: (res: any) => void) {
|
|
|
|
wx.ajax({
|
|
|
|
method: "GET",
|
|
|
|
url: "?r=takeda/account/info",
|
|
|
|
data: {},
|
|
|
|
}).then((res) => {
|
|
|
|
self.setData({
|
|
|
|
userInfo: res,
|
|
|
|
});
|
|
|
|
callback?.(res);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
getMenuInfo(self) {
|
|
|
|
const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
|
|
|
|
self.setData({
|
|
|
|
menuButtonInfo,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|