Commit cb33fc1e authored by 罗超's avatar 罗超

1

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