Browse Source

登录接口

master
kola-web 5 months ago
parent
commit
5ddd9604fa
  1. 89
      src/app.ts
  2. 8
      src/pages/login/index.ts

89
src/app.ts

@ -1,41 +1,41 @@ @@ -1,41 +1,41 @@
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";
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;
wx.WebIM = require('@/utils/webIM/WebIM.js').default;
const dayjs = require("dayjs");
const licia = require("miniprogram-licia");
const dayjs = require('dayjs');
const licia = require('miniprogram-licia');
require("/utils/dayjs/day-zh-cn.js");
require('/utils/dayjs/day-zh-cn.js');
dayjs.locale("zh-cn"); // 全局使用
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/",
// appid:wx2b0bb13edf717c1d
url: 'https://m.shizhong.hbraas.com',
upFileUrl: 'https://m.shizhong.hbraas.com/',
imageUrl: 'https://m.shizhong.hbraas.com/shizhong/',
// pro
// appid:wx1e025040096c7e1d
// url: 'https://m.raredheart.hbsaas.com',
// upFileUrl: 'https://m.raredheart.hbsaas.com/',
// imageUrl: 'https://m.raredheart.hbsaas.com/wt/',
// url: 'https://m.shizhong.hbsaas.com',
// upFileUrl: 'https://m.shizhong.hbsaas.com/',
// imageUrl: 'https://m.shizhong.hbsaas.com/wt/',
loginState: "",
loginState: '',
isLogin: 0,
doctorId: null,
scene: null,
needDeal: "",
caseNav: "0",
needDeal: '',
caseNav: '0',
},
onLaunch() {
Page = page as WechatMiniprogram.Page.Constructor;
@ -43,21 +43,20 @@ App<IAppOption>({ @@ -43,21 +43,20 @@ App<IAppOption>({
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;
// });
// },
// });
wx.login({
success: (res) => {
wx.ajax({
method: 'GET',
url: '?r=shizhong/user/init-login',
data: {
code: res.code,
},
}).then((res) => {
this.globalData.loginState = res.loginState;
this.globalData.isLogin = res.isLogin;
});
},
});
wx.setInnerAudioOption({
obeyMuteSwitch: false,
@ -68,7 +67,6 @@ App<IAppOption>({ @@ -68,7 +67,6 @@ App<IAppOption>({
if (options.query.scene) {
this.globalData.scene = parseScene(options.query.scene);
}
// this.startLogin();
},
waitLogin(waitLoginState = false) {
let time: number;
@ -79,16 +77,15 @@ App<IAppOption>({ @@ -79,16 +77,15 @@ App<IAppOption>({
if (waitLoginState) {
resolve(true);
} else if (this.globalData.isLogin === 0) {
reject(new Error("未登录"));
wx.reLaunch({ url: "/module1/pages/login/index" });
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("还在审核中"));
wx.reLaunch({ url: '/module1/pages/setInfoResult/index' });
reject(new Error('还在审核中'));
} else {
wx.reLaunch({ url: "/module1/pages/setInfo/index" });
reject(new Error("还不是医生"));
wx.reLaunch({ url: '/module1/pages/setInfo/index' });
reject(new Error('还不是医生'));
}
});
} else {
@ -100,14 +97,14 @@ App<IAppOption>({ @@ -100,14 +97,14 @@ App<IAppOption>({
},
getApplyDoctor() {
return wx.ajax({
method: "GET",
url: "?r=takeda/reg/get-apply-doctor",
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",
method: 'GET',
url: '?r=shizhong/account/info',
data: {},
}).then((res) => {
self.setData({

8
src/pages/login/index.ts

@ -3,7 +3,7 @@ let timer: number | null = 0; @@ -3,7 +3,7 @@ let timer: number | null = 0;
Page({
data: {
show: true,
show: false,
menuButtonInfo: {},
mobile: '',
@ -32,7 +32,7 @@ Page({ @@ -32,7 +32,7 @@ Page({
}
wx.ajax({
method: 'POST',
url: '?r=takeda/login/send-verify-code',
url: '?r=shizhong/login/send-verify-code',
data: {
mobile,
},
@ -82,7 +82,7 @@ Page({ @@ -82,7 +82,7 @@ Page({
}
wx.ajax({
method: 'POST',
url: '?r=takeda/login/reg-login',
url: '?r=shizhong/login/reg-login',
data: {
mobile,
code,
@ -104,7 +104,7 @@ Page({ @@ -104,7 +104,7 @@ Page({
if (iv && encryptedData) {
wx.ajax({
method: 'POST',
url: '?r=takeda/login/wx-reg-login',
url: '?r=shizhong/login/wx-reg-login',
data: {
iv: encodeURIComponent(iv),
encryptedData: encodeURIComponent(encryptedData),

Loading…
Cancel
Save