cocos creator:负责生成indexhtml文件
uniapp:
1地址传参,用于用户识别
<web-view ref="webview" src=" >buttonclick:function(event){
let exportJson = {};
let sysInfo = windowwxgetSystemInfoSync();
//获取微信界面大小
let width = sysInfoscreenWidth;
let height = sysInfoscreenHeight;
windowwxlogin({
success: (res) => {
if (rescode) {
consolelog("rescode:", res);
exportJsoncode = rescode;//向服务端传递code用于获取微信小游戏的用户唯一标识
windowwxgetSetting({
success (res) {
consolelog(resauthSetting);
if (resauthSetting["scopeuserInfo"]) {
consolelog("用户已授权");
windowwxgetUserInfo({
success(res){
consolelog(res);
exportJsonuserInfo = resuserInfo;
//此时可进行登录 *** 作
}
});
}else {
consolelog("用户未授权");
let button = windowwxcreateUserInfoButton({
type: 'text',
text: '',
style: {
left: 0,
top: 0,
width: width,
height: height,
backgroundColor: '#00000000',//最后两位为透明度
color: '#ffffff',
fontSize: 20,
textAlign: "center",
lineHeight: height,
}
});
buttononTap((res) => {
if (resuserInfo) {
consolelog("用户授权:", res);
exportJsonuserInfo = resuserInfo;
//此时可进行登录 *** 作
buttondestroy();
}else {
consolelog("用户拒绝授权:", res);
}
});
}
}
})
}else{
consolelog('登录失败!' + reserrMsg)
}
},
});
},
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)