baoMing.vue 13 KB

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