category.vue 12 KB

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