Commit cb33fc1e authored by 罗超's avatar 罗超

1

parent 3feb2fbf
...@@ -23,18 +23,12 @@ ...@@ -23,18 +23,12 @@
></button> ></button>
<!-- #endif --> <!-- #endif -->
<!-- #ifdef MP-ALIPAY --> <!-- #ifdef MP-ALIPAY -->
<!-- <button
:style="sureStyle"
class="hotsopt"
open-type="getAuthorize"
v-if="!canIUseGetUserProfile"
@getuserinfo="showLogin ? getoldUser() : ''"
></button> -->
<button <button
:style="sureStyle" :style="sureStyle"
class="hotsopt" class="hotsopt"
v-if="canIUseGetUserProfile" open-type="getAuthorize"
@tap="showLogin ? getUserInfoAli() : ''" @getAuthorize="onGetAuthorize"
scope="userInfo"
></button> ></button>
<!-- #endif --> <!-- #endif -->
<button :style="cancelStyle" class="hotsopt" @click="close"></button> <button :style="cancelStyle" class="hotsopt" @click="close"></button>
...@@ -284,73 +278,30 @@ export default { ...@@ -284,73 +278,30 @@ export default {
}, },
// -------------------------------支付宝登录--------------------------------- // -------------------------------支付宝登录---------------------------------
getUserProfileAli() { onGetAuthorize(res) {
//新的获取用户资料 let that = this;
var that = this; my.getOpenUserInfo({
wx.getUserProfile({ success: (_res) => {
desc: "用于完善资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 let userInfo = JSON.parse(_res.response).response; // 以下方的报文格式解析两层 response
success: (info) => { that.getUserInfoAli(userInfo);
console.log(info);
this.msg = {
Id: 0,
AliasName: info.userInfo.nickName,
Photo: info.userInfo.avatarUrl,
};
that.getUserInfo(info);
},
fail: () => {
uni.showToast({
title: "微信登录授权失败",
icon: "none",
});
}, },
}); });
}, },
getUserInfoAli(info) { getUserInfoAli(info) {
var that = this; var that = this;
that.showDialog = true; that.showDialog = true;
// uni.login({
// scopes: "auth_user",
// success: (res) => {
// //这里请求接口
// let obj = {
// Source: 1,
// OpenId: "",
// Name: info.userInfo.nickName,
// Photo: info.userInfo.avatarUrl,
// Gender: info.userInfo.gender,
// Moblie: "",
// SuperiorId: 0,
// code: res.code,
// };
// // that.getCode(obj);
//
// },
// fail: () => {
// uni.showToast({
// title: "授权失败",
// icon: "none",
// });
// },
// });
my.getAuthCode({ my.getAuthCode({
scopes: "auth_user", // 主动授权(弹框):auth_user,静默授权(不弹框):auth_base scopes: "auth_base", // 主动授权(弹框):auth_user,静默授权(不弹框):auth_base
success: (res) => { success: (res) => {
console.log(296, res);
if (res.authCode) { if (res.authCode) {
let obj = { let obj = {
// Source: 1, Name: info.nickName,
// OpenId: "", Photo: info.avatar ? info.avatar : "123",
// Name: info.userInfo.nickName, Gender: info.gender === "m" ? 1 : info.gender === "f" ? 2 : 0,
// Photo: info.userInfo.avatarUrl, Moblie: "",
// Gender: info.userInfo.gender,
// Moblie: "",
// SuperiorId: 0,
code: res.authCode, code: res.authCode,
}; };
// console.log(app.serverUrl + '/login/' + res.authCode);
// 调用自己的服务端接口,让服务端进行后端的授权认证
that.getBaseInfoAli();
console.log(327, res);
that.getCodeAli(obj); that.getCodeAli(obj);
} }
}, },
...@@ -362,22 +313,13 @@ export default { ...@@ -362,22 +313,13 @@ export default {
}, },
}); });
}, },
getBaseInfoAli() {
my.getOpenUserInfo({
success: (res) => {
let userInfo = JSON.parse(res.response).response; // 以下方的报文格式解析两层 response
console.log(369, res, userInfo);
},
});
},
//调用获取code //调用获取code
getCodeAli(obj) { getCodeAli(obj) {
var that = this; var that = this;
// uni.showLoading({ uni.showLoading({
// title: "登录中", title: "登录中",
// }); });
//这里请求接口 //这里请求接口
var OpenId = "";
that.request2( that.request2(
{ {
url: "/api/mall/GetAliCode", url: "/api/mall/GetAliCode",
...@@ -388,7 +330,7 @@ export default { ...@@ -388,7 +330,7 @@ export default {
(res) => { (res) => {
if (res.resultCode == 1) { if (res.resultCode == 1) {
obj.OpenId = res.data; obj.OpenId = res.data;
// that.getLoginAli(obj); that.getLoginAli(obj);
} }
} }
); );
...@@ -413,7 +355,7 @@ export default { ...@@ -413,7 +355,7 @@ export default {
{ {
url: "/api/AppletLogin/Login", url: "/api/AppletLogin/Login",
data: { data: {
Source: 1, Source: 2,
OpenId: obj.OpenId, OpenId: obj.OpenId,
Name: obj.Name, Name: obj.Name,
Photo: obj.Photo, Photo: obj.Photo,
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment