category.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. <image src="../../static/img/xn-jhy.png" mode="" 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 clamp">{{ 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.username || ''
  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. .bgi {
  312. display: block;
  313. width: 750rpx;
  314. height: 609rpx;
  315. // width: rpx;
  316. // height: 678rpx;
  317. // width:;
  318. // margin: 53rpx auto;
  319. // position: relative;
  320. // top: -20rpx;
  321. }
  322. }
  323. .top-xtitle {
  324. font-size: 65rpx;
  325. font-family: Microsoft YaHei;
  326. font-weight: bold;
  327. color: #FFFFFF;
  328. line-height: 110rpx;
  329. text-shadow: 0px 5px 8px rgba(96, 1, 0, 0.61);
  330. text-align: center;
  331. }
  332. .top-title {
  333. font-size: 85rpx;
  334. font-family: PingFang SC;
  335. font-weight: bold;
  336. color: #FD424B;
  337. font-family: Microsoft YaHei;
  338. font-weight: bold;
  339. color: #FFFFFF;
  340. line-height: 110rpx;
  341. text-shadow: 0px 5px 8px rgba(96, 1, 0, 0.61);
  342. text-align: center;
  343. padding-bottom: 69rpx;
  344. }
  345. .pop-box {
  346. padding-top: 31rpx;
  347. margin: -100rpx auto 0;
  348. position: relative;
  349. z-index: 99;
  350. width: 156rpx;
  351. height: 36rpx;
  352. font-size: 38rpx;
  353. font-family: PingFang SC;
  354. font-weight: bold;
  355. color: #000;
  356. &::before {
  357. content: '';
  358. width: 220rpx;
  359. height: 17rpx;
  360. background: rgba(254, 166, 78, 1);
  361. opacity: 0.26;
  362. position: absolute;
  363. bottom: -35rpx;
  364. left: -40rpx;
  365. }
  366. }
  367. .red-box {
  368. padding-top: 31rpx;
  369. margin: 0 auto;
  370. position: relative;
  371. z-index: 99;
  372. width: 300rpx;
  373. text-align: center;
  374. height: 36rpx;
  375. font-size: 38rpx;
  376. font-family: PingFang SC;
  377. font-weight: bold;
  378. color: #000;
  379. &::after {
  380. content: '';
  381. width: 300rpx;
  382. height: 17rpx;
  383. background: rgba(254, 166, 78, 1);
  384. opacity: 0.26;
  385. position: absolute;
  386. bottom: -35rpx;
  387. left: 0rpx;
  388. right: 0;
  389. margin: auto;
  390. }
  391. }
  392. .red-box2 {
  393. position: relative;
  394. width: 405rpx;
  395. line-height: 66rpx;
  396. text-align: center;
  397. background: linear-gradient(0deg, #c90f1b, #f14d33);
  398. border-radius: 10rpx;
  399. font-size: 30rpx;
  400. font-weight: 500;
  401. color: #ffffff;
  402. margin: -80rpx auto 0;
  403. position: relative;
  404. z-index: 1;
  405. }
  406. .pop-list {
  407. width: 686rpx;
  408. background: #ffffff;
  409. border-radius: 29rpx;
  410. position: relative;
  411. margin: -33rpx auto 78rpx;
  412. padding: 150rpx 0rpx 30rpx 30rpx;
  413. display: flex;
  414. flex-wrap: wrap;
  415. // box-shadow: 0px 10rpx 20rpx 0px rgba(254, 0, 8, 0.28);
  416. .list-box1 {
  417. text-align: center;
  418. margin-right: 30rpx;
  419. margin-bottom: 30rpx;
  420. .list-top {
  421. width: 100rpx;
  422. height: 100rpx;
  423. .avatar-img {
  424. width: 100rpx;
  425. height: 100rpx;
  426. border-radius: 50%;
  427. }
  428. }
  429. .nickname {
  430. margin-top: 12rpx;
  431. }
  432. }
  433. }
  434. .list-box {
  435. width: 686rpx;
  436. background: #ffffff;
  437. border-radius: 29rpx;
  438. position: relative;
  439. margin: -33rpx auto 0;
  440. padding: 100rpx 30rpx 0rpx 30rpx;
  441. display: flex;
  442. flex-wrap: wrap;
  443. // box-shadow: 0px 10rpx 20rpx 0px rgba(254, 0, 8, 0.28);
  444. .upload-box {
  445. width: 100%;
  446. height: 290rpx;
  447. background: #ffffff;
  448. // border: 1px solid #E63931;
  449. border-radius: 15rpx;
  450. display: flex;
  451. flex-direction: column;
  452. padding-top: 24rpx;
  453. margin: 0 auto 50rpx;
  454. .upload-left {
  455. font-weight: 400;
  456. color: #000;
  457. text {
  458. color: #FD424B;
  459. font-size: 30rpx;
  460. }
  461. }
  462. .upload-right {
  463. margin-top: 16rpx;
  464. width: 100%;
  465. height: 100%;
  466. border: 1px solid #888888;
  467. border-radius: 15rpx;
  468. flex: 1;
  469. display: flex;
  470. align-items: center;
  471. justify-content: center;
  472. .upload-img {
  473. width: 102rpx;
  474. height: 102rpx;
  475. // border: 1px solid #888888;
  476. // border-radius: 3rpx;
  477. // width: 133rpx;
  478. // height: 133rpx;
  479. // margin-top: 44rpx;
  480. }
  481. }
  482. }
  483. .list {
  484. display: flex;
  485. flex-direction: column;
  486. align-items: center;
  487. width: 100%;
  488. margin-top: 32rpx;
  489. // height: 133rpx;
  490. .list-left {
  491. width: 100%;
  492. text-align: left;
  493. color: #000;
  494. text {
  495. color: #FD424B;
  496. font-size: 30rpx;
  497. }
  498. }
  499. input {
  500. height: 66rpx;
  501. // line-height: 66rpx;
  502. margin-top: 32rpx;
  503. // height: 88rpx;
  504. }
  505. .list-input {
  506. padding-left: 24rpx;
  507. // margin: 12rpx 0 ;
  508. height: 66rpx;
  509. line-height: 66rpx;
  510. // display: flex;
  511. // align-items: center;
  512. width: 100%;
  513. font-size: 26rpx;
  514. // flex: 1;
  515. color: #000;
  516. border: 1rpx solid #929292;
  517. border-radius: 15rpx;
  518. text-align: left;
  519. .input-placeholder {
  520. // height: 70rpx;
  521. color: #929292;
  522. font-size: 26rpx;
  523. }
  524. }
  525. .box-right {
  526. display: flex;
  527. align-items: center;
  528. padding-left: 24rpx;
  529. height: 66rpx;
  530. line-height: 66rpx;
  531. border: 1rpx solid #f3afad;
  532. border-radius: 22rpx;
  533. margin: 32rpx 36rpx 0 36rpx;
  534. width: 96%;
  535. font-size: 36rpx;
  536. color: #ff9797;
  537. text-align: left;
  538. line-height: 1;
  539. }
  540. }
  541. }
  542. .sub {
  543. width: 690rpx;
  544. height: 83rpx;
  545. background: #f95349;
  546. border-radius: 42rpx;
  547. font-size: 32rpx;
  548. font-family: PingFang SC;
  549. font-weight: 500;
  550. color: #FFFFFF;
  551. line-height: 83rpx;
  552. text-align: center;
  553. margin: 53rpx auto 60rpx;
  554. &.action {
  555. background: #999999;
  556. }
  557. }
  558. }
  559. </style>