feat:微信支付宝一键登录
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"version" : "1.0",
|
||||||
|
"configurations" : [
|
||||||
|
{
|
||||||
|
"playground" : "standard",
|
||||||
|
"type" : "uni-app:app-android"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
+15
-1
@@ -146,5 +146,19 @@ export function bindInvitationCode(params) {
|
|||||||
data: params,
|
data: params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// 微信一键登录
|
||||||
|
export function wechatLogin(params) {
|
||||||
|
return request({
|
||||||
|
url: `/auth/loginByWechat?wechatCode=${params.wechatCode}&isValid=${params.isValid}`,
|
||||||
|
method: "post"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 支付宝一键登录
|
||||||
|
export function alipayLogin(params) {
|
||||||
|
return request({
|
||||||
|
url: "/auth/loginByAlipay",
|
||||||
|
method: "post",
|
||||||
|
data: params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
+2
-2
@@ -299,8 +299,8 @@
|
|||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
color: #999999;
|
color: #999999;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 24rpx;
|
||||||
height: 210rpx;
|
// height: 210rpx;
|
||||||
width: calc(100% - 80rpx);
|
width: calc(100% - 80rpx);
|
||||||
.policy_a_warp{
|
.policy_a_warp{
|
||||||
color: $app-policy-color;
|
color: $app-policy-color;
|
||||||
|
|||||||
+24
-1
@@ -23,7 +23,8 @@
|
|||||||
/* 模块配置 */
|
/* 模块配置 */
|
||||||
"modules" : {
|
"modules" : {
|
||||||
"Payment" : {},
|
"Payment" : {},
|
||||||
"Camera" : {}
|
"Camera" : {},
|
||||||
|
"OAuth" : {}
|
||||||
},
|
},
|
||||||
/* 应用发布信息 */
|
/* 应用发布信息 */
|
||||||
"distribute" : {
|
"distribute" : {
|
||||||
@@ -76,6 +77,12 @@
|
|||||||
"appid" : "wx7a5902cd556d9396",
|
"appid" : "wx7a5902cd556d9396",
|
||||||
"UniversalLinks" : "https://app.tbmall.xin/uni-universallinks/__UNI__4910728/"
|
"UniversalLinks" : "https://app.tbmall.xin/uni-universallinks/__UNI__4910728/"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"oauth" : {
|
||||||
|
"weixin" : {
|
||||||
|
"appid" : "wx7a5902cd556d9396",
|
||||||
|
"UniversalLinks" : "https://app.tbmall.xin/uni-universallinks/__UNI__4910728/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"icons" : {
|
"icons" : {
|
||||||
@@ -117,6 +124,22 @@
|
|||||||
/*忽略版本提示*/
|
/*忽略版本提示*/
|
||||||
"compatible" : {
|
"compatible" : {
|
||||||
"ignoreVersion" : true
|
"ignoreVersion" : true
|
||||||
|
},
|
||||||
|
"nativePlugins" : {
|
||||||
|
"Hyy-Alipay" : {
|
||||||
|
"__plugin_info__" : {
|
||||||
|
"name" : "【免费开源】支付宝,授权,授权登录",
|
||||||
|
"description" : "用过支付宝原生sdk,原生授权登录,更安全,有问题请联系作者",
|
||||||
|
"platforms" : "Android",
|
||||||
|
"url" : "https://ext.dcloud.net.cn/plugin?id=11931",
|
||||||
|
"android_package_name" : "",
|
||||||
|
"ios_bundle_id" : "",
|
||||||
|
"isCloud" : true,
|
||||||
|
"bought" : 1,
|
||||||
|
"pid" : "11931",
|
||||||
|
"parameters" : {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* 快应用特有相关 */
|
/* 快应用特有相关 */
|
||||||
|
|||||||
+15
@@ -416,6 +416,11 @@
|
|||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
|
},{
|
||||||
|
"path": "bind-phone/bind-phone",
|
||||||
|
"style": {
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
"path": "register/register",
|
"path": "register/register",
|
||||||
"style": {
|
"style": {
|
||||||
@@ -544,5 +549,15 @@
|
|||||||
"bottom": "env(safe-area-inset-bottom)"
|
"bottom": "env(safe-area-inset-bottom)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"condition" : { //模式配置,仅开发期间生效
|
||||||
|
"current": 0, //当前激活的模式(list 的索引项)
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"name": "", //模式名称
|
||||||
|
"path": "", //启动页面,必选
|
||||||
|
"query": "" //启动参数,在页面的onLoad函数里面得到
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,247 @@
|
|||||||
|
<template>
|
||||||
|
<view class="register_warp">
|
||||||
|
<view class="header_">
|
||||||
|
<view style="margin-top: 10rpx">
|
||||||
|
<up-image
|
||||||
|
src="/static/common/left.png"
|
||||||
|
width="18"
|
||||||
|
height="20"
|
||||||
|
bgColor="#f1f6ff00"
|
||||||
|
@click="jumpMine"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="title_">绑定手机号</view>
|
||||||
|
<view></view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="register_ifo_warp">
|
||||||
|
<view class="register_info_item">
|
||||||
|
<up-input
|
||||||
|
placeholder="请输入手机号"
|
||||||
|
border="surround"
|
||||||
|
v-model="form.mobile"
|
||||||
|
:customStyle="inputCss"
|
||||||
|
></up-input>
|
||||||
|
</view>
|
||||||
|
<view class="register_info_item">
|
||||||
|
<up-input
|
||||||
|
placeholder="请输入验证码"
|
||||||
|
border="surround"
|
||||||
|
v-model="form.smsCode"
|
||||||
|
:customStyle="inputCss"
|
||||||
|
>
|
||||||
|
<template #suffix style="margin-right: 10rpx">
|
||||||
|
<view v-if="countdown" class="code-warp">
|
||||||
|
<up-count-down
|
||||||
|
:time="60 * 1000"
|
||||||
|
format="ss"
|
||||||
|
@finish="countdown = false"
|
||||||
|
></up-count-down>
|
||||||
|
<text style="margin-left: 10rpx">s</text>
|
||||||
|
</view>
|
||||||
|
<view v-else @click="getMobileCode" class="code_msg">
|
||||||
|
获取验证码
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</up-input>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
class="login_comm_but login_comm_but_yes"
|
||||||
|
@click="registerFun"
|
||||||
|
:loading="butLoading"
|
||||||
|
>
|
||||||
|
登录
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<up-toast ref="uToastRef"></up-toast>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { SMS_TYPE } from "@/utils/enumUtils.js";
|
||||||
|
import { getUserList } from "@/api/common.js";
|
||||||
|
import { wechatLogin } from "@/api/auth.js";
|
||||||
|
import {
|
||||||
|
setStorageFun,
|
||||||
|
TOKEN_NAME,
|
||||||
|
USER_KEY,
|
||||||
|
USER_DATA,
|
||||||
|
USER_LOGIN_TIME,
|
||||||
|
} from "@/utils/auth.js";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {
|
||||||
|
mobile: null,
|
||||||
|
smsCode: null, // 验证码
|
||||||
|
wechatCode: null,
|
||||||
|
},
|
||||||
|
inputCss: {
|
||||||
|
height: "80rpx",
|
||||||
|
background: "#F3F3F3FF",
|
||||||
|
"border-radius": "30rpx",
|
||||||
|
border: "0rpx",
|
||||||
|
"padding-left": "16px",
|
||||||
|
},
|
||||||
|
countdown: false, // 清空倒计时
|
||||||
|
butLoading: false,
|
||||||
|
disabled: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
const pages = getCurrentPages();
|
||||||
|
const currentPage = pages[pages.length - 1];
|
||||||
|
const id = currentPage.options?.key;
|
||||||
|
if (id) {
|
||||||
|
this.disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.form.wechatCode = id;
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
jumpMine() {
|
||||||
|
uni.reLaunch({
|
||||||
|
url: "/pages/login_package/login/login",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async registerFun() {
|
||||||
|
const form = this.form;
|
||||||
|
if (!form.mobile) {
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: "请输入手机号",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!form.smsCode) {
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: "请输入验证码",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.butLoading = true;
|
||||||
|
const params = {
|
||||||
|
mobile: form.mobile,
|
||||||
|
smsCode: form.smsCode,
|
||||||
|
isValid: true,
|
||||||
|
wechatCode: form.id,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await wechatLogin(params);
|
||||||
|
console.log("微信登录接口返回:", response);
|
||||||
|
if (resp && resp.bizcode === 100) {
|
||||||
|
const data = resp.data;
|
||||||
|
setStorageFun(TOKEN_NAME, data.token);
|
||||||
|
// 用于无感登录
|
||||||
|
setStorageFun(USER_KEY, "");
|
||||||
|
const userInfo = {
|
||||||
|
avatar: data.avatarUrl,
|
||||||
|
name: data.name,
|
||||||
|
userId: data.userId,
|
||||||
|
grade: data.grade,
|
||||||
|
inviteCode: data.inviteCode,
|
||||||
|
};
|
||||||
|
setStorageFun(USER_DATA, userInfo);
|
||||||
|
// 当前登录得时间戳
|
||||||
|
let currentTimeStamp = new Date().getTime();
|
||||||
|
setStorageFun(USER_LOGIN_TIME, currentTimeStamp);
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "success",
|
||||||
|
message: resp.msg,
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.switchTab({
|
||||||
|
url: "/pages/home/home",
|
||||||
|
});
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
this.butLoading = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取手机验证码
|
||||||
|
*/
|
||||||
|
async getMobileCode() {
|
||||||
|
const form = this.form;
|
||||||
|
if (!form.mobile) {
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: "请输入手机号码",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.countdown = true;
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
mobile: form.mobile,
|
||||||
|
type: SMS_TYPE.WECHAT,
|
||||||
|
};
|
||||||
|
const response = await getUserList(params);
|
||||||
|
if (response && response.bizcode === 100) {
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "success",
|
||||||
|
message: response.msg,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.countdown = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.header_ {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 30rpx;
|
||||||
|
.title_ {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 36rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.register_warp {
|
||||||
|
height: calc(100vh - 280rpx);
|
||||||
|
padding: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.register_title_warp {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
color: #333333;
|
||||||
|
|
||||||
|
.register_title_warp_title {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 62rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.register_title_warp_download {
|
||||||
|
font-size: 30rpx;
|
||||||
|
padding: 0 25rpx;
|
||||||
|
height: 70rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
color: #fff;
|
||||||
|
background-color: #7934f6;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.register_ifo_warp {
|
||||||
|
margin-top: 30rpx;
|
||||||
|
|
||||||
|
.register_info_item {
|
||||||
|
margin-bottom: 40rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,8 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="login_warp">
|
<view class="login_warp">
|
||||||
<view class="login_logo_warp">
|
<view class="login_logo_warp">
|
||||||
<view style="text-align: center;">
|
<view style="text-align: center">
|
||||||
<up-image src="/static/logo.png" width="90" height="118" bgColor="#f1f6ff00" radius="10"></up-image>
|
<up-image
|
||||||
|
src="/static/logo.png"
|
||||||
|
width="90"
|
||||||
|
height="118"
|
||||||
|
bgColor="#f1f6ff00"
|
||||||
|
radius="10"
|
||||||
|
></up-image>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view style="margin-top: 20rpx;">
|
<!-- <view style="margin-top: 20rpx;">
|
||||||
<up-image src="/static/logo_z.png" width="100" height="40" bgColor="#f1f6ff00"></up-image>
|
<up-image src="/static/logo_z.png" width="100" height="40" bgColor="#f1f6ff00"></up-image>
|
||||||
@@ -10,28 +16,60 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="login_info">
|
<view class="login_info">
|
||||||
<view class="login_info_item">
|
<view class="login_info_item">
|
||||||
<up-input placeholder="请输入手机号/账户名称" border="surround" v-model="form.name" :customStyle="inputCss"
|
<up-input
|
||||||
@change="checkNameParam"></up-input>
|
placeholder="请输入手机号/账户名称"
|
||||||
|
border="surround"
|
||||||
|
v-model="form.name"
|
||||||
|
:customStyle="inputCss"
|
||||||
|
@change="checkNameParam"
|
||||||
|
></up-input>
|
||||||
</view>
|
</view>
|
||||||
<!-- 密码登录 -->
|
<!-- 密码登录 -->
|
||||||
<view class="login_info_item" v-if="loginWay === 'password'">
|
<view class="login_info_item" v-if="loginWay === 'password'">
|
||||||
<up-input placeholder="请输入密码" border="surround" v-model="form.password" :customStyle="inputCss"
|
<up-input
|
||||||
:type="isShow ? 'text' : 'password'" @change="checkParam">
|
placeholder="请输入密码"
|
||||||
<template #suffix style="margin-right: 10rpx;">
|
border="surround"
|
||||||
<up-image v-if="isShow" src="/static/login/show.png" width="20" height="20" bgColor="#f1f6ff00"
|
v-model="form.password"
|
||||||
@click="isShow = false;"></up-image>
|
:customStyle="inputCss"
|
||||||
<up-image v-else src="/static/login/hidden.png" width="20" height="20" bgColor="#f1f6ff00"
|
:type="isShow ? 'text' : 'password'"
|
||||||
@click="isShow = true;"></up-image>
|
@change="checkParam"
|
||||||
|
>
|
||||||
|
<template #suffix style="margin-right: 10rpx">
|
||||||
|
<up-image
|
||||||
|
v-if="isShow"
|
||||||
|
src="/static/login/show.png"
|
||||||
|
width="20"
|
||||||
|
height="20"
|
||||||
|
bgColor="#f1f6ff00"
|
||||||
|
@click="isShow = false"
|
||||||
|
></up-image>
|
||||||
|
<up-image
|
||||||
|
v-else
|
||||||
|
src="/static/login/hidden.png"
|
||||||
|
width="20"
|
||||||
|
height="20"
|
||||||
|
bgColor="#f1f6ff00"
|
||||||
|
@click="isShow = true"
|
||||||
|
></up-image>
|
||||||
</template>
|
</template>
|
||||||
</up-input>
|
</up-input>
|
||||||
</view>
|
</view>
|
||||||
<!-- 验证码登录 -->
|
<!-- 验证码登录 -->
|
||||||
<view class="login_info_item" v-else>
|
<view class="login_info_item" v-else>
|
||||||
<up-input placeholder="请输入验证码" border="surround" v-model="form.code" :customStyle="inputCss">
|
<up-input
|
||||||
<template #suffix style="margin-right: 10rpx;">
|
placeholder="请输入验证码"
|
||||||
|
border="surround"
|
||||||
|
v-model="form.code"
|
||||||
|
:customStyle="inputCss"
|
||||||
|
>
|
||||||
|
<template #suffix style="margin-right: 10rpx">
|
||||||
<view v-if="countdown" class="code-warp">
|
<view v-if="countdown" class="code-warp">
|
||||||
<up-count-down :time="60 * 1000" format="ss" @finish="countdown = false"></up-count-down>
|
<up-count-down
|
||||||
<text style="margin-left: 10rpx;">s</text>
|
:time="60 * 1000"
|
||||||
|
format="ss"
|
||||||
|
@finish="countdown = false"
|
||||||
|
></up-count-down>
|
||||||
|
<text style="margin-left: 10rpx">s</text>
|
||||||
</view>
|
</view>
|
||||||
<view v-else @click="getMobileCode" class="code_msg">
|
<view v-else @click="getMobileCode" class="code_msg">
|
||||||
获取验证码
|
获取验证码
|
||||||
@@ -41,25 +79,65 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="login_comm_but login_comm_but_yes" @click="loginFun">
|
<view class="login_comm_but login_comm_but_yes" @click="loginFun">
|
||||||
<text style="margin-left: 10rpx;">登录</text>
|
<text style="margin-left: 10rpx">登录</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="cut_way_warp">
|
<view class="cut_way_warp">
|
||||||
<view v-if="loginWay === 'password'" @click="loginWay = 'code'">验证码登录</view>
|
<view v-if="loginWay === 'password'" @click="loginWay = 'code'"
|
||||||
<view v-if="loginWay === 'code'" @click="loginWay = 'password'">密码登录登录</view>
|
>验证码登录</view
|
||||||
|
>
|
||||||
|
<view v-if="loginWay === 'code'" @click="loginWay = 'password'"
|
||||||
|
>密码登录登录</view
|
||||||
|
>
|
||||||
<view @click="jumpForgot">忘记密码</view>
|
<view @click="jumpForgot">忘记密码</view>
|
||||||
<view @click="jumpRegister">注册</view>
|
<view @click="jumpRegister">注册</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view>
|
||||||
|
<view class="other_login">其他登录方式</view>
|
||||||
|
<view class="login_other_icon">
|
||||||
|
<view class="login_other_item" @click="wechatOneLogin">
|
||||||
|
<up-image
|
||||||
|
src="/static/login/WXICON.png"
|
||||||
|
width="44"
|
||||||
|
height="44"
|
||||||
|
bgColor="#f1f6ff00"
|
||||||
|
></up-image>
|
||||||
|
微信登录
|
||||||
|
</view>
|
||||||
|
<!-- <view class="login_other_item" @click="alipayOneLogin">
|
||||||
|
<up-image
|
||||||
|
src="/static/login/ZFB.png"
|
||||||
|
width="44"
|
||||||
|
height="44"
|
||||||
|
bgColor="#f1f6ff00"
|
||||||
|
></up-image>
|
||||||
|
支付宝登录
|
||||||
|
</view> -->
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<view class="policy_warp">
|
<view class="policy_warp">
|
||||||
<up-checkbox name="isCheck" usedAlone v-model:checked="isPolicy" shape="circle" activeColor="#7934F6" size="19"
|
<up-checkbox
|
||||||
iconSize="18">
|
name="isCheck"
|
||||||
|
usedAlone
|
||||||
|
v-model:checked="isPolicy"
|
||||||
|
shape="circle"
|
||||||
|
activeColor="#7934F6"
|
||||||
|
size="19"
|
||||||
|
iconSize="18"
|
||||||
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
<text>已阅读并同意</text>
|
<text>已阅读并同意</text>
|
||||||
<text class="policy_a_warp" @click="jumpUserAgreement">《服务协议》</text>
|
<text class="policy_a_warp" @click="jumpUserAgreement"
|
||||||
|
>《服务协议》</text
|
||||||
|
>
|
||||||
<text>、</text>
|
<text>、</text>
|
||||||
<text class="policy_a_warp" @click="jumpPrivacyAgreement">《隐私政策》</text>
|
<text class="policy_a_warp" @click="jumpPrivacyAgreement"
|
||||||
|
>《隐私政策》</text
|
||||||
|
>
|
||||||
<text>、</text>
|
<text>、</text>
|
||||||
<text class="policy_a_warp" @click="jumpProductAgreement">《售后保障协议》</text>
|
<text class="policy_a_warp" @click="jumpProductAgreement"
|
||||||
|
>《售后保障协议》</text
|
||||||
|
>
|
||||||
</template>
|
</template>
|
||||||
</up-checkbox>
|
</up-checkbox>
|
||||||
</view>
|
</view>
|
||||||
@@ -68,13 +146,22 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import InputCodeComm from "@/components/code-comm/code-comm.vue";
|
||||||
|
import { SMS_TYPE } from "@/utils/enumUtils.js";
|
||||||
|
import { getUserList } from "@/api/common.js";
|
||||||
|
import { loginbysms, loginbypw, wechatLogin, alipayLogin } from "@/api/auth.js";
|
||||||
|
import {
|
||||||
|
setStorageFun,
|
||||||
|
TOKEN_NAME,
|
||||||
|
USER_KEY,
|
||||||
|
USER_DATA,
|
||||||
|
USER_LOGIN_TIME,
|
||||||
|
} from "@/utils/auth.js";
|
||||||
|
import CryptoJS from "crypto-js";
|
||||||
|
|
||||||
import InputCodeComm from '@/components/code-comm/code-comm.vue';
|
// #ifdef APP-PLUS
|
||||||
import { SMS_TYPE } from '@/utils/enumUtils.js';
|
const hyyAlipay = uni.requireNativePlugin("Hyy-Alipay");
|
||||||
import { getUserList } from '@/api/common.js';
|
// #endif
|
||||||
import { loginbysms, loginbypw } from '@/api/auth.js';
|
|
||||||
import { setStorageFun, TOKEN_NAME, USER_KEY, USER_DATA, USER_LOGIN_TIME } from '@/utils/auth.js';
|
|
||||||
import CryptoJS from 'crypto-js';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -85,20 +172,21 @@ export default {
|
|||||||
form: {
|
form: {
|
||||||
name: null,
|
name: null,
|
||||||
password: null,
|
password: null,
|
||||||
code: null
|
code: null,
|
||||||
},
|
},
|
||||||
inputCss: {
|
inputCss: {
|
||||||
"height": '80rpx',
|
height: "80rpx",
|
||||||
"background": "#F3F3F3FF",
|
background: "#F3F3F3FF",
|
||||||
"border-radius": "30rpx",
|
"border-radius": "30rpx",
|
||||||
"border": "0rpx",
|
border: "0rpx",
|
||||||
"padding-left": "16px",
|
"padding-left": "16px",
|
||||||
},
|
},
|
||||||
loginWay: 'password',
|
loginWay: "password",
|
||||||
isShow: false,// 是否显示
|
isShow: false, // 是否显示
|
||||||
isPolicy: false,// 是否同意
|
isPolicy: false, // 是否同意
|
||||||
countdown: false,// 清空倒计时
|
countdown: false, // 清空倒计时
|
||||||
}
|
loading: false,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
jumpHome() {
|
jumpHome() {
|
||||||
@@ -109,36 +197,37 @@ export default {
|
|||||||
// })
|
// })
|
||||||
// }else{
|
// }else{
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url: '/pages/home/home',
|
url: "/pages/home/home",
|
||||||
})
|
});
|
||||||
// }
|
// }
|
||||||
|
|
||||||
},
|
},
|
||||||
async loginFun() {
|
async loginFun(val = {}) {
|
||||||
const then = this;
|
const then = this;
|
||||||
const form = this.form;
|
const form = this.form;
|
||||||
const params = {}
|
const params = {};
|
||||||
if (!this.isPolicy) {
|
if (!this.isPolicy) {
|
||||||
this.$refs.uToastRef.show({
|
this.$refs.uToastRef.show({
|
||||||
type: 'error',
|
type: "error",
|
||||||
message: "请阅读完相关协议以及政策,并且勾选同意选项",
|
message: "请阅读完相关协议以及政策,并且勾选同意选项",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let response = {};
|
let response = val;
|
||||||
if (this.loginWay === 'password') {
|
if (this.loginWay === "password") {
|
||||||
params.mobile = form.name;
|
params.mobile = form.name;
|
||||||
params.password = CryptoJS.MD5(form.password).toString();
|
params.password = CryptoJS.MD5(form.password).toString();
|
||||||
response = await loginbypw(params);
|
response = await loginbypw(params);
|
||||||
} else {
|
}
|
||||||
|
if (this.loginWay === "code") {
|
||||||
params.mobile = form.name;
|
params.mobile = form.name;
|
||||||
params.smsCode = form.code;
|
params.smsCode = form.code;
|
||||||
response = await loginbysms(params);
|
response = await loginbysms(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
setStorageFun(TOKEN_NAME, data.token);
|
setStorageFun(TOKEN_NAME, data.token);
|
||||||
// 用于无感登录
|
// 用于无感登录
|
||||||
setStorageFun(USER_KEY, '');
|
setStorageFun(USER_KEY, "");
|
||||||
const userInfo = {
|
const userInfo = {
|
||||||
avatar: data.avatarUrl,
|
avatar: data.avatarUrl,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
@@ -151,7 +240,7 @@ export default {
|
|||||||
let currentTimeStamp = new Date().getTime();
|
let currentTimeStamp = new Date().getTime();
|
||||||
setStorageFun(USER_LOGIN_TIME, currentTimeStamp);
|
setStorageFun(USER_LOGIN_TIME, currentTimeStamp);
|
||||||
this.$refs.uToastRef.show({
|
this.$refs.uToastRef.show({
|
||||||
type: 'success',
|
type: "success",
|
||||||
message: response.msg,
|
message: response.msg,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -172,7 +261,7 @@ export default {
|
|||||||
const form = this.form;
|
const form = this.form;
|
||||||
if (!form.name) {
|
if (!form.name) {
|
||||||
this.$refs.uToastRef.show({
|
this.$refs.uToastRef.show({
|
||||||
type: 'error',
|
type: "error",
|
||||||
message: "请输入账号",
|
message: "请输入账号",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -182,54 +271,162 @@ export default {
|
|||||||
const params = {
|
const params = {
|
||||||
mobile: form.name,
|
mobile: form.name,
|
||||||
type: SMS_TYPE.LOGIN,
|
type: SMS_TYPE.LOGIN,
|
||||||
}
|
};
|
||||||
const response = await getUserList(params);
|
const response = await getUserList(params);
|
||||||
console.log("responseresponseresponse", response);
|
console.log("responseresponseresponse", response);
|
||||||
if (response && response.bizcode === 100) {
|
if (response && response.bizcode === 100) {
|
||||||
this.$refs.uToastRef.show({
|
this.$refs.uToastRef.show({
|
||||||
type: 'success',
|
type: "success",
|
||||||
message: response.msg,
|
message: response.msg,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.countdown = false;
|
this.countdown = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
jumpForgot(){
|
jumpForgot() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/rwa_package/setting/forgot-pass?type=3",
|
url: "/pages/rwa_package/setting/forgot-pass?type=3",
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
jumpRegister() {
|
jumpRegister() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/login_package/register/register",
|
url: "/pages/login_package/register/register",
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
// 用户协议
|
// 用户协议
|
||||||
jumpUserAgreement() {
|
jumpUserAgreement() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/mine_package/mine_user_agreement/mine_user_agreement?backPath=login'
|
url: "/pages/mine_package/mine_user_agreement/mine_user_agreement?backPath=login",
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
// 隐私协议
|
// 隐私协议
|
||||||
jumpPrivacyAgreement() {
|
jumpPrivacyAgreement() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/mine_package/mine_privacy_agreement/mine_privacy_agreement?backPath=login'
|
url: "/pages/mine_package/mine_privacy_agreement/mine_privacy_agreement?backPath=login",
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
// 售后保障协议
|
// 售后保障协议
|
||||||
jumpProductAgreement() {
|
jumpProductAgreement() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/mine_package/mine_product_agreement/mine_product_agreement?backPath=login'
|
url: "/pages/mine_package/mine_product_agreement/mine_product_agreement?backPath=login",
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 微信登录
|
||||||
|
async wechatOneLogin() {
|
||||||
|
const then = this;
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
|
// 检查是否同意协议
|
||||||
|
if (!this.isPolicy) {
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: "请阅读完相关协议以及政策,并且勾选同意选项",
|
||||||
|
});
|
||||||
|
this.loading = false;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
try {
|
||||||
|
// 1. 调用微信登录API
|
||||||
|
uni.login({
|
||||||
|
provider: "weixin",
|
||||||
|
// onlyAuthorize: true,
|
||||||
|
success: async (loginRes) => {
|
||||||
|
console.log("微信登录成功:", loginRes);
|
||||||
|
|
||||||
|
// 2. 发送code到后端换取token
|
||||||
|
const params = {
|
||||||
|
isValid: false,
|
||||||
|
wechatCode: loginRes.code,
|
||||||
|
// 可以根据需要添加其他参数
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await wechatLogin(params);
|
||||||
|
console.log("微信登录接口返回:", response);
|
||||||
|
|
||||||
|
if (response && response.bizcode === 100) {
|
||||||
|
this.loginWay = "wechat";
|
||||||
|
this.loginFun(response);
|
||||||
|
} else if (response.bizcode === 601) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/login_package/bind-phone/bind-phone?id=${loginRes.code}`,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: response.msg || "微信登录失败",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
this.loading = false;
|
||||||
|
console.error("微信登录失败:", err);
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: "微信登录失败,请重试",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
this.loading = false;
|
||||||
|
console.error("微信登录异常:", error);
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: "微信登录异常,请重试",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 支付宝一键登录
|
||||||
|
async alipayOneLogin() {
|
||||||
|
const then = this;
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
|
console.log("支付宝登录", hyyAlipay);
|
||||||
|
|
||||||
|
// 检查是否同意协议
|
||||||
|
if (!this.isPolicy) {
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: "请阅读完相关协议以及政策,并且勾选同意选项",
|
||||||
|
});
|
||||||
|
this.loading = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hyyAlipay.openAuthScheme(
|
||||||
|
{
|
||||||
|
appId: "2021005183625053", // 支付宝分配给开发者的应用 ID
|
||||||
|
scheme: "trustbridgeapp", // manifest.json -> "App常用其他设置" -> "UrlSchemes"里设置
|
||||||
|
},
|
||||||
|
(res) => {
|
||||||
|
console.log("支付宝回调", res);
|
||||||
|
|
||||||
|
alipayLogin({
|
||||||
|
certifyId: res.auth_code,
|
||||||
|
}).then((response) => {
|
||||||
|
console.log("支付宝登录接口返回:", response);
|
||||||
|
if (response && response.bizcode === 100) {
|
||||||
|
this.loginWay = "alipay";
|
||||||
|
this.loginFun(response);
|
||||||
|
} else {
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: response.msg || "微信登录失败",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.login_warp {
|
.login_warp {
|
||||||
height: calc(100vh - 460rpx);
|
height: calc(100vh - 400rpx);
|
||||||
padding: 250rpx 50rpx 0;
|
padding: 150rpx 50rpx 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login_logo_warp {
|
.login_logo_warp {
|
||||||
@@ -251,7 +448,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.login_comm_but {
|
.login_comm_but {
|
||||||
background: #CCCCCC;
|
background: #cccccc;
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@@ -276,4 +473,24 @@ export default {
|
|||||||
color: #999999;
|
color: #999999;
|
||||||
margin-top: 20rpx;
|
margin-top: 20rpx;
|
||||||
}
|
}
|
||||||
|
.other_login {
|
||||||
|
font-size: 28rpx;
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 80rpx;
|
||||||
|
margin-bottom: 32rpx;
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
|
.login_other_icon {
|
||||||
|
display: flex;
|
||||||
|
padding: 0 100rpx;
|
||||||
|
justify-content: center;
|
||||||
|
.login_other_item {
|
||||||
|
display: flex;
|
||||||
|
flex: 50%;
|
||||||
|
font-size: 28rpx;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 80rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.3 KiB |
@@ -23,6 +23,7 @@ export const SMS_TYPE = {
|
|||||||
"PASSWD": "passwd",
|
"PASSWD": "passwd",
|
||||||
"LOGIN": "login",
|
"LOGIN": "login",
|
||||||
"REGISTER": "register",
|
"REGISTER": "register",
|
||||||
|
"WECHAT": "wechatValid"
|
||||||
}
|
}
|
||||||
|
|
||||||
// 图片类型 图片分类:COMMON-公共,CATEGORY-商品类目图标,BRAND-品牌LOGO,SHOP-店铺LOGO,GOODS-商品图片,SPECS-商品规格图片
|
// 图片类型 图片分类:COMMON-公共,CATEGORY-商品类目图标,BRAND-品牌LOGO,SHOP-店铺LOGO,GOODS-商品图片,SPECS-商品规格图片
|
||||||
|
|||||||
+2
-1
@@ -64,7 +64,8 @@ function request(options) {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.bizcode === 100) {
|
// 601 微信登录没注册
|
||||||
|
if (data.bizcode === 100 || data.bizcode === 601) {
|
||||||
resolve(data); // 成功时返回数据
|
resolve(data); // 成功时返回数据
|
||||||
} else if (data.bizcode === 201) {
|
} else if (data.bizcode === 201) {
|
||||||
if ([201, 200].includes(data.errcode)) {
|
if ([201, 200].includes(data.errcode)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user