feat(apply): 入驻只收基本信息并新增启动页、材料后补与改服务城市
入驻表单移除身份证与证件材料(服务城市单选下拉,默认北京),只填姓名/手机/性别/城市/简介即可提交;新增 pages/launch 启动页先解析身份再跳转,无身份直接进申请页不再闪现首页;新增 pages/materials 证件材料补传页;个人资料页支持在职陪诊师修改服务城市;appId 更名为 wxapp_companion。
This commit is contained in:
+15
-95
@@ -5,6 +5,7 @@
|
||||
// 审核通过后本页 onShow 会强刷角色,直接切回首页,不需要用户手动重新登录。
|
||||
const API = require('../../utils/api.js')
|
||||
const role = require('../../utils/role.js')
|
||||
const { CITY_OPTIONS, CITY_LABELS, cityIndex, cityLabel } = require('../../utils/city.js')
|
||||
|
||||
const SEX_OPTIONS = [
|
||||
{ value: 'female', label: '女' },
|
||||
@@ -12,10 +13,6 @@ const SEX_OPTIONS = [
|
||||
]
|
||||
const SEX_LABELS = SEX_OPTIONS.map((item) => item.label)
|
||||
const MOBILE_REGEX = /^1[3-9]\d{9}$/
|
||||
const ID_NUMBER_REGEX = /^\d{17}[\dXx]$/
|
||||
// 服务端单张限 5MB,但 wx.request 请求体上限 10MB:
|
||||
// base64 膨胀 4/3,两张 5MB 图 ≈ 13MB 会在发送前就失败,端上按 3MB/张收紧
|
||||
const MAX_IMAGE_BYTES = 3 * 1024 * 1024
|
||||
|
||||
Page({
|
||||
data: {
|
||||
@@ -27,30 +24,18 @@ Page({
|
||||
serviceAreaText: '',
|
||||
submitTimeText: '',
|
||||
accountName: '微信用户',
|
||||
today: '',
|
||||
sexLabels: SEX_LABELS,
|
||||
sexIndex: 0,
|
||||
cityLabels: CITY_LABELS,
|
||||
cityIndex: 0,
|
||||
form: {
|
||||
name: '',
|
||||
mobile: '',
|
||||
idNumber: '',
|
||||
sex: '',
|
||||
serviceAreas: '',
|
||||
introduction: ''
|
||||
},
|
||||
healthExpireDate: '',
|
||||
photos: {
|
||||
qualification: '',
|
||||
healthCertificate: ''
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
const now = new Date()
|
||||
const pad = (n) => String(n).padStart(2, '0')
|
||||
this.setData({ today: `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}` })
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.refresh()
|
||||
},
|
||||
@@ -99,7 +84,7 @@ Page({
|
||||
view: 'pending',
|
||||
application,
|
||||
accountName,
|
||||
serviceAreaText: (application.applicant.serviceAreas || []).join('、'),
|
||||
serviceAreaText: (application.applicant.serviceAreas || []).map(cityLabel).join('、'),
|
||||
submitTimeText: this.formatTime(application.createtime)
|
||||
})
|
||||
return
|
||||
@@ -121,13 +106,11 @@ Page({
|
||||
accountName,
|
||||
rejectReason: application.rejectReason || '',
|
||||
sexIndex: sexIndex > -1 ? sexIndex : 0,
|
||||
healthExpireDate: application.healthExpireDate || '',
|
||||
cityIndex: cityIndex((applicant.serviceAreas || [])[0]),
|
||||
form: {
|
||||
name: applicant.name || '',
|
||||
mobile: applicant.mobile || '',
|
||||
idNumber: applicant.idNumber || '',
|
||||
sex: applicant.sex || '',
|
||||
serviceAreas: (applicant.serviceAreas || []).join(','),
|
||||
introduction: applicant.introduction || ''
|
||||
}
|
||||
})
|
||||
@@ -158,97 +141,32 @@ Page({
|
||||
this.setData({ sexIndex: index, 'form.sex': option ? option.value : '' })
|
||||
},
|
||||
|
||||
onExpireChange(e) {
|
||||
this.setData({ healthExpireDate: e.detail.value })
|
||||
},
|
||||
|
||||
pickImage(e) {
|
||||
const field = e.currentTarget.dataset.field
|
||||
if (!field) return
|
||||
|
||||
wx.chooseMedia({
|
||||
count: 1,
|
||||
mediaType: ['image'],
|
||||
sourceType: ['album', 'camera'],
|
||||
sizeType: ['compressed'],
|
||||
success: (res) => {
|
||||
const file = res.tempFiles && res.tempFiles[0]
|
||||
if (!file) return
|
||||
if (file.size && file.size > 10 * 1024 * 1024) {
|
||||
wx.showToast({ title: '请选择 10MB 以内的图片', icon: 'none' })
|
||||
return
|
||||
}
|
||||
// 先压再读:原图直传很容易把请求体顶到小程序 10MB 上限
|
||||
wx.compressImage({
|
||||
src: file.tempFilePath,
|
||||
quality: 60,
|
||||
success: (compressed) => this.readAsDataUrl(compressed.tempFilePath, field),
|
||||
fail: () => this.readAsDataUrl(file.tempFilePath, field)
|
||||
})
|
||||
},
|
||||
fail: () => {}
|
||||
})
|
||||
},
|
||||
|
||||
readAsDataUrl(path, field) {
|
||||
wx.getFileSystemManager().readFile({
|
||||
filePath: path,
|
||||
encoding: 'base64',
|
||||
success: (res) => {
|
||||
const bytes = Math.floor((res.data.length * 3) / 4)
|
||||
if (bytes > MAX_IMAGE_BYTES) {
|
||||
wx.showToast({ title: '图片过大,请重新拍摄或裁剪到 3MB 以内', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const mime = /\.png$/i.test(path) ? 'png' : 'jpeg'
|
||||
this.setData({ [`photos.${field}`]: `data:image/${mime};base64,${res.data}` })
|
||||
},
|
||||
fail: () => {
|
||||
wx.showToast({ title: '读取图片失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
onCityChange(e) {
|
||||
this.setData({ cityIndex: Number(e.detail.value) || 0 })
|
||||
},
|
||||
|
||||
submit() {
|
||||
if (this.data.submitting) return
|
||||
|
||||
const { form, photos, healthExpireDate, application } = this.data
|
||||
const { form, cityIndex: cityIdx } = this.data
|
||||
const name = form.name.trim()
|
||||
const mobile = form.mobile.trim()
|
||||
const idNumber = form.idNumber.trim().toUpperCase()
|
||||
const areas = form.serviceAreas
|
||||
.split(/[,,、\s]+/)
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean)
|
||||
const serviceArea = CITY_OPTIONS[cityIdx] || CITY_OPTIONS[0]
|
||||
|
||||
if (!name) return this.toast('请填写姓名')
|
||||
if (!MOBILE_REGEX.test(mobile)) return this.toast('请填写正确的手机号')
|
||||
if (!ID_NUMBER_REGEX.test(idNumber)) return this.toast('请填写 18 位身份证号')
|
||||
if (!areas.length) return this.toast('请填写服务城市')
|
||||
if (!healthExpireDate) return this.toast('请选择健康证明有效期')
|
||||
|
||||
// 驳回后重新提交时允许沿用上次上传的证件照
|
||||
const isResubmit = !!application && application.status === 'rejected'
|
||||
if (!photos.qualification && !isResubmit) return this.toast('请上传资质证书照片')
|
||||
if (!photos.healthCertificate && !isResubmit) return this.toast('请上传健康证明照片')
|
||||
|
||||
// 先只收基本信息:身份证与证件材料不在此填写,材料可审核通过后补传
|
||||
const payload = {
|
||||
applicant: {
|
||||
name,
|
||||
mobile,
|
||||
idNumber,
|
||||
sex: form.sex,
|
||||
serviceAreas: areas,
|
||||
serviceAreas: [serviceArea.value],
|
||||
introduction: form.introduction.trim()
|
||||
},
|
||||
healthExpireDate
|
||||
}
|
||||
}
|
||||
|
||||
const materials = {}
|
||||
if (photos.qualification) materials.qualification = photos.qualification
|
||||
if (photos.healthCertificate) materials.healthCertificate = photos.healthCertificate
|
||||
if (Object.keys(materials).length) payload.materials = materials
|
||||
|
||||
this.setData({ submitting: true })
|
||||
API.attendantApplication
|
||||
.create(payload)
|
||||
@@ -261,7 +179,9 @@ Page({
|
||||
view: 'pending',
|
||||
application: next,
|
||||
rejectReason: '',
|
||||
serviceAreaText: next ? (next.applicant.serviceAreas || []).join('、') : areas.join('、'),
|
||||
serviceAreaText: next
|
||||
? (next.applicant.serviceAreas || []).map(cityLabel).join('、')
|
||||
: cityLabel(serviceArea.value),
|
||||
submitTimeText: next ? this.formatTime(next.createtime) : ''
|
||||
})
|
||||
return
|
||||
|
||||
+17
-76
@@ -25,6 +25,10 @@
|
||||
<text class="row-label">服务城市</text>
|
||||
<text class="row-value">{{serviceAreaText}}</text>
|
||||
</view>
|
||||
<view class="row">
|
||||
<text class="row-label">证件材料</text>
|
||||
<text class="row-value">{{application.hasQualification && application.hasHealthCertificate ? '已上传' : '待补充'}}</text>
|
||||
</view>
|
||||
<view class="row">
|
||||
<text class="row-label">提交时间</text>
|
||||
<text class="row-value">{{submitTimeText}}</text>
|
||||
@@ -55,7 +59,7 @@
|
||||
<view class="reject-box" wx:if="{{rejectReason}}">
|
||||
<text class="reject-title">上次申请未通过</text>
|
||||
<text class="reject-text">原因:{{rejectReason}}</text>
|
||||
<text class="reject-hint">修改后可重新提交,已上传的证件照无需重复上传。</text>
|
||||
<text class="reject-hint">修改后可重新提交。</text>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
@@ -86,18 +90,6 @@
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">身份证号</text>
|
||||
<input
|
||||
class="field-input"
|
||||
value="{{form.idNumber}}"
|
||||
data-key="idNumber"
|
||||
maxlength="18"
|
||||
placeholder="18 位身份证号"
|
||||
bindinput="onInput"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">性别</text>
|
||||
<picker
|
||||
@@ -116,13 +108,18 @@
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">服务城市</text>
|
||||
<input
|
||||
class="field-input"
|
||||
value="{{form.serviceAreas}}"
|
||||
data-key="serviceAreas"
|
||||
placeholder="多个城市用逗号分隔"
|
||||
bindinput="onInput"
|
||||
/>
|
||||
<picker
|
||||
class="field-picker"
|
||||
mode="selector"
|
||||
range="{{cityLabels}}"
|
||||
value="{{cityIndex}}"
|
||||
bindchange="onCityChange"
|
||||
>
|
||||
<view class="field-value">
|
||||
{{cityLabels[cityIndex]}}
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<view class="field field-block">
|
||||
@@ -138,62 +135,6 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<text class="card-title">证件材料</text>
|
||||
|
||||
<view class="upload-row">
|
||||
<view class="upload-tile" data-field="qualification" bindtap="pickImage">
|
||||
<image
|
||||
wx:if="{{photos.qualification}}"
|
||||
class="upload-img"
|
||||
src="{{photos.qualification}}"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<view wx:else class="upload-empty">
|
||||
<text class="upload-plus">+</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="upload-meta">
|
||||
<text class="upload-name">资质证书照片</text>
|
||||
<text class="upload-tip">{{photos.qualification ? '已选择,点击可重新上传' : 'JPG / PNG,单张不超过 3MB'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="upload-row">
|
||||
<view class="upload-tile" data-field="healthCertificate" bindtap="pickImage">
|
||||
<image
|
||||
wx:if="{{photos.healthCertificate}}"
|
||||
class="upload-img"
|
||||
src="{{photos.healthCertificate}}"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<view wx:else class="upload-empty">
|
||||
<text class="upload-plus">+</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="upload-meta">
|
||||
<text class="upload-name">健康证明照片</text>
|
||||
<text class="upload-tip">{{photos.healthCertificate ? '已选择,点击可重新上传' : 'JPG / PNG,单张不超过 3MB'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">健康证有效期</text>
|
||||
<picker
|
||||
class="field-picker"
|
||||
mode="date"
|
||||
value="{{healthExpireDate}}"
|
||||
start="{{today}}"
|
||||
bindchange="onExpireChange"
|
||||
>
|
||||
<view class="field-value {{healthExpireDate ? '' : 'placeholder'}}">
|
||||
{{healthExpireDate || '请选择到期日期'}}
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="submit-btn" loading="{{submitting}}" disabled="{{submitting}}" bindtap="submit">
|
||||
提交申请
|
||||
</button>
|
||||
|
||||
@@ -69,6 +69,13 @@
|
||||
color: #2A211B;
|
||||
}
|
||||
|
||||
.card-tip {
|
||||
display: block;
|
||||
padding-bottom: 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: #9C9188;
|
||||
}
|
||||
|
||||
/* 表单行 */
|
||||
.field {
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user