category.vue 12 KB

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