category.vue 13 KB

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