const api = require('../../utils/api.js')
|
|
Page({
|
|
data: {
|
|
statusBarHeight: 44,
|
|
baseURL: api.baseURL
|
|
},
|
|
getUserProfile(e) {
|
|
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
|
|
wx.getUserProfile({
|
|
desc: '授权登录', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
|
|
success: (data) => {
|
|
wx.login({
|
|
success({
|
|
code
|
|
}) {
|
|
if (code) {
|
|
//发起网络请求
|
|
api.post('/api/wxlogin', {
|
|
...data,
|
|
code: code
|
|
}).then(({
|
|
data
|
|
}) => {
|
|
// 存储用户uid
|
|
wx.setStorage({
|
|
key: "userInfo",
|
|
data: {...data}
|
|
})
|
|
|
|
// 授权成功关闭当前页面,跳转至基础信息登记页面
|
|
wx.redirectTo({
|
|
url: '../basicInformation/basicInformation'
|
|
})
|
|
})
|
|
|
|
} else {
|
|
console.log('登录失败!' + res.errMsg)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
});
|
|
},
|
|
// 分享朋友
|
|
onShareAppMessage: (res) => {
|
|
let data = '';
|
|
wx.getStorage({
|
|
key: 'project',
|
|
success({
|
|
data: {
|
|
surveysheetid = '',
|
|
cid = ''
|
|
}
|
|
}) {
|
|
data = `?surveysheetid=${surveysheetid}&cid=${cid}`
|
|
}
|
|
})
|
|
return {
|
|
title: '业主思维',
|
|
path: '/pages/basicInformation/basicInformation' + data,
|
|
imageUrl: api.baseURL+"/public/uploadfile/logo.png",
|
|
success: (res) => {
|
|
console.log("转发成功", res);
|
|
},
|
|
fail: (res) => {
|
|
console.log("转发失败", res);
|
|
}
|
|
}
|
|
},
|
|
// 分享朋友圈
|
|
onShareTimeline: (res) => {
|
|
let data = '';
|
|
wx.getStorage({
|
|
key: 'project',
|
|
success({
|
|
data: {
|
|
surveysheetid = '',
|
|
cid = ''
|
|
}
|
|
}) {
|
|
data = `?surveysheetid=${surveysheetid}&cid=${cid}`
|
|
}
|
|
})
|
|
return {
|
|
title: '业主思维',
|
|
path: '/pages/basicInformation/basicInformation' + data,
|
|
imageUrl: api.baseURL+"/public/uploadfile/logo.png",
|
|
success: (res) => {
|
|
console.log("转发成功", res);
|
|
},
|
|
fail: (res) => {
|
|
console.log("转发失败", res);
|
|
}
|
|
}
|
|
},
|
|
onShow() {
|
|
// 获取设备的信息
|
|
let systemInfo = wx.getSystemInfoSync();
|
|
// 获取信号区高度, 并设置标题高度
|
|
let statusBarHeight = systemInfo['statusBarHeight']
|
|
if (systemInfo.platform === 'andorid') {
|
|
statusBarHeight = statusBarHeight + 1;
|
|
} else if (systemInfo.platform === 'ios') {
|
|
statusBarHeight = statusBarHeight + 6;
|
|
} else {
|
|
statusBarHeight = statusBarHeight;
|
|
}
|
|
this.setData({
|
|
statusBarHeight
|
|
})
|
|
}
|
|
})
|