优化代码
This commit is contained in:
@@ -270,8 +270,18 @@ export default {
|
||||
const lastCleanTime = uni.getStorageSync("last_clean_time") || 0;
|
||||
const now = Date.now();
|
||||
if (now - lastCleanTime < 7 * 24 * 3600 * 1000) return; // 7 days
|
||||
uni.clearStorage();
|
||||
uni.setStorageSync("last_clean_time", now);
|
||||
request({
|
||||
url: "user/logout",
|
||||
method: "POST",
|
||||
data: {
|
||||
id: this.info.id,
|
||||
},
|
||||
userInfo: false,
|
||||
})
|
||||
.then((res) => {
|
||||
uni.clearStorage();
|
||||
uni.setStorageSync("last_clean_time", now);
|
||||
})
|
||||
},
|
||||
//关闭弹窗(取消)
|
||||
closePopup() {
|
||||
|
||||
@@ -16,9 +16,8 @@
|
||||
</view>
|
||||
<view class="title">主播库</view>
|
||||
<view class="content">
|
||||
|
||||
<scroll-view
|
||||
show-scrollbar="false"
|
||||
show-scrollbar="false"
|
||||
scroll-y="true"
|
||||
class="scroll"
|
||||
refresher-enabled="true"
|
||||
@@ -88,8 +87,17 @@
|
||||
</view>
|
||||
<view class="addition" @click="openPopupQuantity()"> </view>
|
||||
</view>
|
||||
<anchorLibrary class="createModule" ref="createModule" @Refresh="getAnchorList"></anchorLibrary>
|
||||
<modifyStreamer ref="modifyStreamer" class="createModule" :message="modifyStreamerMessage" @Refresh="getAnchorList"></modifyStreamer>
|
||||
<anchorLibrary
|
||||
class="createModule"
|
||||
ref="createModule"
|
||||
@Refresh="getAnchorList"
|
||||
></anchorLibrary>
|
||||
<modifyStreamer
|
||||
ref="modifyStreamer"
|
||||
class="createModule"
|
||||
:message="modifyStreamerMessage"
|
||||
@Refresh="getAnchorList"
|
||||
></modifyStreamer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -115,18 +123,18 @@ export default {
|
||||
});
|
||||
},
|
||||
onShareAppMessage(res) {
|
||||
if (res.from === 'menu') {
|
||||
if (res.from === "menu") {
|
||||
return {
|
||||
title: '分享',
|
||||
path: "/pages/Home/Home"
|
||||
}
|
||||
title: "分享",
|
||||
path: "/pages/Home/Home",
|
||||
};
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 重新编辑主播信息
|
||||
onRecompose(item) {
|
||||
this.modifyStreamerMessage = item;
|
||||
this.$refs.modifyStreamer.open();
|
||||
this.modifyStreamerMessage = item;
|
||||
this.$refs.modifyStreamer.open();
|
||||
},
|
||||
// 删除主播信息
|
||||
onExpurgate(item) {
|
||||
@@ -191,7 +199,7 @@ export default {
|
||||
},
|
||||
components: {
|
||||
anchorLibrary,
|
||||
modifyStreamer
|
||||
modifyStreamer,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -242,7 +250,7 @@ export default {
|
||||
color: transparent;
|
||||
display: none;
|
||||
}
|
||||
.empty{
|
||||
.empty {
|
||||
position: absolute;
|
||||
top: 200rpx;
|
||||
left: 0;
|
||||
|
||||
@@ -62,7 +62,9 @@
|
||||
<view class="Nickname" @click="modifyPassword">
|
||||
<view class="avatarmodify-item">密码</view>
|
||||
<view class="NicknameInput">
|
||||
<view class="NicknameInput-name">{{ havaPassword == true ? "" : "未设置" }}</view>
|
||||
<view class="NicknameInput-name">{{
|
||||
havaPassword == true ? "" : "未设置"
|
||||
}}</view>
|
||||
<image
|
||||
class="more"
|
||||
src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/More.png"
|
||||
@@ -128,15 +130,15 @@ export default {
|
||||
uni.setStorageSync("userinfo", res.data);
|
||||
setTimeout(() => {
|
||||
uni.getStorage({
|
||||
key: "userinfo",
|
||||
success: (res) => {
|
||||
this.id = res.data.id;
|
||||
this.name = res.data.nickName;
|
||||
this.userinfo = this.useravatar = res.data.headerIcon;
|
||||
this.email = res.data.email;
|
||||
this.havaPassword = res.data.havaPassword;
|
||||
},
|
||||
});
|
||||
key: "userinfo",
|
||||
success: (res) => {
|
||||
this.id = res.data.id;
|
||||
this.name = res.data.nickName;
|
||||
this.userinfo = this.useravatar = res.data.headerIcon;
|
||||
this.email = res.data.email;
|
||||
this.havaPassword = res.data.havaPassword;
|
||||
},
|
||||
});
|
||||
}, 300);
|
||||
} else {
|
||||
console.log(res.msg);
|
||||
@@ -179,22 +181,39 @@ export default {
|
||||
method: "POST",
|
||||
data: {
|
||||
uuid: data.uuid,
|
||||
userId: this.id,
|
||||
id: this.id,
|
||||
},
|
||||
userInfo: true,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.showToast({
|
||||
title: "登录成功",
|
||||
icon: "success",
|
||||
request({
|
||||
url: "user/confirm",
|
||||
method: "POST",
|
||||
data: {
|
||||
uuid: data.uuid,
|
||||
id: this.id,
|
||||
},
|
||||
userInfo: true,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.showToast({
|
||||
title: "登录成功",
|
||||
icon: "success",
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.showToast({
|
||||
title: "登录失败",
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.showToast({
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
placeholder="请输入邮箱号"
|
||||
v-model="email"
|
||||
/>
|
||||
<text class="error" v-if="turnsoutemail == ''">第一次填写邮箱时请确保填写正确的邮箱地址,填写错误请联系客服</text>
|
||||
<text class="error" v-if="turnsoutemail == ''"
|
||||
>第一次填写邮箱时请确保填写正确的邮箱地址,填写错误请联系客服</text
|
||||
>
|
||||
<text class="error" v-if="error">请输入正确的邮箱地址</text>
|
||||
<view v-if="turnsoutemail != ''" class="Verificationcodebox">
|
||||
<input
|
||||
@@ -33,9 +35,16 @@
|
||||
placeholder="验证码"
|
||||
v-model="Verificationcode"
|
||||
/>
|
||||
<view class="Verificationcodebtn" @click="sendVerificationCode">获取验证码</view>
|
||||
<view class="Verificationcodebtn" @click="sendVerificationCode"
|
||||
:style="isCounting ? 'background-image: linear-gradient(0deg, #cccccc, #dddddd); cursor: not-allowed;' : ''"
|
||||
> {{ isCounting ? `${countdown}秒后重发` : '获取验证码' }}</view
|
||||
>
|
||||
</view>
|
||||
<text v-if="VerificationcodeSent && turnsoutemail != ''" class="VerificationcodeSent">验证码已发送至{{turnsoutemail}}邮箱,请注意查收</text>
|
||||
<text
|
||||
v-if="VerificationcodeSent && turnsoutemail != ''"
|
||||
class="VerificationcodeSent"
|
||||
>验证码已发送至{{ turnsoutemail }}邮箱,请注意查收</text
|
||||
>
|
||||
<!-- -->
|
||||
<view class="btn" @click="onSubmit">确认</view>
|
||||
|
||||
@@ -53,12 +62,15 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
title: "Hello",
|
||||
email: "",//邮箱
|
||||
Verificationcode: "",//验证码
|
||||
id: "",//用户id
|
||||
error: false,//邮箱错误
|
||||
VerificationcodeSent: false,//验证码是否已发送
|
||||
turnsoutemail:'',//修改前的邮箱
|
||||
email: "", //邮箱
|
||||
Verificationcode: "", //验证码
|
||||
id: "", //用户id
|
||||
error: false, //邮箱错误
|
||||
VerificationcodeSent: false, //验证码是否已发送
|
||||
turnsoutemail: "", //修改前的邮箱
|
||||
countdown: 0, //验证码倒计时
|
||||
isCounting: false, //是否正在倒计时
|
||||
timer: null, //倒计时定时器
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
@@ -66,14 +78,24 @@ export default {
|
||||
this.id = options.id;
|
||||
},
|
||||
methods: {
|
||||
// 倒计时
|
||||
startCountdown() {
|
||||
this.countdown = 60;
|
||||
this.isCounting = true;
|
||||
this.timer = setInterval(() => {
|
||||
this.countdown -- ;
|
||||
if (this.countdown <= 0) {
|
||||
this.isCounting = false;
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
//提交验证
|
||||
onSubmit() {
|
||||
if (this.turnsoutemail == "") {
|
||||
this.setEmail()
|
||||
}else{
|
||||
this.hasEmail()
|
||||
this.setEmail();
|
||||
} else {
|
||||
this.hasEmail();
|
||||
}
|
||||
|
||||
},
|
||||
//有邮箱修改
|
||||
hasEmail() {
|
||||
@@ -129,6 +151,9 @@ export default {
|
||||
},
|
||||
//发送验证码
|
||||
sendVerificationCode() {
|
||||
if (this.isCounting) {
|
||||
return;
|
||||
}
|
||||
request({
|
||||
url: "user/sendUpdateMailConfirmMail",
|
||||
method: "POST",
|
||||
@@ -138,6 +163,7 @@ export default {
|
||||
userInfo: true,
|
||||
}).then((ress) => {
|
||||
this.VerificationcodeSent = true;
|
||||
this.startCountdown();
|
||||
});
|
||||
},
|
||||
//第一次提交
|
||||
@@ -209,7 +235,7 @@ export default {
|
||||
onCustomerService() {
|
||||
uni.navigateTo({
|
||||
url: "/pages/Mine/minecomponents/contact",
|
||||
})
|
||||
});
|
||||
},
|
||||
//返回上一页
|
||||
onBack() {
|
||||
@@ -296,7 +322,7 @@ export default {
|
||||
text-align: center;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
.VerificationcodeSent{
|
||||
.VerificationcodeSent {
|
||||
color: #00afb2;
|
||||
font-size: 24rpx;
|
||||
margin-top: 40rpx;
|
||||
@@ -318,7 +344,7 @@ export default {
|
||||
color: red;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
.forget{
|
||||
.forget {
|
||||
font-size: 24rpx;
|
||||
color: #00afb2;
|
||||
margin-top: 50rpx;
|
||||
|
||||
@@ -474,6 +474,8 @@ export default {
|
||||
im.on(GoEasy.IM_EVENT.MESSAGE_READ, this.onMessageRead); //监听已读消息
|
||||
|
||||
this.getscrollviewheight();
|
||||
|
||||
this.checkRecordPermission();
|
||||
},
|
||||
methods: {
|
||||
//暂停所有播放
|
||||
@@ -535,7 +537,6 @@ export default {
|
||||
},
|
||||
//语音切换
|
||||
onVoice(status) {
|
||||
this.checkRecordPermission();
|
||||
if (status) {
|
||||
this.inputfocus = false;
|
||||
this.MoreStatus = false;
|
||||
@@ -754,8 +755,8 @@ export default {
|
||||
getIOSDeviceType() {
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
const model = systemInfo.model;
|
||||
if (/iPhone X|iPhone11|iPhone12|iPhone13|iPhone14/i.test(model)) {
|
||||
if (/iPhone X|iPhone XS|iPhone 11 Pro/i.test(model)) {
|
||||
if (/iPhone X|iPhone11|iPhone12|iPhone13|iPhone14|iPhone15|iPhone16|iPhone15 Pro|iPhone15 Pro Max|iPhone14 Pro|iPhone14 Pro Max|iPhone13 Pro|iPhone13 Pro Max|iPhone12 Pro|iPhone12 Pro Max|iPhone11 Pro|iPhone11 Pro Max|iPhone13 mini|iPhone12 mini|iPhoneXS|iPhoneXS Max/i.test(model)) {
|
||||
if (/iPhone X|iPhone XS|iPhone 11 Pro|iPhone 11 Pro Max|iPhone 12 Pro|iPhone 12 Pro Max|iPhone 13 Pro|iPhone 13 Pro Max|iPhone 14 Pro|iPhone 14 Pro Max|iPhone 15 Pro|iPhone 15 Pro Max|iPhone 16/i.test(model)) {
|
||||
this.ioshide = 88;
|
||||
} else if (/iPhone 12|iPhone 13|iPhone 14/i.test(model)) {
|
||||
this.ioshide = 94;
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
<button class="login-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
|
||||
使用手机号快捷登录
|
||||
</button>
|
||||
<button class="login-btns" @click="loginWithEmailOrAccount">
|
||||
使用邮箱或者账号登录
|
||||
</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -51,6 +54,12 @@ export default {
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 邮箱或者账号登录
|
||||
loginWithEmailOrAccount() {
|
||||
uni.navigateTo({
|
||||
url: "/pages/loginWithEmailOrAccount/loginWithEmailOrAccount",
|
||||
});
|
||||
},
|
||||
// 返回首页
|
||||
Return() {
|
||||
uni.reLaunch({
|
||||
@@ -156,6 +165,12 @@ export default {
|
||||
border: 1px solid #00ff0000;
|
||||
color: #ffffff;
|
||||
}
|
||||
.login-btns{
|
||||
margin-top: 20rpx;
|
||||
background-color: hsla(0, 0%, 100%, 0);
|
||||
border: 1px solid #00ff0000;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.tips {
|
||||
color: #666;
|
||||
|
||||
190
pages/loginWithEmailOrAccount/loginWithEmailOrAccount.vue
Normal file
190
pages/loginWithEmailOrAccount/loginWithEmailOrAccount.vue
Normal file
@@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="bg"> </view>
|
||||
<view class="Return" @click="onBack">
|
||||
<image
|
||||
class="ReturnImg"
|
||||
src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Return.png"
|
||||
mode="scaleToFill"
|
||||
/>
|
||||
</view>
|
||||
<view class="title">邮箱或账号登录</view>
|
||||
<view class="form">
|
||||
<view class="form-content">
|
||||
<input
|
||||
type="text"
|
||||
class="input"
|
||||
placeholder="请输入邮箱或账号"
|
||||
v-model="EmailOrAccount"
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
class="input"
|
||||
placeholder="请输入密码"
|
||||
v-model="Password"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<view class="btn" @click="onLogin">登录</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from "../../components/request.js";
|
||||
import { goEasylogin } from "../../components/goEasyTool/tool.js";
|
||||
import { useCounterStore } from "@/stores/counter";
|
||||
|
||||
const counter = useCounterStore();
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
title: "Hello",
|
||||
EmailOrAccount: "",
|
||||
Password: "",
|
||||
};
|
||||
},
|
||||
onLoad() {},
|
||||
methods: {
|
||||
// 登录
|
||||
onLogin() {
|
||||
const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,16}$/;
|
||||
if (!passwordRegex.test(this.Password)) {
|
||||
uni.showToast({
|
||||
title: "密码必须包含大小写字母和数字,长度6-16位",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
title: "登录中...",
|
||||
mask: true,
|
||||
});
|
||||
request({
|
||||
url: "user/loginWithMail",
|
||||
method: "POST",
|
||||
data: {
|
||||
userNameOrEmail: this.EmailOrAccount,
|
||||
password: this.Password,
|
||||
},
|
||||
userInfo: false,
|
||||
})
|
||||
.then((res) => {
|
||||
uni.hideLoading();
|
||||
console.log(res);
|
||||
this.info = res;
|
||||
const now = Date.now();
|
||||
uni.setStorageSync("last_clean_time", now);
|
||||
counter.$patch({ myitem: this.info.data });
|
||||
if (res.code === 200) {
|
||||
uni.setStorageSync("userinfo", this.info.data);
|
||||
uni.setStorageSync("token", this.info.data.token);
|
||||
goEasylogin(
|
||||
this.$goeasy,
|
||||
String(this.info.data.id),
|
||||
this.info.data.headerIcon,
|
||||
this.info.data.nickName
|
||||
);
|
||||
uni.reLaunch({
|
||||
url: this.lastPage||'/pages/Home/Home',
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: err.msg,
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
},
|
||||
// 返回上一页
|
||||
onBack() {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.bg {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: -1;
|
||||
background: linear-gradient(to bottom, #11cb2a6e, #2574fc6d);
|
||||
}
|
||||
.bgImg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.Return {
|
||||
position: absolute;
|
||||
top: 110rpx;
|
||||
left: 35rpx;
|
||||
width: 46rpx;
|
||||
height: 46rpx;
|
||||
z-index: 1;
|
||||
}
|
||||
.title {
|
||||
position: fixed;
|
||||
top: 120rpx;
|
||||
left: 0;
|
||||
right: 0;
|
||||
text-align: center;
|
||||
font-size: 34rpx;
|
||||
color: #100e0f;
|
||||
font-weight: bold;
|
||||
z-index: 1;
|
||||
}
|
||||
.ReturnImg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.form {
|
||||
position: absolute;
|
||||
top: 0rpx;
|
||||
left: 0rpx;
|
||||
right: 0rpx;
|
||||
bottom: 0rpx;
|
||||
}
|
||||
.form-content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.input {
|
||||
width: 80%;
|
||||
height: 80rpx;
|
||||
border: none;
|
||||
border-bottom: #4fcacd solid 1px;
|
||||
margin-bottom: 150rpx;
|
||||
padding-left: 10rpx;
|
||||
font-size: 24rpx;
|
||||
color: #000000;
|
||||
}
|
||||
.btn {
|
||||
width: 80%;
|
||||
height: 80rpx;
|
||||
background-color: #4fcacd;
|
||||
border-radius: 20rpx;
|
||||
font-size: 28rpx;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
line-height: 80rpx;
|
||||
margin-top: 100rpx;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user