平板端快衣店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

170 lines
4.3 KiB

<template>
<view>
<view class="formBox">
<uni-forms ref="form" :modelValue="formData" :rules="rules" labelWidth="85px">
<uni-forms-item label="店铺名称" name="shopName" required>
<uni-easyinput type="text" v-model="formData.shopName" placeholder="请输入店铺名称" trim="all" />
</uni-forms-item>
<uni-forms-item label="店铺地址" required name="shopAddress">
<uni-easyinput type="text" v-model="formData.shopAddress" placeholder="请输入店铺地址(精确到门牌号)"
trim="all" />
</uni-forms-item>
<uni-forms-item label="用户姓名" required name="nickname">
<uni-easyinput type="text" v-model="formData.nickname" placeholder="请输入真实姓名"
trim="all" />
</uni-forms-item>
<uni-forms-item label="手机号" name="mobile" required>
<uni-easyinput type="digit" v-model="formData.mobile" placeholder="请输入手机号" trim="all" />
</uni-forms-item>
<uni-forms-item label="验证码" name="code" required>
<uni-easyinput type="digit" v-model="formData.code" placeholder="请输入验证码" trim="all" />
<button class="button" size="mini" type="default" @click="sendLoginSms" :disabled="choose" :class="choose == false ? 'hasChosen':'notChosen'">
{{ choose ? clock + '重新获取' : '获取验证码' }}
</button>
</uni-forms-item>
</uni-forms>
<u-button type="primary" @tap.stop="submit()">提交注册</u-button>
</view>
</view>
</template>
<script>
import { reg } from '@/utils/global.js'
export default {
data() {
return {
// 表单数据
formData: {
shopName: '',
shopAddress: '',
mobile: '',
code: '',
LoginSms:'',
nickname:''
},
rules: {
// 对name字段进行必填验证
shopName: {
rules: [{
required: true,
errorMessage: '请输入店铺名称',
}, ],
},
shopAddress: {
rules: [{
required: true,
errorMessage: '请输入店铺地址',
}, ],
},
nickname: {
rules: [{
required: true,
errorMessage: '请输入用户姓名',
}, ],
},
mobile: {
rules: [{
required: true,
errorMessage: '请输入手机号',
}, ],
},
code: {
rules: [{
required: true,
errorMessage: '请填写验证码',
}, ],
},
},
choose:false,
isChoose:false,
clock: 60 ,// 倒计时
}
},
onLoad() {
},
methods: {
sendLoginSms(){ // 获取验证码
this.isChoose = false
if(reg(this.formData.mobile,this.clock) && this.isChoose == false){
this.choose = true
this.setTime()
this.tui.request("/common/captcha/sendRegistSms/"+this.formData.mobile, "GET", {
}).then((res) => {
if (res.code == 200) {
uni.showToast({
title: "发送成功",
icon: 'success'
})
}else{
this.tui.toast(res.message)
}
}).catch((res) => {
this.tui.toast(res)
})
}else if(reg(this.formData.mobile,this.clock) && this.isChoose == true){
}
},
setTime(){// 倒计时函数
if(this.clock == 0){
this.clock = 60
this.choose = false
return
}else{
this.clock--
if(this.clock < 10){this.clock = '0'+this.clock}
}
setTimeout(() => { this.setTime() },1000)
},
// 触发提交表单
submit() {
this.$refs.form.validate().then(res => {
this.tui.request("/auth/shopRegister", "post", res, false, true).then((res1) => {
if (res1.code == 200) {
uni.showModal({
title: "注册成功",
content: "稍后会有管理员联系您!",
showCancel:false,
success: function(res) {
uni.navigateBack({
delta: 1
})
}
})
} else {
uni.showToast({
title: "添加失败",
icon: 'none'
})
}
})
}).catch(err => {
})
}
}
}
</script>
<style lang="scss" scoped>
.formBox {
margin: 20rpx;
padding: 20rpx 26rpx;
border-radius: 14rpx;
box-shadow: 0px 1px 10px 2px #e2e2e2;
background-color: #fff;
.uni-data-select {
width: 100%;
}
}
.hasChosen{
height: 74rpx;
line-height: 74rpx;
color: #fff;
border: none;
background: #5fd9ee;
}
</style>