国外MOSE官网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

538 lines
15 KiB

1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
  1. <template>
  2. <view class="volunteer-apply-page">
  3. <!-- 头部背景图 -->
  4. <view class="header-section">
  5. <image src="../static/volunteer_bg@2x.png" class="bg-image" mode="aspectFit"></image>
  6. </view>
  7. <!-- 提示信息 -->
  8. <view class="tip-section">
  9. <uv-icon name="info-circle-fill" color="#1488DB" size="32"></uv-icon>
  10. <text class="tip-text">以下内容均为必填项请根据您的实际情况认真填写</text>
  11. </view>
  12. <!-- 表单内容 -->
  13. <view class="form-section">
  14. <uv-form ref="form" :model="formData" :rules="rules" labelPosition="left" labelWidth="120">
  15. <!-- 姓名 -->
  16. <uv-form-item label="姓名" prop="name" borderBottom>
  17. <uv-input
  18. v-model="formData.name"
  19. placeholder="请输入您的姓名"
  20. border="none"
  21. clearable
  22. ></uv-input>
  23. </uv-form-item>
  24. <!-- 手机号 -->
  25. <uv-form-item label="手机号" prop="phone" borderBottom>
  26. <uv-input
  27. v-model="formData.phone"
  28. placeholder="请输入您的手机号"
  29. border="none"
  30. clearable
  31. type="number"
  32. ></uv-input>
  33. </uv-form-item>
  34. <!-- 性别 -->
  35. <uv-form-item label="性别" prop="sex" borderBottom @click="openGenderPicker">
  36. <uv-input
  37. v-model="formData.sexText"
  38. placeholder="请选择"
  39. border="none"
  40. readonly
  41. suffixIcon="arrow-right"
  42. ></uv-input>
  43. </uv-form-item>
  44. <!-- 所在地区 -->
  45. <uv-form-item label="所在地区" prop="area" borderBottom @click="openRegionPicker">
  46. <uv-input
  47. v-model="formData.areaText"
  48. placeholder="请选择"
  49. border="none"
  50. readonly
  51. suffixIcon="arrow-right"
  52. ></uv-input>
  53. </uv-form-item>
  54. <!-- 详细地址 -->
  55. <uv-form-item label="详细地址" prop="address" borderBottom>
  56. <uv-input
  57. v-model="formData.address"
  58. placeholder="请输入详细地址"
  59. border="none"
  60. clearable
  61. ></uv-input>
  62. </uv-form-item>
  63. <!-- 职业类型 -->
  64. <uv-form-item label="职业类型" prop="career" borderBottom @click="openProfessionPicker">
  65. <uv-input
  66. v-model="formData.careerText"
  67. placeholder="请选择"
  68. border="none"
  69. readonly
  70. suffixIcon="arrow-right"
  71. ></uv-input>
  72. </uv-form-item>
  73. <!-- 最高学历 -->
  74. <uv-form-item label="最高学历" prop="qualifications" borderBottom @click="openEducationPicker">
  75. <uv-input
  76. v-model="formData.qualificationsText"
  77. placeholder="请选择"
  78. border="none"
  79. readonly
  80. suffixIcon="arrow-right"
  81. ></uv-input>
  82. </uv-form-item>
  83. <!-- 技能特长 -->
  84. <uv-form-item label="技能特长" prop="skill">
  85. <uv-textarea
  86. v-model="formData.skill"
  87. placeholder="请输入您的技能特长"
  88. border="none"
  89. :maxlength="200"
  90. count
  91. height="120"
  92. ></uv-textarea>
  93. </uv-form-item>
  94. </uv-form>
  95. <!-- 紧急联系人信息 -->
  96. <view class="emergency-section">
  97. <view class="section-title">紧急联系人信息</view>
  98. <uv-form ref="emergencyForm" :model="emergencyData" labelPosition="left" labelWidth="120">
  99. <!-- 联系人姓名 -->
  100. <uv-form-item label="姓名" prop="emergencyName" borderBottom>
  101. <uv-input
  102. v-model="emergencyData.emergencyName"
  103. placeholder="请输入您的紧急联系人姓名"
  104. border="none"
  105. clearable
  106. ></uv-input>
  107. </uv-form-item>
  108. <!-- 联系人手机号 -->
  109. <uv-form-item label="手机号" prop="emergencyPhone" borderBottom>
  110. <uv-input
  111. v-model="emergencyData.emergencyPhone"
  112. placeholder="请输入您的紧急联系人手机号"
  113. border="none"
  114. clearable
  115. type="number"
  116. ></uv-input>
  117. </uv-form-item>
  118. </uv-form>
  119. </view>
  120. </view>
  121. <!-- 提交按钮 -->
  122. <view class="submit-section">
  123. <!-- 圆角的 -->
  124. <uv-button
  125. type="primary"
  126. shape="circle"
  127. size="large"
  128. :loading="submitting"
  129. @click="submitApplication"
  130. >
  131. 提交申请
  132. </uv-button>
  133. </view>
  134. <!-- 性别选择器 -->
  135. <uv-picker
  136. ref="genderPicker"
  137. :columns="genderOptions"
  138. @confirm="onGenderConfirm"
  139. ></uv-picker>
  140. <!-- 地区选择器 -->
  141. <uv-picker
  142. ref="regionPicker"
  143. :columns="addressList"
  144. @confirm="onAddressConfirm"
  145. @change="onAddressChange"
  146. keyName="name"
  147. ></uv-picker>
  148. <!-- 职业选择器 -->
  149. <uv-picker
  150. ref="professionPicker"
  151. :columns="professionOptions"
  152. @confirm="onProfessionConfirm"
  153. ></uv-picker>
  154. <!-- 学历选择器 -->
  155. <uv-picker
  156. ref="educationPicker"
  157. :columns="educationOptions"
  158. @confirm="onEducationConfirm"
  159. ></uv-picker>
  160. </view>
  161. </template>
  162. <script>
  163. import chinaRegions from '@/static/china-regions.json'
  164. export default {
  165. name: 'VolunteerApply',
  166. data() {
  167. return {
  168. submitting: false,
  169. formData: {
  170. name: '',
  171. phone: '',
  172. sex: '',
  173. sexText: '',
  174. area: '',
  175. areaText: '',
  176. address: '',
  177. career: '',
  178. careerText: '',
  179. qualifications: '',
  180. qualificationsText: '',
  181. skill: ''
  182. },
  183. emergencyData: {
  184. emergencyName: '',
  185. emergencyPhone: ''
  186. },
  187. rules: {
  188. name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
  189. phone: [
  190. { required: true, message: '请输入手机号', trigger: 'blur' },
  191. { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }
  192. ],
  193. sex: [{ required: true, message: '请选择性别', trigger: 'change' }],
  194. area: [{ required: true, message: '请选择所在地区', trigger: 'change' }],
  195. address: [{ required: true, message: '请输入详细地址', trigger: 'blur' }],
  196. career: [{ required: true, message: '请选择职业类型', trigger: 'change' }],
  197. qualifications: [{ required: true, message: '请选择最高学历', trigger: 'change' }]
  198. },
  199. genderOptions: [['男', '女']],
  200. provinces: [], //省
  201. citys: [], //市
  202. areas: [], //区
  203. pickerValue: [0, 0, 0],
  204. defaultValue: [3442, 1, 2],
  205. professionOptions: [[
  206. '学生', '教师', '医生', '工程师', '设计师', '销售',
  207. '服务员', '公务员', '自由职业', '专业技术人员', '其他'
  208. ]],
  209. educationOptions: [[
  210. '高中及以下', '大专', '本科', '硕士', '博士'
  211. ]]
  212. }
  213. },
  214. computed: {
  215. addressList() {
  216. return [this.provinces, this.citys, this.areas];
  217. }
  218. },
  219. onLoad(options) {
  220. // 如果是编辑模式,加载已有数据
  221. if (options.edit && options.data) {
  222. this.loadExistingData(JSON.parse(decodeURIComponent(options.data)));
  223. }
  224. },
  225. created() {
  226. this.getAddressData()
  227. },
  228. methods: {
  229. // 加载已有数据(编辑模式)
  230. loadExistingData(data) {
  231. this.formData = {
  232. name: data.name || '李双欢',
  233. phone: data.phone || '15478451233',
  234. sex: data.sex || '男',
  235. sexText: data.sex || '男',
  236. area: data.area || '湖南省长沙市区',
  237. areaText: data.area || '湖南省长沙市区',
  238. address: data.address || '阳光小区45栋二单元1203',
  239. career: data.career || '专业技术人员',
  240. careerText: data.career || '专业技术人员',
  241. qualifications: data.qualifications || '本科',
  242. qualificationsText: data.qualifications || '本科',
  243. skill: data.skill || '计算机、跑步'
  244. };
  245. this.emergencyData = {
  246. emergencyName: data.emergencyName || '李四',
  247. emergencyPhone: data.emergencyPhone || '14563236320'
  248. };
  249. },
  250. // 初始化地区数据
  251. getAddressData() {
  252. console.log('开始加载地区数据');
  253. try {
  254. // 直接使用导入的地区数据(已简化,只包含name字段)
  255. this.provinces = chinaRegions;
  256. console.log('成功加载地区数据,省份数量:', this.provinces.length);
  257. this.handlePickValueDefault();
  258. uni.showToast({
  259. title: '地区数据加载成功',
  260. icon: 'success'
  261. });
  262. } catch (error) {
  263. console.error('加载地区数据失败:', error);
  264. uni.showToast({
  265. title: '地区数据加载失败',
  266. icon: 'error'
  267. });
  268. }
  269. },
  270. handlePickValueDefault() {
  271. if (this.provinces.length > 0) {
  272. // 设置省(默认选择第一个省份)
  273. this.pickerValue[0] = 0;
  274. // 设置市(默认选择第一个市)
  275. this.citys = this.provinces[0]?.children || [];
  276. this.pickerValue[1] = 0;
  277. // 设置区(默认选择第一个区)
  278. this.areas = this.citys[0]?.children || [];
  279. this.pickerValue[2] = 0;
  280. console.log('初始化地区数据:', {
  281. provinces: this.provinces.length,
  282. citys: this.citys.length,
  283. areas: this.areas.length
  284. });
  285. }
  286. },
  287. // 打开性别选择器
  288. openGenderPicker() {
  289. // console.log('我点击了性别选择去');
  290. this.$refs.genderPicker.open();
  291. },
  292. // 打开地区选择器
  293. openRegionPicker() {
  294. this.$refs.regionPicker.open();
  295. },
  296. // 打开职业选择器
  297. openProfessionPicker() {
  298. this.$refs.professionPicker.open();
  299. },
  300. // 打开学历选择器
  301. openEducationPicker() {
  302. this.$refs.educationPicker.open();
  303. },
  304. // 性别选择确认
  305. onGenderConfirm(value) {
  306. this.formData.sex = value[0];
  307. this.formData.sexText = value[0];
  308. },
  309. // 地区选择变化(三级联动)
  310. onAddressChange(e) {
  311. console.log('地区选择变化:', e);
  312. const { columnIndex, index, value } = e;
  313. if (columnIndex === 0) {
  314. // 选择省份时,更新市级数据
  315. this.citys = this.provinces[index]?.children || [];
  316. this.areas = this.citys[0]?.children || [];
  317. this.pickerValue = [index, 0, 0];
  318. } else if (columnIndex === 1) {
  319. // 选择市时,更新区级数据
  320. this.areas = this.citys[index]?.children || [];
  321. this.pickerValue[1] = index;
  322. this.pickerValue[2] = 0;
  323. } else if (columnIndex === 2) {
  324. // 选择区
  325. this.pickerValue[2] = index;
  326. }
  327. },
  328. // 地区选择确认
  329. onAddressConfirm(e) {
  330. console.log('确认选择的地区:', e);
  331. if (e.value && e.value.length >= 3) {
  332. this.formData.address = `${e.value[0].name}/${e.value[1].name}/${e.value[2].name}`;
  333. this.formData.addressText = this.formData.address;
  334. uni.showToast({
  335. icon: 'success',
  336. title: '地区选择成功'
  337. });
  338. } else {
  339. uni.showToast({
  340. icon: 'none',
  341. title: '请选择完整的省市区信息'
  342. });
  343. }
  344. },
  345. // 职业选择确认
  346. onProfessionConfirm(value) {
  347. this.formData.career = value[0];
  348. this.formData.careerText = value[0];
  349. },
  350. // 学历选择确认
  351. onEducationConfirm(value) {
  352. this.formData.qualifications = value[0];
  353. this.formData.qualificationsText = value[0];
  354. },
  355. // 提交申请
  356. async submitApplication() {
  357. try {
  358. // 验证主表单
  359. const valid = await this.$refs.form.validate();
  360. if (!valid) return;
  361. // 验证紧急联系人信息
  362. if (!this.emergencyData.emergencyName || !this.emergencyData.emergencyPhone) {
  363. uni.showToast({
  364. title: '请填写紧急联系人信息',
  365. icon: 'none'
  366. });
  367. return;
  368. }
  369. this.submitting = true;
  370. // 模拟提交
  371. await this.submitVolunteerApplication();
  372. uni.showToast({
  373. title: '申请提交成功',
  374. icon: 'success'
  375. });
  376. setTimeout(() => {
  377. uni.navigateBack();
  378. }, 1500);
  379. } catch (error) {
  380. console.error('提交失败:', error);
  381. uni.showToast({
  382. title: '提交失败,请重试',
  383. icon: 'none'
  384. });
  385. } finally {
  386. this.submitting = false;
  387. }
  388. },
  389. // 提交志愿者申请API
  390. async submitVolunteerApplication() {
  391. // 模拟API调用
  392. return new Promise((resolve) => {
  393. setTimeout(() => {
  394. console.log('志愿者申请数据:', {
  395. ...this.formData,
  396. ...this.emergencyData
  397. });
  398. resolve();
  399. }, 1000);
  400. });
  401. }
  402. }
  403. }
  404. </script>
  405. <style lang="scss" scoped>
  406. // @import '@/uni.scss';
  407. .volunteer-apply-page {
  408. min-height: 100vh;
  409. background-color: #f5f5f5;
  410. }
  411. .header-section {
  412. position: relative;
  413. width: 96%;
  414. height: 290rpx;
  415. margin: 25rpx auto;
  416. .bg-image {
  417. width: 100%;
  418. height: 100%;
  419. }
  420. }
  421. .tip-section {
  422. display: flex;
  423. align-items: center;
  424. padding: 30rpx;
  425. background-color: #fff;
  426. margin: 20rpx 30rpx;
  427. border-radius: 16rpx;
  428. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  429. .tip-text {
  430. margin-left: 16rpx;
  431. font-size: 28rpx;
  432. color: #666;
  433. line-height: 1.5;
  434. }
  435. }
  436. .form-section {
  437. background-color: #fff;
  438. margin: 20rpx 30rpx;
  439. border-radius: 16rpx;
  440. padding: 40rpx 30rpx;
  441. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  442. }
  443. .emergency-section {
  444. margin-top: 40rpx;
  445. padding-top: 40rpx;
  446. border-top: 1rpx solid #f0f0f0;
  447. .section-title {
  448. font-size: 32rpx;
  449. font-weight: bold;
  450. color: #333;
  451. margin-bottom: 30rpx;
  452. }
  453. }
  454. .submit-section {
  455. padding: 40rpx 30rpx;
  456. padding-bottom: 60rpx;
  457. }
  458. // 覆盖uvUI样式
  459. :deep(.uv-form-item__body__right__content__input) {
  460. font-size: 28rpx !important;
  461. }
  462. :deep(.uv-form-item__body__left__text) {
  463. font-size: 28rpx !important;
  464. color: #333 !important;
  465. }
  466. :deep(.uv-input__content__field-wrapper__field) {
  467. font-size: 28rpx !important;
  468. }
  469. :deep(.uv-textarea__content__field) {
  470. font-size: 28rpx !important;
  471. }
  472. </style>