index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <view class="container">
  3. <view class="header">
  4. <text class="title">�𣂷蛹�鞾鵭閫��撣?/text>
  5. <text class="subtitle">��澈銝㮖��亥�嚗�葬�拇凒憭𡁜振摨?/text>
  6. </view>
  7. <view class="form">
  8. <!-- ��霂瑞�颲枏� -->
  9. <view class="form-item">
  10. <text class="label">��霂瑞�嚗�虾�㚁�</text>
  11. <input
  12. class="input"
  13. v-model="formData.inviteCode"
  14. placeholder="颲枏���霂瑞��臬��𥪯�蝥扳��輯��鍦�"
  15. @blur="validateInviteCode"
  16. />
  17. <text class="hint" v-if="inviteCodeInfo">�唾��鞾鵭閫��撣��{{ inviteCodeInfo.guideName }}</text>
  18. </view>
  19. <!-- �笔�憪枏� -->
  20. <view class="form-item">
  21. <text class="label">�笔�憪枏�</text>
  22. <input
  23. class="input"
  24. v-model="formData.realName"
  25. placeholder="霂瑁��亦�摰𧼮��?
  26. />
  27. </view>
  28. <!-- �𧢲㦤�?-->
  29. <view class="form-item">
  30. <text class="label">�𧢲㦤�?/text>
  31. <input
  32. class="input"
  33. v-model="formData.phone"
  34. type="number"
  35. placeholder="霂瑁��交��箏噡"
  36. maxlength="11"
  37. />
  38. </view>
  39. <!-- 頨思遢霂�噡 -->
  40. <view class="form-item">
  41. <text class="label">頨思遢霂�噡</text>
  42. <input
  43. class="input"
  44. v-model="formData.idCard"
  45. placeholder="霂瑁��亥澈隞質��?
  46. maxlength="18"
  47. />
  48. </view>
  49. <!-- �啣� -->
  50. <view class="form-item">
  51. <text class="label">�𠉛頂�啣�</text>
  52. <input
  53. class="input"
  54. v-model="formData.address"
  55. placeholder="霂瑁��亥�蝟餃𧑐��"
  56. />
  57. </view>
  58. <!-- �嗉��∪噡嚗��匧‵嚗?-->
  59. <view class="form-item">
  60. <text class="label">�嗉��∪噡 <text class="optional">嚗��匧‵嚗𣬚鍂鈭𦒘膛�𤑳�蝞梹�</text></text>
  61. <input
  62. class="input"
  63. v-model="formData.bankCard"
  64. placeholder="霂瑁��仿𣂎銵�㨃�?
  65. maxlength="30"
  66. />
  67. </view>
  68. <!-- 撘��瑁�嚗��匧‵嚗?-->
  69. <view class="form-item">
  70. <text class="label">撘��瑁� <text class="optional">嚗��匧‵嚗?/text></text>
  71. <input
  72. class="input"
  73. v-model="formData.bankName"
  74. placeholder="霂瑁��亙��瑁��滨妍嚗��嚗帋葉�賢極��𣂎銵�嘀撌𧼮予瘝單𣈲銵?
  75. />
  76. </view>
  77. <!-- �鞾鵭閫��撣�恕霂�縑�荔��匧‵嚗?-->
  78. <view class="section-divider">
  79. <text class="divider-text">�鞾鵭閫��撣�恕霂�縑�荔��匧‵嚗?/text>
  80. </view>
  81. <!-- �鞾鵭閫��撣��銋血噡 -->
  82. <view class="form-item">
  83. <text class="label">�鞾鵭閫��撣��銋血噡 <text class="optional">嚗��匧‵嚗?/text></text>
  84. <input
  85. class="input"
  86. v-model="formData.teacherNo"
  87. placeholder="憒���鞾鵭閫��撣��銋佗�霂瑕‵�躰�銋血噡"
  88. />
  89. </view>
  90. <!-- �鞾鵭閫��撣���?-->
  91. <view class="form-item">
  92. <text class="label">�鞾鵭閫��撣���?<text class="optional">嚗��匧‵嚗?/text></text>
  93. <view class="upload-section">
  94. <image
  95. v-if="formData.teacherPhoto"
  96. :src="formData.teacherPhoto"
  97. class="preview-image"
  98. @click="chooseImage('teacherPhoto')"
  99. />
  100. <view v-else class="upload-placeholder" @click="chooseImage('teacherPhoto')">
  101. <text class="upload-icon">�𣊭</text>
  102. <text class="upload-text">銝𠹺��抒�</text>
  103. </view>
  104. </view>
  105. </view>
  106. <!-- 霂�髡�抒� -->
  107. <view class="form-item">
  108. <text class="label">霂�髡�抒� <text class="optional">嚗��匧‵嚗?/text></text>
  109. <view class="upload-section">
  110. <image
  111. v-if="formData.certificateImage"
  112. :src="formData.certificateImage"
  113. class="preview-image"
  114. @click="chooseImage('certificateImage')"
  115. />
  116. <view v-else class="upload-placeholder" @click="chooseImage('certificateImage')">
  117. <text class="upload-icon">�𣊭</text>
  118. <text class="upload-text">銝𠹺�霂�髡</text>
  119. </view>
  120. </view>
  121. </view>
  122. <!-- �𣂷漱�厰僼 -->
  123. <button class="btn-submit" @click="submit">�𣂷漱�唾窈</button>
  124. </view>
  125. </view>
  126. </template>
  127. <script>
  128. import { registerGuide, validateInviteCode } from '../../../utils/api.js'
  129. export default {
  130. data() {
  131. return {
  132. formData: {
  133. inviteCode: '',
  134. realName: '',
  135. phone: '',
  136. idCard: '',
  137. address: '',
  138. bankCard: '',
  139. bankName: '',
  140. teacherNo: '',
  141. teacherPhoto: '',
  142. certificateImage: ''
  143. },
  144. inviteCodeInfo: null
  145. }
  146. },
  147. onLoad(options) {
  148. // 憒���厰�霂瑞���㺭嚗諹䌊�典‵�?
  149. if (options.inviteCode) {
  150. this.formData.inviteCode = options.inviteCode
  151. this.validateInviteCode()
  152. }
  153. },
  154. methods: {
  155. async validateInviteCode() {
  156. if (!this.formData.inviteCode) {
  157. this.inviteCodeInfo = null
  158. return
  159. }
  160. try {
  161. const res = await validateInviteCode(this.formData.inviteCode)
  162. if (res.code === 200) {
  163. this.inviteCodeInfo = res.data
  164. uni.showToast({
  165. title: '��霂瑞��㗇�',
  166. icon: 'success'
  167. })
  168. } else {
  169. this.inviteCodeInfo = null
  170. uni.showToast({
  171. title: '��霂瑞��䭾�',
  172. icon: 'none'
  173. })
  174. }
  175. } catch (e) {
  176. this.inviteCodeInfo = null
  177. uni.showToast({
  178. title: '撉諹�憭梯揖',
  179. icon: 'none'
  180. })
  181. }
  182. },
  183. chooseImage(field) {
  184. uni.chooseImage({
  185. count: 1,
  186. sizeType: ['compressed'],
  187. sourceType: ['album', 'camera'],
  188. success: (res) => {
  189. const tempFilePath = res.tempFilePaths[0]
  190. this.uploadImage(field, tempFilePath)
  191. }
  192. })
  193. },
  194. uploadImage(field, filePath) {
  195. uni.showLoading({ title: '銝𠹺�銝?..' })
  196. // TODO: 摰鮋�摨磰砲銝𠹺��唳��∪膥
  197. // 餈䠷�蝞��硋�����湔𦻖雿輻鍂�砍𧑐頝臬�
  198. setTimeout(() => {
  199. this.formData[field] = filePath
  200. uni.hideLoading()
  201. uni.showToast({
  202. title: '銝𠹺��𣂼�',
  203. icon: 'success'
  204. })
  205. }, 1000)
  206. },
  207. async submit() {
  208. // 撉諹�銵典�
  209. if (!this.formData.realName) {
  210. uni.showToast({ title: '霂瑁��亦�摰𧼮��?, icon: 'none' })
  211. return
  212. }
  213. if (!this.formData.phone) {
  214. uni.showToast({ title: '霂瑁��交��箏噡', icon: 'none' })
  215. return
  216. }
  217. if (!this.formData.idCard) {
  218. uni.showToast({ title: '霂瑁��亥澈隞質��?, icon: 'none' })
  219. return
  220. }
  221. try {
  222. uni.showLoading({ title: '�𣂷漱銝?..' })
  223. const userId = uni.getStorageSync('userId')
  224. const res = await registerGuide({
  225. userId: userId,
  226. ...this.formData
  227. })
  228. uni.hideLoading()
  229. if (res.code === 200) {
  230. uni.showModal({
  231. title: '�唾窈�𣂼�',
  232. content: '�函��鞾鵭閫��撣�𤚗霂瑕歇�𣂷漱嚗諹窈蝑匧�摰⊥瓲',
  233. showCancel: false,
  234. success: () => {
  235. uni.navigateBack()
  236. }
  237. })
  238. } else {
  239. uni.showToast({
  240. title: res.message || '�𣂷漱憭梯揖',
  241. icon: 'none'
  242. })
  243. }
  244. } catch (e) {
  245. uni.hideLoading()
  246. uni.showToast({
  247. title: '�𣂷漱憭梯揖',
  248. icon: 'none'
  249. })
  250. }
  251. }
  252. }
  253. }
  254. </script>
  255. <style scoped>
  256. .container {
  257. padding: 30rpx;
  258. background: #F8F8F8;
  259. min-height: 100vh;
  260. }
  261. .header {
  262. text-align: center;
  263. padding: 60rpx 0 40rpx;
  264. }
  265. .title {
  266. font-size: 48rpx;
  267. font-weight: bold;
  268. color: #333;
  269. display: block;
  270. margin-bottom: 20rpx;
  271. }
  272. .subtitle {
  273. font-size: 28rpx;
  274. color: #666;
  275. }
  276. .form {
  277. background: #fff;
  278. border-radius: 20rpx;
  279. padding: 40rpx;
  280. }
  281. .form-item {
  282. margin-bottom: 40rpx;
  283. }
  284. .label {
  285. font-size: 28rpx;
  286. color: #333;
  287. display: block;
  288. margin-bottom: 20rpx;
  289. font-weight: bold;
  290. }
  291. .input {
  292. width: 100%;
  293. height: 80rpx;
  294. border: 1rpx solid #E0E0E0;
  295. border-radius: 10rpx;
  296. padding: 0 20rpx;
  297. font-size: 28rpx;
  298. }
  299. .hint {
  300. font-size: 24rpx;
  301. color: #F97316;
  302. margin-top: 10rpx;
  303. display: block;
  304. }
  305. .optional {
  306. font-size: 24rpx;
  307. color: #999;
  308. font-weight: normal;
  309. }
  310. .section-divider {
  311. margin: 20rpx 0 30rpx;
  312. padding: 20rpx 0;
  313. border-top: 1rpx solid #f0f0f0;
  314. }
  315. .divider-text {
  316. font-size: 26rpx;
  317. color: #999;
  318. }
  319. .upload-section {
  320. display: flex;
  321. align-items: center;
  322. }
  323. .preview-image {
  324. width: 200rpx;
  325. height: 200rpx;
  326. border-radius: 10rpx;
  327. object-fit: cover;
  328. }
  329. .upload-placeholder {
  330. width: 200rpx;
  331. height: 200rpx;
  332. border: 2rpx dashed #E0E0E0;
  333. border-radius: 10rpx;
  334. display: flex;
  335. flex-direction: column;
  336. align-items: center;
  337. justify-content: center;
  338. background: #F8F8F8;
  339. }
  340. .upload-icon {
  341. font-size: 60rpx;
  342. margin-bottom: 10rpx;
  343. }
  344. .upload-text {
  345. font-size: 24rpx;
  346. color: #999;
  347. }
  348. .btn-submit {
  349. width: 100%;
  350. height: 90rpx;
  351. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  352. color: #fff;
  353. border-radius: 45rpx;
  354. font-size: 32rpx;
  355. font-weight: bold;
  356. margin-top: 40rpx;
  357. }
  358. </style>