合并提交

master
lemon橪 2022-05-10 12:08:45 +08:00
commit 75365c428d
5 changed files with 296 additions and 115 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
# OSX # OSX
# #
.DS_Store .DS_Store
node_modules/
#Intellij idea #Intellij idea
.idea/ .idea/

View File

@ -14,6 +14,23 @@ export function resetByMobile(params) {
}); });
} }
/**
* 账号密码登陆
* @params password
* @params username
*/
export function userLogin(params){
return http.request({
method: "POST",
url:`/passport/member/userLogin`,
data: params,
header: {
"content-type": "application/x-www-form-urlencoded",
},
})
}
/** /**
* 发送验证码 * 发送验证码
* @param mobile * @param mobile

View File

@ -63,7 +63,16 @@
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
], ],
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ], "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ],
"schemes" : "lilishop" "schemes" : "lilishop",
"permissionExternalStorage" : {
"request" : "none",
"prompt" : "应用保存运行状态等信息,需要获取读写手机存储(系统提示为访问设备上的照片、媒体内容和文件)权限,请允许。"
},
"permissionPhoneState" : {
"request" : "none",
"prompt" : "为保证您正常、安全地使用,需要获取设备识别码(部分手机提示为获取手机号码)使用权限,请允许"
},
"autoSdkPermissions" : false
}, },
"ios" : { "ios" : {
"idfa" : false, "idfa" : false,

View File

@ -10,67 +10,111 @@
</div> </div>
</div> </div>
<!-- 手机号 --> <!-- 手机号 -->
<div v-show="current == 0"> <div v-show="!enableUserPwdBox">
<u-input <div v-show="current == 0">
:custom-style="inputStyle" <u-input
:placeholder-style="placeholderStyle" :custom-style="inputStyle"
placeholder="请输入手机号 (11位)" :placeholder-style="placeholderStyle"
class="mobile" placeholder="请输入手机号 (11位)"
focus class="mobile"
v-model="mobile" focus
type="number" v-model="mobile"
maxlength="11" type="number"
/> maxlength="11"
<div />
:class="!enabuleFetchCode ? 'disable' : 'fetch'" <div
@click="fetchCode" :class="!enableFetchCode ? 'disable' : 'fetch'"
class="btn" @click="fetchCode"
> class="btn"
获取验证码 >
获取验证码
</div>
</div> </div>
<div class="flex"> <!-- 输入验证码 -->
<u-checkbox-group :icon-size="24" width="45rpx"> <div v-show="current == 1" class="box-code">
<u-checkbox <verifyCode
shape="circle" type="bottom"
v-model="enabulePrivacy" @confirm="submit"
active-color="#FF5E00" boxActiveColor="#D8D8D8"
></u-checkbox> v-model="code"
</u-checkbox-group> isFocus
<div class="tips"> boxNormalColor="#D8D8D8"
未注册的手机号验证后将自动创建用户账号登录即代表您已同意<span cursorColor="#D8D8D8"
@click="navigateToPrivacy('privacy')" />
>使用条款及隐私协议</span
<div class="fetch-btn">
<u-verification-code
change-text="验证码已发送x"
end-text="重新获取验证码"
unique-key="page-login"
:seconds="seconds"
@end="end"
@start="start"
ref="uCode"
@change="codeChange"
></u-verification-code>
<span @tap="fetchCode" :style="{ color: codeColor }">
{{ tips }}</span
> >
</div> </div>
</div> </div>
</div> </div>
<!-- 输入验证码 -->
<div v-show="current == 1" class="box-code"> <!-- 帐号密码登录 -->
<verifyCode <div v-show="enableUserPwdBox">
type="bottom" <u-input
@confirm="submit" :custom-style="inputStyle"
boxActiveColor="#D8D8D8" :placeholder-style="placeholderStyle"
v-model="code" placeholder="请输入用户名"
isFocus class="mobile"
boxNormalColor="#D8D8D8" focus
cursorColor="#D8D8D8" v-model="userData.username"
/>
<u-input
:custom-style="inputStyle"
:placeholder-style="placeholderStyle"
placeholder="请输入密码"
class="mobile"
focus
v-model="userData.password"
type="password"
/> />
<div class="fetch-btn"> <div
<u-verification-code :class="!enableUserBtnColor ? 'disable' : 'fetch'"
change-text="验证码已发送x" @click="passwordLogin"
end-text="重新获取验证码" class="btn"
unique-key="page-login" >
:seconds="seconds" 帐号密码登录
@end="end"
@start="start"
ref="uCode"
@change="codeChange"
></u-verification-code>
<span @tap="fetchCode" :style="{ color: codeColor }"> {{ tips }}</span>
</div> </div>
</div> </div>
<div class="flex" v-show="current != 1">
<u-checkbox-group :icon-size="24" width="45rpx">
<u-checkbox
shape="circle"
v-model="enablePrivacy"
active-color="#FF5E00"
></u-checkbox>
</u-checkbox-group>
<div class="tips">
未注册的手机号验证后将自动创建用户账号登录即代表您已同意<span
@click="navigateToPrivacy('privacy')"
>隐私协议</span>
<span @click="navigateToPrivacys('user')">
用户协议
</span>
</div>
</div>
<div
v-if="current != 1"
class="user-password-tips"
@click="enableUserPwdBox = !enableUserPwdBox"
>
{{ !enableUserPwdBox ? "帐号密码" : "手机号" }}登录
</div>
<!-- 循环出当前可使用的第三方登录模式 --> <!-- 循环出当前可使用的第三方登录模式 -->
<div class="flex login-list"> <div class="flex login-list">
<div <div
@ -115,7 +159,7 @@
<script> <script>
import { openIdLogin, loginCallback } from "@/api/connect.js"; import { openIdLogin, loginCallback } from "@/api/connect.js";
import api from "@/config/api.js"; import api from "@/config/api.js";
import { sendMobile, smsLogin } from "@/api/login"; import { sendMobile, smsLogin, userLogin } from "@/api/login";
import myVerification from "@/components/verification/verification.vue"; // import myVerification from "@/components/verification/verification.vue"; //
import uuid from "@/utils/uuid.modified.js"; // uuid import uuid from "@/utils/uuid.modified.js"; // uuid
import verifyCode from "@/components/verify-code/verify-code"; import verifyCode from "@/components/verify-code/verify-code";
@ -124,6 +168,8 @@ import { whetherNavigate } from "@/utils/Foundation"; //登录跳转
import storage from "@/utils/storage.js"; // import storage from "@/utils/storage.js"; //
import wechatH5Login from "./wechatH5Login.vue"; import wechatH5Login from "./wechatH5Login.vue";
import { webConnect } from "@/api/connect.js"; import { webConnect } from "@/api/connect.js";
import { md5 } from "@/utils/md5.js";
export default { export default {
components: { myVerification, verifyCode, wechatH5Login }, components: { myVerification, verifyCode, wechatH5Login },
@ -134,6 +180,7 @@ export default {
flage: false, // flage: false, //
codeFlag: true, // codeFlag: true, //
tips: "", tips: "",
enableUserPwdBox: false, //
current: 0, current: 0,
codeColor: "#999", // codeColor: "#999", //
lightColor: this.$lightColor, lightColor: this.$lightColor,
@ -148,9 +195,14 @@ export default {
desc: "已经发送验证码至", desc: "已经发送验证码至",
}, },
], ],
userData: {
username: "",
password: "",
},
showBack: false, showBack: false,
enabuleFetchCode: false, enableFetchCode: false,
enabulePrivacy: false, // enableUserBtnColor:false,
enablePrivacy: false, //
mobile: "", // mobile: "", //
code: "", // code: "", //
inputStyle: { inputStyle: {
@ -186,6 +238,15 @@ export default {
}; };
}, },
onShow() { onShow() {
// app
// #ifdef APP-PLUS
storage.setAccessToken("");
storage.setRefreshToken("");
storage.setUserInfo({});
// #endif
//#ifdef H5 //#ifdef H5
let isWXBrowser = /micromessenger/i.test(navigator.userAgent); let isWXBrowser = /micromessenger/i.test(navigator.userAgent);
if (isWXBrowser) { if (isWXBrowser) {
@ -286,10 +347,21 @@ export default {
current(val) { current(val) {
val ? (this.showBack = true) : (this.showBack = false); val ? (this.showBack = true) : (this.showBack = false);
}, },
userData:{
handler(val){
if(this.userData.username && this.userData.password) {
this.enableUserBtnColor = true;
}else{
this.enableUserBtnColor = false;
}
},
deep:true,
},
mobile: { mobile: {
handler(val) { handler(val) {
if (val.length == 11) { if (val.length == 11) {
this.enabuleFetchCode = true; this.enableFetchCode = true;
} }
}, },
}, },
@ -297,25 +369,31 @@ export default {
async flage(val) { async flage(val) {
if (val) { if (val) {
if (this.$refs.uCode.canGetCode) { if (this.$refs.uCode.canGetCode) {
// if (this.enableUserPwdBox) {
uni.showLoading({}); this.submitUserLogin();
let res = await sendMobile(this.mobile); return;
uni.hideLoading(); //
// this.start()
if (res.data.success) {
this.current = 1;
this.$refs.uCode.start();
} else { } else {
uni.showToast({ //
title: res.data.message, uni.showLoading({});
duration: 2000, let res = await sendMobile(this.mobile);
icon: "none", uni.hideLoading();
}); // this.start()
this.flage = false; if (res.data.success) {
this.$refs.verification.getCode(); this.current = 1;
this.$refs.uCode.start();
} else {
uni.showToast({
title: res.data.message,
duration: 2000,
icon: "none",
});
this.flage = false;
this.$refs.verification.getCode();
}
} }
} else { } else {
this.$u.toast("请倒计时结束后再发送"); !this.enableUserPwdBox ? this.$u.toast("请倒计时结束后再发送") : "";
} }
} else { } else {
this.$refs.verification.hide(); this.$refs.verification.hide();
@ -464,7 +542,13 @@ export default {
* 1.如果跳转的链接为登录页面或跳转的链接为空页面则会重新跳转到首页 * 1.如果跳转的链接为登录页面或跳转的链接为空页面则会重新跳转到首页
* 2.都不满足返回跳转页面 * 2.都不满足返回跳转页面
*/ */
whetherNavigate(); if (user.data.result.mobile) {
whetherNavigate();
} else {
uni.navigateTo({
url: "/pages/passport/bindUserPhone",
});
}
} else { } else {
uni.switchTab({ uni.switchTab({
url: "/pages/tabbar/home/index", url: "/pages/tabbar/home/index",
@ -485,7 +569,10 @@ export default {
// #ifdef H5 // #ifdef H5
let code = connectLogin.code; let code = connectLogin.code;
let buyer = api.buyer; let buyer = api.buyer;
window.open(buyer + `/passport/connect/connect/login/web/` + code, "_self"); window.open(
buyer + `/passport/connect/connect/login/web/` + code,
"_self"
);
// #endif // #endif
// #ifdef APP-PLUS // #ifdef APP-PLUS
this.nonH5OpenId(connectLogin); this.nonH5OpenId(connectLogin);
@ -504,42 +591,48 @@ export default {
/** /**
* 执行登录 * 执行登录
*/ */
smsLogin({ mobile: this.mobile, code: this.code }, this.clientType).then((res) => { smsLogin({ mobile: this.mobile, code: this.code }, this.clientType).then(
if (res.data.success) { (res) => {
storage.setAccessToken(res.data.result.accessToken); this.getUserInfoMethods(res);
storage.setRefreshToken(res.data.result.refreshToken);
/**
* 登录成功后获取个人信息
*/
getUserInfo().then((user) => {
if (user.data.success) {
/**
* 个人信息存储到缓存userInfo中
*/
storage.setUserInfo(user.data.result);
storage.setHasLogin(true);
//
uni.showToast({
title: "登录成功!",
icon: "none",
});
/**
* 计算出当前router路径
* 1.如果跳转的链接为登录页面或跳转的链接为空页面则会重新跳转到首页
* 2.都不满足返回跳转页面
*/
whetherNavigate();
} else {
uni.switchTab({
url: "/pages/tabbar/home/index",
});
}
});
} }
}); );
}, },
//
getUserInfoMethods(res) {
console.log(res);
if (res.data.success) {
storage.setAccessToken(res.data.result.accessToken);
storage.setRefreshToken(res.data.result.refreshToken);
/**
* 登录成功后获取个人信息
*/
getUserInfo().then((user) => {
if (user.data.success) {
/**
* 个人信息存储到缓存userInfo中
*/
storage.setUserInfo(user.data.result);
storage.setHasLogin(true);
//
uni.showToast({
title: "登录成功!",
icon: "none",
});
whetherNavigate();
} else {
uni.switchTab({
url: "/pages/tabbar/home/index",
});
}
});
}
},
// //
verification(val) { verification(val) {
this.flage = val == this.$store.state.verificationKey ? true : false; this.flage = val == this.$store.state.verificationKey ? true : false;
@ -549,6 +642,12 @@ export default {
uni.navigateTo({ uni.navigateTo({
url: "/pages/mine/help/tips?type=" + val, url: "/pages/mine/help/tips?type=" + val,
}); });
console.log(val)
},
navigateToPrivacys(val){
uni.navigateTo({
url:"/pages/mine/help/tips?type="+ val,
})
}, },
// //
start() { start() {
@ -569,9 +668,63 @@ export default {
this.codeFlag = true; this.codeFlag = true;
console.log(this.codeColor); console.log(this.codeColor);
}, },
passwordLogin() {
if (!this.enablePrivacy) {
uni.showToast({
title: "请同意用户隐私",
duration: 2000,
icon: "none",
});
return false;
}
if (!this.userData.username) {
uni.showToast({
title: "请填写用户名",
duration: 2000,
icon: "none",
});
return false;
}
if (!this.userData.password) {
uni.showToast({
title: "请填写密码",
duration: 2000,
icon: "none",
});
return false;
}
if (!this.flage) {
this.$refs.verification.error(); //
return false;
}
},
//
async submitUserLogin() {
const params = JSON.parse(JSON.stringify(this.userData));
params.password = md5(params.password);
try {
let res = await userLogin(params);
if (res.data.success) {
console.log("zhixing ")
this.getUserInfoMethods(res);
} else {
this.$refs.verification.getCode();
this.flage = false;
}
} catch (error) {
this.$refs.verification.getCode();
}
},
// //
fetchCode() { fetchCode() {
if (!this.enabulePrivacy) { if (!this.enablePrivacy) {
uni.showToast({ uni.showToast({
title: "请同意用户隐私", title: "请同意用户隐私",
duration: 2000, duration: 2000,
@ -700,7 +853,6 @@ page {
.login-item { .login-item {
width: 80rpx; width: 80rpx;
border-radius: 10rpx; border-radius: 10rpx;
height: 80rpx; height: 80rpx;
display: flex; display: flex;
@ -709,4 +861,10 @@ page {
margin: 0 20rpx; margin: 0 20rpx;
} }
.user-password-tips {
text-align: center;
color: $main-color;
margin: 20px 0;
}
</style> </style>

View File

@ -21,11 +21,7 @@ export default {
}; };
}, },
onLoad(params) { onLoad(params) {
params.IM params.IM ? (this.src = `${configs.imWebSrc}?token=${storage.getAccessToken()}&id=${params.IM}`): (this.src = decodeURIComponent(params.src));
? (this.src = `${configs.imWebSrc}?token=${storage.getAccessToken()}&id=${
params.IM
}`)
: (this.src = decodeURIComponent(params.src));
console.log(this.src); console.log(this.src);
}, },
}; };