10 changed files with 415 additions and 237 deletions
@ -1,32 +1,44 @@ |
|||||
<template> |
<template> |
||||
<view> |
<view> |
||||
<view class="cu-timeline"> |
<view class="cu-timeline"> |
||||
<view class="cu-time">昨天</view> |
<!-- <view class="cu-time">昨天</view> --> |
||||
<view class="cu-item cur cuIcon-noticefill"> |
<view :key="index" class="cu-item cur" v-for="(item, index) in userSigns"> |
||||
<view class="content bg-green shadow-blur"> |
<view class="content bg-green shadow-blur"> |
||||
<text>22:22</text>【广州市】快件已到达地球 |
<text>{{ generateTime(item.time - 0) }}</text> |
||||
</view> |
【 {{ item.siteName }} 】打卡 |
||||
</view> |
</view> |
||||
<view class="cu-item text-red cuIcon-attentionforbidfill"> |
</view> |
||||
<view class="content bg-red shadow-blur">这是第一次,我家的铲屎官走了这么久。久到足足有三天!!</view> |
</view> |
||||
</view> |
</view> |
||||
</view> |
|
||||
|
|
||||
<view class="cu-timeline"> |
|
||||
<view class="cu-time">06-17</view> |
|
||||
<view class="cu-item"> |
|
||||
<view class="content"> |
|
||||
<text>01:30</text>【喵星】 MX-12138 已揽收,准备发往银河系 |
|
||||
</view> |
|
||||
</view> |
|
||||
</view> |
|
||||
</view> |
|
||||
</template> |
</template> |
||||
|
|
||||
<script> |
<script> |
||||
export default { |
import { mapState } from 'vuex'; |
||||
data() { |
|
||||
return {}; |
export default { |
||||
}, |
data() { |
||||
}; |
return {}; |
||||
|
}, |
||||
|
|
||||
|
computed: mapState('statistics', ['userSigns']), |
||||
|
|
||||
|
methods: { |
||||
|
/** |
||||
|
* 格式化时间为文本 |
||||
|
* @param {number} time ms数 |
||||
|
*/ |
||||
|
generateTime(time) { |
||||
|
let type = 'YYYY-MM-DD HH:mm'; |
||||
|
if (this.$moment().isSame(time, 'day')) { |
||||
|
return `今天 ${this.$moment(time).format('HH:mm')}`; |
||||
|
} |
||||
|
|
||||
|
if (this.$moment().isSame(time, 'year')) { |
||||
|
type = 'MM-DD HH:mm'; |
||||
|
} |
||||
|
|
||||
|
return this.$moment(time).format(type); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
</script> |
</script> |
||||
|
@ -1,209 +1,243 @@ |
|||||
<template> |
<template> |
||||
<view> |
<view> |
||||
<form class="padding-lr cu-form-group flex-direction"> |
<form class="padding-lr cu-form-group flex-direction"> |
||||
<view class="cu-form-group flex flex-direction padding-tb"> |
<view class="cu-form-group flex flex-direction padding-tb"> |
||||
<view class="title padding-bottom-sm"><span v-show="!userInfo" class="text-red padding-right-xs">*</span>姓名</view> |
<view class="title padding-bottom-sm"> |
||||
<input :disabled="userInfo ? true : false" placeholder="请输入真实姓名" name="input" type="text" v-model="name" /> |
<span class="text-red padding-right-xs" v-show="!userInfo">*</span>姓名 |
||||
</view> |
</view> |
||||
<view class="cu-form-group flex flex-direction padding-tb"> |
<input |
||||
<view class="title padding-bottom-sm"><span v-show="!userInfo" class="text-red padding-right-xs">*</span>身份证</view> |
:disabled="(userinfo && userInfo.id) ? true : false" |
||||
<input :disabled="userInfo ? true : false" placeholder="请输入身份证号" name="input" type="text" v-model="idCard" /> |
name="input" |
||||
</view> |
placeholder="请输入真实姓名" |
||||
<view class="cu-form-group flex flex-direction padding-tb"> |
type="text" |
||||
<view class="title padding-bottom-sm"><span v-show="!userInfo" class="text-red padding-right-xs">*</span>联系方式</view> |
v-model="name" |
||||
<input :disabled="userInfo ? true : false" placeholder="请输入手机号码" name="input" type="number" v-model="phone" /> |
/> |
||||
</view> |
</view> |
||||
<view class="cu-form-group flex flex-direction padding-tb"> |
<view class="cu-form-group flex flex-direction padding-tb"> |
||||
<view class="title padding-bottom-sm"><span v-show="!userInfo" class="text-red padding-right-xs">*</span>身份</view> |
<view class="title padding-bottom-sm"> |
||||
<radio-group class="block" @change="RadioChange" v-if="!userInfo"> |
<span class="text-red padding-right-xs" v-show="!(userinfo && userInfo.id)">*</span>身份证 |
||||
<view class="flex"> |
</view> |
||||
<view class="flex-sub margin-tb-sm" v-for="(identity,index) in identitys" :key="index"> |
<input |
||||
<label class="flex justify-between align-center"> |
:disabled="(userinfo && userInfo.id) ? true : false" |
||||
<radio class="round margin-right-xs" :checked="index === current" :value="identity.value"></radio> |
name="input" |
||||
<text class="flex-sub" style="font-size: 34rpx;">{{ identity.name }}</text> |
placeholder="请输入身份证号" |
||||
</label> |
type="text" |
||||
</view> |
v-model="idCard" |
||||
</view> |
/> |
||||
</radio-group> |
</view> |
||||
<input v-else disabled name="input" type="text" :value="current === 0 ? '学生' : current === 1 ? '教师' : '工作人员'" /> |
<view class="cu-form-group flex flex-direction padding-tb"> |
||||
</view> |
<view class="title padding-bottom-sm"> |
||||
<view class="cu-form-group flex flex-direction padding-tb"> |
<span class="text-red padding-right-xs" v-show="!(userinfo && userInfo.id)">*</span>联系方式 |
||||
<view class="title padding-bottom-sm"><span v-show="!userInfo" class="text-red padding-right-xs">*</span>学号</view> |
</view> |
||||
<input :disabled="userInfo ? true : false" placeholder="请输入学号" name="input" type="text" v-model="studentID" /> |
<input |
||||
</view> |
:disabled="(userinfo && userInfo.id) ? true : false" |
||||
|
name="input" |
||||
</form> |
placeholder="请输入手机号码" |
||||
<user-agreement v-if="!userInfo" @changeIntentions='changeIntentions'></user-agreement> |
type="number" |
||||
<button v-show="!userInfo" class="bg-cyan margin primary-btn" hover-class="cc-active" @tap="handleSubmitUserInfo">确认提交</button> |
v-model="phone" |
||||
</view> |
/> |
||||
|
</view> |
||||
|
<view class="cu-form-group flex flex-direction padding-tb"> |
||||
|
<view class="title padding-bottom-sm"> |
||||
|
<span class="text-red padding-right-xs" v-show="!(userinfo && userInfo.id)">*</span>身份 |
||||
|
</view> |
||||
|
<radio-group @change="RadioChange" class="block" v-if="!(userinfo && userInfo.id)"> |
||||
|
<view class="flex"> |
||||
|
<view :key="index" class="flex-sub margin-tb-sm" v-for="(identity,index) in identitys"> |
||||
|
<label class="flex justify-between align-center"> |
||||
|
<radio |
||||
|
:checked="index === current" |
||||
|
:value="identity.value" |
||||
|
class="round margin-right-xs" |
||||
|
></radio> |
||||
|
<text class="flex-sub" style="font-size: 34rpx;">{{ identity.name }}</text> |
||||
|
</label> |
||||
|
</view> |
||||
|
</view> |
||||
|
</radio-group> |
||||
|
<input |
||||
|
:value="current === 0 ? '学生' : current === 1 ? '教师' : '工作人员'" |
||||
|
disabled |
||||
|
name="input" |
||||
|
type="text" |
||||
|
v-else |
||||
|
/> |
||||
|
</view> |
||||
|
<view class="cu-form-group flex flex-direction padding-tb"> |
||||
|
<view class="title padding-bottom-sm"> |
||||
|
<span class="text-red padding-right-xs" v-show="!(userinfo && userInfo.id)">*</span>学号 |
||||
|
</view> |
||||
|
<input |
||||
|
:disabled="(userinfo && userInfo.id) ? true : false" |
||||
|
name="input" |
||||
|
placeholder="请输入学号" |
||||
|
type="text" |
||||
|
v-model="studentID" |
||||
|
/> |
||||
|
</view> |
||||
|
</form> |
||||
|
<user-agreement @changeIntentions="changeIntentions" v-if="!(userinfo && userInfo.id)"></user-agreement> |
||||
|
<button |
||||
|
@tap="handleSubmitUserInfo" |
||||
|
class="bg-cyan margin primary-btn" |
||||
|
hover-class="cc-active" |
||||
|
v-show="!(userinfo && userInfo.id)" |
||||
|
>确认提交</button> |
||||
|
</view> |
||||
</template> |
</template> |
||||
|
|
||||
<script> |
<script> |
||||
import { |
import { showToast } from 'common/script/util'; |
||||
showToast |
import { SUBMIT_USER_INFO } from 'api/api'; |
||||
} from 'common/script/util'; |
import { mapState, mapMutations } from 'vuex'; |
||||
import { |
|
||||
SUBMIT_USER_INFO |
|
||||
} from 'api/api'; |
|
||||
import { mapState,mapMutations } from 'vuex'; |
|
||||
|
|
||||
export default { |
export default { |
||||
data() { |
data() { |
||||
return { |
return { |
||||
name: '', |
name: '', |
||||
idCard: '', |
idCard: '', |
||||
phone: '', |
phone: '', |
||||
identitys: [{ |
identitys: [ |
||||
value: '0', |
{ |
||||
name: '学生', |
value: '0', |
||||
}, |
name: '学生', |
||||
{ |
}, |
||||
value: '1', |
{ |
||||
name: '教师', |
value: '1', |
||||
}, |
name: '教师', |
||||
{ |
}, |
||||
value: '2', |
{ |
||||
name: '工作人员', |
value: '2', |
||||
}, |
name: '工作人员', |
||||
], |
}, |
||||
studentID: '', |
], |
||||
current: 0, |
studentID: '', |
||||
agree: false |
current: 0, |
||||
}; |
agree: false, |
||||
}, |
}; |
||||
|
}, |
||||
|
|
||||
created() { |
created() { |
||||
if(this.userInfo){ |
if (this.userInfo) { |
||||
this.name = this.userInfo.name; |
this.name = this.userInfo.name; |
||||
this.idCard = this.userInfo.idCard; |
this.idCard = this.userInfo.idCard; |
||||
this.phone = this.userInfo.phone; |
this.phone = this.userInfo.phone; |
||||
this.studentID = this.userInfo.no; |
this.studentID = this.userInfo.no; |
||||
this.current = this.userInfo.post; |
this.current = this.userInfo.post; |
||||
} |
} |
||||
}, |
}, |
||||
|
|
||||
computed: mapState('user', ['userInfo','pagePath']), |
computed: mapState('user', ['userInfo', 'pagePath']), |
||||
|
|
||||
methods: { |
methods: { |
||||
...mapMutations('user', ['setUserInfo']), |
...mapMutations('user', ['setUserInfo']), |
||||
RadioChange: function(evt) { |
RadioChange: function(evt) { |
||||
for (let i = 0; i < this.identitys.length; i++) { |
for (let i = 0; i < this.identitys.length; i++) { |
||||
if (this.identitys[i].value === evt.target.value) { |
if (this.identitys[i].value === evt.target.value) { |
||||
this.current = i; |
this.current = i; |
||||
break; |
break; |
||||
} |
} |
||||
} |
} |
||||
}, |
}, |
||||
|
|
||||
changeIntentions(data){ |
changeIntentions(data) { |
||||
this.agree = data; |
this.agree = data; |
||||
}, |
}, |
||||
|
|
||||
/** |
/** |
||||
* 提交基本信息 |
* 提交基本信息 |
||||
*/ |
*/ |
||||
async handleSubmitUserInfo() { |
async handleSubmitUserInfo() { |
||||
try { |
try { |
||||
if (!this.checkRules()) return; |
if (!this.checkRules()) return; |
||||
|
|
||||
const { |
const { name, idCard, phone, studentID, current } = this; |
||||
name, |
const params = { |
||||
idCard, |
param: { |
||||
phone, |
idCard, |
||||
studentID, |
name, |
||||
current |
no: studentID, |
||||
} = this; |
phone, |
||||
const params = { |
post: current, |
||||
param: { |
}, |
||||
idCard, |
}; |
||||
name, |
|
||||
no: studentID, |
|
||||
phone, |
|
||||
post: current |
|
||||
} |
|
||||
}; |
|
||||
|
|
||||
const res = await this.$http.post(SUBMIT_USER_INFO, params); |
const res = await this.$http.post(SUBMIT_USER_INFO, params); |
||||
const { |
const { success, code, msg, data } = res.data; |
||||
success, |
if (success && code === 200) { |
||||
code, |
this.success = true; |
||||
msg, |
this.setUserInfo(data); |
||||
data |
this.openPage(pagePath); |
||||
} = res.data; |
} else { |
||||
if (success && code === 200) { |
uni.showToast({ |
||||
this.success = true; |
title: msg || '提交基本信息成功', |
||||
this.setUserInfo(data); |
icon: 'none', |
||||
this.openPage(pagePath) |
}); |
||||
} else { |
} |
||||
uni.showToast({ |
} catch (error) { |
||||
title: msg || '提交基本信息成功', |
console.log('error: ', error); |
||||
icon: 'none' |
if (error.msg) { |
||||
}); |
uni.showToast({ |
||||
} |
title: error.msg || '提交基本信息失败', |
||||
} catch (error) { |
icon: 'none', |
||||
console.log('error: ', error); |
}); |
||||
if (error.msg) { |
} |
||||
uni.showToast({ |
} |
||||
title: error.msg || '提交基本信息失败', |
}, |
||||
icon: 'none' |
|
||||
}); |
|
||||
} |
|
||||
} |
|
||||
}, |
|
||||
|
|
||||
// 验证信息 |
// 验证信息 |
||||
checkRules() { |
checkRules() { |
||||
const { name,idCard,phone,identitys,studentID,agree } = this; |
const { name, idCard, phone, identitys, studentID, agree } = this; |
||||
if (!name) { |
if (!name) { |
||||
showToast('请输入姓名'); |
showToast('请输入姓名'); |
||||
return; |
return; |
||||
} |
} |
||||
if (!this.verifyIdCard(idCard)) { |
if (!this.verifyIdCard(idCard)) { |
||||
showToast('请输入正确的身份证号'); |
showToast('请输入正确的身份证号'); |
||||
return; |
return; |
||||
} |
} |
||||
if (!this.verifyPhone(phone)) { |
if (!this.verifyPhone(phone)) { |
||||
showToast('请输入正确的手机号'); |
showToast('请输入正确的手机号'); |
||||
return false; |
return false; |
||||
} |
} |
||||
if (!identitys) { |
if (!identitys) { |
||||
showToast('请选择身份'); |
showToast('请选择身份'); |
||||
return; |
return; |
||||
} |
} |
||||
if (!studentID) { |
if (!studentID) { |
||||
showToast('请输入学号'); |
showToast('请输入学号'); |
||||
return; |
return; |
||||
} |
} |
||||
if(!agree) { |
if (!agree) { |
||||
showToast('请选择是否同意《用户服务协议》和《隐私政策》'); |
showToast('请选择是否同意《用户服务协议》和《隐私政策》'); |
||||
return; |
return; |
||||
} |
} |
||||
return true; |
return true; |
||||
}, |
}, |
||||
|
|
||||
/** |
/** |
||||
* 验证手机号格式 |
* 验证手机号格式 |
||||
* @param {string} phone 手机号 |
* @param {string} phone 手机号 |
||||
*/ |
*/ |
||||
verifyPhone(phone) { |
verifyPhone(phone) { |
||||
const phoneExg = /^1\d{10}$/; |
const phoneExg = /^1\d{10}$/; |
||||
return phoneExg.test(phone); |
return phoneExg.test(phone); |
||||
}, |
}, |
||||
|
|
||||
/** |
/** |
||||
* 验证身份证号格式 |
* 验证身份证号格式 |
||||
* @param {string} idCard 身份证号 |
* @param {string} idCard 身份证号 |
||||
*/ |
*/ |
||||
verifyIdCard(idCard) { |
verifyIdCard(idCard) { |
||||
const idCardExg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; |
const idCardExg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; |
||||
return idCardExg.test(idCard); |
return idCardExg.test(idCard); |
||||
}, |
}, |
||||
}, |
}, |
||||
}; |
}; |
||||
</script> |
</script> |
||||
|
|
||||
<style lang="scss" scoped> |
<style lang="scss" scoped> |
||||
.primary-btn { |
.primary-btn { |
||||
border-radius: 15rpx; |
border-radius: 15rpx; |
||||
} |
} |
||||
</style> |
</style> |
||||
|
Loading…
Reference in new issue