123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <template>
- <view class="container">
- <u-form :model="registerForm" ref="registerForm" label-width="160"
- :label-style="{ color: '#000', fontSize: '30rpx'}">
- <u-form-item label="账号" prop="zhangHao" required :border-bottom="false">
- <u-input height="80" placeholder="请输入账号" border-color="#d0d0d0" v-model="registerForm.zhangHao"
- :border="true" class="form-item-input" />
- </u-form-item>
- <u-form-item label="密码" prop="miMa" required :border-bottom="false">
- <u-input height="80" placeholder="请输入密码" border-color="#d0d0d0" v-model="registerForm.miMa"
- :border="true" class="form-item-input" type="password" />
- </u-form-item>
- <u-form-item label="确认密码" prop="queRenMiMa" required :border-bottom="false">
- <u-input height="80" placeholder="请确认密码" border-color="#d0d0d0" v-model="registerForm.queRenMiMa"
- :border="true" class="form-item-input" type="password" />
- </u-form-item>
- <u-form-item label="手机号码" prop="shouJiHaoMa" required :border-bottom="false">
- <u-input height="80" placeholder="请输入手机号" border-color="#d0d0d0" v-model="registerForm.shouJiHaoMa"
- :border="true" class="form-item-input" type="number" />
- </u-form-item>
- <u-form-item label="身份证" prop="shenFenZheng" :border-bottom="false">
- <u-input height="80" placeholder="请输入身份证" border-color="#d0d0d0" v-model="registerForm.shenFenZheng"
- :border="true" class="form-item-input" />
- </u-form-item>
- <u-form-item label="性别" prop="xingBie" required :border-bottom="false">
- <u-radio-group v-model="registerForm.xingBie">
- <u-radio v-for="(item, index) in radioList1" :key="index" :name="item.name"
- :disabled="item.disabled">
- {{ item.text }}
- </u-radio>
- </u-radio-group>
- </u-form-item>
- <view class="form-button" @click="submit">
- 注册
- </view>
- <view class="form-tip" @click="back">已有账号,立即登录</view>
- </u-form>
- </view>
- </template>
- <script>
- import {
- msg
- } from "@/utils/common.js"
- export default {
- data() {
- return {
- registerForm: {
- zhangHao: '', //账号
- miMa: "", //密码
- queRenMiMa: '', // 确认密码
- shouJiHaoMa: '', // 手机号码
- shenFenZheng: '', // 身份证
- xingBie: '' // 性别
- },
- radioList1: [{
- name: '男',
- text: '男',
- disabled: false
- },
- {
- name: '女',
- text: '女',
- disabled: false
- }
- ],
- rules: {
- zhangHao: [{
- required: true,
- message: '请输入账号',
- trigger: ['blur']
- }],
- miMa: [{
- required: true,
- message: '请输入密码',
- trigger: ['blur']
- }],
- queRenMiMa: [{
- required: true,
- message: '请确认密码',
- trigger: ['blur']
- }, {
- required: true,
- message: "密码与确认密码不一致",
- trigger: ['blur'],
- validator: this.validateConfirmPassword
- }],
- shouJiHaoMa: [{
- required: true,
- message: '请输入手机号码',
- trigger: ['blur']
- }, {
- pattern: /^1[3-9]\d{9}$/,
- message: '请输入正确的手机号',
- trigger: ['blur']
- }],
- shenFenZheng: [{
- pattern: /^(?:\d{15}|\d{17}[\dXx])$/,
- transform(value) {
- return String(value);
- },
- message: '请输入正确的手机号',
- trigger: ['blur']
- }],
- xingBie: [{
- required: true,
- message: '请选择性别',
- trigger: ['change']
- }]
- }
- };
- },
- methods: {
- validateConfirmPassword(rule, value, callback) {
- if (value !== this.registerForm.miMa) {
- callback(new Error('密码与确认密码不一致'));
- } else {
- callback(); // 校验通过
- }
- },
- submit() {
- const that = this;
- that.$refs.registerForm.validate((valid) => {
- console.log(valid, that.registerForm.xingBie, 456);
- if (valid) {
- msg("数据验证成功")
- }
- })
- },
- // 提示
- showToast(msg, type) {
- uni.showToast({
- icon: type ? type : "none",
- title: msg
- })
- },
- back() {
- uni.navigateBack({
- delta: 1,
- animationType: 'pop-out',
- animationDuration: 200
- })
- }
- },
- onLoad() {},
- onReady() {
- this.$refs.registerForm.setRules(this.rules);
- }
- }
- </script>
- <style lang="scss">
- .u-form-item {
- padding: 30rpx 0 !important;
- }
- .u-form-item .u-input--border {
- border-radius: 16rpx !important;
- }
- .u-form-item .u-form-item--left__content__label {
- display: block !important;
- text-align: justify;
- text-align-last: justify;
- padding: 0 20rpx 0 10rpx;
- }
- .u-input {
- background-color: #f7f7f7 !important;
- }
- </style>
- <style lang="scss" scoped>
- .container {
- height: 100vh;
- width: 100vw;
- background-color: #ffffff;
- padding: 0 40rpx;
- }
- .form-item-input {
- width: 100%;
- }
- .form-button {
- background: linear-gradient(90deg, #006af5, #21b0fc);
- border-radius: 20rpx;
- line-height: 80rpx;
- text-align: center;
- color: #fff;
- margin: 20rpx 0 50rpx;
- }
- .form-tip {
- text-align: center;
- color: #000000;
- }
- </style>
|