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

637 lines
17 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"
>
<u-alert
:center="stateType === 'primary'"
:title="stateTitle"
:type="stateType"
/>
</view>
<u-cell-group
:border="false"
:customStyle="{'fontSize':'40rpx', 'backgroundColor':'#fff'}"
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="businessLicense">
<u-cell title="营业执照名称" :border="false">
<template #icon>
<text class="required">*</text>
</template>
<template #value>
<u-input
v-model="form.businessLicense"
: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>
<view v-else class="img-wrap">
<image
:src="form.avatar"
class="img-preview"
/>
<view
v-if="!reviewing"
class="delete-badge"
@click.stop="deleteImg('avatar')"
>
x
</view>
</view>
</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" v-if="!reviewing">
<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="full-title">
<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>
<u-upload
:maxCount="9"
:fileList="quaPics"
:disabled="reviewing"
:deletable="!reviewing"
name="quaPics"
multiple
@afterRead="quaAfterRead"
@delete="quaDeletePic"
/>
</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-if="reviewStatus !== 1"
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" @close="handlePopupClose">
<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="确定"
@click="save"
/>
</view>
</u-popup>
</u--form>
</template>
<script>
import CitySelect from '@/components/CitySelect'
import {getShopData, getWholesaler, removeApply, saveWholesaler, saveWholesalerDraft} from '@/api/join'
import {getCity, registerVerify} from '@/api/user'
import {chooseImage, uploadImage, formatRichText} from '@/utils'
import { pageListenMixins } from '@/mixins/pageListenMixins'
export default {
name: 'pkgJoinWholesaler',
components: {
CitySelect
},
mixins: [pageListenMixins],
data() {
return {
tips: '获取验证码',
form: {
name: '',
businessLicense: '',
avatar: '',
contact: '',
phone: '',
captcha: '',
qualification: '',
area: '',
address: ''
},
rules: {
'name': {
type: 'string',
required: true,
message: '请填写批发商名称',
trigger: ['blur', 'change']
},
'businessLicense': {
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: {},
quaPics: [],
isAgree: false,
show: false,
notice: '',
showRemove: false,
applyType: null,
isDraft: null,
reviewStatus: null,
stateTitle: '',
stateType: 'primary',
// 是否为审核中
reviewing: false,
pageKeyId: Object.freeze('merchantApplyWholesaler'),
partnerId: '',
promoterUid: ''
}
},
onLoad(options) {
this.partnerId = options.partnerId || ''
this.promoterUid = options.promoterUid || ''
this.init()
},
onUnload() {
this.saveDraft()
},
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() {
uni.showLoading({ title: '加载中...', mask: true })
getCity().then(({data}) => {
this.district = data
})
getShopData({partnerId: this.partnerId, promoterUid: this.promoterUid}).then(({data}) => {
this.notice = formatRichText(data.merchantApplyNotice)
this.initInfo()
}).catch(() => {
uni.hideLoading()
})
},
initInfo() {
getWholesaler().then(({data}) => {
this.applyType = data.applyType
this.isDraft = data.isDraft
this.reviewStatus = data.reviewStatus
if(data.isDraft === null || data.isDraft === 1) {
this.show = true
}
console.log(data.reviewStatus);
switch (data.reviewStatus) {
case 0:
this.stateTitle = '审核中'
this.stateType = 'primary'
this.reviewing = true
break;
case 1:
this.stateTitle = '审核通过'
this.stateType = 'success'
this.reviewing = false
break;
case 2:
this.stateTitle = '审核驳回:' + data.reviewMsg
this.stateType = 'error'
this.reviewing = false
break;
}
if (data.wholesalerInfo) {
this.form = data.wholesalerInfo
this.quaPics = []
if (this.form.qualification) {
this.form.qualification.split(',').map(item => {
if (item) {
this.quaPics.push({url: item})
}
})
}
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].filter(Boolean).join(' ')
}
}).finally(() => {
uni.hideLoading()
})
},
chooseLogoImg(target) {
if (this.reviewing) return
chooseImage(img => {
if (target === 'avatar') {
this.form.avatar = img
}
})
},
// 删除头像
deleteImg(target) {
if (target === 'avatar') {
this.form.avatar = ''
}
},
// 删除商家资质图片
quaDeletePic(event) {
this[`${event.name}`].splice(event.index, 1)
},
// 商家资质批量上传
quaAfterRead(event) {
const that = this
if (event.file.length > 0) {
event.file.map(item => {
uploadImage(item.url, img => {
that.quaPics.push({url: img})
})
})
}
},
// 省市区
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.buildQualification()
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
this.reviewing = false
}
})
this.initInfo()
})
},
changeAgree(event) {
this.isAgree = event.detail.value.length > 0
},
save() {
if (!this.isAgree) {
uni.showToast({
title: '请先阅读并同意入驻申请须知',
icon: 'none'
})
return
}
this.show = false
},
handlePopupClose() {
if (!this.isAgree) {
uni.showToast({
title: '请先阅读并同意入驻申请须知',
icon: 'none'
})
return
}
this.show = false
},
saveDraft() {
if (this.reviewing) return
this.buildQualification()
saveWholesalerDraft(this.form)
},
buildQualification() {
this.form.qualification = ''
const tempArr = []
this.quaPics.map(item => {
item.url && tempArr.push(item.url)
})
this.form.qualification = tempArr.join(',')
}
}
}
</script>
<style lang="less">
@import "@/assets/css/pkg_join.less";
/deep/ .u-cell__title-text {
white-space: nowrap !important;
}
/deep/ .full-title {
.u-cell__title {
width: 100% !important;
white-space: nowrap !important;
}
}
</style>
<style lang="less" scoped>
/deep/ .cityselect-nav {
.item {
font-size: 30rpx !important;
}
}
/deep/ .cityselect-item {
.cityselect-item-box {
font-size: 30rpx !important;
}
}
.font-color-red{
font-size: 24rpx;
}
.img-wrap {
position: relative;
display: inline-block;
.delete-badge {
position: absolute;
top: 0;
right: 20rpx;
background: #000;
color: #fff;
padding: 2rpx 8rpx;
border-radius: 0 0 0 200rpx;
font-size: 22rpx;
z-index: 10;
text-align: center;
}
}
.captcha-wrap {
display: flex;
align-items: center;
.captcha-wrap-input {
flex: 1;
}
}
.btn-submit{
position: sticky !important;
}
</style>