| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- windowHeight:wx.getSystemInfoSync().windowHeight * (750 / wx.getSystemInfoSync().windowWidth),
- },
- selectRole(e){
- var role = e.currentTarget.dataset.role;
- var that = this;
- app.requestP({
- url:'/role/changeRole',
- method:'post',
- contentType:' application/json',
- data:{
- roleCode:role
- }
- }).then(res=>{
- //通过token来判断是否是登录状态
- var token = wx.getStorageSync('token');
- //如果有token,则去拉取用户数据,相反则只显示界面
- if(token){
- app.requestP({
- url: "/user/getUserInfo",
- }).then(function(res){
- const {ifOverFlow,loginRole} = res.data.data;
- //移除之前缓存的用户信息,确保拿到用户最新数据
- wx.removeStorageSync('userInfo');
- wx.setStorageSync('userInfo',res.data.data);
- //admin 管理员 doctor 医生 register 自由注册 可申请为操作员 personnel 操作员 已选择企业未认证
- if(ifOverFlow == 'N'){
- if(loginRole == 'personnel'){
- that.showModel('/pages/userAuth/workerSelect');
- }else if(loginRole == 'doctor'){
- that.showModel('/pages/userAuth/doctorInfo');
- }else if(loginRole == 'admin'){
- that.showModel('/pages/userAuth/adminInfo');
- }
- }else{
- app.showToptip(that,'success','身份切换成功');
- wx.navigateBack({
- delta: 1
- });
- }
- }).catch(err=>{
- app.showToptip(that,'error',err.data.msg)
- })
- }
- }).catch(err=>{
- app.showToptip(that,'error',err.data.msg);
- })
- },
- showModel(url){
- wx.showModal({
- title: '您还未认证,暂无权限',
- // content: '确定要删除该图片?',
- showCancel: true, //是否显示取消按钮
- cancelText: "取消", //默认是“取消”
- cancelColor: '#000', //取消文字的颜色
- confirmText: "去认证", //默认是“确定”
- confirmColor: '#2D59E6', //确定文字的颜色
- success: function (res) {
- if (res.cancel) {
- //点击取消,默认隐藏弹框
- } else {
- //点击去认证
- wx.navigateTo({
- url: url,
- })
- }
- },
- fail: function (res) {}, //接口调用失败的回调函数
- complete: function (res) {}, //接口调用结束的回调函数(调用成功、失败都会执行)
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|