422 lines
12 KiB
Vue
422 lines
12 KiB
Vue
<template>
|
||
<u--form :model="form" errorType="toast" labelWidth="216rpx" ref="wholesalerForm">
|
||
<view class="box-state" v-if="stateTitle && isDraft!==1 && applyType === 4">
|
||
<u-alert :center="stateType==='primary'" :title="stateTitle" :type="stateType"/>
|
||
</view>
|
||
|
||
<u-cell-group title="采购批发商基本信息" :border="false" :customStyle="{'fontSize':'40rpx'}">
|
||
|
||
<u-form-item prop="name">
|
||
<u-cell title="批发商名称" :border="false">
|
||
<template #icon>
|
||
<text class="required">*</text>
|
||
</template>
|
||
<template #value>
|
||
<u-input v-model="form.name" border="none" placeholder="请填写批发商名称"/>
|
||
</template>
|
||
</u-cell>
|
||
</u-form-item>
|
||
|
||
<u-form-item prop="avatar">
|
||
<u-cell title="头像" :border="false"/>
|
||
<u-cell :border="false">
|
||
<template #title>
|
||
<view class="box-upload" @click="chooseLogoImg('avatar')">
|
||
<view class="btn-upload" v-if="form.avatar.length===0">上传图片</view>
|
||
<image class="img-preview" :src="form.avatar" v-else/>
|
||
</view>
|
||
</template>
|
||
</u-cell>
|
||
</u-form-item>
|
||
|
||
<u-form-item prop="contact">
|
||
<u-cell title="联系人姓名" :border="false">
|
||
<template #icon>
|
||
<text class="required">*</text>
|
||
</template>
|
||
<template #value>
|
||
<u-input v-model="form.contact" border="none" placeholder="请填写联系人姓名"/>
|
||
</template>
|
||
</u-cell>
|
||
</u-form-item>
|
||
|
||
<u-form-item prop="phone">
|
||
<u-cell title="联系方式" :border="false">
|
||
<template #icon>
|
||
<text class="required">*</text>
|
||
</template>
|
||
<template #value>
|
||
<u-input v-model="form.phone" border="none" placeholder="请填写联系方式"/>
|
||
</template>
|
||
</u-cell>
|
||
</u-form-item>
|
||
|
||
<u-form-item prop="captcha">
|
||
<u-cell title="验证码" :border="false">
|
||
<template #icon>
|
||
<text class="required">*</text>
|
||
</template>
|
||
<template #value>
|
||
<u-input v-model="form.captcha" border="none" placeholder="请填写验证码">
|
||
<template slot="suffix">
|
||
<u-code
|
||
ref="uCode"
|
||
@change="codeChange"
|
||
seconds="30"
|
||
changeText="X秒重新获取"
|
||
></u-code>
|
||
<u-button
|
||
@tap="getCode"
|
||
:text="tips"
|
||
type="success"
|
||
size="normal"
|
||
></u-button>
|
||
</template>
|
||
</u-input>
|
||
</template>
|
||
</u-cell>
|
||
</u-form-item>
|
||
|
||
<u-form-item prop="qualification">
|
||
<view class="licence-section">
|
||
<u-cell :border="false">
|
||
<template #icon>
|
||
<text class="required">*</text>
|
||
</template>
|
||
<template #title>
|
||
<view>商家资质<text class="font-color-red">(请上传营业执照及行业相关资质证明)</text></view>
|
||
</template>
|
||
</u-cell>
|
||
</view>
|
||
<view class="licence-image">
|
||
<u-cell :border="false">
|
||
<template #title>
|
||
<view class="box-upload" @click="chooseLogoImg('licence')">
|
||
<view class="btn-upload" v-if="form.qualification.length===0">上传图片</view>
|
||
<image class="img-preview" :src="form.qualification" v-else/>
|
||
</view>
|
||
</template>
|
||
</u-cell>
|
||
</view>
|
||
</u-form-item>
|
||
|
||
<u-form-item prop="area">
|
||
<u-cell title="省市区" :border="false" isLink>
|
||
<template #icon>
|
||
<text class="required">*</text>
|
||
</template>
|
||
<template #value>
|
||
<view class="u-text__value" :class="{'area-item':form.area.length===0}">
|
||
<CitySelect ref="cityselect" :defaultValue="form.area" @callback="result" :items="district"/>
|
||
</view>
|
||
</template>
|
||
</u-cell>
|
||
</u-form-item>
|
||
|
||
<u-form-item prop="address">
|
||
<u-cell title="详细地址" :border="false">
|
||
<template #icon>
|
||
<text class="required">*</text>
|
||
</template>
|
||
<template #value>
|
||
<u-input v-model="form.address" border="none" placeholder="请填写详细地址"/>
|
||
</template>
|
||
</u-cell>
|
||
</u-form-item>
|
||
|
||
</u-cell-group>
|
||
<view class="btn-submit btn-remove" v-if="reviewStatus===0 && isDraft!==1" @click="changeRemove(true)">撤销申请</view>
|
||
<view class="btn-submit" @click="onSubmit" v-else>提交申请</view>
|
||
|
||
<u-modal :show="showRemove" content="您确定撤销申请吗?" showCancelButton @cancel="changeRemove(false)"
|
||
@confirm="onRemove"></u-modal>
|
||
|
||
<u-popup :show="show" mode="center" round="10" closeable @close="show=false">
|
||
<view class="popup-body">
|
||
<view class="tc bold">入驻申请须知</view>
|
||
<view class="content">
|
||
<rich-text :nodes="notice" />
|
||
</view>
|
||
<view class="agree-box">
|
||
<checkbox-group @change="changeAgree">
|
||
<label>
|
||
<checkbox value="yes" style="transform:scale(0.8)"/>
|
||
</label>
|
||
<text>我已仔细阅读并同意</text>
|
||
</checkbox-group>
|
||
</view>
|
||
<u-button type="error" text="确定" :disabled="!isAgree" @click="save"></u-button>
|
||
</view>
|
||
</u-popup>
|
||
</u--form>
|
||
</template>
|
||
|
||
<script>
|
||
import CitySelect from "@/components/CitySelect";
|
||
import {getShopData, getWholesaler, removeApply, saveWholesaler} from "@/api/join";
|
||
import {getCity, registerVerify} from "@/api/user";
|
||
import {chooseImage} from "@/utils";
|
||
|
||
export default {
|
||
name: "pkgJoinWholesaler",
|
||
components: {
|
||
CitySelect
|
||
},
|
||
data() {
|
||
return {
|
||
tips: "",
|
||
form: {
|
||
name: "",
|
||
avatar: "",
|
||
contact: "",
|
||
phone: "",
|
||
captcha: "",
|
||
qualification: "",
|
||
area: "",
|
||
address: ""
|
||
},
|
||
rules: {
|
||
'name': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请填写批发商名称',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
'contact': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请填写联系人姓名',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
'phone': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请填写联系方式',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
'captcha': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请填写验证码',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
'qualification': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请上传营业执照',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
'area': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请选择所在省市',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
'address': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请填写详细地址',
|
||
trigger: ['blur', 'change']
|
||
}
|
||
},
|
||
|
||
district: [],
|
||
address: {},
|
||
|
||
isAgree: false,
|
||
show: false,
|
||
notice: "",
|
||
showRemove: false,
|
||
|
||
applyType: null,
|
||
isDraft: null,
|
||
reviewStatus: null,
|
||
stateTitle: "",
|
||
stateType: "primary",
|
||
isPass: false
|
||
}
|
||
},
|
||
onLoad(options) {
|
||
this.init();
|
||
},
|
||
onReady() {
|
||
this.$refs.wholesalerForm.setRules(this.rules);
|
||
},
|
||
methods: {
|
||
changeRemove(state){
|
||
this.showRemove=state
|
||
},
|
||
codeChange(text) {
|
||
this.tips = text;
|
||
},
|
||
getCode() {
|
||
if (this.form.phone.length === 0) return;
|
||
if (this.$refs.uCode.canGetCode) {
|
||
uni.showLoading({
|
||
title: '正在获取验证码'
|
||
})
|
||
registerVerify({phone: this.form.phone, type: "merchantApply"}).then(() => {
|
||
uni.hideLoading();
|
||
// 这里此提示会被this.start()方法中的提示覆盖
|
||
uni.$u.toast('验证码已发送');
|
||
// 通知验证码组件内部开始倒计时
|
||
this.$refs.uCode.start();
|
||
}).catch(err => {
|
||
uni.hideLoading();
|
||
uni.$u.toast(err.msg);
|
||
})
|
||
} else {
|
||
uni.$u.toast('倒计时结束后再发送');
|
||
}
|
||
},
|
||
|
||
init() {
|
||
getCity().then(({data}) => {
|
||
this.district = data;
|
||
});
|
||
|
||
getShopData().then(({data}) => {
|
||
this.notice = data.merchantApplyNotice;
|
||
this.initInfo();
|
||
});
|
||
},
|
||
|
||
initInfo() {
|
||
getWholesaler().then(({data}) => {
|
||
this.applyType = data.applyType;
|
||
if (data.applyType === 4) {
|
||
this.isDraft = data.isDraft;
|
||
this.reviewStatus = data.reviewStatus;
|
||
}
|
||
|
||
switch (data.reviewStatus) {
|
||
case 0:
|
||
this.stateTitle = "审核中";
|
||
this.stateType = "primary";
|
||
break;
|
||
case 1:
|
||
this.isPass = true;
|
||
break;
|
||
case 2:
|
||
this.stateTitle = "审核驳回:" + data.reviewMsg;
|
||
this.stateType = "error";
|
||
break;
|
||
}
|
||
|
||
if (data.wholesalerInfo) {
|
||
this.form = data.wholesalerInfo;
|
||
this.form.position = this.$forceToDecimal(this.form.longitude, 6) + ',' + this.$forceToDecimal(this.form.latitude, 6);
|
||
this.form.area = `${this.form.provinceName} ${this.form.cityName} ${this.form.areaName}`;
|
||
}
|
||
});
|
||
},
|
||
|
||
chooseLogoImg(target) {
|
||
chooseImage(img => {
|
||
switch (target) {
|
||
case "avatar":
|
||
this.form.avatar = img;
|
||
break;
|
||
case "licence":
|
||
this.form.qualification = img;
|
||
break;
|
||
}
|
||
});
|
||
},
|
||
|
||
// 省市区
|
||
result(values) {
|
||
this.address = {
|
||
province: values.province.name || "",
|
||
city: values.city.name || "",
|
||
district: values.district.name || "",
|
||
provinceId: values.province.id,
|
||
cityId: values.city.id,
|
||
areaId: values.district.id
|
||
};
|
||
this.form.area = `${this.address.province} ${this.address.city} ${this.address.district}`;
|
||
this.form.provinceId = values.province.id;
|
||
this.form.cityId = values.city.id;
|
||
this.form.areaId = values.district.id;
|
||
},
|
||
|
||
onSubmit() {
|
||
this.$refs.wholesalerForm.validate().then(res => {
|
||
// 校验通过
|
||
this.show = true;
|
||
}).catch(errors => {
|
||
// 校验失败
|
||
})
|
||
},
|
||
|
||
onRemove() {
|
||
removeApply().then(res => {
|
||
uni.showToast({
|
||
title: res.msg,
|
||
icon: "none",
|
||
duration: 3000,
|
||
success: () => {
|
||
this.showRemove = false;
|
||
setTimeout(() => {
|
||
uni.navigateBack();
|
||
}, 3000)
|
||
}
|
||
})
|
||
});
|
||
},
|
||
|
||
changeAgree(event) {
|
||
this.isAgree = event.detail.value.length > 0
|
||
},
|
||
|
||
save() {
|
||
saveWholesaler(this.form).then(res => {
|
||
if (res.status === 200) {
|
||
uni.showToast({
|
||
title: "您的入驻申请已提交成功,请耐心等待审核",
|
||
icon: "none",
|
||
success: () => {
|
||
this.initInfo();
|
||
this.show = false;
|
||
}
|
||
})
|
||
}
|
||
}).catch(err => {
|
||
uni.showToast({
|
||
title: err.msg,
|
||
icon: "none",
|
||
success: () => {
|
||
this.show = false;
|
||
}
|
||
})
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="less">
|
||
@import "@/assets/css/pkg_join.less";
|
||
|
||
/deep/ .cityselect-nav {
|
||
.item {
|
||
font-size: 30rpx !important;
|
||
}
|
||
}
|
||
|
||
/deep/ .cityselect-item {
|
||
.cityselect-item-box {
|
||
font-size: 30rpx !important;
|
||
}
|
||
}
|
||
|
||
/deep/ .licence-section{
|
||
.u-cell__title{
|
||
width: 650rpx!important;
|
||
}
|
||
}
|
||
.font-color-red{
|
||
font-size: 24rpx;
|
||
}
|
||
</style>
|