// pages/mine/mine.js
|
import userservice from '../../../service/userservice';
|
import $f from '../../../service/baserequest';
|
|
const app = getApp();
|
|
Page({
|
/**
|
* 页面的初始数据
|
*/
|
data: {
|
icon1: $f.baseIconUrl + 'res/learn_2.png',
|
|
version: app.globalData.version,
|
//认证状态,[企业, 场景, 个人]
|
authStatus: [],
|
//场景类型
|
sceneType: app.globalData.userInfo.extension2,
|
},
|
|
/**
|
* 生命周期函数--监听页面加载
|
*/
|
onLoad: function (options) {
|
this.setData({
|
userRealName: app.globalData.userInfo.realname,
|
sceneType: app.globalData.userInfo.extension2,
|
});
|
this.getBaseInfo();
|
},
|
|
onShow() {
|
this.getAuthStatus();
|
},
|
|
//获取用户认证状态
|
getAuthStatus() {
|
var that = this;
|
userservice.getAuthStatus(
|
app.globalData.accessToken.openId,
|
app.globalData.accessToken.userId,
|
{
|
success(res) {
|
if (res.success) {
|
that.setData({
|
authStatus: res.data,
|
});
|
} else {
|
wx.showToast({
|
title: res.message,
|
duration: 2000,
|
icon: 'error',
|
});
|
}
|
},
|
},
|
);
|
},
|
|
getBaseInfo() {
|
var that = this;
|
userservice.getBaseInfo(
|
app.globalData.accessToken.userId,
|
{
|
success(data) {
|
if (data.company != null) {
|
that.setData({
|
companyName: data.company.ciName,
|
});
|
}
|
},
|
},
|
app.globalData.accessToken.openId,
|
);
|
},
|
|
logout() {
|
wx.reLaunch({
|
url: '/pages/mUser/userlogin/userlogin',
|
});
|
},
|
|
goto(e) {
|
var url = '';
|
var index = e.currentTarget.dataset.index;
|
switch (index) {
|
case '0':
|
//监测数据
|
url = '/pages/mService/pDevicedata/pDevicedata';
|
break;
|
case '1':
|
//通知管理
|
url = '/pages/mNotice/notice/notice';
|
break;
|
case '2':
|
//技术支持
|
url = '/pages/mUser/pSupport/pSupport';
|
break;
|
case '3':
|
//我的收藏
|
url = '';
|
break;
|
case '4':
|
//我要咨询
|
url = '/pages/mConsult/consultonline/consultonline';
|
break;
|
case '5':
|
//环保日程
|
url = '/pages/mService/pSchedule/pSchedule';
|
break;
|
case '6':
|
//关于
|
url = '/pages/mUser/pAbout/pAbout';
|
break;
|
case '7':
|
//操作指引
|
url = '/pages/mUser/pInstructions/pInstructions';
|
break;
|
case '8':
|
//守法承诺
|
url = '/pages/mPromise/promisehome/promise';
|
break;
|
}
|
if (url != '') {
|
wx.navigateTo({
|
url: url,
|
});
|
} else {
|
wx.showToast({
|
title: '功能敬请期待',
|
duration: 1000,
|
icon: 'none',
|
mask: true,
|
});
|
}
|
},
|
|
//认证
|
gotoAuthentication(e) {
|
//等待认证状态加载完毕
|
if (this.data.authStatus.length == 0) return;
|
var url = '';
|
var index = e.currentTarget.dataset.index;
|
switch (index) {
|
//企业认证
|
case '0':
|
url = '/pages/mUser/companyauthentication/companyauthentication';
|
break;
|
//场景认证
|
case '1':
|
switch (this.data.sceneType) {
|
case '1':
|
url = '/pages/mUser/sceneauthentication/sceneauthentication';
|
break;
|
case '6':
|
url = '/pages/mUser/sceneauthentication/industrial/index';
|
break;
|
default:
|
url = '/pages/mUser/sceneauthentication/sceneauthentication';
|
break;
|
}
|
break;
|
//个人认证
|
case '2':
|
url = '/pages/mUser/personalauthentication/personalauthentication';
|
break;
|
}
|
if (url != '') {
|
wx.navigateTo({
|
url: url,
|
success: res => {
|
res.eventChannel.emit('acceptDataFromOpenerPage', {
|
authStatus: this.data.authStatus[parseInt(index)],
|
});
|
},
|
});
|
} else {
|
wx.showToast({
|
title: '功能敬请期待',
|
duration: 1000,
|
icon: 'none',
|
mask: true,
|
});
|
}
|
},
|
|
//环信码
|
gotoQrcode() {
|
wx.navigateTo({
|
url: '/pages/mUser/pQrcode/pQrcode',
|
// success: (res) => {
|
// res.eventChannel.emit('acceptDataFromOpenerPage', app.globalData.)
|
// },
|
});
|
},
|
});
|