微信小程序使用微信授权获取手机号成功后,跳转页面,初始化页面调接口时卡死;点小程序右上角三个点再次进入小程序,不走微信授权进入小程序的同一个页面,接口初始化正常,页面渲染正常,这个是啥原因?
// 1、子组件
// 微信授权方法
getPhoneNumber: function(e) {
if (!e.detail.code) {
uni.showToast({
title: '获取手机号失败',
icon: 'none'
})
return;
}
if (e.detail.errno == '1400001') {
if (this.jumpPage == 'pages/my/my') {
uni.hideTabBar();
}
this.confirmPopup = true;
showModal('温馨提示', '微信授权次数已用尽,请联系工作人员');
// clearInterval(this.timer);
// this.messageShow = true;
// this.messageCode = '';
} else {
if (e.detail.errMsg == 'getPhoneNumber:ok') {
this.encryptedData = e.detail.encryptedData;
this.iv = e.detail.iv;
const parmas = {
code: this.Code,
encryptedData: this.encryptedData,
iv: this.iv,
operate: '1',
channelId: 'ssvb_minip'
}
console.log('授权上送字段', parmas)
this.$api.wxAuth(parmas).then((res) => {
console.log('申请授权',res)
if (res.code == 'BSC00000') {
const weixinLogin = {
phoneNumber: res.data.user_name,
phoneNumberFormat: formatMobilePhone(res.data
.user_name),
address: res.data.address,
user_name: res.data.nickName,
roleId: res.data.roleId,
user_id: res.data.user_id,
token: res.data.value,
tokenType: res.data.tokenType,
sm2_pubkey: res.data.sm2_pubkey
}
// 存储授权返回数据,到状态管理
this.$store.commit('SET_WEIXINLOGIN', weixinLogin);
// 给父组件传递方法
this.$emit('savevalue', res.data.roleId)
} else {
this.wamingPopup = true;
this.popupcontent = res.msg;
}
})
}
}
},
// 2、父组件:
// 控制跳转页面
saveValue(roleId) {
if (roleId == 0) {
uni.navigateTo({
url: '/reportObstacles/report/index'
})
} else if (roleId == 1) {
uni.navigateTo({
url: '/reportObstacles/handle/index'
})
}
},
// 3、功能页面
onLoad() {
this.malfunctionGetDict();
},
methods:{
// 位置查询
malfunctionGetDict() {
const parmas = {
dictType: 'ssvb_address'
}
this.$api.malfunctionGetDict(parmas).then(res => {
if (res.code == 'BSC00000') {
this.locationList = res.data;
this.$store.commit('SET_LOCATIONLIST', this.locationList);
this.selectBtn();
} else {
this.confirmPopup = true;
this.popupcontent = res.msg;
}
})
},
// 查询页面数据
selectBtn() {
if (!this.hasMoreData) {
return;
}
const parmas = {
appUserId: this.loginResInfo.user_id,
appUserName: this.loginResInfo.user_name,
page: {
pageSize: this.pageSize, // 每页数据条数
page: this.page
}
}
this.$api.malfunctionSelect(parmas).then(res => {
if (res.code == 'BSC00000') {
let newReportList = res.data.data;
newReportList.forEach(item => {
if (item.level != '' && item.level != undefined && item.level != null) {
if (item.level == '0') {
item.levelFormat = '紧急'
} else if (item.level == '1') {
item.levelFormat = '一般'
} else if (item.level == '2') {
item.levelFormat = '普通'
}
}
if (item.status != '' && item.status != undefined && item.status != null) {
if (item.status == '0') {
item.statusFormat = '待接单'
} else if (item.status == '1') {
item.statusFormat = '已接单'
} else if (item.status == '2') {
item.statusFormat = '退回待接单'
} else if (item.status == '3') {
item.statusFormat = '待评价'
} else if (item.status == '4') {
item.statusFormat = '已完结'
}
}
if (item.appDate != '' && item.appDate != undefined && item.appDate != null) {
item.appDateFormat = formatDateSplice(item.appDate)
}
if (item.appTime != '' && item.appTime != undefined && item.appTime != null) {
item.appTimeFormat = formatDateTim(item.appTime)
}
if (item.fileList.length != 0) {
item.fileList.forEach(iteam => {
if (!iteam.filePath.indexOf('/') == '0') {
iteam.filePath = '/' + iteam.filePath
}
iteam.imgUrl = apiUrl.baseUrl + '/api/file/download' + iteam
.filePath + iteam.fileName
})
}
})
if (newReportList) {
newReportList = filterArr(newReportList, this.locationList);
}
this.reportList = this.reportList.concat(newReportList);
console.log('this.reportList', this.reportList)
if (!res.data.page.pages) {
this.hasMoreData = false;
this.status = 'noMore';
} else if (this.page >= res.data.page.pages) {
this.hasMoreData = false;
this.status = 'noMore';
} else {
this.hasMoreData = true;
this.status = 'more';
}
this.$appletAuthorize.appletAuthorize();
} else {
this.confirmPopup = true;
this.popupcontent = res.msg;
}
})
},
}
没有这个问题,一直都是正常的