日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

uniapp 生成html5_uni-app 登录(h5+ app 篇)

發(fā)布時(shí)間:2024/3/13 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 uniapp 生成html5_uni-app 登录(h5+ app 篇) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

完整代碼

微信登錄

微信登錄

手機(jī)號(hào)碼登錄

var _self;

export default {

data:{

},

onLoad:function(){

_self = this;

},

methods:{

getuserinfoh5appwx: function(){

uni.login({

success:function(res2){

console.log(JSON.stringify(res2) + '2');

uni.getUserInfo({

success:function(res3){

console.log(JSON.stringify(res3) + '3');

}

})

},

});

},

getuserinfo : function(res1){

console.log(JSON.stringify(res1) + '1');

//如果只需要opendid 和非加密數(shù)據(jù)至此登錄完成

//此處連接數(shù)據(jù)庫(kù)利用openid 就可以進(jìn)行登錄環(huán)節(jié)

//免費(fèi)的視頻教程 http://www.hcoder.net/tutorials/info_141.html

uni.login({

success:function(res2){

console.log(JSON.stringify(res2) + '2');

//獲取 sessionKey

uni.request({

url : 'https:///hoa.hcoder.net/xcxencode/?c=sk&appid=wxbb7f9f1f2c6f4f33&secret=739b970b832f0df158f54c494a08e440&code='+res2.code,

success:function(res3){

console.log(JSON.stringify(res3) + '3');

//記錄到本地

try{

uni.setStorageSync('sk', res3.data.session_key);

uni.setStorageSync('openid', res3.data.openid);

}catch(e){

//TODO handle the exception

}

uni.hideLoading();

//以下步驟可以獲取加密信息,需要授權(quán)

//獲取加密信息

if(!res1.detail.iv){

uni.showToast({

title:"您取消了授權(quán),登錄失敗",

icon:"none"

});

return false;

}

try{

var sessionKey = uni.getStorageSync('sk');

console.log(sessionKey);

}catch(e){

//TODO handle the exception

}

uni.request({

/**

* $appid = $_POST['appid'];

$sessionKey = $_POST['sessionKey'];

$encryptedData = $_POST['encryptedData'];

$iv = $_POST['iv'];

*/

method : "POST",

url : 'https:///hoa.hcoder.net/xcxencode/',

header : {'content-type':'application/x-www-form-urlencoded'},

data : {

appid : "wxbb7f9f1f2c6f4f33",

sessionKey : sessionKey,

iv : res1.detail.iv,

encryptedData : res1.detail.encryptedData

},

success:function(res4){

//"{"openId":"oS6of0V0rdp9nY_BuvCnQUasOHYc","nickName":"深海",

//"gender":1,"language":"zh_CN","city":"Xi'an","province":"Shaanxi",

//"country":"China","avatarUrl":"https://wx.qlogo.cn/mmopen/vi_32/7iags6YD4enyU"

console.log(JSON.stringify(res4) + '4');

//至此登錄完成

}

});

}

})

}

});

}

}

}

總結(jié)

以上是生活随笔為你收集整理的uniapp 生成html5_uni-app 登录(h5+ app 篇)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。