category.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. <image src="../../static/img/jiuzai.png" mode="widthFix" class="bgi"></image>
  5. </view>
  6. <view class="pop-box">公众参与</view>
  7. <view class="pop-list">
  8. <view class="list-box1" v-for="(item, index) in peoplelist" :key="index" v-if="index < 20">
  9. <view class="list-top">
  10. <image src="../../static/img/002.png" mode="" class="avatar-img"></image>
  11. </view>
  12. <view class="nickname">{{ item.name }}</view>
  13. </view>
  14. </view>
  15. <view class="red-box">救在身边报名</view>
  16. <!-- <view class="people">
  17. </view> -->
  18. <view class="list-box">
  19. <view class="list">
  20. <view class="list-left">姓名 <text>*</text></view>
  21. <input type="text" v-model="name" class="list-input" placeholder="请填写您的姓名" />
  22. </view>
  23. <view class="list">
  24. <view class="list-left">手机号码 <text>*</text></view>
  25. <input type="text" v-model="phone" class="list-input" placeholder="请填写您的联系方式" />
  26. </view>
  27. <view class="list" @click="getLocation">
  28. <view class="list-left">地址 <text>*</text></view>
  29. <!-- <picker-address class="box-right" @change="onCityClick">{{ address }}</picker-address> -->
  30. <input type="text" v-model="showaddress" class="list-input" placeholder="请选择常用地址" />
  31. </view>
  32. <view class="list">
  33. <view class="list-left">机构 <text>*</text></view>
  34. <picker @change="bindPickerChange" :range="chooseMechanismList" style="width: 100%;">
  35. <input type="text" v-model="mechanism" class="list-input" placeholder="请填写您的所在机构" disabled />
  36. <!-- <view class="list-input">{{'请填写您的所在机构'}}</view> -->
  37. </picker>
  38. </view>
  39. <view class="list">
  40. <view class="list-left">志愿者编号 / 证书编号</view>
  41. <input type="text" v-model="volunteer_id" class="list-input" placeholder="请填写您的志愿者编号 / 证书编号" />
  42. </view>
  43. <view class="upload-box">
  44. <view class="upload-left">证件 <text>*</text></view>
  45. <view class="upload-right">
  46. <image :src="certificates" mode="" class="upload-img" @click.stop="imgsub" v-if="certificates">
  47. </image>
  48. <image src="../../static/images/upload.png" class="upload-img" mode="" v-if="!certificates"
  49. @click.stop="imgsub"></image>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="sub" :class="{ action: loding }" @click="!loding ? applyRescuer() : ''">提交申请</view>
  54. </view>
  55. </template>
  56. <script>
  57. import {
  58. mapState,
  59. mapMutations
  60. } from 'vuex';
  61. import {
  62. saveUrl,
  63. interceptor
  64. } from '@/utils/loginUtils.js';
  65. import {
  66. mechanism
  67. } from '@/api/ask.js';
  68. import {
  69. getNumber,
  70. getInstitution
  71. } from '@/api/index.js';
  72. import {
  73. upload,
  74. addrescuer
  75. } from '@/api/ask.js';
  76. import {
  77. getMechanismList,
  78. applyRescuer,
  79. getRescuerList,
  80. getApplyList
  81. } from '@/api/category.js'
  82. import pickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
  83. export default {
  84. components: {
  85. pickerAddress
  86. },
  87. data() {
  88. return {
  89. longitude4: '',
  90. latitude4: '',
  91. longitude: '',
  92. latitude: '',
  93. name: '',
  94. phone: '',
  95. mechanism: '',
  96. title: '选择机构',
  97. show: false,
  98. list: [],
  99. initSelected: [],
  100. searchVal: '',
  101. address: '',
  102. certificates: '',
  103. loding: false, //是否提交中
  104. showaddress: '', //显示用的地址
  105. count: 0,
  106. peoplelist: [],
  107. addressData: {
  108. name: '',
  109. mobile: '',
  110. latitude: 0, //纬度
  111. longitude: 0, //经度
  112. address: {
  113. province: '',
  114. city: '',
  115. district: '',
  116. detail: ''
  117. },
  118. area: '',
  119. default: false
  120. },
  121. chooseMechanismList: [], //供选择的机构列表
  122. mechanismList: [], //完整机构列表
  123. volunteer_id: '', //志愿者标号
  124. institution_id: '', //机构id
  125. };
  126. },
  127. onLoad() {
  128. let obj = this;
  129. obj.name = obj.userInfo.nickname || ''
  130. obj.phone = obj.userInfo.mobile
  131. console.log('开始加载事件');
  132. },
  133. computed: {
  134. ...mapState('user', ['hasLogin', 'userInfo']),
  135. },
  136. onShow() {
  137. this.loadData();
  138. this.getApplyList()
  139. this.getMechanismList()
  140. if (this.hasLogin) {} else {
  141. saveUrl();
  142. uni.showModal({
  143. title: '登录',
  144. content: '您未登录,是否马上登陆?',
  145. success: e => {
  146. if (e.confirm) {
  147. interceptor();
  148. }
  149. },
  150. fail: e => {
  151. console.log(e);
  152. }
  153. });
  154. }
  155. },
  156. watch: {
  157. searchVal() {
  158. this.ListDate();
  159. }
  160. },
  161. methods: {
  162. getApplyList() {
  163. getApplyList().then(res => {
  164. console.log(res,'getApplyList')
  165. })
  166. },
  167. // 获取救援者列表
  168. getRescuerList(lat, lon) {
  169. getRescuerList({
  170. page: 1,
  171. limit: 20,
  172. latitude: lat,
  173. longitude: lon,
  174. }).then(res => {
  175. console.log(res, 'getRescuerList++++++++++')
  176. this.peoplelist = res.data
  177. })
  178. },
  179. // 获取机构
  180. getMechanismList() {
  181. getMechanismList().then(({
  182. data
  183. }) => {
  184. this.mechanismList = data
  185. if (data) {
  186. this.chooseMechanismList = data.map(item => {
  187. return item.name
  188. })
  189. }
  190. })
  191. },
  192. // 选择机构
  193. bindPickerChange(e) {
  194. this.mechanism = this.chooseMechanismList[e.detail.value]
  195. this.institution_id = this.mechanismList[e.detail.value].id
  196. },
  197. applyRescuer() {
  198. let obj = this
  199. if (obj.name == '') {
  200. obj.$api.msg('请输入您的姓名');
  201. return;
  202. }
  203. const reg = /^(\+?0?86-?)?1[\d]\d{9}$/;
  204. if (!reg.test(obj.phone)) {
  205. obj.$api.msg('请填写正确的手机号码');
  206. return;
  207. }
  208. if (obj.showaddress == '') {
  209. obj.$api.msg('请选择您的所在地区');
  210. return;
  211. }
  212. if (obj.mechanism == '') {
  213. obj.$api.msg('请选择机构');
  214. return;
  215. }
  216. if (obj.certificates == '') {
  217. obj.$api.msg('请上传救护员证书或身份证');
  218. return;
  219. }
  220. let data = {
  221. name: obj.name,
  222. phone: obj.phone,
  223. institution_id: obj.institution_id,
  224. volunteer_id: obj.volunteer_id,
  225. address: obj.showaddress,
  226. latitude: obj.addressData.latitude,
  227. longitude: obj.addressData.longitude,
  228. certificateimage: obj.certificates
  229. }
  230. applyRescuer(data).then(res => {
  231. console.log(res, '申请+++++++++')
  232. obj.loding = false;
  233. uni.navigateTo({
  234. url: '../joinSuc/joinNow'
  235. });
  236. })
  237. },
  238. async loadData() {
  239. let obj = this;
  240. // obj.getRescuerList()
  241. obj.getLocal()
  242. },
  243. // 选择当前位置
  244. getLocation() {
  245. console.log('选择当前位置');
  246. let obj = this;
  247. // let wxOjb = require('jweixin-module');
  248. uni.chooseLocation({
  249. success: function(res) {
  250. console.log(res)
  251. obj.addressData.area = res.name;
  252. console.log('位置名称:' + res.name);
  253. console.log('详细地址:' + res.address);
  254. console.log('纬度:' + res.latitude);
  255. console.log('经度:' + res.longitude);
  256. obj.addressData.latitude = res.latitude;
  257. obj.addressData.longitude = res.longitude;
  258. // let dizhi = obj.addressData.latitude + ','+ obj.addressData.longitude;
  259. obj.showaddress = res.address;
  260. }
  261. });
  262. },
  263. onChange(val) {
  264. let obj = this;
  265. console.log(val, 'onChange');
  266. },
  267. onSearchInput(val) {
  268. this.searchVal = val.value;
  269. },
  270. // 上传图片
  271. imgsub() {
  272. console.log('imgsub');
  273. upload({
  274. filename: ''
  275. }).then(data => {
  276. this.certificates = data[0].fullurl;
  277. });
  278. },
  279. // 获取本地坐标
  280. getLocal() {
  281. let obj = this;
  282. let wxOjb = require('jweixin-module');
  283. wxOjb.ready(()=> {
  284. uni.getLocation({
  285. type: 'gcj02',
  286. success(e) {
  287. console.log(e)
  288. obj.latitude4 = Math.abs(e.latitude)
  289. obj.longitude4 = Math.abs(e.longitude)
  290. obj.getRescuerList(obj.latitude4,obj.longitude4)
  291. },
  292. fail(err) {
  293. obj.getLocal()
  294. }
  295. })
  296. })
  297. }
  298. }
  299. };
  300. </script>
  301. <style lang="scss">
  302. page {
  303. // background-color: #FD3B34;
  304. background-image: url();
  305. }
  306. .content {
  307. line-height: 1;
  308. // background-color: #FD3B34;
  309. .top {
  310. width: 750rpx;
  311. margin: 0 0 -150rpx;
  312. .bgi {
  313. display: block;
  314. width: 750rpx;
  315. height: 609rpx;
  316. // margin: 53rpx auto;
  317. // position: relative;
  318. // top: -20rpx;
  319. }
  320. }
  321. .top-xtitle {
  322. font-size: 65rpx;
  323. font-family: Microsoft YaHei;
  324. font-weight: bold;
  325. color: #FFFFFF;
  326. line-height: 110rpx;
  327. // text-shadow: 0px 5px 8px rgba(96, 1, 0, 0.61);
  328. text-align: center;
  329. }
  330. .top-title {
  331. font-size: 85rpx;
  332. font-family: PingFang SC;
  333. font-weight: bold;
  334. color: #FD424B;
  335. font-family: Microsoft YaHei;
  336. font-weight: bold;
  337. color: #FFFFFF;
  338. line-height: 110rpx;
  339. // text-shadow: 0px 5px 8px rgba(96, 1, 0, 0.61);
  340. text-align: center;
  341. padding-bottom: 69rpx;
  342. }
  343. .pop-box {
  344. padding-top: 31rpx;
  345. margin: 0 auto;
  346. position: relative;
  347. z-index: 99;
  348. width: 156rpx;
  349. height: 36rpx;
  350. font-size: 38rpx;
  351. font-family: PingFang SC;
  352. font-weight: bold;
  353. color: #000;
  354. &::before {
  355. content: '';
  356. width: 220rpx;
  357. height: 17rpx;
  358. background: rgba(254, 166, 78, 1);
  359. opacity: 0.26;
  360. position: absolute;
  361. bottom: -35rpx;
  362. left: -40rpx;
  363. }
  364. }
  365. .red-box {
  366. padding-top: 31rpx;
  367. margin: 0 auto;
  368. position: relative;
  369. z-index: 99;
  370. width: 300rpx;
  371. text-align: center;
  372. height: 36rpx;
  373. font-size: 38rpx;
  374. font-family: PingFang SC;
  375. font-weight: bold;
  376. color: #000;
  377. &::after {
  378. content: '';
  379. width: 300rpx;
  380. height: 17rpx;
  381. background: rgba(254, 166, 78, 1);
  382. opacity: 0.26;
  383. position: absolute;
  384. bottom: -35rpx;
  385. left: 0rpx;
  386. right: 0;
  387. margin: auto;
  388. }
  389. }
  390. .red-box2 {
  391. position: relative;
  392. width: 405rpx;
  393. line-height: 66rpx;
  394. text-align: center;
  395. // background: linear-gradient(0deg, #c90f1b, #f14d33);
  396. border-radius: 10rpx;
  397. font-size: 30rpx;
  398. font-weight: 500;
  399. color: #ffffff;
  400. margin: -80rpx auto 0;
  401. position: relative;
  402. z-index: 1;
  403. }
  404. .pop-list {
  405. width: 686rpx;
  406. background: #ffffff;
  407. border-radius: 29rpx;
  408. position: relative;
  409. margin: -33rpx auto 78rpx;
  410. padding: 150rpx 0rpx 30rpx 30rpx;
  411. display: flex;
  412. flex-wrap: wrap;
  413. // box-shadow: 0px 10rpx 20rpx 0px rgba(254, 0, 8, 0.28);
  414. .list-box1 {
  415. text-align: center;
  416. margin-right: 30rpx;
  417. margin-bottom: 30rpx;
  418. .list-top {
  419. width: 100rpx;
  420. height: 100rpx;
  421. .avatar-img {
  422. width: 100rpx;
  423. height: 100rpx;
  424. border-radius: 50%;
  425. }
  426. }
  427. .nickname {
  428. margin-top: 12rpx;
  429. }
  430. }
  431. }
  432. .list-box {
  433. width: 686rpx;
  434. background: #ffffff;
  435. border-radius: 29rpx;
  436. position: relative;
  437. margin: -33rpx auto 0;
  438. padding: 100rpx 30rpx 0rpx 30rpx;
  439. display: flex;
  440. flex-wrap: wrap;
  441. // box-shadow: 0px 10rpx 20rpx 0px rgba(254, 0, 8, 0.28);
  442. .upload-box {
  443. width: 100%;
  444. height: 290rpx;
  445. background: #ffffff;
  446. // border: 1px solid #E63931;
  447. border-radius: 15rpx;
  448. display: flex;
  449. flex-direction: column;
  450. padding-top: 24rpx;
  451. margin: 0 auto 50rpx;
  452. .upload-left {
  453. font-weight: 400;
  454. color: #000;
  455. text {
  456. color: #FD424B;
  457. font-size: 30rpx;
  458. }
  459. }
  460. .upload-right {
  461. margin-top: 16rpx;
  462. width: 100%;
  463. height: 100%;
  464. border: 1px solid #888888;
  465. border-radius: 15rpx;
  466. flex: 1;
  467. display: flex;
  468. align-items: center;
  469. justify-content: center;
  470. .upload-img {
  471. width: 102rpx;
  472. height: 102rpx;
  473. // border: 1px solid #888888;
  474. // border-radius: 3rpx;
  475. // width: 133rpx;
  476. // height: 133rpx;
  477. // margin-top: 44rpx;
  478. }
  479. }
  480. }
  481. .list {
  482. display: flex;
  483. flex-direction: column;
  484. align-items: center;
  485. width: 100%;
  486. margin-top: 32rpx;
  487. // height: 133rpx;
  488. .list-left {
  489. width: 100%;
  490. text-align: left;
  491. color: #000;
  492. text {
  493. color: #FD424B;
  494. font-size: 30rpx;
  495. }
  496. }
  497. input {
  498. height: 66rpx;
  499. // line-height: 66rpx;
  500. margin-top: 32rpx;
  501. // height: 88rpx;
  502. }
  503. .list-input {
  504. padding-left: 24rpx;
  505. // margin: 12rpx 0 ;
  506. height: 66rpx;
  507. line-height: 66rpx;
  508. // display: flex;
  509. // align-items: center;
  510. width: 100%;
  511. font-size: 26rpx;
  512. // flex: 1;
  513. color: #000;
  514. border: 1rpx solid #929292;
  515. border-radius: 15rpx;
  516. text-align: left;
  517. .input-placeholder {
  518. // height: 70rpx;
  519. color: #929292;
  520. font-size: 26rpx;
  521. }
  522. }
  523. .box-right {
  524. display: flex;
  525. align-items: center;
  526. padding-left: 24rpx;
  527. height: 66rpx;
  528. line-height: 66rpx;
  529. border: 1rpx solid #f3afad;
  530. border-radius: 22rpx;
  531. margin: 32rpx 36rpx 0 36rpx;
  532. width: 96%;
  533. font-size: 36rpx;
  534. color: #ff9797;
  535. text-align: left;
  536. line-height: 1;
  537. }
  538. }
  539. }
  540. .sub {
  541. width: 690rpx;
  542. height: 83rpx;
  543. background: #f95349;
  544. border-radius: 42rpx;
  545. font-size: 32rpx;
  546. font-family: PingFang SC;
  547. font-weight: 500;
  548. color: #FFFFFF;
  549. line-height: 83rpx;
  550. text-align: center;
  551. margin: 53rpx auto 60rpx;
  552. &.action {
  553. background: #999999;
  554. }
  555. }
  556. }
  557. </style>