无论是在微信开发者工具预览还是真机调试,或者是小程序正式发布后都无法继续执行下去,然而在模拟器里却正常,我也改掉了之前两个老的接口,也没获取微信用户昵称和头像啊
<template>
<view class="content">
<image :src="imgURL" class="image"></image>
<button type="warn" class="login_button" @click="int()">
<view class="word">
登
</view>
<view class="word">
录
</view>
</button>
</view>
</template>
<script>
import common from '@/pages/common/common.js'
var status
export default {
data() {
return {
status:'0',
imgURL:'/static/background_image1.jpg',
ischeck:true,
t:''
}
},
methods: {
int()
{
uni.login({
provider: 'weixin',
success: function(loginRes) {
console.log(loginRes)
//获取openid
uniCloud.callFunction({
name:'user',
data:
{
code:loginRes.code,
avatarUrl:'https://great.wzznft.com/i/2023/01/30/xiafwg.png',
nickName:"知蛛"
}
})
.then(res=>{
// console.log("this.avatarUrl="+this.avatarUrl)
console.log("res.result.avatarUrl="+res.result.avatarUrl)
uni.setStorageSync('openid',res.result.openid)
uni.setStorageSync('avatarUrl',res.result.avatarUrl)
uni.setStorageSync('nickName',res.result.nickName)
var adminBd=false
var openid=uni.getStorageSync('openid')
uniCloud.database().collection('info').where({openid:openid}).field("_id,status,openid,key").get().then(res => {
var adminList = res.result.data
console.log("res.result.data="+res.result.data)
var key
var status
var _id
adminList.forEach(async(item)=>{
key=item.key
status=item.status
_id=item._id
})
if(res.result.data.length==0)
{
uni.showModal({
title: '提示',
content: '你还未注册',
cancelText: '退出',
confirmText: '去注册',
success(res)
{
if (res.confirm)
{
console.log('用户点击去注册');
uni.navigateTo({
url:'/pages/login/register'
})
}
else
{
console.log('用户点击退出');
}
}
});
}
else
{
uni.setStorageSync('key',key)
console.log("hahaha")
console.log("status="+status)
if(status==1)
{
uni.setStorageSync('user_id',_id)
common.index[0]=0
common.index[1]=0
common.index[2]=1
common.index[3]=0
console.log("common.index[0]="+common.index[0])
console.log("common.index[1]="+common.index[1])
console.log("common.index[2]="+common.index[2])
uni.reLaunch({
url:'/pages/votion/vote'
})
}
else
{
uni.showModal({
content: '您的账号还在审核中',
success: function (res) {
if (res.confirm)
{
console.log('用户点击确定');
}
else if (res.cancel)
{
console.log('用户点击取消');
}
}
})
}
}
}).catch(err => {console.log(err); })
})
}
})
}
}
}
</script>
2***@qq.com (作者)
谢谢
2023-01-31 10:48