This commit is contained in:
@fawn-nine
2024-05-29 15:34:50 +08:00
parent bb53af8bde
commit 4386f615f2
79 changed files with 6942 additions and 4121 deletions

500
pages/user/addAddress.vue Normal file
View File

@@ -0,0 +1,500 @@
<template>
<view>
<view class="addressHeader">
<!-- 顶部导航栏 -->
<z-nav-bar :title="navName"></z-nav-bar>
</view>
<view class="addContent">
<u-form :model="addressForm" ref='addForm' :rules="rules" label-width="180rpx">
<u-form-item label="收件人 :" prop="username">
<u-input type="string" v-model="addressForm.username" placeholder="姓名" clearable
border="surround" />
</u-form-item>
<u-form-item label="手机号码 :" prop="userphone">
<u-input type="number" v-model="addressForm.userphone" placeholder="手机号" clearable
border="surround" />
</u-form-item>
<u-form-item label="所在地区 :" prop="">
<view class="add_arrow" @click="addreShow=true">{{addressForm.areaidpathtext}}</view>
<u-picker @cancel="addcancel" :show="addreShow" ref="uPicker" :columns="columns" keyName="UName"
@confirm="addconfirm" @change="changeHandler" ></u-picker>
</u-form-item>
<u-form-item label="详细地址 :" prop="useraddress">
<u-input type="string" v-model="addressForm.useraddress" placeholder="小区楼栋/乡村名称" clearable
border="surround" />
</u-form-item>
<u-form-item label="默认地址 :">
<u-switch v-model="addressForm.isDafault" active-color="#ff9e02" @change="changeSwitch"></u-switch>
</u-form-item>
</u-form>
</view>
<view class="addFooter">
<view class="submit" @click="uploadSub">
保存
</view>
<view class="del" v-if="isShowDel" @click="deleteShow=true">
删除
</view>
</view>
<u-modal :show="deleteShow" content="你确定要删除地址吗?" :showCancelButton="true" @cancel="deleteShow=false"
@confirm="deleteSub">
</u-modal>
<music-play :playData="playData"></music-play>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import $http from '@/config/requestConfig.js';
import addressList1 from "@/static/json/address.json"
import {
mapState
} from 'vuex';
export default {
data() {
return {
// array: ['中国', '美国', '巴西', '日本'],
// indexp:0,
// indexq:0,
// indexc:0,
playData:{},
addreShow: false, //是否显示
columns: [], //省份数据显示,三级联动需要三维数组,展示初始数据
columnData: [], //市数据
columnDatas: [], //区地址
switchTrue: true,
switchFalse: false,
addressChanged:false, // 地址修改标记
navName: '', // 顶部导航栏标题
provId: '', // 存储省id
cityId: '', // 存储市id
countyId: '', // 存储区id
addressList: [],
// 地址
addressForm: {
addressid: '',
username: '',
userphone: '',
area: '',
useraddress: '',
isDafault: false,
areaidpathtext: ''
},
isShowDel: false,
editIndex: 0,
deleteShow: false,
rules: {
username: [{
required: true,
message: "请输入收件人姓名",
trigger: "blur"
}],
userphone: [{
required: true,
message: "请输入手机号",
},
{
// 自定义验证函数
validator: (rule, value, callback) => {
// 返回true表示校验通过返回false表示不通过
// 过滤第一层先判断输入为不为空因为required: false不是必填项所以为空应该返回true
if (value) {
return this.$u.test.mobile(value);
} else {
return true
}
},
message: '手机号码不正确',
// 触发器可以同时用blur和change
trigger: ['change', 'blur'],
}
],
useraddress: [{
required: true,
message: "请输入所在地区",
trigger: "blur"
}]
}
}
},
onLoad(e) {
this.addressList = addressList1
if (e.type == 0) {
this.navName = '添加地址'
this.isShowDel = false
} else {
this.navName = '编辑地址'
this.isShowDel = true
this.editIndex = e.index
this.getAddress()
}
this.initDataPicker() //初始化省份列表
},
onShow() {
},
computed: {
...mapState(['userInfo']),
},
onReady() {
this.$refs.addForm.setRules(this.rules)
},
components:{
musicPlay
},
methods: {
// 三级联动
initDataPicker() {
// console.log(this.addressList,'addressList')
// this.$http
// .post('api/province/getProvince')
// .then(res => {
// if (res.code == 0) {
// this.addressList = res.provinceEntity
//此处的province主要用作数据的初始化即刚打开就需要进行展示的数据这个跟第一条省份数据相关我的第一条是北京市所以需要columns中的三维数组第一维度是省份数据数组第二维度是市数据数组第三维度是区数据数组
let province = []; //初始数据需要展示的省份
let province1 = [{
"cityId": this.addressList[0].cityList[0].cityId,
"provId": this.addressList[0].cityList[0].provId,
"cityName": this.addressList[0].cityList[0].cityName,
"UName": this.addressList[0].cityList[0].cityName,
"createDate": this.addressList[0].cityList[0].createDate,
"regionCode": this.addressList[0].cityList[0].regionCode,
"countyList": this.addressList[0].cityList[0].countyList
}]; //因为第一个市北京市,所以就直接添加北京市下辖的直辖市了 也即初始数据需要展示的市,北京市只有一个市辖区
let province2 = []; //初始数据需要展示的区域数据,也即是 北京市市辖区内的区
for (let i = 0; i < this.addressList.length; i++) {
this.addressList[i].UName = this.addressList[i].provName
if (this.addressList[i].cityList == null) {
// 如果没有cityList数据就添加一项用省份的信息
// console.log('存在单一',this.addressList[i].provId)
this.addressList[i].cityList = [{
"cityId": this.addressList[i].provId,
"provId": this.addressList[i].provId,
"cityName": this.addressList[i].provName,
"UName": this.addressList[i].provName,
"createDate": this.addressList[i].createDate,
"regionCode": this.addressList[i].regionCode,
"countyList": [{
"countyId": this.addressList[i].provId,
"cityId": this.addressList[i].provId,
"countyName": this.addressList[i].provName,
"UName": this.addressList[i].provName,
"createDate": this.addressList[i].createDate,
"regionCode": this.addressList[i].regionCode
}]
}]
} else {
for (let j = 0; j < this.addressList[i].cityList.length; j++) {
this.addressList[i].cityList[j].UName = this.addressList[i].cityList[j]
.cityName
for (let k = 0; k < this.addressList[i].cityList[j].countyList.length; k++) {
this.addressList[i].cityList[j].countyList[k].UName = this.addressList[i]
.cityList[j].countyList[k].countyName
}
}
}
province.push(this.addressList[i]);
}
this.addressList[0].cityList[0].countyList.map(item => {
province2.push(item);
});
//省数据 因为要做数据初始化,所以是三维数组
// 数据格式 [ [所有的省份数据:{},{}] , [第一个省份下的所有的市:{},{},{}] , [第一个市下面所有的区:{},{},{}] ]
this.columns.push(province);
this.columns.push(province1);
this.columns.push(province2);
// console.log(6666666,this.columns)
// 市数据数组筛选address.json文件将全国所有省下面的市数据放入数组
// 格式[ [第一个省下面所有市,{},{},{}] , [第二个省下面所有市{},{},{}] , [第三个省下面所有市{},{},{}] ] 注意,以上的第一第二对应着 columns[0] 的数据
this.addressList.map(item => {
let city = [];
item.cityList.map(item1 => {
city.push(item1);
});
this.columnData.push(city);
});
//区数据数组
//数据格式: [ 所有省下面所有市的所有区 [ 第一个省下面所有市的区:[ [第一个省下面第一个市的所有区] , [第一个省下面第二个市的所有区] ,] , [ 第二个省下面所有市的区:[ [第二个省下面第一个市的所有区] , [第二个省下面第二个市的所有区] ,] ]
let area = [];
this.addressList.map((item, index) => {
let area1 = []; //省下面所有市的初始化
item.cityList.map(item1 => {
area = []; //市下面的区初始化
item1.countyList.map(item2 => {
area.push(item2);
});
area1.push(area); // 每循环一个市,添加该市下面的所有区
});
this.columnDatas.push(area1); // 每循环一个省,添加该省下面的所有市
});
// };
// }).catch(e => {
// console.log(e,'e')
// })
},
changeHandler(e) { //城市选择时触发
// console.log(e,'变化了',this.columnData, this.columnDatas)
this.addressChanged = true
const {
columnIndex, //当前选择的列,省 / 市 / 区
value, // 当前选择的数组内容
values, // values为当前变化列的数组内容
index, // 当前列的下标值
indexs, // 当前选择 省 市 区的下表值
picker = this.$refs.uPicker
} = e;
// 当第一列值发生变化时,变化第二列和第三列的值(省份变更,市和区跟着变更)
if (columnIndex === 0) { // 判断当前变更的是省还是市还是区
// picker为选择器this实例变化第二列对应的选项
picker.setColumnValues(1, this.columnData[
index]); //设置市为该省下面的所有市index是当前省在省份数组的下标对应市数组中的下表就是 该省下面的所有市 的数据
picker.setColumnValues(2, this.columnDatas[index][0]); // 设置区域为该省下面第一个市下面的所有区域
}
if (columnIndex === 1) {
// 当第二列发生变化 变化对应的第三列
picker.setColumnValues(2, this.columnDatas[indexs[0]][index]); //同上
}
},
addconfirm(e) { //点击确定按钮
// console.log(e,'选中的值')
this.addressChanged = true
this.addreShow = false;
this.addressForm.areaidpathtext = e.value[0].UName + '-' + e.value[1].UName + '-' + e.value[2].UName
this.provId = e.value[0].provId
this.cityId = e.value[1].cityId
this.countyId = e.value[2].regionCode
},
addcancel() { //点击取消按钮
this.addreShow = false;
},
// 保存地址
uploadSub() {
this.$refs.addForm.validate()
.then(res => {
let link_add = ''
if (!this.isShowDel) {
link_add = 'book/userAddress/save'
} else {
link_add = 'book/userAddress/update'
// this.addconfirm(e)
}
if (this.addressForm.areaidpath == '') {
uni.showToast({
title: '请补全所在地址信息',
icon: "none"
});
return
}
// this.addressForm.userId = this.userInfo.id
// this.addressForm.consigneePhone = this.addressForm.userphone
// this.addressForm.consigneeName = this.addressForm.username
// this.addressForm.regionCode = ''
// // this.addressForm.userid = this.userInfo.id
// if(this.addressChanged){ // 如果修改过地址区域,就重新赋值,否则保持不变
// this.addressForm.areaidpath = `${this.provId}_${this.cityId}_${this.countyId}`
// this.addressChanged = false
// }
// this.addressForm.areaid = this.countyId
// this.addressForm.isDefault = this.addressForm.isDafault ? 1 : 0
// let data = this.addressForm
let data = {
'id':this.addressForm.addressid,
'detailAddress' : this.addressForm.useraddress,
'regionCode':this.countyId,
'userId':this.userInfo.id,
'consigneePhone':this.addressForm.userphone,
'consigneeName': this.addressForm.username,
'isDefault':this.addressForm.isDafault ? 1 : 0
}
console.log(data,'保存参数')
$http.request({
url: link_add,
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
if (res.code == 0) {
uni.showToast({
title: '操作成功',
duration: 1000,
});
setTimeout(function() {
uni.navigateBack()
}, 1000);
}
})
}).catch(errors => {
uni.showToast({
title: '请补全信息',
icon: "none"
});
})
},
changeSwitch(e) {
e ? this.addressForm.isdefault = 1 : this.addressForm.isdefault = 0
this.addressForm.isDafault = e
console.log(this.addressForm, e)
},
// 编辑地址获取信息
getAddress() {
this.$http
.post(`book/userAddress/getUserAddress?userId=${this.userInfo.id}`)
.then(res => {
if (res.code == 0) {
this.addressForm = {
'useraddress':res.list[this.editIndex].detailAddress,
'userphone':res.list[this.editIndex].consigneePhone,
'username':res.list[this.editIndex].consigneeName,
'isdefault':res.list[this.editIndex].isDefault,
'isDafault':res.list[this.editIndex].isDefault == 1 ? true : false,
'areaidpathtext':res.list[this.editIndex].province +'-'+ res.list[this.editIndex].city +'-'+ res.list[this.editIndex].county
,'addressid':res.list[this.editIndex].id
}
this.countyId = res.list[this.editIndex].regionCode
// this.addressForm = res.list[this.editIndex]
if (this.addressForm.isdefault == 1) {
this.addressForm.isDafault = true
}
}
})
},
// 删除地址
deleteSub() {
let addressArr = [];
addressArr.push(this.addressForm.addressid)
this.deleteShow = false
this.$http
.get(`book/userAddress/delete?id=${this.addressForm.addressid}`)
.then(res => {
if (res.code == 0) {
uni.showToast({
title: '地址删除成功',
duration: 1000,
});
uni.navigateBack()
}
})
},
},
}
</script>
<style lang="scss" scoped>
.flexbox{display: flex;}
.selectAdd{ justify-content: space-between;
.addItem{ display: block;width: 30%}
}
.add_arrow {
height: 28px;
line-height: 28px;
width: 100%;
position: relative;
&::after {
content: '';
position: absolute;
right: 20upx;
top: 50%;
transform: translateY(-50%);
width: 40upx;
height: 40upx;
background-image: url('../../static/icon/icon_right.png');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
}
}
.addContent {
width: 90%;
margin: 20rpx auto 0 auto;
.addItem {
width: 100%;
height: 100%;
display: flex;
align-items: center;
padding: 25rpx 10rpx;
uni-picker {
flex: 1;
}
.pickerItem {
height: 100%;
padding: 20rpx;
background-color: #dfdfdf;
border-radius: 20rpx;
border-bottom: solid 1px #ccc;
color: #7d7d7d;
}
}
}
.addFooter {
width: 100%;
margin: 50rpx 0 0 0;
view {
font-size: 34rpx;
width: 80%;
padding: 25rpx 0;
text-align: center;
color: #fff;
border-radius: 20rpx;
margin: 30rpx auto 0 auto;
}
.submit {
background-image: linear-gradient(90deg, #eba00b 0%, #c96713 100%)
}
.del {
background-image: linear-gradient(90deg, #bf0c0c 0%, #95110c 100%)
}
}
</style>

152
pages/user/address.vue Normal file
View File

@@ -0,0 +1,152 @@
<template>
<view class="">
<view class="addressHeader">
<!-- 顶部导航栏 -->
<z-nav-bar title="地址管理"></z-nav-bar>
</view>
<view class="addressMain">
<view class="addressItem" v-for="(item,index) in addressList" :key="index">
<view class="addrContent">
<view class="addrContentTop">
<view class="userName">
{{item.consigneeName}}
</view>
<view class="userTel">
{{item.consigneePhone}}
</view>
<view class="userMoren" v-if="item.isDefault==1">
默认
</view>
</view>
<view class="addrContentBottom">
<view class="userAddress">
{{item.province}} {{item.city}} {{item.county}}
{{item.detailAddress}}
</view>
</view>
</view>
<view class="addrEdit" @click="toAddress(1,index)">
<u-icon name="edit-pen" color="#a7a5a5" size="24"></u-icon>
</view>
</view>
</view>
<view class="addressFooter">
<view class="addAddress" @click="toAddress(0,0)">
+ 添加收货地址
</view>
</view>
<music-play :playData="playData"></music-play>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import {
mapState
} from 'vuex';
export default {
data() {
return {
playData:{},
addressList: []
}
},
onShow() {
this.getUserAddress()
},
computed: {
...mapState(['userInfo']),
},
components:{
musicPlay
},
methods: {
getUserAddress() {
this.$http
.post(`book/userAddress/getUserAddress?userId=${this.userInfo.id}`)
// .post(`book/useraddress/getUserAddress?userId=${this.userInfo.id}`)
.then(res => {
if (res.code == 0) {
this.addressList = res.list
}
})
},
// 跳转页面
toAddress(type, index) {
uni.navigateTo({
url: `/pages/user/addAddress?type=${type}&index=${index}`
})
}
}
}
</script>
<style lang="scss" scoped>
.addressItem {
width: 100%;
display: flex;
padding: 20rpx 10rpx;
margin: 25rpx 0 0 0;
align-items: center;
background-color: #fff;
.addrContent {
margin-left: 40rpx;
flex: 1;
.addrContentTop {
display: flex;
align-items: flex-end;
margin: 0 0 15rpx 0;
.userName {
font-size: 35rpx;
font-weight: bold;
margin-right: 30rpx;
}
.userTel {
font-size: 25rpx;
color: #888;
}
.userMoren {
border: 1px solid #fd6004;
color: #fd6004;
padding: 3rpx 10rpx;
font-size: 22rpx;
border-radius: 10rpx;
margin: 0 0 0 20rpx;
}
}
.addrContentBottom {
font-size: 32rpx;
}
}
.addrEdit {
padding: 10rpx;
}
}
.addressFooter {
width: 100%;
height: auto;
display: flex;
justify-content: center;
position: fixed;
bottom: 30rpx;
.addAddress {
font-size: 34rpx;
width: 90%;
text-align: center;
color: #fff;
background-image: linear-gradient(90deg, #eba00b 0%, #c96713 100%);
border-radius: 20rpx;
padding: 25rpx 0;
}
}
</style>

288
pages/user/bindPhone.vue Normal file
View File

@@ -0,0 +1,288 @@
<template>
<view>
<z-nav-bar title="绑定手机号"></z-nav-bar>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<view class="bindAccountBox">
<image :src="logoUrl"></image>
<view><image src="../../static/icon/bindingIcon.png"></image></view>
<image src="../../static/icon/WeChatIcon.png"></image>
</view>
<view class="inputItem">
<view class="title">*手机号</view>
<view class="info"><input type="number" placeholder="请输入" v-model="phone" /></view>
</view>
<view class="inputItem">
<view class="title">*验证码</view>
<view class="info">
<input type="number" placeholder="请输入" v-model="code" />
<button @click="getCode">{{ codeText }}</button>
</view>
</view>
<view class="registeredBut bindAccountBut"><button @click="onSubmit">立即绑定</button></view>
<music-play :playData="playData"></music-play>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
var clear;
import { mapState, mapMutations } from 'vuex';
import socket from '@/config/socket';
// #ifdef H5
import {publicShare} from '@/config/utils';
// #endif
export default {
data() {
return {
playData:{},
logoUrl: '',
readonly: false,
codeText: '获取验证码',
phone: '',
code: ''
};
},
//第一次加载
onLoad(e) {
this.logoUrl = this.$base.logoUrl;
},
computed: {
...mapState(['userInfo','chatScenesInfo'])
},
//页面显示
onShow() {},
components:{
musicPlay
},
//方法
methods: {
...mapMutations(['setUserInfo']),
//验证码按钮文字状态
getCodeState() {
const _this = this;
this.readonly = true;
this.codeText = '60S后重新获取';
var s = 60;
clear = setInterval(() => {
s--;
_this.codeText = s + 'S后重新获取';
if (s <= 0) {
clearInterval(clear);
_this.codeText = '获取验证码';
_this.readonly = false;
}
}, 1000);
},
//获取验证码
getCode() {
if (this.readonly) {
uni.showToast({
title: '验证码已发送',
icon: 'none'
});
return;
}
if (this.phone == '') {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '手机号格式不正确',
icon: 'none'
});
return;
}
this.$http
.post('api/open/v1/send_sms', {
phone: this.phone,
type: 3104
})
.then(res => {
this.getCodeState();
});
},
//账号绑定
onSubmit() {
if (this.phone == '') {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '手机号格式不正确',
icon: 'none'
});
return;
}
if (this.code == '') {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return;
}
if (!/^[0-9]{6}$/.test(this.code)) {
uni.showToast({
title: '验证码必须是6位数',
icon: 'none'
});
return;
}
if (!(this.userInfo.wxSmallOpenId || this.userInfo.openId || this.userInfo.wxPublicOpenId)) {
uni.showToast({
title: '数据丢失',
icon: 'none'
});
return;
}
let httpData = {
openId: this.userInfo.openId || this.userInfo.wxSmallOpenId || this.userInfo.wxPublicOpenId,
phone: this.phone,
code: this.code,
// #ifdef MP-WEIXIN
type: 1201,
// #endif
// #ifdef H5
type: 1301,
// #endif
// #ifdef APP-PLUS
type: 1101
// #endif
};
if(this.userInfo.unionid || this.userInfo.wxUnionid){
httpData.unionid = this.userInfo.unionid || this.userInfo.wxUnionid;
}
// #ifdef H5
let recommendCode = uni.getStorageSync("recommendCode");
if(recommendCode){
httpData.recommendCode = recommendCode;
}
// #endif
// #ifndef H5
if(this.chatScenesInfo.recommendCode){
httpData.recommendCode = this.chatScenesInfo.recommendCode;
}
// #endif
this.$http
.post('api/open/v1/third_bind',httpData)
.then(res => {
this.setUserInfo(res);
// #ifdef H5
publicShare();
// #endif
socket.init();
uni.showModal({
title: '提示',
content: '账号绑定成功!',
showCancel: false,
success: res => {
uni.navigateBack();
}
});
});
}
},
//页面隐藏
onHide() {},
//页面卸载
onUnload() {},
//页面下来刷新
onPullDownRefresh() {},
//页面上拉触底
onReachBottom() {},
//用户点击分享
onShareAppMessage(e) {
return this.wxShare();
}
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.bindAccountBox {
height: 283upx;
display: flex;
justify-content: center;
align-items: center;
}
.bindAccountBox > image {
width: 95upx;
height: 95upx;
border-radius: 15upx;
}
.bindAccountBox > view {
width: 95upx;
height: 95upx;
padding: 0upx 20upx;
display: flex;
align-items: center;
}
.bindAccountBox > view image {
width: 100%;
height: 40upx;
}
.bindAccountBut {
margin-top: 60upx;
}
.registeredBut {
margin-bottom: 30upx;
padding: 0upx 20upx;
}
.registeredBut button {
font-size: 36upx;
border-radius: 3upx;
text-align: center;
line-height: 90upx;
height: 90upx;
background-color: $themeColor;
color: #fff;
}
.inputItem {
background-color: #fff;
display: flex;
margin-top: 12upx;
padding: 0 25upx;
}
.inputItem .title {
min-width: 190upx;
height: 100upx;
line-height: 100upx;
flex-shrink: 0;
font-size: 30upx;
white-space: nowrap;
}
.inputItem .info {
flex: 1;
display: flex;
align-items: center;
color: #999;
}
.inputItem .info input {
height: 100upx;
line-height: 100upx;
font-size: 30upx;
width: 100%;
}
.inputItem .info button {
height: 80upx;
line-height: 80upx;
font-size: 28upx;
flex-shrink: 0;
padding: 0 15upx;
border: 1upx solid $themeColor;
background-color: #fff;
color: $themeColor;
}
</style>

