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>
<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="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="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>微信一键登录</view>
</button>
@ -43,7 +57,7 @@ export default {
// immediate: true,
},
},
onUnload() { },
onUnload() {},
onHide() {
this.close();
},
@ -76,8 +90,8 @@ export default {
that.$.request({
url: that.cf.URL.get_miniapp_open_id,
data: params,
success: (data, status, msg, code) => { },
fail: (err, status) => { },
success: (data, status, msg, code) => {},
fail: (err, status) => {},
});
} else {
that.$.showModal({
@ -103,13 +117,13 @@ export default {
},
dataType: "json",
success: function (res) {
resolve(res.openid)
resolve(res.openid);
},
});
}
},
});
})
});
},
//
@ -117,10 +131,10 @@ export default {
return new Promise((resolve, reject) => {
wx.getUserInfo({
success: (res) => {
resolve(res)
}
})
})
resolve(res);
},
});
});
},
//
@ -133,7 +147,7 @@ export default {
code: e.detail.code,
},
success: function (res) {
that.doWxUserRegisterAndLogin(res.phoneNumber)
that.doWxUserRegisterAndLogin(res.phoneNumber);
},
});
} else {
@ -143,9 +157,11 @@ export default {
//
async doWxUserRegisterAndLogin(phoneNumber) {
const openId = await this.getWxOpenId()
const {userInfo:{ nickName, avatarUrl }} = await this.getUserprofile()
const that = this
const openId = await this.getWxOpenId();
const {
userInfo: { nickName, avatarUrl },
} = await this.getUserprofile();
const that = this;
this.$.request({
url: this.Config.URL.wx.doWxUserRegisterAndLogin,
@ -153,27 +169,27 @@ export default {
nickName,
avatarUrl,
phoneNumber,
openId
openId,
},
method: "POST",
header: {
'Content-Type': 'application/json;charset=utf-8'
"Content-Type": "application/json;charset=utf-8",
},
dataType: "json",
success: function (data, status, msg, code) {
if (status != 200) {
that.$.confirm(that.__(msg || '登录失败,请重试!'));
return
that.$.confirm(that.__(msg || "登录失败,请重试!"));
return;
}
that.loginSuccess(data)
that.loginSuccess(data);
},
});
},
//
loginSuccess(data) {
const that = this
const that = this;
that.$.setStorageSync("uid", data.user_id);
that.$.setStorageSync("ukey", data.key);
@ -196,7 +212,7 @@ export default {
that.close();
},
});
}
},
},
};
</script>
@ -215,7 +231,7 @@ export default {
.head-img {
width: 100%;
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%;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

File diff suppressed because it is too large Load Diff