| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 |
- <template>
- <view class="container">
- <view class="header">
- <text class="title">成为成长规划师</text>
- <text class="subtitle">分享专业知识,帮助更多家庭</text>
- </view>
- <view class="form">
- <!-- 邀请码输入 -->
- <view class="form-item">
- <text class="label">邀请码(可选)</text>
- <input
- class="input"
- v-model="formData.inviteCode"
- placeholder="输入邀请码可关联上级成长规划师"
- @blur="validateInviteCode"
- />
- <text class="hint" v-if="inviteCodeInfo">关联成长规划师:{{ inviteCodeInfo.guideName }}</text>
- </view>
- <!-- 真实姓名 -->
- <view class="form-item">
- <text class="label">真实姓名</text>
- <input
- class="input"
- v-model="formData.realName"
- placeholder="请输入真实姓名"
- />
- </view>
- <!-- 手机号 -->
- <view class="form-item">
- <text class="label">手机号</text>
- <input
- class="input"
- v-model="formData.phone"
- type="number"
- placeholder="请输入手机号"
- maxlength="11"
- />
- </view>
- <!-- 身份证号 -->
- <view class="form-item">
- <text class="label">身份证号</text>
- <input
- class="input"
- v-model="formData.idCard"
- placeholder="请输入身份证号"
- maxlength="18"
- />
- </view>
- <!-- 地址 -->
- <view class="form-item">
- <text class="label">联系地址</text>
- <input
- class="input"
- v-model="formData.address"
- placeholder="请输入联系地址"
- />
- </view>
- <!-- 银行卡号(选填) -->
- <view class="form-item">
- <text class="label">银行卡号 <text class="optional">(选填,用于佣金结算)</text></text>
- <input
- class="input"
- v-model="formData.bankCard"
- placeholder="请输入银行卡号"
- maxlength="30"
- />
- </view>
- <!-- 开户行(选填) -->
- <view class="form-item">
- <text class="label">开户行 <text class="optional">(选填)</text></text>
- <input
- class="input"
- v-model="formData.bankName"
- placeholder="请输入开户行名称,如:中国工商银行广州天河支行"
- />
- </view>
- <!-- 成长规划师认证信息(选填) -->
- <view class="section-divider">
- <text class="divider-text">成长规划师认证信息(选填)</text>
- </view>
- <!-- 成长规划师证书号 -->
- <view class="form-item">
- <text class="label">成长规划师证书号 <text class="optional">(选填)</text></text>
- <input
- class="input"
- v-model="formData.teacherNo"
- placeholder="如有成长规划师证书,请填写证书号"
- />
- </view>
- <!-- 成长规划师照片 -->
- <view class="form-item">
- <text class="label">成长规划师照片 <text class="optional">(选填)</text></text>
- <view class="upload-section">
- <image
- v-if="formData.teacherPhoto"
- :src="formData.teacherPhoto"
- class="preview-image"
- @click="chooseImage('teacherPhoto')"
- />
- <view v-else class="upload-placeholder" @click="chooseImage('teacherPhoto')">
- <text class="upload-icon">📷</text>
- <text class="upload-text">上传照片</text>
- </view>
- </view>
- </view>
- <!-- 证书照片 -->
- <view class="form-item">
- <text class="label">证书照片 <text class="optional">(选填)</text></text>
- <view class="upload-section">
- <image
- v-if="formData.certificateImage"
- :src="formData.certificateImage"
- class="preview-image"
- @click="chooseImage('certificateImage')"
- />
- <view v-else class="upload-placeholder" @click="chooseImage('certificateImage')">
- <text class="upload-icon">📷</text>
- <text class="upload-text">上传证书</text>
- </view>
- </view>
- </view>
- <!-- 提交按钮 -->
- <button class="btn-submit" :loading="submitting" :disabled="submitting" @click="submit">提交申请</button>
- </view>
- </view>
- </template>
- <script>
- import { registerGuide, validateInviteCode } from '../../../utils/api.js'
- export default {
- onLoad() {
- uni.redirectTo({ url: '/pages/profile/service-role-apply' })
- },
- data() {
- return {
- formData: {
- inviteCode: '',
- realName: '',
- phone: '',
- idCard: '',
- address: '',
- bankCard: '',
- bankName: '',
- teacherNo: '',
- teacherPhoto: '',
- certificateImage: ''
- },
- inviteCodeInfo: null,
- submitting: false
- }
- },
- onLoad(options) {
- // 如果有邀请码参数,自动填充
- if (options.inviteCode) {
- this.formData.inviteCode = options.inviteCode
- this.validateInviteCode()
- }
- },
- methods: {
- async validateInviteCode() {
- if (!this.formData.inviteCode) {
- this.inviteCodeInfo = null
- return
- }
- try {
- const res = await validateInviteCode(this.formData.inviteCode)
- if (res.code === 200) {
- this.inviteCodeInfo = res.data
- uni.showToast({
- title: '邀请码有效',
- icon: 'success'
- })
- } else {
- this.inviteCodeInfo = null
- uni.showToast({
- title: '邀请码无效',
- icon: 'none'
- })
- }
- } catch (e) {
- this.inviteCodeInfo = null
- uni.showToast({
- title: '验证失败',
- icon: 'none'
- })
- }
- },
- chooseImage(field) {
- uni.chooseImage({
- count: 1,
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success: (res) => {
- const tempFilePath = res.tempFilePaths[0]
- this.uploadImage(field, tempFilePath)
- }
- })
- },
- uploadImage(field, filePath) {
- uni.showLoading({ title: '上传中...' })
-
- // TODO: 实际应该上传到服务器
- // 这里简化处理,直接使用本地路径
- setTimeout(() => {
- this.formData[field] = filePath
- uni.hideLoading()
- uni.showToast({
- title: '上传成功',
- icon: 'success'
- })
- }, 1000)
- },
- async submit() {
- if (this.submitting) return
- // 验证表单
- if (!this.formData.realName) {
- uni.showToast({ title: '请输入真实姓名', icon: 'none' })
- return
- }
- if (!this.formData.phone) {
- uni.showToast({ title: '请输入手机号', icon: 'none' })
- return
- }
- if (!this.formData.idCard) {
- uni.showToast({ title: '请输入身份证号', icon: 'none' })
- return
- }
- this.submitting = true
- uni.showLoading({ title: '提交中...' })
- try {
- const userId = uni.getStorageSync('userId')
- const res = await registerGuide({
- userId: userId,
- ...this.formData
- })
- if (res.code === 200) {
- uni.showModal({
- title: '申请成功',
- content: '您的成长规划师申请已提交,请等待审核',
- showCancel: false,
- success: () => {
- uni.navigateBack()
- }
- })
- } else {
- uni.showToast({
- title: res.message || '提交失败',
- icon: 'none'
- })
- }
- } catch (e) {
- uni.showToast({
- title: '提交失败',
- icon: 'none'
- })
- } finally {
- this.submitting = false
- uni.hideLoading()
- }
- }
- }
- }
- </script>
- <style scoped>
- .container {
- padding: 30rpx;
- background: #F8F8F8;
- min-height: 100vh;
- }
- .header {
- text-align: center;
- padding: 60rpx 0 40rpx;
- }
- .title {
- font-size: 48rpx;
- font-weight: bold;
- color: #333;
- display: block;
- margin-bottom: 20rpx;
- }
- .subtitle {
- font-size: 28rpx;
- color: #666;
- }
- .form {
- background: #fff;
- border-radius: 20rpx;
- padding: 40rpx;
- }
- .form-item {
- margin-bottom: 40rpx;
- }
- .label {
- font-size: 28rpx;
- color: #333;
- display: block;
- margin-bottom: 20rpx;
- font-weight: bold;
- }
- .input {
- width: 100%;
- height: 80rpx;
- border: 1rpx solid #E0E0E0;
- border-radius: 10rpx;
- padding: 0 20rpx;
- font-size: 28rpx;
- }
- .hint {
- font-size: 24rpx;
- color: #F97316;
- margin-top: 10rpx;
- display: block;
- }
- .optional {
- font-size: 24rpx;
- color: #999;
- font-weight: normal;
- }
- .section-divider {
- margin: 20rpx 0 30rpx;
- padding: 20rpx 0;
- border-top: 1rpx solid #f0f0f0;
- }
- .divider-text {
- font-size: 26rpx;
- color: #999;
- }
- .upload-section {
- display: flex;
- align-items: center;
- }
- .preview-image {
- width: 200rpx;
- height: 200rpx;
- border-radius: 10rpx;
- object-fit: cover;
- }
- .upload-placeholder {
- width: 200rpx;
- height: 200rpx;
- border: 2rpx dashed #E0E0E0;
- border-radius: 10rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- background: #F8F8F8;
- }
- .upload-icon {
- font-size: 60rpx;
- margin-bottom: 10rpx;
- }
- .upload-text {
- font-size: 24rpx;
- color: #999;
- }
- .btn-submit {
- width: 100%;
- height: 90rpx;
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- color: #fff;
- border-radius: 45rpx;
- font-size: 32rpx;
- font-weight: bold;
- margin-top: 40rpx;
- }
- </style>
|