智慧申请系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

169 lines
4.5 KiB

/*
* @Description:
* @Author: 诺
* @Date: 2021-10-17 11:49:57
* @LastEditors: 诺
* @LastEditTime: 2022-03-20 17:58:20
*/
const app = getApp(),
gData = app.globalData;
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
menus: [
[
{img:'/images/icon14.png',name:'智慧验证',type:'familys',loginType:'104'},
]
],
canIUseGetUserProfile: false
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
wx.login({
success: (res)=> {
this.setData({
wxCode: res.code
})
}
})
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse){
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}
},
getUserInfo: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
},
getUserProfile: (e)=>{
wx.getUserProfile({
desc: '用于完善会员资料',
success: (res) => {
const nickname = res.userInfo.nickName;
var apiType = e.currentTarget.dataset.item;
if(apiType === 'family' || apiType === 'elder' || apiType === 'help' || apiType === 'familys') {
wx.login({
success: (res)=> {
app.ajax(`jjSubsidyApply/client/user/login/${res.code}`, 'post', {name: nickname}, null, (res)=> {
gData.token = res.token;
let urls = {
'family': '/pages/family/index/index',
'familys': '/pages/familys/community/community',
};
apiType.indexOf('family') > -1 ? app.justpage(urls[apiType]) : app.justpage(`/pages/${apiType}/advanced/advanced`);
}, (err)=> {
app.tips(err)
})
},
fail: (err)=> {
console.log(err)
app.tips(err)
}
})
return;
}
if(apiType === 'familys') {
app.justpage("/pages/familys/community/community")
}
if(apiType === 'signture') {
app.justpage("/pages/signature/signature");
return;
}
if (apiType) {
app.globalData.apiType = apiType;
app.globalData.loginType = e.currentTarget.dataset.logintype;
app.justpage("../login/login");
} else {
app.tips("该功能暂未开放");
}
}
})
},
goto:function(e){
var apiType = e.currentTarget.dataset.item;
if(apiType === 'family' || apiType === 'elder' || apiType === 'help' || apiType === 'familys') {
wx.login({
success: (res)=> {
app.ajax(`jjSubsidyApply/client/user/login/${res.code}`, 'get', {}, null, (res)=> {
gData.token = res.token;
let urls = {
'family': '/pages/family/index/index',
'familys': '/pages/familys/community/community',
};
apiType.indexOf('family') > -1 ? app.justpage(urls[apiType]) : app.justpage(`/pages/${apiType}/advanced/advanced`);
}, (err)=> {
app.tips(err)
})
},
fail: (err)=> {
console.log(err)
app.tips(err)
}
})
return;
}
if(apiType === 'familys') {
app.justpage("/pages/familys/community/community")
}
if(apiType === 'signture') {
app.justpage("/pages/signature/signature");
return;
}
if (apiType) {
app.globalData.apiType = apiType;
app.globalData.loginType = e.currentTarget.dataset.logintype;
app.justpage("../login/login");
} else {
app.tips("该功能暂未开放");
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
})