category.vue 12 KB

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