小程序微信授权成功后,执行任何操作页面都会卡死;小程序没有发布正式版,用户隐私保护指引配置了没有生效,页面卡死和用户隐私指引有关嘛?还是页面逻辑的问题?
<template>
<view class="contain-box">
<view class="item-png">
<image src="@/static/logo.png" class="logo-img"></image>
</view>
<view class="item-text">
欢迎来到xxxxxxx
</view>
<view class="item-text">
报障小程序
</view>
<view class="wxLogin-box" @click="wxLogin">
<view class="">
<image src="@/static/whitWxLogin.png" class="wxLogin-png" mode=""></image>
</view>
<view class="wx-login">微信快捷登录</view>
</view>
</view>
<!-- <xc-wxLogin ref="childrenIsShowPopup" @savevalue="saveValue">
</xc-wxLogin> -->
<!-- 授权弹框 -->
<u-popup v-model="isShowPopup" mode="bottom" border-radius="10" :mask-close-able="false" :closeable="false"
z-index="99999">
<view class="prop-top">
<view>
<image src="@/static/logo.png" class="logo-img"></image>
</view>
<view class="prop-bank">
xxxxx报障小程序 申请获取以下权限:
</view>
</view>
<view class="prop-center">
<span class="circle"></span>申请获取并验证你的手机号
</view>
<view class="prop-bottom">
<button class="delete-login" @click="deleteLogin">拒绝</button>
<view @click="allowBtn">
<button class="allow-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"
:phone-number-no-quota-toast="false"> 允许 </button>
</view>
</view>
</u-popup>
<!-- 用户隐私保护指引 -->
<xc-privacyPopup ref="privacyComponent" position="center" @allowPrivacy="allowPrivacy"></xc-privacyPopup>
<!-- 引用loding -->
<xc-loading v-if="this.$store.getters.loding"></xc-loading>
<!-- 引用弹框组件 -->
<xc-confirmPopup v-if="confirmPopup" @cancelBtn="cancelBtn" :content="popupcontent"></xc-confirmPopup>
</template>
<script>
import {
formatMobilePhone,
formatLoginName
} from '@/utils/util.js';
import localStorage from '@/utils/localStorage.js'
export default {
data() {
return {
confirmPopup: false, // 弹框默认隐藏
popupcontent: '', // 弹框内容
isShowPopup: false,
Code: '',
};
},
onShow() {
uni.hideHomeButton({
success: function() {}
});
// 查询隐私协议
if (wx.getPrivacySetting) {
wx.getPrivacySetting({
success: res => {
if (!res.needAuthorization) {
this.$refs.privacyComponent.closePrivacy();
// 查询授权
this.queryAuthLogin();
}
},
fail: () => {},
complete: () => {}
})
} else {
this.queryAuthLogin();
}
},
methods: {
//微信授权登录
wxLogin() {
// this.$refs.childrenIsShowPopup.openPropup();
this.isShowPopup = true;
this.getCode();
},
// 拒绝授权
deleteLogin() {
this.isShowPopup = false;
},
// 允许授权
allowBtn() {
this.isShowPopup = false;
},
// 获取Code
getCode() {
let that = this;
uni.login({
timeout: 10000,
provider: 'weixin',
success: function(data) {
//获取临时登录凭证code
that.Code = data.code;
},
fail: function(err) {
// console.log("loginerr", err);
}
})
},
// 允许授权
getPhoneNumber: function(e) {
console.log('授权打印', e)
let that = this;
if (!e.detail.code) {
uni.showToast({
title: '获取手机号失败',
icon: 'none'
})
return;
}
if (e.detail.errno == '1400001') {
that.confirmPopup = true;
that.popupcontent = '微信授权次数已用尽,请联系工作人员';
} else {
if (e.detail.errMsg == 'getPhoneNumber:ok') {
that.encryptedData = e.detail.encryptedData;
that.iv = e.detail.iv;
const parmas = {
code: that.Code,
encryptedData: that.encryptedData,
iv: that.iv,
operate: '1',
channelId: 'ssvb_minip'
}
console.log('授权上送字段', parmas)
that.$api.wxAuth(parmas).then(async (res) => {
console.log('申请授权', res)
if (res.code == 'BSC00000') {
console.log('授权处理成功')
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
}
// 存储数据
// localStorage.set('weixinLogin', weixinLogin)
await that.$store.commit('SET_WEIXINLOGIN', weixinLogin);
if (res.data.roleId == 0) {
that.toReport();
} else if (res.data.roleId == 1) {
that.tohandle();
}
} else {
that.wamingPopup = true;
that.popupcontent = res.msg;
}
}).catch(error => {
that.confirmPopup = true;
that.popupcontent = error.errMsg;
});
}
}
},
// 工单上报
toReport() {
console.log('跳转工单上报页')
// setTimeout(() => {
// uni.redirectTo({
// url: '/reportObstacles/report/index'
// })
// }, 20000);
uni.redirectTo({
url: '/reportObstacles/report/index'
})
},
// 工单处理
tohandle() {
uni.redirectTo({
url: '/reportObstacles/handle/index'
})
},
// 同意隐私协议
allowPrivacy() {
// 查询授权
this.queryAuthLogin();
},
// 微信授权保存数据
// saveValue(roleId) {
// if (roleId == 0) {
// this.toReport();
// } else if (roleId == 1) {
// this.tohandle();
// }
// },
// 查询授权
queryAuthLogin() {
let that = this;
uni.login({
timeout: 10000,
provider: 'weixin',
success: function(data) {
console.log('data', data)
//获取临时登录凭证codC
that.Code = data.code;
const parmas = {
code: that.Code,
operate: '0',
channelId: 'ssvb_minip'
}
that.$api.wxAuth(parmas).then(async (res) => {
if (res.code == 'BSC00000') {
console.log('查询授权', res)
if (res.data.user_id != null && res.data.user_id != '' && res.data
.user_id !=
undefined) {
that.phoneNumber = res.data.user_name;
that.phoneNumberFormat = formatMobilePhone(res.data.user_name);
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.tokenType + " " + res.data.value,
tokenType: res.data.tokenType,
sm2_prvkey: res.data.sm2_prvkey
}
// 存储数据
// localStorage.set('weixinLogin', weixinLogin)
await that.$store.commit('SET_WEIXINLOGIN', weixinLogin);
if (res.data.roleId == 0) {
that.toReport();
} else if (res.data.roleId == 1) {
that.tohandle();
}
}
} else if (res.code == 'MINIP_00010') {
console.log(res.msg)
} else {
that.confirmPopup = true;
that.popupcontent = res.msg;
}
}).catch(error => {
that.confirmPopup = true;
that.popupcontent = error.errMsg;
});
},
fail: function(err) {
// console.log("loginerr", err);
}
})
},
// 弹框隐藏
cancelBtn() {
this.confirmPopup = false;
},
}
}
</script>
上面是授权页面的标签和js代码
你好,麻烦在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,麻烦提供一下微信号,时间点