baoMing.vue 13 KB

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