|
|
@ -22,30 +22,106 @@ |
|
|
|
<template> |
|
|
|
<view class="container"> |
|
|
|
<view style="font-size:52rpx;margin-left:42rpx;">注册</view> |
|
|
|
<u-form :model="formData" ref="form" :rules="rules"> |
|
|
|
<d-form v-for="(v,k) in fields" :key="k" v-bind="v" :field="k"/> |
|
|
|
<u-form class="inline" :model="formData" errorType="toast" ref="form" :rules="rules"> |
|
|
|
<d-form |
|
|
|
v-for="(v,k) in fields" |
|
|
|
:key="k" |
|
|
|
v-bind="v" |
|
|
|
:field="k" |
|
|
|
@input="formData[k]=$event" |
|
|
|
@select="fields[k].value=$event.value.map(v=>v.value);formData[k]=$event.value[0].value"/> |
|
|
|
</u-form> |
|
|
|
|
|
|
|
<button class="cu-btn round bg-green shadow submit">注册</button> |
|
|
|
<button class="cu-btn round bg-green shadow submit" @click="submit">注册</button> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
<script> |
|
|
|
import request from '@/common/request.js' |
|
|
|
export default { |
|
|
|
data(){ |
|
|
|
return{ |
|
|
|
fields:{ |
|
|
|
name:{placeholder:"请输入企业名称(中文)"}, |
|
|
|
code:{placeholder:"请输入统一社会信用代码"}, |
|
|
|
type:{placeholder:"请选择企业类型",type:"select"}, |
|
|
|
people:{placeholder:"请输入企业联系人"}, |
|
|
|
tel:{placeholder:"请输入手机号码"}, |
|
|
|
password:{placeholder:"请输入密码(6-20位字母和数字的组合)"}, |
|
|
|
creditCode:{placeholder:"请输入统一社会信用代码"}, |
|
|
|
type:{placeholder:"请选择企业类型",type:"select",columns:[[]],value:[]}, |
|
|
|
connectUser:{placeholder:"请输入企业联系人"}, |
|
|
|
connectPhone:{placeholder:"请输入手机号码"}, |
|
|
|
password:{placeholder:"请输入密码(6-20位字母和数字的组合)",type:"password"}, |
|
|
|
}, |
|
|
|
formData:{ |
|
|
|
name: "", |
|
|
|
creditCode: "", |
|
|
|
type: "", |
|
|
|
connectUser: "", |
|
|
|
connectPhone: "", |
|
|
|
password: "", |
|
|
|
}, |
|
|
|
formData:{name:""}, |
|
|
|
rules:{ |
|
|
|
name:{required:true, message:"企业名称必填!", trigger:"blur"} |
|
|
|
name:{required:true, message:"企业名称必填!", trigger:"blur"}, |
|
|
|
creditCode:{required:true, validator(rule, val, call){ |
|
|
|
if(!val)call(new Error('统一社会信用代码必填!')); |
|
|
|
else if(!/^([0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}|[1-9]\d{14})$/.test(val))call(new Error('请输入正确的统一社会信用代码格式!')); |
|
|
|
else call() |
|
|
|
}, trigger:"blur"}, |
|
|
|
type:{required:true, message:"企业类型必选!", trigger:"blur"}, |
|
|
|
connectUser:{required:true, message:"企业联系人必填!", trigger:"blur"}, |
|
|
|
connectPhone:{required:true, validator(rule, val, call){ |
|
|
|
if(!val)call(new Error("手机号码必填!")); |
|
|
|
else if(!/^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/.test(val))call(new Error("请输入正确的手机号码格式!")); |
|
|
|
else call() |
|
|
|
}, trigger:"blur"}, |
|
|
|
password:{required:true, validator(rule,val,call){ |
|
|
|
if(!val)call(new Error('密码必填!')); |
|
|
|
else if(!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/.test(val))call(new Error('密码格式为(6-20位字母和数字的组合)!')); |
|
|
|
else call(); |
|
|
|
}, trigger:"blur"}, |
|
|
|
}, |
|
|
|
} |
|
|
|
}, |
|
|
|
onload(){ |
|
|
|
|
|
|
|
}, |
|
|
|
onShow(){ |
|
|
|
this.init() |
|
|
|
}, |
|
|
|
methods:{ |
|
|
|
async init(){ |
|
|
|
var res=await request("/common/api/dict/queryDictItemByDictCode",{ |
|
|
|
method:"post", |
|
|
|
params:{dictCode:"company_type"} |
|
|
|
}) |
|
|
|
if(res.statu){ |
|
|
|
this.fields.type.columns=[res.data] |
|
|
|
}else{ |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:res.msg||"获取企业类型选项失败!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
async submit(){ |
|
|
|
this.$refs.form.validate().then(async valid=>{ |
|
|
|
if(valid){ |
|
|
|
var res=await request("/base/api/plantCompany/register",{ |
|
|
|
method:"post", |
|
|
|
body:this.formData |
|
|
|
}) |
|
|
|
if(res.statu){ |
|
|
|
uni.showToast({title:"注册成功!"}) |
|
|
|
setTimeout(()=>{ |
|
|
|
uni.reLaunch({url:"/"}) |
|
|
|
},1500) |
|
|
|
}else{ |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:res.msg||"注册失败!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |