This commit is contained in:
徐哼唧L
2024-01-08 13:50:53 +08:00
parent c3f3918c9b
commit 50da1d7e38
14 changed files with 2610 additions and 347 deletions

View File

@@ -15,58 +15,79 @@
<!-- <view class="title" :class="{ active: type == 2000 }" @click="type = 2000">验证码登录/注册</view>
<view class="title" :class="{ active: type == 1000 }" @click="type = 1000">密码登录</view> -->
</view>
<view class="flexbox" style=" margin-top: 20rpx;">
<view class="input_tit" style="margin-top: 0; margin-right: 20rpx;">手机号</view>
<view class="quhao">
<uni-data-select class="myselect" placeholder="选择区号" v-model="quCode" :localdata="quCodeList" style="height: 30rpx !important;"
@change="quChange"></uni-data-select>
<!-- 验证码登录 -->
<view v-if="type == 2000">
<view class="flexbox" style=" margin-top: 50rpx;">
<view class="input_tit emaPho" style="margin-top: 0; margin-right: 20rpx;">
<view @click="brand=3000" :class="{ active: brand == 3000 }">手机号</view>
<span>/</span>
<view @click="brand=4000" :class="{ active: brand == 4000 }">邮箱</view>
</view>
</view>
</view>
<!-- 带区号 -->
<view class="flexbox " style="margin:36rpx 0; justify-content: space-between;">
<view class="triangle borderBottom phoneNumberInput" style="width: 150rpx;">
<input type="number" v-model="quCode" placeholder="区号" placeholder-class="grey" />
<!-- 带区号手机号 -->
<view class="flexbox" v-if="brand == 3000" style="margin:36rpx 0; justify-content: space-between;">
<!-- <view class="triangle borderBottom phoneNumberInput" style="width: 150rpx;">
<input type="number" v-model="quCode" placeholder="区号" placeholder-class="grey" />
</view> -->
<view class="quhao">
<uni-data-select class="myselect" placeholder="请选择区号" v-model="quCode" :localdata="quCodeList"
style="height: 30rpx !important;" @change="quChange"></uni-data-select>
</view>
<view class="triangle borderBottom phoneNumberInput"
:clasfs="[type == 1000 ? 'left_triangle': 'right_triangle']">
<input type="number" v-model="phone" @input="onInput" placeholder="请输入您的手机号"
placeholder-class="grey" />
</view>
</view>
<view class="triangle borderBottom phoneNumberInput"
<!-- 不带区号 -->
<!-- <view class="triangle borderBottom phoneNumberInput input_box"
:clasfs="[type == 1000 ? 'left_triangle': 'right_triangle']">
<input type="number" v-model="phone" @input="onInput" placeholder="请输入您的手机号"
placeholder-class="grey" />
<input type="number" v-model="phone" @input="onInput" placeholder="请输入您的手机号" placeholder-class="grey" />
</view> -->
<!-- 邮箱 -->
<view class="input_box" v-if="brand == 4000">
<input v-model="email" placeholder="请输入您的邮箱" placeholder-class="grey" @input="onInput" />
</view>
<view class="input_tit">验证码</view>
<view class="input_box">
<input v-model="code" placeholder="请输入您的验证码" placeholder-class="grey" @input="onInput" maxlength="6"
@confirm="onSubmit" />
<button class="active" @click="onSetCode">{{ codeText }}</button>
</view>
</view>
<!-- 不带区号 -->
<!-- <view class="triangle borderBottom phoneNumberInput input_box"
:clasfs="[type == 1000 ? 'left_triangle': 'right_triangle']">
<input type="number" v-model="phone" @input="onInput" placeholder="请输入您的手机号" placeholder-class="grey" />
</view> -->
<view class="input_tit" v-if="type == 1000">密码</view>
<view class="input_box" v-if="type == 1000">
<input class="input_item" v-model="password" @input="onInput" :password="!isSee" placeholder="请输入密码"
placeholder-class="grey" @confirm="onSubmit" />
<image v-if="isSee" src="../../static/icon/ic_logon_display.png" mode="aspectFit"
@click="isSee = false">
</image>
<image v-else-if="!isSee" src="../../static/icon/ic_logon_hide.png" mode="aspectFit"
@click="isSee = true">
</image>
<!-- 密码登录 -->
<view v-if="type == 1000">
<!-- 手机号/邮箱 -->
<view class="input_tit" style=" margin-top: 80rpx;">手机号 / 邮箱</view>
<view class="input_box">
<input v-model="phoneEmail" placeholder="请输入您的手机号或者邮箱" placeholder-class="grey" @input="onInput" />
</view>
<view class="input_tit">密码</view>
<view class="input_box">
<input class="input_item" v-model="password" @input="onInput" :password="!isSee" placeholder="请输入密码"
placeholder-class="grey" @confirm="onSubmit" />
<image v-if="isSee" src="../../static/icon/ic_logon_display.png" mode="aspectFit"
@click="isSee = false">
</image>
<image v-else-if="!isSee" src="../../static/icon/ic_logon_hide.png" mode="aspectFit"
@click="isSee = true">
</image>
</view>
</view>
<view class="input_tit" v-if="type == 2000">验证码</view>
<view class="input_box" v-if="type == 2000">
<input v-model="code" placeholder="请输入您的验证码" placeholder-class="grey" @input="onInput" maxlength="6"
@confirm="onSubmit" />
<button class="active" @click="onSetCode">{{ codeText }}</button>
</view>
<view class="protocol_box">
<view class="select" :class="{active: agree}" @click="agree = !agree"></view>
我已同意
<!-- <text @click="plus.runtime.openURL('https://main.nuttyreading.com/agreement.html')">用户协议</text> -->
<!-- <text @click="onPageJump('/pages/user/protocol')">用户协议</text> -->
<span class="highlight" @click="showXieyi('user')">用户协议</span>
<span class="highlight" @click="yhxyShow=true">用户协议</span>
<span class="highlight" @click="showXieyi('privacy')">隐私协议</span>
<span class="highlight" @click="yszcShow=true">隐私协议</span>
<!-- <text @click="onPageJump('/pages/user/protocol')">隐私协议</text>-->
</view>
<view class="btn_box">
@@ -93,6 +114,11 @@
</view>
</view>
<view class="youKeL">
<view @click="onPageJump('/pages/user/visitor')">免登陆体验</view>
</view>
<z-popup v-model="HealthOpen" type="center" :hideOnBlur="false">
<view class="popup_box">
<view class="popup_title">
@@ -138,14 +164,22 @@
</view> -->
<!-- #endif -->
<u-popup :show="xieyiShow" :round="10" @close="xieyiShow=false">
<u-popup :show="yhxyShow" title='用户协议' :round="10" @close="yhxyShow=false">
<view class="tanchu">
<view class="dp_title">{{xieyi.title}}</view>
<view style="max-height: 1000rpx;overflow-y: scroll;">
<view v-html="xieyi.Content"></view>
</view>
<view class="dp_title" v-html="yhxyText.title"></view>
<view class="dp_content" v-html="yhxyText.content"></view>
<!-- <yhxyPage></yhxyPage> -->
</view>
</u-popup>
<u-popup :show="yszcShow" title='隐私政策' :round="10" @close="yszcShow=false">
<view class="tanchu">
<view class="dp_title" v-html="yszcText.title"></view>
<view class="dp_content" v-html="yszcText.content"></view>
<!-- <yszcPage></yszcPage> -->
</view>
</u-popup>
</view>
</view>
@@ -154,9 +188,12 @@
<script>
import $http from '@/config/requestConfig.js';
import md5 from '@/plugins/md5';
// import yhxyPage from '@/pages/agreement/yhxyPage.vue';
// import yszcPage from '@/pages/agreement/yszcPage.vue';
import localuserxieyi from '@/static/json/userAndyinsiP.json'
import localyinsixieyi from '@/static/json/yinsiP.json'
// import localuserxieyi from '@/static/json/userAndyinsiP.json'
// import localyinsixieyi from '@/static/json/yinsiP.json'
var clear;
import {
mapState,
@@ -164,14 +201,21 @@
} from 'vuex';
import socket from '@/config/socket';
export default {
// components: {
// yhxyPage,
// yszcPage
// },
data() {
return {
type: 2000,
brand: 3000,
isSee: false,
code: '',
// phone: '15022449475',
// phone: '18047689535',
phone: '',
email: '',
phoneEmail: '',
password: '',
//验证码
codeText: '获取验证码',
@@ -189,11 +233,10 @@
health_phone: '',
health_password: '',
isSee_H: false,
xieyiShow: false,
xieyi: {
title: '',
Content: ''
},
yhxyShow: false,
yszcShow: false,
yhxyText: {},
yszcText: {},
quShow: false,
quCodeList: [], // 国家区域码
quCode: 86,
@@ -215,6 +258,7 @@
//页面显示
onShow() {
this.getCountyCode()
this.getSettlement()
},
//方法
methods: {
@@ -236,7 +280,7 @@
// this.quCodeList = res.baseAreas
this.quCodeList = res.baseAreas.map(item => {
let obj = {
'text': item.title,
'text': item.title + ' (+' + item.code + ')',
'value': item.code,
}
return obj
@@ -250,6 +294,35 @@
console.log(e, 'e')
});
},
// 获取协议内容
getSettlement() {
this.$http
.post('sys/agreement/getPrivacyDetail')
.then(res => {
this.yszcText = res.privacy
this.yszcText.content = this.yszcText.content.replace(/<h5>/g,
'<view style="font-weight: bold;font-size: 32rpx;margin-top: 20rpx;margin-bottom: 20rpx;">'
);
this.yszcText.content = this.yszcText.content.replace(/<\/h5>/g, '</view>');
}).catch((e) => {
console.log(e, 'e')
})
this.$http
.post('sys/agreement/getUserDetail')
.then(res => {
this.yhxyText = res.user
this.yhxyText.content = this.yhxyText.content.replace(/<h5>/g,
'<view style="font-weight: bold;font-size: 32rpx;margin-top: 20rpx;margin-bottom: 20rpx;">'
);
this.yhxyText.content = this.yhxyText.content.replace(/<\/h5>/g, '</view>');
}).catch((e) => {
console.log(e, 'e')
})
},
quChange(e) {
console.log(e, 'e')
},
@@ -260,17 +333,8 @@
url: "/pages/home/shop/goodsDetail"
})
},
// 显示协议
showXieyi(str) {
if (str == 'user') {
this.xieyi = localuserxieyi
} else {
this.xieyi = localyinsixieyi
}
//console.log(localuserxieyi)
this.xieyiShow = true
},
onPageJump(url) {
uni.navigateTo({
url: url
@@ -316,23 +380,7 @@
if (this.readonly) {
return;
}
if (!this.phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (this.quCode == null || this.quCode == 86) { // 如果没选择国家code默认是中国大陆
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '手机格式不正确',
icon: 'none'
});
return;
}
console.log(this.quCode, '选择的区段')
}
if (!this.agree) {
uni.showToast({
title: '请先同意《用户协议》和《隐私协议》',
@@ -341,19 +389,66 @@
return;
}
this.$http
.get('book/user/sms/sendcode', {
phone: this.phone,
areaCode: this.quCode,
type: 2000
})
.then(res => {
if (this.brand == 3000) {
if (!this.phone) {
uni.showToast({
title: '验证码发送成功',
title: '请输入手机号',
icon: 'none'
});
this.getCodeState();
});
return;
}
if (this.quCode == null || this.quCode == 86) { // 如果没选择国家code默认是中国大陆
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '手机格式不正确',
icon: 'none'
});
return;
}
console.log(this.quCode, '选择的区段')
}
this.$http
.get('book/user/sms/sendcode', {
phone: this.phone,
areaCode: this.quCode,
type: 2000
})
.then(res => {
uni.showToast({
title: '验证码发送成功',
icon: 'none'
});
this.getCodeState();
});
} else {
if (!this.email) {
uni.showToast({
title: '请输入邮箱',
icon: 'none'
});
return;
}
if (!this.$base.mailRegular.test(this.email)) {
uni.showToast({
title: '邮箱格式不正确',
icon: 'none'
});
return;
}
this.$http
.get('book/user/getMailCaptcha', {
email: this.email
})
.then(res => {
uni.showToast({
title: '验证码发送成功',
icon: 'none'
});
this.getCodeState();
});
}
},
// 手机密码登录
@@ -365,24 +460,44 @@
});
return;
}
if (!this.phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (this.quCode == null || this.quCode == 86) {
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '手机格式不正确',
icon: 'none'
});
return;
}
}
let httpData = {};
if (this.type == 2000) {
if (this.brand == 3000) {
if (!this.phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (this.quCode == null || this.quCode == 86) {
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '手机格式不正确',
icon: 'none'
});
return;
}
}
httpData.tel = this.phone;
} else {
if (!this.email) {
uni.showToast({
title: '请输入邮箱',
icon: 'none'
});
return;
}
if (!this.$base.mailRegular.test(this.email)) {
uni.showToast({
title: '邮箱格式不正确',
icon: 'none'
});
return;
}
httpData.tel = this.email;
}
if (!this.code) {
uni.showToast({
title: '请输入验证码',
@@ -391,7 +506,7 @@
return;
}
httpData.code = this.code;
httpData.tel = this.phone;
this.$http
.get('book/user/registerOrLogin', httpData)
.then(res => {
@@ -409,6 +524,13 @@
}, 1000);
});
} else {
if (!this.phoneEmail) {
uni.showToast({
title: '请输入手机号或邮箱',
icon: 'none'
});
return;
}
if (!this.password) {
uni.showToast({
title: '请输入密码',
@@ -418,7 +540,7 @@
}
// httpData.password = md5(this.password);
httpData.password = this.password;
httpData.phone = this.phone;
httpData.phone = this.phoneEmail;
this.$http
.post('book/user/login', httpData)
.then(res => {
@@ -670,7 +792,7 @@
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.myselect{height: 50rpx !important;}
.phoneNumberInput {
width: calc(100% - 160rpx);
// width: 100%;
@@ -692,9 +814,28 @@
.quhao {
height: 50rpx;
width: 180rpx;
width: 290rpx;
margin: 12rpx 15rpx 0 0;
}
.myselect {
height: 50rpx !important;
/deep/.uni-select {
font-size: 24rpx;
}
/deep/.uni-select__selector-item {
font-size: 24rpx;
}
}
.highlight {
color: $themeColor;
}
@@ -704,13 +845,6 @@
position: relative;
.dp_title {
font-size: 32rpx;
margin-bottom: 50rpx;
color: #555;
text-align: center;
font-weight: bold;
}
@@ -817,6 +951,28 @@
margin-top: 20rpx;
font-size: 34rpx;
font-weight: bold;
color: #54a966;
}
.emaPho {}
.emaPho>view {
display: inline-block;
padding: 10rpx 0;
color: #888;
}
.emaPho>view.active {
color: #54a966;
padding: 10rpx 10rpx;
border-bottom: 2px solid #54a966;
font-weight: bold;
}
.emaPho>span {
display: inline-block;
margin: 0 30rpx;
color: #ccc;
}
.input_box {
@@ -1019,9 +1175,61 @@
}
}
.dp_title {
font-size: 36rpx;
margin-bottom: 50rpx;
color: #555;
text-align: center;
font-weight: bold;
}
.dp_content {
max-height: 1000rpx;
overflow-y: scroll;
font-size: 28rpx;
color: #555;
line-height: 45rpx;
.dp_con1 {
font-weight: bold;
font-size: 32rpx;
margin-top: 20rpx;
margin-bottom: 20rpx;
}
// .dp_con2 {
// font-size: 30rpx;
// margin-top: 10rpx;
// margin-bottom: 10rpx;
// }
}
.qie_huan {
font-size: 26rpx;
margin: 20rpx 0 0 0;
text-align: center;
}
.comTy {
font-size: 28rpx;
line-height: 46rpx;
text-align: left;
}
.youKeL {
display: flex;
justify-content: center;
margin: 30rpx 0 0 0;
font-size: 26rpx;
color: #54a966;
view {
font-weight: bold;
border: 1px solid #54a966;
border-radius: 10rpx;
padding: 5rpx 15rpx;
}
}
</style>

View File

@@ -5,33 +5,92 @@
<z-nav-bar title="个人资料"></z-nav-bar>
<view class="tabulate">
<view class="per_list">
<text class="biaoti"></text>
<text class="neirong">{{userMes.tel}}</text>
<text class="biaoti">手机</text>
<text class="neirong">{{userMsage.tel}}</text>
<text class="marPer" v-if="userMsage.tel==''" @click="phoneShow = true;OpenClear()"
style="background-color: #ed901d;">点击绑定</text>
</view>
<view class="per_list">
<text class="biaoti">邮箱</text>
<text class="neirong">{{userMsage.email}}</text>
<text class="marPer" v-if="userMsage.email!=''" @click="emailShow = true;OpenClear()"
style="background-color: #ed901d;">点击绑定</text>
</view>
<view class="per_list per_list_arrow" @click="avatarShow = true">
<text class="biaoti" style="margin-top: 40rpx;">头像</text>
<text class="neirong" style="margin-top: 0;">
<image :src="userMes.avatar" class="per_mes_img"></image>
<image :src="userMsage.avatar" class="per_mes_img"></image>
</text>
</view>
<view class="per_list per_list_arrow" @click="nicknameShow = true">
<text class="biaoti">昵称</text>
<text class="neirong">{{userMes.nickname}}</text>
<text class="neirong">{{userMsage.nickname}}</text>
</view>
<view class="per_list per_list_arrow" @click="passwordShow = true">
<text class="biaoti">修改密码</text>
<text class="biaoti">密码</text>
<text v-if="userMsage.YNpass!=''" class="neirong">点击修改</text>
<text class="marPer" v-if="userMsage.YNpass!=''"
style="background-color: #92c78c;margin-right: 40rpx;">已设定</text>
<text v-if="userMsage.YNpass==''" class="neirong">去设置</text>
<text class="marPer" v-if="userMsage.YNpass==''"
style="background-color: #9d9d9d;margin-right: 40rpx;">未设定</text>
</view>
<view class="per_list per_list_arrow" @click="ageShow = true">
<text class="biaoti">年龄</text>
<text class="neirong">{{userMes.age}}</text>
<text class="neirong">{{userMsage.age}}</text>
</view>
<view class="per_list per_list_arrow" @click="sexShow = true">
<text class="biaoti">性别</text>
<text class="neirong" v-if="userMes.sex==1"></text>
<text class="neirong" v-if="userMes.sex==0"></text>
<text class="neirong" v-if="userMsage.sex==1"></text>
<text class="neirong" v-if="userMsage.sex==0"></text>
</view>
</view>
<!-- 手机 -->
<u-popup :show="phoneShow" :round="10" @close="phoneShow=false;">
<view class="tanchu">
<view class="dp_title">请输入手机号</view>
<view style="display: flex;">
<view class="quhao">
<uni-data-select class="quhaoSel" placeholder="请选择区号" v-model="userMes.quCode"
:localdata="quCodeList"></uni-data-select>
</view> <u--input v-model="userMes.phone" placeholder="请输入手机号" border="surround" clearable>
</u--input>
</view>
<view style="display: flex;">
<u--input v-model="userMes.phonecode" type="number" placeholder="请输入验证码" border="surround" clearable
style="margin-top: 20rpx;">
</u--input>
<button class="emPHCode" @click="onSetCode('phone')">{{ PhoneEmailNote }}</button>
</view>
<u-button color="linear-gradient(to right, #72d386, #317e42)" text="确定" @click="chosePhone()"
style="margin-top: 50rpx;"></u-button>
<view @click="phoneShow=false" class="dp_canBtn">
取消</view>
</view>
</u-popup>
<!-- 邮箱 -->
<u-popup :show="emailShow" :round="10" @close="emailShow=false;PhoneEmailNote = '获取验证码'">
<view class="tanchu">
<view class="dp_title">请输入邮箱</view>
<u--input v-model="userMes.email" placeholder="请输入邮箱" border="surround" clearable>
</u--input>
<view style="display: flex;">
<u--input v-model="userMes.emailcode" type="number" placeholder="请输入验证码" border="surround" clearable
style="margin-top: 20rpx;">
</u--input>
<button class="emPHCode" @click="onSetCode('email')">{{ PhoneEmailNote }}</button>
</view>
<u-button color="linear-gradient(to right, #72d386, #317e42)" text="确定" @click="choseEmail()"
style="margin-top: 50rpx;"></u-button>
<view @click="emailShow=false" class="dp_canBtn">
取消</view>
</view>
</u-popup>
<!-- 头像 -->
<u-popup :show="avatarShow" :round="10" @close="avatarShow=false">
<view class="tanchu">
@@ -91,15 +150,15 @@
<u-popup :show="passwordShow" :round="10" @close="cancelPass">
<view class="tanchu">
<view class="dp_title">请修改密码</view>
<u--input maxlength="8" v-model="userMes.password" placeholder="请输入新密码" :password="true" border="surround" clearable
@input="inputMethod(userMes.password)">
<u--input maxlength="8" v-model="userMiMa.password" placeholder="请输入新密码" :password="true"
border="surround" clearable @input="inputMethod(userMiMa.password)">
</u--input>
<view class="" style="font-size: 28rpx; color: #999;">
<p v-if="note != ''">{{note}}</p>
<p v-html="str2" style="margin-top: 10rpx;"></p>
</view>
<u--input maxlength="8" v-model="userMes.Repassword" placeholder="请再确认密码" :password="true" border="surround" clearable
style="margin-top: 20rpx;"></u--input>
<p v-if="passNote != ''">{{passNote}}</p>
<p v-html="passStr" style="margin-top: 10rpx;"></p>
</view>
<u--input maxlength="8" v-model="userMiMa.Repassword" placeholder="请再确认密码" :password="true"
border="surround" clearable style="margin-top: 20rpx;"></u--input>
<u-button color="linear-gradient(to right, #72d386, #317e42)" text="确定" @click="chosePassword()"
style="margin-top: 50rpx;"></u-button>
<view @click="cancelPass" class="dp_canBtn">取消</view>
@@ -115,6 +174,7 @@
<script>
import musicPlay from '@/components/music.vue'
import $http from '@/config/requestConfig.js';
var clear;
import {
mapState
} from 'vuex';
@@ -131,21 +191,45 @@
return {
playData: {},
userMes: {
quCode: '',
phone: '',
email: '',
id: '',
age: '',
sex: '',
nickname: '',
tel: '',
password: '',
Repassword: '',
oldName: '', // 老的用户名
},
userMsage: {
quCode: '',
phonecode: '',
phone: '',
emailcode: '',
email: '',
id: '',
age: '',
sex: '',
nickname: '',
tel: '',
YNpass: '',
oldName: '', // 老的用户名
},
userMiMa: {
id: '',
password: '',
Repassword: '',
},
readonly: false,
phoneShow: false,
emailShow: false,
avatarShow: false,
nicknameShow: false,
ageShow: false,
sexShow: false,
passwordShow: false,
fileAvatar: [],
quCodeList: [], // 国家区域码
sexList: [{
title: '男',
id: 1,
@@ -155,9 +239,10 @@
id: 0,
}
],
note: '',
str2: '',
passwordOk:false, // 密码是否满足规则
PhoneEmailNote: '获取验证码',
passNote: '',
passStr: '',
passwordOk: false, // 密码是否满足规则
};
},
//第一次加载
@@ -173,6 +258,7 @@
// 隐藏原生的tabbar
uni.hideTabBar();
this.getData();
this.getCountyCode()
},
components: {
musicPlay
@@ -180,8 +266,37 @@
//方法
methods: {
// 获取
getCountyCode() {
let that = this
// 获取国家区域编码
$http.request({
url: "book/baseArea/getAllBaseArea",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data: {},
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
})
.then(res => {
// console.log(res,'区域码')
if (res.code == 0 && res.baseAreas.length > 0) {
that.quCodeList = res.baseAreas.map(item => {
let obj = {
'text': item.title + ' (+' + item.code + ')',
'value': item.code,
}
return obj
})
} else {
that.quCodeList = []
}
}).catch(e => {
console.log(e, 'e')
});
},
getData() {
let that = this
// 获取个人信息
if (this.userInfo.id != undefined) {
this.$http
@@ -194,173 +309,371 @@
that.userMes.tel = res.user.tel
that.userMes.avatar = res.user.avatar
that.userMes.oldName = that.userMes.nickname
that.userMes.id = res.user.id
that.userMsage.age = res.user.age
that.userMsage.email = res.user.email
that.userMsage.sex = res.user.sex
that.userMsage.nickname = res.user.nickname
that.userMsage.tel = res.user.tel
that.userMsage.avatar = res.user.avatar
that.userMsage.YNpass = res.user.password
that.userMiMa.id = res.user.id
});
}
},
cancelPass(){
this.passwordShow = false,
this.userMes.password = '',
this.userMes.Repassword = ''
this.note = '',
this.str2 = ''
cancelPass() {
this.passwordShow = false
this.userMiMa.password = ''
this.userMiMa.Repassword = ''
this.passNote = ''
this.passStr = ''
},
// 密码验证
inputMethod(value) {
this.passwordOk = false
// console.log('输入的值为:', value)
// console.log('输入的值为:', value)
if (strongRegex.test(value)) {
//console.log('强密码-----',value)
this.str2 = "<span style='color:#18bc37'>密码强度很不错哦!</span>"
// this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.note = ''
this.passStr = "<span style='color:#18bc37'>密码强度很不错哦!</span>"
// this.passNote = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.passNote = ''
this.passwordOk = true
} else if (mediumRegex.test(value)) {
//console.log('中等密码-----',value)
this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.str2 = "<span style='color:#2979ff'>密码强度中等!</span>"
this.passNote = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.passStr = "<span style='color:#2979ff'>密码强度中等!</span>"
this.passwordOk = true
} else if (enoughRegex.test(value)) {
//console.log('弱密码-----',value)
this.str2 = "<span style='color:#f3a73f'>密码强度太弱!</span>"
this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.passStr = "<span style='color:#f3a73f'>密码强度太弱!</span>"
this.passNote = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
} else {
this.passwordOk = false
this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.str2 = ""
this.passNote = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.passStr = ""
//console.log('密码-----',value)
}
},
// 头像
choseAvatar(e) {
let that = this
if (that.fileAvatar.length == 0) {
uni.showToast({
title: "请选择图片",
icon: 'none'
});
return
}
that.userMes.avatar = that.fileAvatar[0].url
that.choseData()
that.avatarShow = false
that.fileAvatar.splice(0, 1)
},
// 年龄
choseAge(e) {
let that = this
if (that.userMes.age <= 0) {
uni.showToast({
title: "年龄不能小于0",
icon: 'none'
});
return
}
that.choseData()
that.ageShow = false
},
// 昵称
choseNickname(e) {
let that = this
if (e && e != '') {
that.choseData()
that.nicknameShow = false
} else {
that.userMes.nickname = that.userMes.oldName
console.log(that.userMes.nickname)
uni.showToast({
title: '昵称不可为空',
icon: 'none'
})
}
},
// 性别
choseSex(e) {
let that = this
that.userMes.sex = e
that.choseData()
that.sexShow = false
},
// 修改密码
chosePassword() {
if(!this.passwordOk){
console.log('不满足密码格式',this.note)
uni.showToast({
title:this.note,
icon: 'none'
})
return
}
let that = this
if (that.userMes.Repassword == '' || that.userMes.password == '') {
uni.showToast({
icon: "none",
title: "请输入密码!"
});
return
}
if (that.userMes.Repassword != that.userMes.password) {
uni.showToast({
icon: "none",
title: "两次密码输入不一致!"
});
return
}
that.choseData()
that.passwordShow = false
},
// 修改个人资料
choseData() {
let that = this
$http.request({
url: "book/user/update",
method: "POST",
data: that.userMes,
header: {
'Content-Type': 'application/json'
},
}).then(function(res) {
if (res.code == 0) {
uni.showToast({
title: "修改成功"
});
}
}).catch(function(error) {
console.log(error);
});
},
// 头像上传
afterRead(e) {
let that = this
uni.uploadFile({
url: this.$baseUrl + 'oss/fileoss',
filePath: e.file[0].url,
name: 'file',
formData: {},
success: (res) => {
that.fileAvatar.push({
url: JSON.parse(res.data).url
})
}
});
},
// 删除图片
deletePic() {
let that = this
that.fileAvatar.splice(0, 1)
},
}
},
};
// 清除验证码
OpenClear() {
clearInterval(clear)
this.PhoneEmailNote = '获取验证码';
this.readonly = false;
},
// 获取验证码
emPHCode() {
clear && clearInterval(clear);
this.readonly = true
this.PhoneEmailNote = '60S';
var s = 60;
clear = setInterval(() => {
s--;
this.PhoneEmailNote = s + 'S';
if (s <= 0) {
clearInterval(clear);
this.PhoneEmailNote = '获取验证码';
this.readonly = false;
}
}, 1000);
},
// 发送验证码
onSetCode(e) {
if (this.readonly) {
return;
}
if (e == 'phone') {
if (!this.userMes.phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (this.userMes.quCode == null || this.userMes.quCode == 86) {
if (!this.$base.phoneRegular.test(this.userMes.phone)) {
uni.showToast({
title: '手机格式不正确',
icon: 'none'
});
return;
}
}
this.$http
.get('book/user/sms/sendcode', {
phone: this.userMes.phone,
areaCode: this.userMes.quCode,
type: 2000
})
.then(res => {
uni.showToast({
title: '验证码发送成功',
icon: 'none'
});
this.emPHCode();
});
}
if (e == 'email') {
if (!this.userMes.email) {
uni.showToast({
title: '请输入邮箱',
icon: 'none'
});
return;
}
if (!this.$base.mailRegular.test(this.userMes.email)) {
uni.showToast({
title: '邮箱格式不正确',
icon: 'none'
});
return;
}
this.$http
.get('book/user/getMailCaptcha', {
email: this.userMes.email
})
.then(res => {
uni.showToast({
title: '验证码发送成功',
icon: 'none'
});
this.emPHCode();
});
}
},
// 手机
chosePhone(e) {
this.userMes.code = this.userMes.phonecode
if (this.userMes.email == '') {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (this.userMes.code == '' || this.userMes.code == null) {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return;
}
$http.request({
url: "book/user/updateUserTel",
method: "POST",
data: this.userMes,
header: {
'Content-Type': 'application/json'
},
}).then(function(res) {
if (res.code == 0) {
this.getData();
this.phoneShow = false
uni.showToast({
title: "绑定手机号成功"
});
}
}).catch(function(error) {
console.log(error);
});
},
// 邮箱
choseEmail(e) {
this.userMes.code = this.userMes.emailcode
if (this.userMes.email == '') {
uni.showToast({
title: '请输入邮箱',
icon: 'none'
});
return;
}
if (this.userMes.code == '' || this.userMes.code == null) {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return;
}
$http.request({
url: "book/user/updateUserEmail",
method: "POST",
data: this.userMes,
header: {
'Content-Type': 'application/json'
},
}).then(function(res) {
if (res.code == 0) {
this.getData();
this.emailShow = false
uni.showToast({
title: "绑定邮箱成功"
});
}
}).catch(function(error) {
console.log(error);
});
},
// 头像
choseAvatar(e) {
let that = this
if (that.fileAvatar.length == 0) {
uni.showToast({
title: "请选择图片",
icon: 'none'
});
return
}
that.userMes.avatar = that.fileAvatar[0].url
that.choseData()
that.avatarShow = false
that.fileAvatar.splice(0, 1)
},
// 年龄
choseAge(e) {
let that = this
if (that.userMes.age <= 0) {
uni.showToast({
title: "年龄不能小于0",
icon: 'none'
});
return
}
that.choseData()
that.ageShow = false
},
// 昵称
choseNickname(e) {
let that = this
if (e && e != '') {
that.choseData()
that.nicknameShow = false
} else {
that.userMes.nickname = that.userMes.oldName
console.log(that.userMes.nickname)
uni.showToast({
title: '昵称不可为空',
icon: 'none'
})
}
},
// 性别
choseSex(e) {
let that = this
that.userMes.sex = e
that.choseData()
that.sexShow = false
},
// 修改密码
chosePassword() {
if (!this.passwordOk) {
console.log('不满足密码格式', this.passNote)
uni.showToast({
title: this.passNote,
icon: 'none'
})
return
}
let that = this
if (that.userMiMa.Repassword == '' || that.userMiMa.password == '') {
uni.showToast({
icon: "none",
title: "请输入密码!"
});
return
}
if (that.userMiMa.Repassword != that.userMiMa.password) {
uni.showToast({
icon: "none",
title: "两次密码输入不一致!"
});
return
}
$http.request({
url: "book/user/updateUserPassword",
method: "POST",
data: that.userMiMa,
header: {
'Content-Type': 'application/json'
},
}).then(function(res) {
if (res.code == 0) {
uni.showToast({
title: "修改成功"
});
that.passwordShow = false
}
}).catch(function(error) {
console.log(error);
});
},
// 修改个人资料
choseData() {
let that = this
$http.request({
url: "book/user/update",
method: "POST",
data: that.userMes,
header: {
'Content-Type': 'application/json'
},
}).then(function(res) {
if (res.code == 0) {
that.getData();
// that.$forceUpdate()
uni.showToast({
title: "修改成功"
});
}
}).catch(function(error) {
console.log(error);
});
},
// 头像上传
afterRead(e) {
let that = this
uni.uploadFile({
url: this.$baseUrl + 'oss/fileoss',
filePath: e.file[0].url,
name: 'file',
formData: {},
success: (res) => {
that.fileAvatar.push({
url: JSON.parse(res.data).url
})
}
});
},
// 删除图片
deletePic() {
let that = this
that.fileAvatar.splice(0, 1)
},
},
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
@@ -409,6 +722,17 @@
display: block;
}
text.marPer {
color: #fff;
font-weight: normal;
float: right;
margin: 25rpx 0 0 0;
display: block;
border-radius: 10rpx;
background-color: #eee;
padding: 2rpx 10rpx;
}
}
@@ -484,7 +808,40 @@
margin-top: 25rpx;
color: #888;
}
}
.submit {}
.emPHCode {
height: 80rpx;
width: 200rpx;
background-color: #f8f9fb;
font-size: 28rpx;
padding: 0 14rpx;
color: #54a966;
line-height: 80rpx;
margin: 20rpx 0 0 20rpx;
display: inline-block;
}
.quhao {
height: 60rpx;
width: 240rpx;
margin: 1rpx 15rpx 0 0;
.quhaoSel {
/deep/.uni-select {
font-size: 24rpx;
}
/deep/.uni-select__selector-item {
font-size: 24rpx;
}
/deep/.uni-stat__select {
height: 60rpx;
}
}
}
}
</style>

1255
pages/user/visitor.vue Normal file

File diff suppressed because it is too large Load Diff