250 行
6.2 KiB
Vue
250 行
6.2 KiB
Vue
<!-- 区域公司申请 -->
|
|
<template>
|
|
<view class="apply-page brand-page">
|
|
<view class="page-wrap">
|
|
<shopro-navbar variant="gradient" backText="申请区域公司"></shopro-navbar>
|
|
<view class="page-content">
|
|
<view class="form-card brand-card">
|
|
<view class="form-item">
|
|
<view class="label">公司区域层级</view>
|
|
<picker :range="levelOptions" range-key="label" @change="onLevelChange">
|
|
<view class="picker-val">{{ selectedLevel.label || '请选择公司层级' }}</view>
|
|
</picker>
|
|
</view>
|
|
<view class="form-item" v-if="selectedLevel.value">
|
|
<view class="label">公司区域</view>
|
|
<view class="picker-val" @tap="showAreaSelect = true">{{ areaText || '请选择省市区' }}</view>
|
|
</view>
|
|
|
|
<block v-for="(form, index) in formList" :key="index">
|
|
<view class="form-item" v-if="form.type === 'input' || form.type === 'number'">
|
|
<view class="label">{{ form.name }}</view>
|
|
<input
|
|
class="input"
|
|
v-model="formValues[index]"
|
|
:type="form.type === 'number' ? 'number' : 'text'"
|
|
:placeholder="'请输入' + form.name"
|
|
/>
|
|
</view>
|
|
<view class="form-item" v-if="form.type === 'image'">
|
|
<view class="label">{{ form.name }}</view>
|
|
<u-upload
|
|
:file-list="formImages[index] || []"
|
|
:action="`${$API_URL}/index/upload`"
|
|
maxCount="1"
|
|
width="148"
|
|
height="148"
|
|
@on-uploaded="onImageUploaded($event, index)"
|
|
@on-remove="onImageRemoved(index)"
|
|
></u-upload>
|
|
</view>
|
|
</block>
|
|
|
|
<view class="apply-tip" v-if="huifuRequired">提交申请后,请到「提现」页完成分账进件绑定</view>
|
|
<button class="submit-btn" @tap="submit">提交申请</button>
|
|
</view>
|
|
|
|
<u-select
|
|
mode="mutil-column-auto"
|
|
safe-area-inset-bottom
|
|
:list="areaPickerList"
|
|
v-model="showAreaSelect"
|
|
@confirm="onAreaConfirm"
|
|
></u-select>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
huifuRequired: false,
|
|
levelOptions: [
|
|
{ label: '省级公司', value: 1 },
|
|
{ label: '市级公司', value: 2 },
|
|
{ label: '区县公司', value: 3 }
|
|
],
|
|
selectedLevel: {},
|
|
areaText: '',
|
|
areaId: '',
|
|
showAreaSelect: false,
|
|
addressAreaList: [],
|
|
formList: [],
|
|
formValues: {},
|
|
formImages: {}
|
|
};
|
|
},
|
|
computed: {
|
|
areaPickerList() {
|
|
if (!this.selectedLevel.value || !this.addressAreaList.length) {
|
|
return [];
|
|
}
|
|
if (this.selectedLevel.value === 1) {
|
|
return this.addressAreaList.map(item => ({
|
|
value: item.value,
|
|
label: item.label
|
|
}));
|
|
}
|
|
if (this.selectedLevel.value === 2) {
|
|
return this.addressAreaList.map(item => ({
|
|
value: item.value,
|
|
label: item.label,
|
|
children: (item.children || []).map(city => ({
|
|
value: city.value,
|
|
label: city.label
|
|
}))
|
|
}));
|
|
}
|
|
return this.addressAreaList;
|
|
}
|
|
},
|
|
onLoad() {
|
|
this.loadConfig();
|
|
this.loadArea();
|
|
},
|
|
methods: {
|
|
loadConfig() {
|
|
this.$http('regionalAgent.info').then(res => {
|
|
if (res.code !== 1) return;
|
|
const applyForm = res.data && res.data.apply_form;
|
|
if (applyForm && applyForm.content && applyForm.content.length) {
|
|
this.formList = applyForm.content;
|
|
} else {
|
|
this.formList = [
|
|
{ name: '真实姓名', type: 'input' },
|
|
{ name: '手机号', type: 'number' }
|
|
];
|
|
}
|
|
if (res.data && res.data.huifu_onboard) {
|
|
this.huifuRequired = !!res.data.huifu_onboard.required;
|
|
}
|
|
});
|
|
},
|
|
loadArea() {
|
|
this.$http('address.area').then(res => {
|
|
if (res.code !== 1) return;
|
|
const { provinceData, cityData, areaData } = res.data;
|
|
this.addressAreaList = [];
|
|
provinceData.forEach((item, index) => {
|
|
this.addressAreaList.push({ ...item, children: [] });
|
|
this.addressAreaList[index].children.push(...cityData[index]);
|
|
this.addressAreaList[index].children.forEach((item1, index1) => {
|
|
item1.children = [];
|
|
item1.children.push(...areaData[index][index1]);
|
|
});
|
|
});
|
|
});
|
|
},
|
|
onLevelChange(e) {
|
|
this.selectedLevel = this.levelOptions[e.detail.value];
|
|
this.areaText = '';
|
|
this.areaId = '';
|
|
},
|
|
onAreaConfirm(e) {
|
|
if (!e || !e.length) return;
|
|
const level = this.selectedLevel.value;
|
|
if (level === 1) {
|
|
this.areaText = e[0].label;
|
|
this.areaId = e[0].value;
|
|
} else if (level === 2) {
|
|
this.areaText = `${e[0].label}-${e[1].label}`;
|
|
this.areaId = e[1].value;
|
|
} else {
|
|
this.areaText = `${e[0].label}-${e[1].label}-${e[2].label}`;
|
|
this.areaId = e[2].value;
|
|
}
|
|
},
|
|
onImageUploaded(lists, index) {
|
|
const url = lists && lists.length ? lists[lists.length - 1].response?.data?.url || lists[lists.length - 1].url : '';
|
|
this.$set(this.formValues, index, url);
|
|
this.$set(this.formImages, index, lists);
|
|
},
|
|
onImageRemoved(index) {
|
|
this.$set(this.formValues, index, '');
|
|
this.$set(this.formImages, index, []);
|
|
},
|
|
submit() {
|
|
if (!this.selectedLevel.value || !this.areaId) {
|
|
this.$u.toast('请选择公司区域');
|
|
return;
|
|
}
|
|
const data = this.formList.map((form, index) => ({
|
|
name: form.name,
|
|
type: form.type,
|
|
value: this.formValues[index] || ''
|
|
}));
|
|
const payload = {
|
|
area_id: this.areaId,
|
|
area_level: this.selectedLevel.value,
|
|
data
|
|
};
|
|
this.$http('regionalAgent.apply', payload, '提交中...').then(res => {
|
|
if (res.code === 1) {
|
|
this.$u.toast(res.msg || '申请已提交');
|
|
setTimeout(() => this.$Router.replace({ path: '/pages/app/regional-agent/index' }), 1500);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.apply-page {
|
|
height: 100vh;
|
|
}
|
|
|
|
.page-wrap {
|
|
background: $brand-header-gradient;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.page-content {
|
|
padding: 0 $brand-page-gutter 24rpx;
|
|
}
|
|
|
|
.form-card {
|
|
padding: 32rpx;
|
|
}
|
|
|
|
.form-item {
|
|
margin-bottom: 24rpx;
|
|
|
|
.label {
|
|
font-size: 26rpx;
|
|
color: #666;
|
|
margin-bottom: 12rpx;
|
|
}
|
|
|
|
.input, .picker-val {
|
|
height: 80rpx;
|
|
border: 1rpx solid #e5e5e5;
|
|
border-radius: 12rpx;
|
|
padding: 0 24rpx;
|
|
line-height: 80rpx;
|
|
font-size: 28rpx;
|
|
}
|
|
}
|
|
|
|
.apply-tip {
|
|
margin-top: 24rpx;
|
|
padding: 20rpx 24rpx;
|
|
background: #f0f7ff;
|
|
border-radius: 12rpx;
|
|
font-size: 24rpx;
|
|
line-height: 1.6;
|
|
color: #1677FF;
|
|
}
|
|
|
|
.submit-btn {
|
|
margin-top: 32rpx;
|
|
height: 88rpx;
|
|
line-height: 88rpx;
|
|
background: #1677FF;
|
|
color: #fff;
|
|
border-radius: 44rpx;
|
|
}
|
|
</style>
|