312
pages/user/forget.vue Normal file
View File

@@ -0,0 +1,312 @@
<template>
<view class="page">
<z-nav-bar></z-nav-bar>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<view class="title">忘记密码</view>
<view class="input_box">
<text class="input_tit">手机号</text>
<input type="text" v-model="phone" placeholder="请输入手机号" />
</view>
<view class="input_box">
<text class="input_tit">验证码</text>
<input type="number" v-model="code" placeholder="请输入验证码" />
<button @click="getCode">{{codeText}}</button>
</view>
<view class="input_box">
<text class="input_tit">密码</text>
<input type="password" maxlength="8" v-model="password" placeholder="请输入密码" @input="inputMethod(password)" />
</view>
<view class="" style="font-size: 28rpx; color: #999;">
<p v-if="note != ''">{{note}}</p>
<p v-html="str2" style="margin-top: 10rpx;"></p>
</view>
<view class="input_box">
<text class="input_tit">确认密码</text>
<input type="password" maxlength="8" v-model="confirmPassword" placeholder="请确认密码" />
</view>
<view class="btn_box"><button @click="onSubmit"> </button></view>
<music-play :playData="playData"></music-play>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import md5 from '@/plugins/md5';
// 密码验证的正则
//1、密码为八位及以上并且字母数字特殊字符三项都包括
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
//2、密码为八位及以上并且字母、数字、特殊字符三项中有两项强度是中等
var mediumRegex = new RegExp(
"^(?=.{8,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[a-z])(?=.*\\W))|((?=.*[0-9])(?=.*\\W))|((?=.*[A-Z])(?=.*\\W))).*$",
"g");
var enoughRegex = new RegExp("(?=.{8,}).*", "g");
var clear;
export default {
data() {
return {
playData: {},
//手机号账号
phone: '',
// 密码
password: '',
//验证码
code: '',
//确认密码
confirmPassword: '',
//验证码
codeText: '获取验证码',
//验证码已发
readonly: false,
passwordOk:false,
note: '',
str2: '',
};
},
//第一次加载
onLoad(e) {},
//页面显示
onShow() {},
components: {
musicPlay
},
//方法
methods: {
// 密码验证
inputMethod(value) {
this.passwordOk = false
// console.log('输入的值为:', value)
if (strongRegex.test(value)) {
//console.log('强密码-----',value)
this.str2 = "<span style='color:#18bc37'>密码强度很不错哦!</span>"
// this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度至少为8位。'
this.note = ''
this.passwordOk = true
} else if (mediumRegex.test(value)) {
// console.log('中等密码-----',value)
this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.str2 = "<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位。'
}
else {
this.passwordOk = false
this.note = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.str2 = ""
//console.log('密码-----',value)
}
},
//获取验证码
getCode() {
if (this.readonly) {
uni.showToast({
title: '验证码已发送',
icon: 'none'
});
return;
}
if (!this.phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
return;
}
this.$http
// .post('api/common/v1/send_sms', {
.post('book/user/sms/sendcode', {
phone: this.phone,
type: 3000
})
.then(res => {
this.getCodeState();
});
},
//验证码按钮文字状态
getCodeState() {
const _this = this;
this.readonly = true;
this.codeText = '60S后重新获取';
var s = 60;
clear = setInterval(() => {
s--;
_this.codeText = s + 'S后重新获取';
if (s <= 0) {
clearInterval(clear);
_this.codeText = '获取验证码';
_this.readonly = false;
}
}, 1000);
},
onSubmit() {
if(!this.passwordOk){
console.log('不满足密码格式',this.note)
uni.showToast({
title:this.note,
icon: 'none'
})
return
}
if (!this.phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
return;
}
if (!this.code) {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return;
}
if (!this.password) {
uni.showToast({
title: '请输入密码',
icon: 'none'
});
return;
}
if (!this.confirmPassword) {
uni.showToast({
title: '请输入确认密码',
icon: 'none'
});
return;
}
if (this.confirmPassword != this.password) {
uni.showToast({
title: '两次密码不一致',
icon: 'none'
});
return;
}
if (!this.$base.passwordRegular.test(this.password)) {
uni.showToast({
title: '请输入不少于6位且包含数字和字母的密码',
icon: 'none'
});
return;
}
this.$http
// .post('api/common/v1/forget_password', {
.post('book/user/setPassword', {
phone: this.phone,
code: this.code,
// password: md5(this.password),
password: this.password
})
.then(res => {
uni.showModal({
title: "提示",
content: "密码修改成功!",
showCancel: false,
success: (res) => {
uni.navigateBack();
}
});
});
}
},
//页面隐藏
onHide() {},
//页面卸载
onUnload() {},
//页面下来刷新
onPullDownRefresh() {},
//页面上拉触底
onReachBottom() {},
//用户点击分享
onShareAppMessage(e) {
return this.wxShare();
}
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.page {
background-color: #ffffff;
padding: 0 65rpx;
min-height: 100vh;
.title {
padding: 60rpx 0 40rpx 0;
font-size: 60rpx;
color: #333333;
}
.input_box {
display: flex;
justify-content: space-between;
height: 100rpx;
padding-top: 30rpx;
border-bottom: 1rpx solid #eeeeee;
align-items: center;
text {
font-size: 30rpx;
width: 180rpx;
}
input {
flex: 1;
height: 70rpx;
line-height: 70rpx;
font-size: 30rpx;
}
button {
height: 78rpx;
line-height: 78rpx;
font-size: 30rpx;
color: $themeColor;
&:active {
background-color: transparent;
}
}
}
.btn_box {
margin-top: 70rpx;
button {
font-size: 32rpx;
@include theme('btn_bg') color: #fff;
height: 80rpx;
line-height: 80rpx;
border-radius: 50rpx;
}
}
.protocol {
font-size: 24rpx;
color: #999999;
text-align: center;
margin-top: 20rpx;
text {
color: $themeColor;
}
}
}
</style>

297
pages/user/healthLog.vue Normal file
View File

@@ -0,0 +1,297 @@
<template>
<view class="page">
<z-nav-bar></z-nav-bar>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<view class="title">手机号验证</view>
<view class="input_box">
<text class="input_tit">手机号</text>
<input type="text" v-model="phone" placeholder="请输入手机号" />
</view>
<view class="input_box">
<text class="input_tit">验证码</text>
<input type="text" v-model="code" placeholder="请输入验证码" />
<button @click="getCode">{{codeText}}</button>
</view>
<view class="btn_box"><button @click="onSubmit"> </button></view>
<music-play :playData="playData"></music-play>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import md5 from '@/plugins/md5';
var clear;
import store from '@/store';
import socket from '@/config/socket';
import {
mapState,
mapMutations
} from 'vuex';
export default {
data() {
return {
playData:{},
//手机号账号
phone: '',
// 密码
password: '',
//验证码
code: '',
//验证码
codeText: '获取验证码',
//验证码已发
readonly: false
};
},
//第一次加载
onLoad(e) {
// 隐藏原生的tabbar
uni.hideTabBar();
this.showPhone();
},
computed: {
...mapState(["userInfo"])
},
//页面显示
onShow() {
// 隐藏原生的tabbar
uni.hideTabBar();
},
components:{
musicPlay
},
//方法
methods: {
// 显示手机号
showPhone() {
let HealthMes = store.state.HealthMes;
let IsPhoneHealth = this.$base.phoneRegular.test(HealthMes.cellPhone)
if (IsPhoneHealth) {
this.phone = HealthMes.cellPhone
}
},
//获取验证码
getCode() {
if (this.readonly) {
uni.showToast({
title: '验证码已发送',
icon: 'none'
});
return;
}
if (!this.phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '手机格式不正确',
icon: 'none'
});
return;
}
this.$http
.get('book/user/sms/sendcode', {
phone: this.phone,
type: 2000
})
.then(res => {
this.getCodeState();
});
},
//验证码按钮文字状态
getCodeState() {
const _this = this;
this.readonly = true;
this.codeText = '60S后重新获取';
var s = 60;
clear = setInterval(() => {
s--;
_this.codeText = s + 'S后重新获取';
if (s <= 0) {
clearInterval(clear);
_this.codeText = '获取验证码';
_this.readonly = false;
}
}, 1000);
},
onSubmit() {
if (!this.phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
return;
}
if (!this.code) {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return;
}
let HealthMes = store.state.HealthMes;
let httpData = {};
httpData.code = this.code;
httpData.phone = this.phone;
httpData.yljkOid = HealthMes.yljkOid;
httpData.userName = HealthMes.nameCN;
httpData.customerIcons = HealthMes.customerIcons;
this.$http
.get('book/user/registerHs', httpData)
.then(res => {
uni.showToast({
title: '手机验证成功',
duration: 1000,
});
console.log(res)
res.userInfo.token = res.token.token;
setTimeout(() => {
uni.navigateBack({
delta: 1
});
}, 1000);
this.setUserInfo(res.userInfo);
// socket.init();
// uni.showModal({
// title: '提示',
// content: '该手机号已经注册过花生,您是否要绑定登录?',
// success: function(res) {
// if (res.confirm) {
// console.log('用户点击确定');
// } else if (res.cancel) {
// console.log('用户点击取消');
// }
// }
// });
// uni.showModal({
// title: '提示',
// content: '验证成功,请问您要通过该账户登录花生吗?',
// success: function(res) {
// if (res.confirm) {
// this.setUserInfo(res.userInfo);
// // socket.init();
// uni.switchTab({
// url: "/pages/home/home"
// });
// } else if (res.cancel) {
// console.log('用户点击取消');
// }
// }
// });
});
// let bangDing = {};
// bangDing.phone = this.code;
// httpData.password = this.phone;
// httpData.hsuserId = HealthMes.yljkOid;
// this.$http
// .get('book/user/getEverhealthInfo', bangDing)
// .then(res => {
// console.log(res)
// uni.showToast({
// title: '验证成功',
// duration: 600,
// });
// });
}
},
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.page {
background-color: #ffffff;
padding: 0 65rpx;
min-height: 100vh;
.title {
padding: 60rpx 0 40rpx 0;
font-size: 60rpx;
color: #333333;
}
.input_box {
display: flex;
justify-content: space-between;
height: 100rpx;
padding-top: 30rpx;
border-bottom: 1rpx solid #eeeeee;
align-items: center;
text {
font-size: 30rpx;
width: 180rpx;
}
input {
flex: 1;
height: 70rpx;
line-height: 70rpx;
font-size: 30rpx;
}
button {
height: 78rpx;
line-height: 78rpx;
font-size: 30rpx;
color: $themeColor;
&:active {
background-color: transparent;
}
}
}
.btn_box {
margin-top: 70rpx;
button {
font-size: 32rpx;
@include theme('btn_bg') color: #fff;
height: 80rpx;
line-height: 80rpx;
border-radius: 50rpx;
}
}
.protocol {
font-size: 24rpx;
color: #999999;
text-align: center;
margin-top: 20rpx;
text {
color: $themeColor;
}
}
}
</style>

