category.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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: 20rpx;">
  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: 20rpx;
  322. .sub {
  323. width: 660rpx;
  324. line-height: 100rpx;
  325. background: linear-gradient(0deg, #C90F1B, #F14D33);
  326. border-radius: 50rpx;
  327. font-size: 36rpx;
  328. font-weight: 400;
  329. color: #FFFFFF;
  330. text-align: center;
  331. margin: 60rpx auto 0;
  332. &.action {
  333. background: #999999;
  334. }
  335. }
  336. .top {
  337. width: 750rpx;
  338. .bgi {
  339. width: 750rpx;
  340. }
  341. }
  342. .pop-box {
  343. width: 405rpx;
  344. line-height: 66rpx;
  345. text-align: center;
  346. background: linear-gradient(0deg, #C90F1B, #F14D33);
  347. border-radius: 10rpx;
  348. font-size: 30rpx;
  349. font-weight: 500;
  350. color: #FFFFFF;
  351. margin: -110rpx auto 0;
  352. position: relative;
  353. z-index: 1;
  354. }
  355. .red-box {
  356. width: 405rpx;
  357. line-height: 66rpx;
  358. text-align: center;
  359. background: linear-gradient(0deg, #C90F1B, #F14D33);
  360. border-radius: 10rpx;
  361. font-size: 30rpx;
  362. font-weight: 500;
  363. color: #FFFFFF;
  364. margin: 0rpx auto 0;
  365. position: relative;
  366. z-index: 1;
  367. }
  368. .red-box2 {
  369. position: relative;
  370. width: 405rpx;
  371. line-height: 66rpx;
  372. text-align: center;
  373. background: linear-gradient(0deg, #C90F1B, #F14D33);
  374. border-radius: 10rpx;
  375. font-size: 30rpx;
  376. font-weight: 500;
  377. color: #FFFFFF;
  378. margin: -80rpx auto 0;
  379. position: relative;
  380. z-index: 1;
  381. }
  382. .pop-list {
  383. width: 686rpx;
  384. background: #FFFFFF;
  385. border-radius: 29rpx;
  386. position: relative;
  387. margin: -33rpx auto 78rpx;
  388. padding: 80rpx 0rpx 30rpx 30rpx;
  389. display: flex;
  390. flex-wrap: wrap;
  391. .list-box1 {
  392. text-align: center;
  393. margin-right: 30rpx;
  394. margin-bottom: 30rpx;
  395. .list-top {
  396. width: 100rpx;
  397. height: 100rpx;
  398. .avatar-img {
  399. width: 100rpx;
  400. height: 100rpx;
  401. border-radius: 50%;
  402. }
  403. }
  404. .nickname {
  405. margin-top: 12rpx;
  406. }
  407. }
  408. }
  409. .list-box {
  410. width: 686rpx;
  411. background: #FFFFFF;
  412. border-radius: 29rpx;
  413. position: relative;
  414. margin: -33rpx auto;
  415. padding: 100rpx 30rpx 0rpx 30rpx;
  416. display: flex;
  417. flex-wrap: wrap;
  418. .upload-box {
  419. width: 100%;
  420. height: 247rpx;
  421. background: #FFFFFF;
  422. // border: 1px solid #E63931;
  423. border-radius: 27rpx;
  424. display: flex;
  425. flex-direction: column;
  426. padding: 30rpx 40rpx 30rpx 0;
  427. margin: 0 auto 30rpx;
  428. .upload-left {
  429. font-weight: 400;
  430. color: #E63931;
  431. }
  432. .upload-right {
  433. flex: 1;
  434. display: flex;
  435. align-items: center;
  436. justify-content: center;
  437. .upload-img {
  438. width: 133rpx;
  439. height: 133rpx;
  440. margin-top: 44rpx;
  441. }
  442. }
  443. }
  444. .list {
  445. display: flex;
  446. flex-direction: column;
  447. align-items: center;
  448. width: 100%;
  449. margin-top: 32rpx;
  450. // height: 133rpx;
  451. .list-left {
  452. width: 100%;
  453. text-align: left;
  454. color: #E63931;
  455. }
  456. input {
  457. height: 66rpx;
  458. line-height: 66rpx;
  459. margin-top: 32rpx;
  460. // height: 88rpx;
  461. }
  462. .list-input {
  463. display: inline-block;
  464. padding-left: 24rpx;
  465. // margin: 12rpx 0 ;
  466. width: 100%;
  467. font-size: 36rpx;
  468. flex: 1;
  469. color: #FF9797;
  470. border: 1rpx solid #f3afad;
  471. border-radius: 22rpx;
  472. text-align: left;
  473. padding-right: 24rpx;
  474. height: 100rpx !important;
  475. // background-color: red;
  476. .input-placeholder {
  477. height: 70rpx;
  478. color: #FF9797;
  479. }
  480. }
  481. .box-right {
  482. display: flex;
  483. align-items: center;
  484. padding-left: 24rpx;
  485. height: 66rpx;
  486. line-height: 66rpx;
  487. border: 1rpx solid #f3afad;
  488. border-radius: 22rpx;
  489. margin: 32rpx 36rpx 0 36rpx;
  490. width: 96%;
  491. font-size: 36rpx;
  492. color: #FF9797;
  493. text-align: left;
  494. // line-height: 1;
  495. }
  496. }
  497. }
  498. }
  499. /deep/ .uni-input-input, .uni-input {
  500. height: 70rpx;
  501. line-height: 70rpx;
  502. }
  503. </style>