baoMing.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <template>
  2. <view class="box">
  3. <u-navbar :autoBack="true" title="志愿报名" bgColor="rgba(255,255,255,0)" :placeholder="true" titleStyle="font-weight:bold;color:#000000"></u-navbar>
  4. <view class="ban_box">
  5. <view class="ban_item2">
  6. <image class="top_img" src="https://huli-app.wenlvti.net/app_static/WenWuGuanJia/image/bm_top.png"></image>
  7. </view>
  8. <view class="ban_item1">
  9. <image class="top_img" src="https://huli-app.wenlvti.net/app_static/WenWuGuanJia/image/dt_ban2.png"></image>
  10. </view>
  11. </view>
  12. <!-- 表单 -->
  13. <view class="example">
  14. <uni-forms style="padding: 0 20rpx 0 20rpx" label-position="top" ref="valiForm" :rules="rules" :modelValue="valiFormData">
  15. <uni-forms-item label="您的姓名" label-width="80px" required name="name">
  16. <uni-easyinput v-model="valiFormData.name" placeholder="请输入姓名" />
  17. </uni-forms-item>
  18. <uni-forms-item label="您的联系电话" label-width="100px" required name="mobile">
  19. <uni-easyinput type="number" v-model="valiFormData.mobile" placeholder="请输入联系电话" />
  20. </uni-forms-item>
  21. <uni-forms-item label="您的身份证" label-width="100px" required name="id_card">
  22. <uni-easyinput type="idcard" v-model="valiFormData.id_card" placeholder="请输入身份证号" />
  23. </uni-forms-item>
  24. <uni-forms-item label="住址" label-width="100px" required name="address">
  25. <uni-easyinput v-model="valiFormData.address" placeholder="请输入住址" />
  26. </uni-forms-item>
  27. <uni-forms-item label="单位" label-width="80px" required name="unit_name">
  28. <uni-easyinput v-model="valiFormData.unit_name" placeholder="请输入单位名称" />
  29. </uni-forms-item>
  30. <!-- <uni-forms-item label="所在区域" label-width="80px" required name="region_id">
  31. <view style="width: 100%; height: 72rpx; border-radius: 10rpx; background-color: #f7dfc0">
  32. <uni-data-picker
  33. v-model="valiFormData.region_id"
  34. :clear-icon="false"
  35. :localdata="regionList"
  36. popup-title="请选择区域"
  37. @nodeclick="onnodeclick"
  38. :map="{ text: 'title', value: 'id' }"
  39. ></uni-data-picker>
  40. </view>
  41. </uni-forms-item> -->
  42. <!-- <uni-forms-item label="备注" label-width="80px" required name="notesVal">
  43. <uni-easyinput v-model="valiFormData.notesVal" placeholder="请输入申请类型(个人、家庭、机构)" />
  44. </uni-forms-item> -->
  45. <uni-forms-item label="认领原因" label-width="80px" required name="intro">
  46. <uni-easyinput type="textarea" v-model="valiFormData.intro" placeholder="请输入认领原因或个人介绍(可上传个人优秀证明、奖项)" />
  47. <view @click="chooseFile" class="scfj">
  48. <view>上传文件</view>
  49. <view>
  50. <uni-icons type="wallet" size="18"></uni-icons>
  51. </view>
  52. </view>
  53. </uni-forms-item>
  54. </uni-forms>
  55. </view>
  56. <view v-if="valiFormData.status == '-1'" class="text-wrapper_3" @click="modifySubmit('valiForm')">
  57. <view class="bm_tit">确认修改</view>
  58. </view>
  59. <view v-else class="text-wrapper_3" @click="submit('valiForm')">
  60. <view class="bm_tit">报名</view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. let that;
  66. export default {
  67. data() {
  68. return {
  69. regionList: [],
  70. cr_id: '' /* 文物id */,
  71. modifyId: '' /* 修改资料的文物id */,
  72. volunteer_id: '' /* 志愿者id */,
  73. /* 表单数据 */
  74. valiFormData: {
  75. name: '',
  76. mobile: '',
  77. address: '',
  78. id_card: '',
  79. unit_name: '',
  80. fullurl: '',
  81. intro: ''
  82. // region_id: '' /* 区域id */
  83. },
  84. /* 校验规则 */
  85. rules: {
  86. // 对name字段进行必填验证
  87. name: {
  88. // name 字段的校验规则
  89. rules: [
  90. // 校验 name 不能为空
  91. {
  92. required: true,
  93. errorMessage: '请输入姓名'
  94. },
  95. // 对name字段进行长度验证
  96. {
  97. minLength: 1,
  98. maxLength: 6,
  99. errorMessage: '{label}长度在 {minLength} 到 {maxLength} 个字符'
  100. }
  101. ],
  102. // 当前表单域的字段中文名,可不输入
  103. label: '姓名',
  104. validateTrigger: 'submit'
  105. },
  106. /* 手机号校验 */
  107. mobile: {
  108. // mobile 字段的校验规则
  109. rules: [
  110. // 校验 mobile 不能为空
  111. {
  112. required: true,
  113. errorMessage: '请输入联系电话'
  114. },
  115. // 对mobile字段进行长度验证
  116. {
  117. minLength: 11,
  118. maxLength: 11,
  119. errorMessage: '{label}长度为 {minLength} 个字符'
  120. }
  121. ],
  122. // 当前表单域的字段中文名,可不输入
  123. label: '手机号',
  124. validateTrigger: 'submit'
  125. },
  126. /* 身份证校验 */
  127. id_card: {
  128. // idCard 字段的校验规则
  129. rules: [
  130. // 校验 idCard 不能为空
  131. {
  132. required: true,
  133. errorMessage: '请输入身份证号'
  134. },
  135. // 对idCard字段进行长度验证
  136. {
  137. minLength: 18,
  138. maxLength: 18,
  139. errorMessage: '{label}长度为 {minLength} 个字符'
  140. }
  141. ],
  142. // 当前表单域的字段中文名,可不输入
  143. label: '身份证号',
  144. validateTrigger: 'submit'
  145. },
  146. /* 单位 */
  147. unit_name: {
  148. rules: [
  149. // 校验 unit 不能为空
  150. {
  151. required: true,
  152. errorMessage: '请输入单位名称'
  153. }
  154. ]
  155. },
  156. address: {
  157. rules: [
  158. // 校验 住址 不能为空
  159. {
  160. required: true,
  161. errorMessage: '请输入单位名称'
  162. }
  163. ]
  164. },
  165. // notesVal: {
  166. // rules: [
  167. // // 校验 申请类型 不能为空
  168. // {
  169. // required: true,
  170. // errorMessage: '请输入申请类型'
  171. // }
  172. // ]
  173. // },
  174. intro: {
  175. rules: [
  176. {
  177. required: true,
  178. errorMessage: '请输入认领原因或个人介绍'
  179. }
  180. ]
  181. }
  182. // region_id: {
  183. // rules: [
  184. // {
  185. // required: true,
  186. // errorMessage: '请选择所在区域'
  187. // }
  188. // ]
  189. // }
  190. }
  191. };
  192. },
  193. onLoad(o) {
  194. that = this;
  195. this.cr_id = o.id;
  196. this.volunteer_id = o.volunteer_id;
  197. this.modifyId = o.modifyId;
  198. this.details();
  199. // this.getCulturalRelicCategory();
  200. },
  201. methods: {
  202. // onnodeclick(e) {
  203. // this.region_id = e.id;
  204. // console.log(this.region_id, 1212);
  205. // },
  206. // 区域
  207. // getCulturalRelicCategory() {
  208. // this.$api.getCulturalRelicCategory({ main_body_id: 1, type: 1 }, function (res) {
  209. // // console.log(res, 565656);
  210. // const result = [];
  211. // for (const item of res.data) {
  212. // let parent = result.find((parentItem) => parentItem.id === item.pid);
  213. // // 如果父级对象尚未存在于结果数组中,将其添加进去
  214. // if (!parent) {
  215. // parent = {
  216. // ...item,
  217. // children: []
  218. // };
  219. // result.push(parent);
  220. // } else {
  221. // // 确保不将父级自身添加到其children数组
  222. // if (parent.id !== item.id) {
  223. // parent.children.push(item);
  224. // }
  225. // }
  226. // }
  227. // that.regionList = result;
  228. // // console.log(that.regionList, 66666);
  229. // });
  230. // },
  231. // 测试上传文件
  232. chooseFile() {
  233. let userToken = '';
  234. let auth = this.$db.get('auth');
  235. userToken = auth.token;
  236. wx.chooseMessageFile({
  237. count: 1,
  238. type: 'file', // 修改为支持的文档类型
  239. // 配置后导致读取不到聊天文件
  240. // extension: ['.doc', '.xlsx', '.docx', '.ppt'],
  241. success(res) {
  242. const tempFilePaths = res.tempFiles;
  243. uni.uploadFile({
  244. url: that.$config.baseUrl + 'api/common/upload?token=' + userToken,
  245. filePath: tempFilePaths[0].path,
  246. name: 'file',
  247. header: {
  248. 'content-type': 'multipart/form-data' // 根据实际情况设置请求头
  249. },
  250. formData: {}, // 如果需要,添加额外的form数据
  251. success: (res) => {
  252. console.log('上传成功,服务器响应数据:', res.data);
  253. let url = JSON.parse(res.data);
  254. that.valiFormData.fullurl = url.data.fullurl;
  255. // console.log('生成的链接', that.valiFormData.fullurl);
  256. that.$common.errorToShow('上传成功');
  257. },
  258. fail: (err) => {
  259. console.error('文件上传失败:', err);
  260. }
  261. });
  262. }
  263. });
  264. },
  265. submit() {
  266. this.$refs.valiForm.validate(['id'], async (err, valiFormData) => {
  267. if (!err) {
  268. console.log('校验成功');
  269. /* 检验成功 */
  270. const { name, mobile, address, id_card, unit_name, intro, fullurl } = this.valiFormData;
  271. this.$api.applyVolunteer(
  272. {
  273. main_body_id: 1,
  274. name: name,
  275. mobile: mobile,
  276. address: address,
  277. unit_name: unit_name,
  278. id_card: id_card,
  279. intro: intro,
  280. cr_id: this.cr_id,
  281. file: fullurl
  282. },
  283. function (res) {
  284. if (res.code === 1) {
  285. that.$common.errorToShow(res.msg);
  286. setTimeout(() => {
  287. uni.switchTab({
  288. url: '/pages/shouhu/shouhu'
  289. });
  290. }, 1000);
  291. } else {
  292. that.$common.errorToShow(res.msg);
  293. }
  294. // console.log(res);
  295. }
  296. );
  297. } else {
  298. that.$common.errorToShow('请完善信息');
  299. }
  300. });
  301. },
  302. // 志愿者详情判断是否为被驳回
  303. details() {
  304. this.$api.details({ main_body_id: 1 }, function (res) {
  305. // 被驳回
  306. if (res.data != null && res.data.status == '-1') {
  307. console.log(res);
  308. that.valiFormData = res.data;
  309. console.log(that.valiFormData, '被驳回');
  310. }
  311. if (res.data != null && res.data.status == '2') {
  312. that.$common.errorToShow('您已经是志愿者,正在前往守护');
  313. setTimeout(() => {
  314. uni.switchTab({
  315. url: '/pages/shouhu/shouhu'
  316. });
  317. }, 3000);
  318. }
  319. if (res.data != null && res.data.status == '0') {
  320. that.$common.errorToShow('您的资料正在审核中');
  321. setTimeout(() => {
  322. uni.switchTab({
  323. url: '/pages/shouhu/shouhu'
  324. });
  325. }, 3000);
  326. }
  327. });
  328. },
  329. // 修改资料
  330. modifySubmit() {
  331. this.$refs.valiForm.validate(['id'], async (err, valiFormData) => {
  332. if (!err) {
  333. console.log('校验成功');
  334. /* 检验成功 */
  335. const { name, mobile, address, id_card, unit_name, intro } = this.valiFormData;
  336. this.$api.editApplyVolunteer(
  337. {
  338. main_body_id: 1,
  339. name: name,
  340. mobile: mobile,
  341. address: address,
  342. unit_name: unit_name,
  343. id_card: id_card,
  344. intro: intro,
  345. volunteer_id: this.volunteer_id || this.valiFormData.id,
  346. cr_id: this.cr_id || this.valiFormData.cr_list[0].id
  347. },
  348. function (res) {
  349. if (res.code === 1) {
  350. that.$common.errorToShow(res.msg);
  351. } else {
  352. that.$common.errorToShow(res.msg);
  353. }
  354. // console.log(res);
  355. }
  356. );
  357. } else {
  358. that.$common.errorToShow('请完善信息');
  359. }
  360. });
  361. }
  362. }
  363. };
  364. </script>
  365. <style>
  366. .box {
  367. width: 100%;
  368. padding-bottom: 50rpx;
  369. background-image: url('https://huli-app.wenlvti.net/app_static/WenWuGuanJia/image/xy_bgt.png');
  370. background-size: 100% 100%;
  371. background-repeat: repeat-y;
  372. height: auto;
  373. }
  374. .ban_box {
  375. position: relative;
  376. margin-top: 40rpx;
  377. }
  378. .top_img {
  379. width: 100%;
  380. height: 100%;
  381. }
  382. .ban_item1 {
  383. position: absolute;
  384. top: -20rpx;
  385. left: 233rpx;
  386. width: 290rpx;
  387. height: 290rpx;
  388. margin: auto;
  389. }
  390. .ban_item2 {
  391. width: 250rpx;
  392. height: 250rpx;
  393. margin: auto;
  394. }
  395. /deep/.uni-forms-item__error {
  396. color: red !important;
  397. }
  398. .is-input-border {
  399. background-color: #f7dfc0 !important;
  400. }
  401. .uni-forms-item__label {
  402. color: #000000 !important;
  403. }
  404. .text-wrapper_3 {
  405. margin: auto;
  406. margin-top: 50rpx;
  407. height: 80rpx;
  408. flex-direction: column;
  409. width: 240rpx;
  410. background: url('/static/img/dt_bg2.png') no-repeat;
  411. background-size: 100% 100%;
  412. }
  413. .bm_tit {
  414. text-align: center;
  415. font-size: 36rpx;
  416. line-height: 80rpx;
  417. letter-spacing: 6rpx;
  418. text-align: center;
  419. font-weight: 700;
  420. background: linear-gradient(180deg, #af7e44 0%, #934b36 100%);
  421. -webkit-background-clip: text;
  422. -webkit-text-fill-color: transparent;
  423. }
  424. .example {
  425. height: 87%;
  426. margin: 20rpx 32rpx 0 32rpx;
  427. }
  428. .uni-forms {
  429. padding: 0 20rpx 0 20rpx;
  430. }
  431. .uni-forms-item {
  432. margin-bottom: 30rpx !important;
  433. }
  434. .active {
  435. border: 6rpx solid #efb57a;
  436. border-radius: 10rpx;
  437. }
  438. .img {
  439. width: 230rpx;
  440. height: 250rpx;
  441. border: 6rpx solid #efb57a;
  442. border-radius: 10rpx;
  443. }
  444. .map_tit {
  445. display: flex;
  446. align-items: center;
  447. margin-left: 60rpx;
  448. margin-top: 40rpx;
  449. font-size: 40rpx;
  450. font-family: Songti SC, Songti SC;
  451. font-weight: 900;
  452. line-height: 52rpx;
  453. color: #444444;
  454. }
  455. .scarch_box {
  456. width: 430rpx;
  457. height: 82rpx;
  458. padding: 15rpx 0 0 30rpx;
  459. /* background-image: url('/static/img/search_bg1.png');
  460. background-size: 100% 100%; */
  461. }
  462. .rl_box {
  463. width: 90%;
  464. margin: auto;
  465. margin-top: 40rpx;
  466. display: flex;
  467. justify-content: space-between;
  468. }
  469. .rl_item {
  470. width: 188rpx;
  471. height: 102rpx;
  472. background-image: url('/static/img/rl_bg.png');
  473. background-size: 100% 100%;
  474. }
  475. .tit {
  476. text-align: center;
  477. line-height: 102rpx;
  478. font-weight: 700;
  479. font-size: 36rpx;
  480. letter-spacing: 6rpx;
  481. background: linear-gradient(180deg, #af7e44 0%, #934b36 100%);
  482. -webkit-background-clip: text;
  483. -webkit-text-fill-color: transparent;
  484. }
  485. .scfj {
  486. width: 170rpx;
  487. height: 50rpc;
  488. line-height: 50rpx;
  489. align-items: center;
  490. display: flex;
  491. background-color: #f7dfc0;
  492. position: absolute;
  493. top: -60rpx;
  494. right: 2rpx;
  495. border-radius: 5rpx;
  496. justify-content: space-around;
  497. }
  498. .tit2 {
  499. text-align: center;
  500. line-height: 66rpx;
  501. font-weight: 700;
  502. font-size: 32rpx;
  503. letter-spacing: 6rpx;
  504. background: linear-gradient(180deg, #af7e44 0%, #934b36 100%);
  505. -webkit-background-clip: text;
  506. -webkit-text-fill-color: transparent;
  507. }
  508. .is-input-error-border {
  509. border: none !important;
  510. }
  511. .xx_box {
  512. padding: 20rpx;
  513. background-color: #e1bf9a;
  514. width: 660rpx;
  515. height: 560rpx;
  516. padding-top: 80rpx;
  517. }
  518. .xx_tit {
  519. height: 360rpx;
  520. font-size: 30rpx;
  521. padding: 20rpx;
  522. text-indent: 2em;
  523. background-color: #f3e3d3;
  524. overflow: scroll;
  525. }
  526. </style>