1295
pages/user/login.vue Normal file

File diff suppressed because it is too large Load Diff

572
pages/user/persCount.vue Normal file
View File

@@ -0,0 +1,572 @@
<template>
<view>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<z-nav-bar title="我的账户"></z-nav-bar>
<view class="ACTable">
<u-tabs :list="tab_list" @click="tab_click" lineColor="#54a966 100% 100%"
:activeStyle="{color: '#303133',fontWeight: 'bold',transform: 'scale(1.1)'}" v-if="iosHide"></u-tabs>
<u-tabs :list="tab_list_ios" @click="tab_click" lineColor="#54a966 100% 100%"
:activeStyle="{color: '#303133',fontWeight: 'bold',transform: 'scale(1.1)'}" v-if="!iosHide"></u-tabs>
<view v-if="tab_muJian==0">
<view class="AC_mes">
<view style="font-size: 50rpx;font-weight: bold;">{{userMes.peanutCoin}}</view>
<view style="color: #888;font-size: 30rpx;margin-top: 10rpx;">天医币</view>
<text v-if="platform != 'ios'" class="AC_chong" @click="buPoint()">充值</text>
</view>
<view class="AC_con">
<view class="AC_jilu">充值记录</view>
<view v-for="(item,index) in MoneyRecord" class="AC_List">
<view class="AC_title">
{{item.orderType}}
<view>
<text v-if="item.changeAmount>0">+</text>
<text>{{item.changeAmount}}</text>
天医币
</view>
</view>
<view class="AC_mark">{{item.remark}}</view>
<view class="AC_time">{{item.createTime}}</view>
</view>
</view>
</view>
<view v-if="tab_muJian==1">
<view class="couponList">
<view v-for="(item,index) in couponTabs" @click="couponTabCLi(index)"
:class="couponListTab==index?'couStyle':''">{{item.name}}</view>
</view>
<view>
<view class="card" v-for="item in cardList">
<view>
<view class="content">
<view :class="couponListTab==0?'page-group':'page-group grey'">
<i class="fold-page"></i>
<span class="page">优惠券</span>
</view>
<i class="dot-left"></i>
<i class="dot-right"></i>
<view class="coupon-detail">
<view :class="couponListTab==0?'':'grey'">
<span></span>
<span>{{item.coupons.amount}}</span>
</view>
<view>
<view>{{item.coupons.couponName}}</view>
<view>{{item.coupons.useLevel}}元可用</view>
<view>
<span v-if="item.coupons.couponProType == 0">使用类型商品类</span>
<span v-if="item.coupons.couponProType == 1">使用类型电子书</span>
</view>
</view>
<view>
<view v-if="couponListTab==0" @click="onPageJump('../bookShop/bookShopIndex')">
立即使用</view>
</view>
</view>
</view>
<view class="footer">
<view style="margin: 0 0 8rpx 0;">使用时间{{item.coupons.takeEffectDate}} -
{{item.coupons.expirationDate}}
</view>
<view>{{item.coupons.note}}</view>
<view class="arrow"></view>
<view class="arrow-up"></view>
</view>
<view class="ribbon" v-if="couponListTab==0">未使用</view>
<view class="ribbon grey" v-if="couponListTab==1">已使用</view>
<view class="ribbon grey" v-if="couponListTab==2">已过期</view>
</view>
</view>
<view v-if="cardList.length==0" style="text-align: center;font-size: 30rpx;color: #666;">暂无代金券
</view>
</view>
</view>
<view>
<view v-if="status==0" style="text-align: center;">
<u-loading-icon style="display: inline-block;"></u-loading-icon>
<font style='vertical-align: super;margin-left: 10px;font-size: 26rpx;color: #909399;'>努力加载中</font>
</view>
<view v-if="status==1">
<u-divider text="全部加载完成"></u-divider>
</view>
</view>
<view style="padding-bottom: 20rpx;">
<u-back-top :scroll-top="scrollTop" bottom="60" :customStyle='bgiStyle' :iconStyle="iconStyle">
</u-back-top>
</view>
</view>
<music-play :playData="playData"></music-play>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import $http from '@/config/requestConfig.js';
import {
mapState
} from 'vuex';
export default {
data() {
return {
playData: {},
platform: null,
tab_list: [{
name: '天医币',
}, {
name: '优惠券',
}],
tab_list_ios: [{
name: '优惠券',
}],
couponTabs: [{
name: '未使用'
}, {
name: '已使用'
}, {
name: '已过期'
}],
cardList: [],
couponListTab: 0,
MoneyRecord: [],
userMes: {},
RecordScreen: {
userid: '',
page: 1,
limit: 5,
},
scrollTop: 0,
status: 3,
totalPage: 0,
totalCount: 0,
tab_muJian: 0,
bgiStyle: {
background: '#2ab58833'
},
iconStyle: {
fontSize: '40rpx',
fontWeight: 'bold',
color: '#54a966',
},
};
},
// 返回顶部
onPageScroll(e) {
this.scrollTop = e.scrollTop;
},
// 下拉刷新
onReachBottom() {
this.status = 0
if (this.RecordScreen.page < this.totalPage) {
this.RecordScreen.page = this.RecordScreen.page + 1
setTimeout(() => {
this.$http
.post('book/transactiondetails/list?userId=' + this.userInfo.id + '&page=' + this
.RecordScreen.page + '&limit=' + this.RecordScreen.limit)
.then(res => {
this.totalPage = res.page.totalPage
this.totalCount = res.page.totalCount
for (let i in res.page.list) {
this.MoneyRecord.push(res.page.list[i])
}
});
}, 1000)
} else {
this.status = 1
}
},
//第一次加载
onLoad(e) {
// 隐藏原生的tabbar
uni.hideTabBar();
// #ifdef APP-PLUS
this.platform = uni.getSystemInfoSync().platform
console.log('操纵系统', this.platform)
// #endif
},
computed: {
...mapState(['userInfo'])
},
//页面显示
onShow() {
// 隐藏原生的tabbar
uni.hideTabBar();
this.getData();
this.getCourpe();
},
components: {
musicPlay
},
//方法
methods: {
// 获取
getData() {
if(!this.iosHide){
this.tab_muJian=1
}
// 用户详情
if (this.userInfo.id != undefined) {
this.$http
.post('book/user/info/' + this.userInfo.id)
.then(res => {
this.userMes = res.user
});
}
// 充值记录
this.$http
.post('book/transactiondetails/list?userId=' + this.userInfo.id + '&page=' + this.RecordScreen
.page + '&limit=' + this.RecordScreen.limit)
.then(res => {
this.MoneyRecord = res.page.list
this.totalPage = res.page.totalPage
this.totalCount = res.page.totalCount
});
},
// 点击tab
tab_click(e) {
this.tab_muJian = e.index
},
// 优惠券
getCourpe() {
this.$http
.post('/book/couponhistory/appGetUserCenterCoupon?userId=' + this.userInfo.id + '&useStatus=' + this
.couponListTab)
.then(res => {
// this.cardList = res.couponVos
this.cardList = res.couponVos
});
},
// 切换优惠券
couponTabCLi(e) {
this.couponListTab = e
this.getCourpe()
},
// 充值天医币
buPoint() {
uni.navigateTo({
url: '../peanut/reCharge'
});
},
// 跳转
onPageJump(url) {
uni.navigateTo({
url: url
});
},
},
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.ACTable {
padding: 20rpx 30rpx;
.AC_mes {
margin-top: 50rpx;
padding: 30rpx 30rpx;
box-shadow: 0 0px 10px 1px #d3d1d133;
background-color: #fff;
border-radius: 15rpx;
margin-bottom: 40rpx;
position: relative;
.AC_chong {
background-color: #54a966;
color: #fff;
border-radius: 80rpx;
padding: 15rpx 50rpx;
font-size: 35rpx;
position: absolute;
top: 50rpx;
right: 50rpx;
}
}
.AC_con {
margin-top: 50rpx;
padding: 30rpx 30rpx;
box-shadow: 0 0px 10px 1px #d3d1d133;
background-color: #fff;
border-radius: 15rpx;
margin-bottom: 40rpx;
font-size: 30rpx;
.AC_jilu {
font-size: 32rpx;
text-align: center;
margin-bottom: 30rpx;
}
.AC_List {
border-bottom: 1px solid #eee;
padding: 40rpx 10rpx;
.AC_title {
font-size: 32rpx;
margin-bottom: 20rpx;
view {
float: right;
font-size: 34rpx;
font-weight: bold;
}
}
.AC_mark {
font-size: 28rpx;
margin-bottom: 15rpx;
color: #888;
}
.AC_time {
color: #bababa;
font-size: 25rpx;
}
}
}
.couponList {
view {
display: inline-block;
padding: 0 0 25rpx 0;
margin: 40rpx 0 40rpx 0;
width: 33%;
text-align: center;
font-size: 30rpx;
}
.couStyle {
border-bottom: 5rpx solid #54a966;
color: #54a966;
font-weight: bold;
}
}
.card {
width: 100%;
overflow: hidden;
margin-bottom: 30rpx;
padding-left: 10rpx;
position: relative;
}
.card>view {
background: #fff;
border-radius: 5rpx;
}
.card .dot-left,
.card .dot-right {
display: block;
width: 12rpx;
height: 12rpx;
border-radius: 50%;
background: #f5f5f5;
position: absolute;
z-index: 999;
}
.card .dot-left {
bottom: -6rpx;
left: -6rpx;
}
.card .dot-right {
bottom: -6rpx;
right: -6rpx;
}
.card .page-group {
position: absolute;
top: 10rpx;
left: -2rpx;
width: 100%;
max-width: 200rpx;
.fold-page {
display: block;
width: 10rpx;
height: 8rpx;
background: #54a966;
transform: skewY(-40deg);
position: absolute;
top: -5rpx;
left: -8rpx;
z-index: 0;
}
.page {
position: absolute;
z-index: 1;
display: block;
padding: 5rpx 20rpx 3rpx 20rpx;
height: 40rpx;
line-height: 40rpx;
background: linear-gradient(137deg, #54a966 0%, #0d5e1e 100%);
border-radius: 0 20rpx 20rpx 0;
color: #fff;
text-align: center;
font-size: 24rpx;
overflow: hidden;
left: -8rpx;
}
}
.card .page-group.grey {
.fold-page {
background: #c6c6c6;
}
.page {
background: linear-gradient(137deg, #c6c6c6 0%, #999595 100%);
}
}
.card .content {
width: 100%;
height: 180rpx;
border-bottom: 1rpx dotted #f5f5f5;
position: relative;
z-index: 2;
}
.card .content .coupon-detail {
display: flex;
padding: 0 15rpx 0 20rpx;
}
.card .content .coupon-detail>view {
height: 130rpx;
display: flex;
align-items: center;
}
.card .content .coupon-detail>view:first-child {
color: #54a966;
padding-top: 100rpx;
width: 30%;
}
.card .content .coupon-detail>view.grey {
color: #c6c6c6;
}
.card .content .coupon-detail>view:first-child>span:first-child {
font-size: 30rpx;
margin: 0 10rpx 0 0;
}
.card .content .coupon-detail>view:first-child>span:last-child {
font-size: 70rpx;
}
.card .content .coupon-detail>view:last-child>view {
color: #54a966;
border: 1rpx solid #54a966;
border-radius: 50rpx;
font-size: 12px;
line-height: 25px;
width: 150rpx;
height: 50rpx;
margin: 100rpx 0 0 5rpx;
text-align: center;
}
.card .coupon-detail>view:nth-child(2) {
flex-direction: column;
padding-top: 60rpx;
width: 40%;
}
.card .coupon-detail>view:nth-child(2)>view {
width: 100%;
}
.card .coupon-detail>view:nth-child(2)>view:first-child {
color: #333;
font-weight: bold;
font-size: 25rpx;
margin: 0 0 10rpx 0;
}
.card .coupon-detail>view:nth-child(2)>view:last-child {
font-size: 12px;
color: #adadad;
margin-top: 5rpx;
}
.card .coupon-detail>view:nth-child(2)>view:last-child>view {
transform: scale(0.8);
margin-left: -14rpx;
}
.card {
.footer {
color: #999;
font-size: 12px;
padding: 30rpx 15rpx 30rpx 30rpx;
}
.ribbon {
width: 160rpx;
height: 40rpx;
background: #54a966;
position: absolute;
right: -40rpx;
top: 25rpx;
transform: rotateZ(45deg);
text-align: center;
color: #fff;
font-size: 20rpx;
line-height: 44rpx;
}
.ribbon.grey {
background: #c6c6c6;
}
}
}
</style>

850
pages/user/persData.vue Normal file
View File

@@ -0,0 +1,850 @@
<template>
<view>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<z-nav-bar title="个人资料"></z-nav-bar>
<view class="tabulate">
<view class="per_list">
<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="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">{{userMsage.nickname}}</text>
</view>
<view class="per_list per_list_arrow" @click="passwordShow = true">
<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">{{userMsage.age}}</text>
</view>
<view class="per_list per_list_arrow" @click="sexShow = true">
<text class="biaoti">性别</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">
<view class="dp_title">请更换头像</view>
<u-upload :fileList="fileAvatar" @afterRead="afterRead" @delete="deletePic" multiple :maxCount="1"
width="150" height="150" :previewFullImage="true">
</u-upload>
<u-button color="linear-gradient(to right, #72d386, #317e42)" text="确定" @click="choseAvatar()"
style="margin-top: 50rpx;"></u-button>
<view @click="avatarShow=false" class="dp_canBtn">取消</view>
</view>
</u-popup>
<!-- 昵称 -->
<u-popup :show="nicknameShow" :round="10" @close="nicknameShow=false">
<view class="tanchu">
<view class="dp_title">请输入昵称</view>
<u--input v-model="userMes.nickname" placeholder="请输入昵称" border="surround" clearable></u--input>
<u-button color="linear-gradient(to right, #72d386, #317e42)" text="确定"
@click="choseNickname(userMes.nickname)" style="margin-top: 50rpx;"></u-button>
<view @click="nicknameShow=false" class="dp_canBtn">取消</view>
</view>
</u-popup>
<!-- 年龄 -->
<u-popup :show="ageShow" :round="10" @close="ageShow=false">
<view class="tanchu">
<view class="dp_title">请输入年龄</view>
<u--input v-model="userMes.age" type="number" placeholder="请输入年龄" border="surround" clearable>
</u--input>
<u-button color="linear-gradient(to right, #72d386, #317e42)" text="确定" @click="choseAge()"
style="margin-top: 50rpx;"></u-button>
<view @click="ageShow=false" class="dp_canBtn">
取消</view>
</view>
</u-popup>
<!-- 性别 -->
<u-popup :show="sexShow" :round="10" @close="sexShow=false">
<view class="tanchu">
<view class="dp_title">请选择性别</view>
<u-radio-group v-model="userMes.sex">
<view style="width: 100%;">
<view v-for="(item, index) in sexList" @click="choseSex(item.id)" class="dp_sex">
{{item.title}}
<u-radio :key="index" activeColor="#54a966" :name='item.id'
style="float: right;margin-top: 5rpx;" @change="choseSex(item.id)"></u-radio>
</view>
</view>
</u-radio-group>
<view @click="sexShow=false" class="dp_canBtn">取消</view>
</view>
</u-popup>
<!-- 密码 -->
<u-popup :show="passwordShow" :round="10" @close="cancelPass">
<view class="tanchu">
<view class="dp_title">请修改密码</view>
<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="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>
</view>
</u-popup>
<!-- <view class="btn_box">
<button @click="chosePassword" class="active"> </button>
</view> -->
<music-play :playData="playData"></music-play>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import $http from '@/config/requestConfig.js';
var clear;
import {
mapState
} from 'vuex';
// 密码验证的正则
//1、密码为八位及以上并且字母数字特殊字符三项都包括
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
//2、密码为八位及以上并且字母、数字、特殊字符三项中有两项强度是中等
var mediumRegex = new RegExp(
"^(?=.{8,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[a-z])(?=.*\\W))|((?=.*[0-9])(?=.*\\W))|((?=.*[A-Z])(?=.*\\W))).*$",
"g");
var enoughRegex = new RegExp("(?=.{8,}).*", "g");
export default {
data() {
return {
playData: {},
userMes: {
quCode: '',
phone: '',
email: '',
id: '',
age: '',
sex: '',
nickname: '',
tel: '',
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,
},
{
title: '女',
id: 0,
}
],
PhoneEmailNote: '获取验证码',
passNote: '',
passStr: '',
passwordOk: false, // 密码是否满足规则
};
},
//第一次加载
onLoad(e) {
// 隐藏原生的tabbar
uni.hideTabBar();
},
computed: {
...mapState(['userInfo'])
},
//页面显示
onShow() {
// 隐藏原生的tabbar
uni.hideTabBar();
this.getData();
this.getCountyCode()
},
components: {
musicPlay
},
//方法
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
.post('book/user/info/' + that.userInfo.id)
.then(res => {
that.userMes.id = res.user.id
that.userMes.age = res.user.age
that.userMes.sex = res.user.sex
that.userMes.nickname = res.user.nickname
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.userMiMa.password = ''
this.userMiMa.Repassword = ''
this.passNote = ''
this.passStr = ''
},
// 密码验证
inputMethod(value) {
this.passwordOk = false
// console.log('输入的值为:', value)
if (strongRegex.test(value)) {
//console.log('强密码-----',value)
this.passStr = "<span style='color:#18bc37'>密码强度很不错哦!</span>"
// this.passNote = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.passNote = ''
this.passwordOk = true
} else if (mediumRegex.test(value)) {
//console.log('中等密码-----',value)
this.passNote = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.passStr = "<span style='color:#2979ff'>密码强度中等!</span>"
this.passwordOk = true
} else if (enoughRegex.test(value)) {
//console.log('弱密码-----',value)
this.passStr = "<span style='color:#f3a73f'>密码强度太弱!</span>"
this.passNote = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
} else {
this.passwordOk = false
this.passNote = '请至少使用大小写字母、数字、符号两种类型组合的密码长度为8位。'
this.passStr = ""
//console.log('密码-----',value)
}
},
// 清除验证码
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 == '' || 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.phone == '') {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (this.userMes.code == '' || this.userMes.code == null) {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return;
}
let that = this
$http.request({
url: "book/user/updateUserTel",
method: "POST",
data: this.userMes,
header: {
'Content-Type': 'application/json'
},
}).then(function(res) {
if (res.code == 0) {
that.getData();
that.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;
}
let that = this
$http.request({
url: "book/user/updateUserEmail",
method: "POST",
data: this.userMes,
header: {
'Content-Type': 'application/json'
},
}).then(function(res) {
if (res.code == 0) {
that.getData();
that.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';
.btn_box {
margin-top: 40rpx;
padding: 10px;
button {
font-size: 32rpx;
background-color: #e5e5e5;
color: #fff;
height: 80rpx;
line-height: 80rpx;
border-radius: 50rpx;
&.active {
@include theme('btn_bg') color: #fff;
}
}
}
.tabulate {
.per_list {
font-size: 30rpx;
background-color: #fff;
padding: 0;
align-items: center;
position: relative;
border-top: 1px solid #e5e5e5;
width: 100%;
overflow: auto;
text.biaoti {
color: #333;
display: inline-block;
margin: 25rpx 0 25rpx 40rpx;
}
text.neirong {
color: #888;
font-weight: normal;
float: right;
margin: 25rpx 80rpx 0 0;
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;
}
}
.per_list_arrow {
font-size: 30rpx;
background-color: #fff;
padding: 0;
align-items: center;
position: relative;
border-top: 1px solid #e5e5e5;
width: 100%;
overflow: auto;
&:active {
background-color: #f5f5f5;
}
&::after {
content: '';
position: absolute;
right: 20upx;
top: 50%;
transform: translateY(-50%);
width: 40upx;
height: 40upx;
background-image: url('../../static/icon/icon_right.png');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
}
.per_mes_img {
width: 100rpx;
height: 100rpx;
background-color: #fff;
border-radius: 120rpx;
margin: 10rpx 0;
}
}
}
.tanchu {
padding: 60rpx 50rpx 80rpx 50rpx;
.dp_title {
font-size: 32rpx;
margin-bottom: 50rpx;
color: #555;
text-align: center;
font-weight: bold;
}
.dp_sex {
font-size: 30rpx;
padding-bottom: 20rpx;
margin-bottom: 20rpx;
border-bottom: 1px solid #ededed;
image {
width: 40rpx;
height: 40rpx;
display: inline-block;
margin-right: 20rpx;
vertical-align: bottom;
}
}
.dp_canBtn {
text-align: center;
font-size: 28rpx;
margin-top: 25rpx;
color: #888;
}
.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>

75
pages/user/protocol.vue Normal file
View File

@@ -0,0 +1,75 @@
<template>
<view class="protocol_page">
<z-nav-bar title="协议"></z-nav-bar>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<view class="title">{{title}}</view>
<jyf-parser ref="article"></jyf-parser>
</view>
</template>
<script>
export default {
data() {
return {
type:1000,
title:"用户协议"
};
},
//第一次加载
onLoad(e) {
console.log(e)
if(e.type){
this.type = parseInt(e.type);
let title;
switch (this.type) {
case 1000:
title = "登录注册用户协议";
break;
}
this.title = title;
}
this.pageData();
},
//页面显示
onShow() {},
//方法
methods: {
pageData() {
this.$http
.get('api/common/v1/protocol', {
type: this.type
})
.then(res => {
console.log(res)
this.$refs.article.setContent(res);
});
}
},
//页面隐藏
onHide() {},
//页面卸载
onUnload() {},
//页面下来刷新
onPullDownRefresh() {},
//页面上拉触底
onReachBottom() {},
//用户点击分享
onShareAppMessage(e) {
return this.wxShare();
}
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.protocol_page {
background-color: #fff;
padding: 30upx;
font-size: 30upx;
line-height: 180%;
.title {
font-size: 50upx;
padding-bottom: 30upx;
}
}
</style>

300
pages/user/register.vue Normal file
View File

@@ -0,0 +1,300 @@
<template>
<view class="page">
<z-nav-bar></z-nav-bar>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<view class="title">注册</view>
<view class="input_box">
<text class="input_tit">手机号</text>
<input type="text" v-model="phone" placeholder="请输入手机号" />
</view>
<view class="input_box">
<text class="input_tit">验证码</text>
<input type="number" v-model="code" placeholder="请输入验证码" />
<button @click="getCode">{{codeText}}</button>
</view>
<view class="input_box">
<text class="input_tit">密码</text>
<input password v-model="password" placeholder="请输入密码" />
</view>
<view class="input_box">
<text class="input_tit">确认密码</text>
<input password v-model="confirmPassword" placeholder="请确认密码" />
</view>
<view class="input_box">
<text class="input_tit">推荐码</text>
<input type="text" v-model="recommendCode" placeholder="推荐码(非必填)" @confirm="onSubmit" />
</view>
<view class="protocol_box">
<view class="select" :class="{active: agree}" @click="agree = !agree"></view>
我已同意
<text @click="onPageJump('/pages/user/protocol')">用户协议</text>
<text @click="onPageJump('/pages/user/protocol')">隐私协议</text>
</view>
<view class="btn_box"><button @click="onSubmit"> </button></view>
</view>
</template>
<script>
import md5 from '@/plugins/md5';
var clear;
export default {
data() {
return {
//手机号
phone: '',
// 密码
password: '',
//验证码
code: '',
//确认密码
confirmPassword: '',
// 推荐码
recommendCode: "",
//验证码
codeText: '获取验证码',
//验证码已发
readonly: false,
agree: false,
};
},
//第一次加载
onLoad(e) {},
//页面显示
onShow() {},
//方法
methods: {
onJumpPage(url) {
uni.navigateTo({
url: url
});
},
//获取验证码
getCode() {
if (this.readonly) {
uni.showToast({
title: '验证码已发送',
icon: 'none'
});
return;
}
if (!this.phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
return;
}
this.$http
// .post('api/common/v1/send_sms', {
.post('book/user/sms/sendcode', {
phone: this.phone,
type: 1000
})
.then(res => {
this.getCodeState();
});
},
//验证码按钮文字状态
getCodeState() {
const _this = this;
this.readonly = true;
this.codeText = '60S后重新获取';
var s = 60;
clear = setInterval(() => {
s--;
_this.codeText = s + 'S后重新获取';
if (s <= 0) {
clearInterval(clear);
_this.codeText = '获取验证码';
_this.readonly = false;
}
}, 1000);
},
onSubmit() {
if (!this.agree) {
uni.showToast({
title: '请先同意《用户协议》和《隐私协议》',
icon: 'none'
});
return;
}
if (!this.phone) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return;
}
if (!this.$base.phoneRegular.test(this.phone)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
return;
}
if (!this.code) {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return;
}
if (!this.password) {
uni.showToast({
title: '请输入密码',
icon: 'none'
});
return;
}
if (!this.confirmPassword) {
uni.showToast({
title: '请输入确认密码',
icon: 'none'
});
return;
}
if (this.confirmPassword != this.password) {
uni.showToast({
title: '两次密码不一致',
icon: 'none'
});
return;
}
if (!this.$base.passwordRegular.test(this.password)) {
uni.showToast({
title: '请输入不少于6位且包含数字和字母的密码',
icon: 'none'
});
return;
}
let httpData = {
tel: this.phone,
code: this.code,
// password: md5(this.password),1
password: this.password,
};
if (this.recommendCode) {
httpData.recommendCode = this.recommendCode;
}
this.$http
.post('book/user/register', httpData)
.then(res => {
uni.showModal({
title: "提示",
content: "注册成功!",
showCancel: false,
success: (res) => {
uni.navigateBack();
}
});
});
}
},
//页面隐藏
onHide() {},
//页面卸载
onUnload() {},
//页面下来刷新
onPullDownRefresh() {},
//页面上拉触底
onReachBottom() {},
//用户点击分享
onShareAppMessage(e) {
return this.wxShare();
}
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.page {
background-color: #FFF;
padding: 0 65rpx;
min-height: 100vh;
.title {
padding: 60rpx 0 40rpx 0;
font-size: 60rpx;
color: #333333;
}
.input_box {
display: flex;
justify-content: space-between;
height: 100rpx;
padding-top: 30rpx;
border-bottom: 1rpx solid #eeeeee;
align-items: center;
text{
font-size: 30rpx;
width: 180rpx;
}
input {
flex: 1;
height: 70rpx;
line-height: 80rpx;
font-size: 30rpx;
}
button {
height: 78rpx;
line-height: 78rpx;
font-size: 30rpx;
color: $themeColor;
&:active {
background-color: transparent;
}
}
}
.btn_box {
margin-top: 40rpx;
button {
font-size: 32rpx;
@include theme('btn_bg') color: #fff;
height: 80rpx;
line-height: 80rpx;
border-radius: 50rpx;
}
}
.protocol_box {
margin-top: 40rpx;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
font-size: 28rpx;
color: #333333;
.select {
width: 36rpx;
height: 36rpx;
background-image: url("../../static/icon/ic_gender_unselected.png");
background-position: center center;
background-repeat: no-repeat;
background-size: 100% auto;
margin-right: 15rpx;
&.active {
background-image: url("../../static/icon/ic_agreed.png");
}
}
>text {
color: $themeColor;
}
}
}
</style>

1255
pages/user/visitor.vue Normal file

File diff suppressed because it is too large Load Diff