This commit is contained in:
mixtan 2025-05-07 16:27:27 +08:00
commit ee731a4892
3 changed files with 1098 additions and 1148 deletions

View File

@ -1,12 +1,26 @@
<template> <template>
<view class="loginPopup-container"> <view class="loginPopup-container">
<uni-popup ref="popup" type="bottom" :mask-click="false" :safe-area="true" :borderRadius="'10px 10x 10px 10px'"> <uni-popup
ref="popup"
type="bottom"
:mask-click="false"
:safe-area="true"
:borderRadius="'10px 10x 10px 10px'"
>
<view class="popup-box"> <view class="popup-box">
<view class="head-img"></view> <view class="head-img"></view>
<view class="uni-icon uni-icon-closeempty" color="#888" @click="close"></view> <view
class="uni-icon uni-icon-closeempty"
color="#888"
@click="close"
></view>
<view class="popup-content"> <view class="popup-content">
<view class="title"> 微信账号登录小发同城小程序 </view> <view class="title"> 微信账号登录小发同城小程序 </view>
<button class="btn-login" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"> <button
class="btn-login"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
>
<view class="iconfontAili icon-weixin"></view> <view class="iconfontAili icon-weixin"></view>
<view>微信一键登录</view> <view>微信一键登录</view>
</button> </button>
@ -43,7 +57,7 @@ export default {
// immediate: true, // immediate: true,
}, },
}, },
onUnload() { }, onUnload() {},
onHide() { onHide() {
this.close(); this.close();
}, },
@ -76,8 +90,8 @@ export default {
that.$.request({ that.$.request({
url: that.cf.URL.get_miniapp_open_id, url: that.cf.URL.get_miniapp_open_id,
data: params, data: params,
success: (data, status, msg, code) => { }, success: (data, status, msg, code) => {},
fail: (err, status) => { }, fail: (err, status) => {},
}); });
} else { } else {
that.$.showModal({ that.$.showModal({
@ -103,13 +117,13 @@ export default {
}, },
dataType: "json", dataType: "json",
success: function (res) { success: function (res) {
resolve(res.openid) resolve(res.openid);
}, },
}); });
} }
}, },
}); });
}) });
}, },
// //
@ -117,10 +131,10 @@ export default {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wx.getUserInfo({ wx.getUserInfo({
success: (res) => { success: (res) => {
resolve(res) resolve(res);
} },
}) });
}) });
}, },
// //
@ -133,7 +147,7 @@ export default {
code: e.detail.code, code: e.detail.code,
}, },
success: function (res) { success: function (res) {
that.doWxUserRegisterAndLogin(res.phoneNumber) that.doWxUserRegisterAndLogin(res.phoneNumber);
}, },
}); });
} else { } else {
@ -143,9 +157,11 @@ export default {
// //
async doWxUserRegisterAndLogin(phoneNumber) { async doWxUserRegisterAndLogin(phoneNumber) {
const openId = await this.getWxOpenId() const openId = await this.getWxOpenId();
const {userInfo:{ nickName, avatarUrl }} = await this.getUserprofile() const {
const that = this userInfo: { nickName, avatarUrl },
} = await this.getUserprofile();
const that = this;
this.$.request({ this.$.request({
url: this.Config.URL.wx.doWxUserRegisterAndLogin, url: this.Config.URL.wx.doWxUserRegisterAndLogin,
@ -153,27 +169,27 @@ export default {
nickName, nickName,
avatarUrl, avatarUrl,
phoneNumber, phoneNumber,
openId openId,
}, },
method: "POST", method: "POST",
header: { header: {
'Content-Type': 'application/json;charset=utf-8' "Content-Type": "application/json;charset=utf-8",
}, },
dataType: "json", dataType: "json",
success: function (data, status, msg, code) { success: function (data, status, msg, code) {
if (status != 200) { if (status != 200) {
that.$.confirm(that.__(msg || '登录失败,请重试!')); that.$.confirm(that.__(msg || "登录失败,请重试!"));
return return;
} }
that.loginSuccess(data) that.loginSuccess(data);
}, },
}); });
}, },
// //
loginSuccess(data) { loginSuccess(data) {
const that = this const that = this;
that.$.setStorageSync("uid", data.user_id); that.$.setStorageSync("uid", data.user_id);
that.$.setStorageSync("ukey", data.key); that.$.setStorageSync("ukey", data.key);
@ -196,7 +212,7 @@ export default {
that.close(); that.close();
}, },
}); });
} },
}, },
}; };
</script> </script>
@ -215,7 +231,7 @@ export default {
.head-img { .head-img {
width: 100%; width: 100%;
height: 190px; height: 190px;
background-image: url("../static/images/login-bg.png"); background-image: url("https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/static/xcxfile/appicon/login-bg.png");
background-size: 100% 100%; background-size: 100% 100%;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

File diff suppressed because it is too large Load Diff