Commit 60c0f1cd authored by 罗超's avatar 罗超

完善登录流程

parent bb2971ce
......@@ -175,8 +175,6 @@
uni.hideLoading();
if (res.resultCode == 1) {
this.showDialog = false;
//小程序用户名称
let mallUserName = res.data.Name;
uni.setStorageSync("mall_UserInfo", res.data);
that.$emit("changeuserinfo");
if (res.couponResultCode == 1) {
......@@ -191,65 +189,119 @@
uni.removeStorageSync("Up");
uni.removeStorageSync("CounponPassword");
uni.removeStorageSync("KeyWord");
let uid = uni.getStorageSync("mall_UserInfo").UserId;
that.msg.Id = uid;
//HK 2023-10-31 新增
let b2bLoginParam = {
OpenId: res.data.OpenId
}
let b2bResult = {
accountId: 0,
customerId: 0,
customerInfoChildrenId: 0,
realNameAuthentication: 0,
account: "",
name: mallUserName,
customerName: "",
photo: "",
secretKey: "",
token: "",
groupId: 0,
isMember: 0,
createBy: "",
EmLoginMobile: "",
contactNumber: "",
salesBaseInfo: {},
count: 0,
customerType: 2, //直客,2-同行
directCustomerId: 0, //直客Id
}
that.apipost("LvXiaoYou_post_GetLvXiaoYouCustomerLogin", b2bLoginParam, b2bRes => {
var b2bData = b2bRes.data;
if (b2bRes.resultCode == 1) {
b2bResult.accountId = b2bData.customerAccountId;
b2bResult.customerId = b2bData.customerId;
b2bResult.customerInfoChildrenId = b2bData.customerInfoChildrenId;
b2bResult.name = b2bData.name;
b2bResult.customerName = b2bData.customerName;
b2bResult.token = b2bData.token;
b2bResult.isMember = b2bData.isMember;
b2bResult.account = b2bData.account;
b2bResult.createBy = b2bData.createBy;
b2bResult.salesBaseInfo = b2bData.salesBaseInfo;
b2bResult.groupId = b2bData.groupId;
b2bResult.contactNumber = b2bData.contactNumber;
uni.setStorageSync('b2b_user', b2bResult)
that.$emit("changeuserinfo");
uni.setStorageSync("lastLogin",new Date().getTime())
} else {
uni.redirectTo({
url: '/pages/jiuzhai/bind_Customer'
})
}
}, (error2) => {
uni.redirectTo({
url: '/pages/jiuzhai/bind_Customer'
})
});
const {OpenId,Unoinid,Name} = res.data
// let uid = uni.getStorageSync("mall_UserInfo").UserId;
// that.msg.Id = uid;
// #ifdef MP-AG
this.agentUserLoginHandle(OpenId,Name)
// #endif
// #ifdef MP-DI
this.directUserLoginHandle(OpenId,Unoinid,Name)
// #endif
}
}
);
},
directUserLoginHandle(OpenId,Unoinid,Name){
let Pid = 0
if(uni.getStorageSync('direct_user_id')){
Pid = uni.getStorageSync('direct_user_id')
if(isNaN(Pid)) Pid = 0
}
const parameters={
OpenId,
Unoinid,
Pid
}
this.apipost("HePingGuoLvLogin_post", parameters, r =>{
const u = r.data
const user = {
accountId: u.directCustomerId,
customerId: u.directCustomerId,
customerInfoChildrenId: u.directCustomerId,
realNameAuthentication: 0,
account: "",
name: Name,
customerName: u.name,
photo: u.photo,
secretKey: "",
token: u.token,
groupId: 0,
isMember: 0,
createBy: u.pid,
EmLoginMobile: u.moblie,
contactNumber: u.moblie,
salesBaseInfo: u.salesBaseInfo,
count: 0,
customerType: 1, //直客,2-同行
directCustomerId: u.directCustomerId //直客Id
}
uni.setStorageSync('b2b_user', user)
this.$emit("changeuserinfo");
uni.setStorageSync("lastLogin",new Date().getTime())
},e=>{
uni.showToast({
title:'用户登录失败',
icon:'none'
})
})
},
agentUserLoginHandle(openId,Name){
var that = this;
let b2bLoginParam = {
OpenId: openId
}
let b2bResult = {
accountId: 0,
customerId: 0,
customerInfoChildrenId: 0,
realNameAuthentication: 0,
account: "",
name: Name,
customerName: "",
photo: "",
secretKey: "",
token: "",
groupId: 0,
isMember: 0,
createBy: "",
EmLoginMobile: "",
contactNumber: "",
salesBaseInfo: {},
count: 0,
customerType: 2, //直客,2-同行
directCustomerId: 0, //直客Id
}
that.apipost("LvXiaoYou_post_GetLvXiaoYouCustomerLogin", b2bLoginParam, b2bRes => {
var b2bData = b2bRes.data;
if (b2bRes.resultCode == 1) {
b2bResult.accountId = b2bData.customerAccountId;
b2bResult.customerId = b2bData.customerId;
b2bResult.customerInfoChildrenId = b2bData.customerInfoChildrenId;
b2bResult.name = b2bData.name;
b2bResult.customerName = b2bData.customerName;
b2bResult.token = b2bData.token;
b2bResult.isMember = b2bData.isMember;
b2bResult.account = b2bData.account;
b2bResult.createBy = b2bData.createBy;
b2bResult.salesBaseInfo = b2bData.salesBaseInfo;
b2bResult.groupId = b2bData.groupId;
b2bResult.contactNumber = b2bData.contactNumber;
uni.setStorageSync('b2b_user', b2bResult)
that.$emit("changeuserinfo");
uni.setStorageSync("lastLogin",new Date().getTime())
} else {
uni.redirectTo({
url: '/pages/jiuzhai/bind_Customer'
})
}
}, (error2) => {
uni.redirectTo({
url: '/pages/jiuzhai/bind_Customer'
})
});
},
updateuserinfo(msg) {
this.request2({
url: "/api/MemberUser/SetMemberPhoto",
......@@ -266,129 +318,7 @@
},
closeBtn() {
this.showCoupons = false;
},
// -------------------------------支付宝登录---------------------------------
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;
my.getAuthCode({
scopes: "auth_base", // 主动授权(弹框):auth_user,静默授权(不弹框):auth_base
success: (res) => {
if (res.authCode) {
let obj = {
Name: info.nickName,
Photo: info.avatar ? info.avatar : "123",
Gender: info.gender === "m" ? 1 : info.gender === "f" ? 2 : 0,
Moblie: "",
code: res.authCode,
};
that.getCodeAli(obj);
}
},
fail: () => {
uni.showToast({
title: "授权失败",
icon: "none",
});
},
});
},
//调用获取code
getCodeAli(obj) {
var that = this;
uni.showLoading({
title: "登录中..",
});
//这里请求接口
that.request2({
url: "/api/mall/GetAliCode",
data: {
Code: obj.code,
},
},
(res) => {
if (res.resultCode == 1) {
obj.OpenId = res.data;
that.getLoginAli(obj);
}
}
);
},
//登录
getLoginAli(obj) {
var that = this;
that.showLogin = false;
let pid = uni.getStorageSync("pid") ? uni.getStorageSync("pid").pid : 0;
let Up = uni.getStorageSync("Up") ? uni.getStorageSync("Up").Up : 0;
let SmallShopId = uni.getStorageSync("SmallShopId") ?
uni.getStorageSync("SmallShopId").SmallShopId :
0;
let CounponPassword = uni.getStorageSync("CounponPassword") ?
uni.getStorageSync("CounponPassword").CounponPassword :
0;
let KeyWord = uni.getStorageSync("KeyWord") ?
uni.getStorageSync("KeyWord").KeyWord :
"";
that.request2({
url: "/api/AppletLogin/Login",
data: {
Source: 2,
OpenId: obj.OpenId,
Name: obj.Name,
Photo: obj.Photo,
Gender: obj.Gender,
Moblie: "",
SuperiorId: pid,
SmallShopId: SmallShopId,
UserPageType: Up,
CounponPassword: CounponPassword,
KeyWord: KeyWord,
},
},
(res) => {
uni.hideLoading();
that.showLogin = true; //防止多次点击登录
if (res.resultCode == 1) {
this.showDialog = false;
uni.setStorageSync("mall_UserInfo", res.data);
that.$emit("changeuserinfo");
if (res.couponResultCode == 1) {
if (uni.getStorageSync("ComeFrom")) {
that.ComeFrom = uni.getStorageSync("ComeFrom").ComeFrom;
}
that.showCoupons = true;
that.couponMessage = res.couponMessage;
}
uni.removeStorageSync("pid");
uni.removeStorageSync("SmallShopId");
uni.removeStorageSync("Up");
uni.removeStorageSync("CounponPassword");
uni.removeStorageSync("KeyWord");
let uid = uni.getStorageSync("mall_UserInfo").UserId;
that.msg.Id = uid;
let IsOpenMiAi = uni.getStorageSync("basedata") ?
uni.getStorageSync("basedata").mall.setting.is_show_miai :
0; //是否开启相亲模式
if (IsOpenMiAi == 0) {
//不是相亲模式的时候去更新头像和昵称
// #ifdef MP-WEIXIN
that.updateuserinfo(that.msg); //更新用户头像
// #endif
}
}
}
);
},
}
},
};
</script>
......
......@@ -54,16 +54,6 @@
</template>
</view>
</template>
<!-- #ifdef MP-DI -->
<view class="">
直客 MP
</view>
<!-- #endif -->
<!-- #ifdef MP-AG -->
<view class="">
同业 MP
</view>
<!-- #endif -->
<coupon v-if="showCoupons" :coupon-message="couponMessage" :cform="ComeFrom" @goLook="()=>showCoupons = false" @closeBtn="()=>showCoupons = false"></coupon>
<auth v-if="showAuth" @changeuserinfo="reloadUserinfo" @gbAuth="gbAuth"></auth>
<official-account></official-account>
......@@ -167,7 +157,9 @@
}
const mu = uni.getStorageSync('mall_UserInfo')
const bu = uni.getStorageSync('b2b_user')
if(!mu || !bu) this.showAuth= true
this.init()
uni.showNavigationBarLoading();
if (uni.getStorageSync('coupons')) {
......
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