Files
xdd-uniapp-new/pkg_join/views/wholesaler.vue
T

527 lines
14 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<u--form
ref="wholesalerForm"
:model="form"
errorType="toast"
labelWidth="216rpx"
>
<view
v-if="stateTitle && isDraft!==1 && applyType === 4"
class="box-state"
>
<u-alert
:center="stateType === 'primary'"
:title="stateTitle"
:type="stateType"
/>
</view>
<u-cell-group
:border="false"
:customStyle="{'fontSize':'40rpx'}"
title="采购批发商基本信息"
>
<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"
:disabled="reviewing"
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
v-if="!form.avatar"
class="btn-upload"
>上传图片</view>
<image
v-else
:src="form.avatar"
class="img-preview"
/>
</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"
:disabled="reviewing"
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"
:disabled="reviewing"
maxlength="11"
type="number"
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>
<view class="captcha-wrap">
<view class="captcha-wrap-input">
<u-input
v-model="form.captcha"
:disabled="reviewing"
border="none"
placeholder="请填写验证码"
/>
</view>
<view class="captcha-wrap-ft">
<u-code
ref="uCode"
seconds="30"
changeText="X秒重新获取"
@change="codeChange"
/>
<u-button
:text="tips"
type="success"
size="normal"
@tap="getCode"
/>
</view>
</view>
</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
v-if="!form.qualification"
class="btn-upload"
>上传图片</view>
<view v-else>
<view v-if="qualificationArr.length > 0" class="flex">
<image
v-for="(item, index) in qualificationArr"
:key="index"
:src="item"
class="img-preview"
/>
</view>
</view>
</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"
:disabled="reviewing"
:items="district"
@callback="result"
/>
</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"
:disabled="reviewing"
border="none"
placeholder="请填写详细地址"
/>
</template>
</u-cell>
</u-form-item>
</u-cell-group>
<view
v-if="reviewStatus === 0 && isDraft !== 1"
class="btn-submit btn-remove"
@click="changeRemove(true)"
>
撤销申请
</view>
<view
v-else
class="btn-submit"
@click="onSubmit"
>
提交申请
</view>
<u-modal
:show="showRemove"
content="您确定撤销申请吗?"
showCancelButton
@cancel="changeRemove(false)"
@confirm="onRemove"
/>
<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"
/>
</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'
import { pageListenMixins } from '@/mixins/pageListenMixins'
export default {
name: 'pkgJoinWholesaler',
components: {
CitySelect
},
mixins: [pageListenMixins],
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: {},
qualificationArr: [],
isAgree: false,
show: false,
notice: '',
showRemove: false,
applyType: null,
isDraft: null,
reviewStatus: null,
stateTitle: '',
stateType: 'primary',
// 是否为审核中
reviewing: false,
pageKeyId: Object.freeze('merchantApplyWholesaler')
}
},
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.reviewing) return
if (!this.form.phone) {
uni.$u.toast('请输入手机号')
return
}
if (this.form.phone.length !== 11) {
uni.$u.toast('请输入11位手机号')
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
}
if(data.isDraft === null || data.isDraft === 1) {
this.show = true
}
if (data.isDraft !== 1) {
switch (data.reviewStatus) {
case 0:
this.stateTitle = '审核中'
this.stateType = 'primary'
this.reviewing = true
break;
case 1:
this.reviewing = false
break;
case 2:
this.stateTitle = '审核驳回:' + data.reviewMsg
this.stateType = 'error'
this.reviewing = false
break;
}
}
if (data.wholesalerInfo) {
this.form = data.wholesalerInfo
if (this.form.qualification) {
this.qualificationArr = this.form.qualification.split(',')
}
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) {
if (this.reviewing) return
chooseImage(img => {
switch (target) {
case 'avatar':
this.form.avatar = img
break
case 'licence':
this.form.qualification = img
this.qualificationArr = [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 => {
// 校验通过
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
}
})
})
}).catch(errors => {
// 校验失败
console.log(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() {
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;
}
.captcha-wrap {
display: flex;
align-items: center;
.captcha-wrap-input {
flex: 1;
}
}
</style>