123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <template>
- <view class="pages">
- <view class="" :style="{height: navHeight+'px' }"></view>
- <!-- 自定义导航 -->
- <view class="navbar-box">
- <u-navbar title="信息填写" :safeAreaInsetTop="true" @leftClick="leftClick"></u-navbar>
- </view>
- <view class="page-wrap">
- <view class="form-wrap">
- <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" labelWidth="120rpx" >
- <u-form-item label="姓名" prop="name" borderBottom>
- <u--input v-model="form.name" placeholder="与证件名字一致" border="none"></u--input>
- </u-form-item>
- <u-form-item label="身份证" prop="sfz" borderBottom>
- <u--input v-model="form.sfz" placeholder="身份证号码" border="none"></u--input>
- </u-form-item>
- <u-form-item label="手机号" prop="mobile" borderBottom>
- <u--input v-model="form.mobile" placeholder="常用手机号" border="none"></u--input>
- </u-form-item>
- </u--form>
- <view class="set-default u-flex u-row-between">
- <view class="left">
- <view class="up">设置为默认信息</view>
- <view class="down">提醒:每次下单会默认使用该信息</view>
- </view>
- <view class="right">
- <u-switch v-model="form.default" activeValue='1' inactiveValue='0'></u-switch>
- </view>
- </view>
- </view>
- <view class="btn-wrap">
- <view class="full-btn" @click="submit">保存</view>
- <view class="full-btn white" @click="cancel">取消</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { systemInfo } from "@/mixin.js";
- export default {
- mixins:[systemInfo],
- data() {
- return {
- id:'',
- type:'',
- fromPage:'',
- form: {
- name: '',
- sfz:'',
- mobile:'',
- default:'0',
- },
- rules: {
- 'name': [
- {
- type: 'string',
- required: true,
- message: '请填写姓名',
- trigger: ['blur', 'change']
- }
- ],
- 'sfz': [
- {
- type: 'string',
- required: true,
- message: '请输入身份证',
- trigger: ['blur', 'change']
- },
- {
- validator: (rule, value, callback) => {
- // 上面有说,返回true表示校验通过,返回false表示不通过
- // this.$u.test.mobile()就是返回true或者false的
- return this.$u.test.idCard(value);
- },
- message: '请输入正确身份证',
- // 触发器可以同时用blur和change
- trigger: ['change', 'blur'],
- }
- ],
- mobile: [
- {
- type: 'string',
- required: true,
- message: '请输入手机号',
- trigger: ['blur', 'change']
- },
- {
- validator: (rule, value, callback) => {
- // 上面有说,返回true表示校验通过,返回false表示不通过
- // this.$u.test.mobile()就是返回true或者false的
- return this.$u.test.mobile(value);
- },
- message: '请输入正确手机号',
- // 触发器可以同时用blur和change
- trigger: ['change', 'blur'],
- }
- ],
- },
- }
- },
- onLoad(page) {
- this.getSystemInfo();
- this.type = page.type;
- this.fromPage = page.fromPage;
- this.id = page.id;
- },
- onReady() {
- this.$refs.uForm.setRules(this.rules)
- },
- methods: {
- leftClick() {
- let canNavBack = getCurrentPages();
- if(canNavBack && canNavBack.length>1) {
- uni.navigateBack({
- delta: 1
- });
- } else {
- history.back();
- }
- },
- submit() {
- this.$refs.uForm.validate().then(res => {
- uni.$u.toast('表单校验失败')
- }).catch(errors => {
- uni.$u.toast('表单校验失败')
- })
- },
- cancel(){
- this.leftClick();
- }
- }
- }
- </script>
- <style>
- page{
- background-color: #F4F5F7;
- }
- </style>
- <style lang="scss" scoped>
- .form-wrap{
- background: #FFFFFF;
- box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(226,226,226,0.5);
- border-radius: 24rpx;
- margin-bottom: 70rpx;
- padding: 10rpx 40rpx 24rpx;
- }
- .set-default{
- padding-top: 26rpx;
- .up{
- font-size: 28rpx;
- font-weight: 500;
- color: #606060;
- line-height: 42rpx;
- margin-bottom: 20rpx;
- }
- .down{
- font-size: 24rpx;
- font-weight: 400;
- color: #7F7F7F;
- line-height: 36rpx;
- }
- }
- </style>
|