rescuers.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <template>
  2. <view class="container">
  3. <image src="https://sos.liuniu946.com/static/img/img010.png"></image>
  4. <view class="label-item">
  5. <view class="content-box">
  6. <view class="tip"><image src="/static/img/img012.png"></image></view>
  7. <view class="number">参与人数{{total}}人</view>
  8. <view class="list flex_item">
  9. <view class="list-item" v-if="list.length > 0" v-for="ls in list">
  10. <view class="portrait"><image :src="ls.avatar"></image></view>
  11. <view class="name clamp">{{ls.helper_name}}</view>
  12. </view>
  13. <view class="noDate" v-if="list.length == 0">暂无数据</view>
  14. </view>
  15. </view>
  16. <view class="content-box" v-if="userInfo.helper == 0">
  17. <view class="tip"><image src="/static/img/img012.png"></image></view>
  18. <view class="number">报名参与</view>
  19. <view class="list">
  20. <view class="list-input flex_item">
  21. <view class="lable">姓名:</view>
  22. <view><input class="input-box" type="text" v-model="name" placeholder="请输入您的姓名" /></view>
  23. </view>
  24. <view class="list-input flex_item">
  25. <view class="lable">手机:</view>
  26. <view><input class="input-box" type="number" v-model="phone" placeholder="请填写您的联系方式" /></view>
  27. </view>
  28. <view class="list-input flex_item" @click="getLocation">
  29. <view class="lable">地址:</view>
  30. <view class="address">{{addressDate}}</view>
  31. </view>
  32. <view class="list-input flex_item" @click="ToKey">
  33. <view class="lable">机构:</view>
  34. <view class="flex seach-box">
  35. <input class="input-box" type="text" v-model="mechanism" placeholder='请输入机构关键字'/>
  36. </view>
  37. </view>
  38. <view class="list-input">
  39. <view class="lable">证件:</view>
  40. <view class="icon">
  41. <image class="image" v-show="img1" :src="image" @click="scImg"></image>
  42. <image class="image1" v-show="img2" :src="image2" @click="scImg" mode="widthFix"></image>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="btn" v-if="userInfo.helper == 0"><view class="submit" @click="BeHelper">马上报名</view></view>
  48. <view class="text-box" v-if="userInfo.helper == 1">您已经是一名救援者了!</view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import { mapState,mapMutations } from 'vuex';
  54. import { upload,toBeHelper,hospitalList,getAllHelper } from '@/api/record.js';
  55. import pickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
  56. import LbPicker from '@/components/lb-picker/index.vue'
  57. // #ifdef MP
  58. import { openMap } from '@/utils/rocessor.js';
  59. // #endif
  60. import { getUserInfo } from '@/api/login.js';
  61. export default {
  62. components: {
  63. pickerAddress,
  64. LbPicker
  65. },
  66. data() {
  67. return {
  68. userInfo:'',
  69. addressDate:'请选择定位地址',//选择定位地址
  70. total:'',
  71. img1:true,//图片1显示
  72. img2:false,//图片2显示
  73. list:'',//报名列表
  74. name:'',//姓名
  75. phone:'',//联系方式
  76. // addr:'',//省市区
  77. keyword:'',//机构关键字
  78. mechanism:'',//机构
  79. hospital_id:"",//机构id
  80. image:'/static/img/img013.png',//资格证
  81. image2:'',
  82. region:'',
  83. meList: [],//机构列表
  84. commonly_lat:'',//经度
  85. commonly_lng:'',//维度
  86. };
  87. },
  88. onLoad(option) {
  89. if(option.mechanism == '' || option.mechanism == undefined){
  90. this.mechanism = '';
  91. }else{
  92. this.mechanism = option.mechanism;
  93. }
  94. if(option.hospital_id == '' || option.hospital_id == undefined){
  95. this.hospital_id = '';
  96. }else{
  97. this.hospital_id = option.hospital_id;
  98. console.log(this.hospital_id)
  99. }
  100. },
  101. onShow() {
  102. this.GetUser();
  103. this.loadData();
  104. // addressDate:'请选择定位地址',//选择定位地址
  105. // name:'',//姓名
  106. // phone:'',//联系方式
  107. // image2:'',
  108. // commonly_lat:'',//经度
  109. // commonly_lng:'',//维度
  110. if(uni.getStorageSync('name')){
  111. this.name = uni.getStorageSync('name')
  112. }
  113. if(uni.getStorageSync('addressDate')){
  114. this.addressDate = uni.getStorageSync('addressDate')
  115. }
  116. if(uni.getStorageSync('phone')){
  117. this.phone = uni.getStorageSync('phone')
  118. }
  119. if(uni.getStorageSync('image2')){
  120. this.img1 = false;
  121. this.img2 = true;
  122. this.image2 = uni.getStorageSync('image2')
  123. }
  124. if(uni.getStorageSync('commonly_lat')){
  125. this.commonly_lat = uni.getStorageSync('commonly_lat')
  126. }
  127. if(uni.getStorageSync('commonly_lng')){
  128. this.commonly_lng = uni.getStorageSync('commonly_lng')
  129. }
  130. },
  131. //下拉刷新
  132. onPullDownRefresh() {
  133. this.loadData();
  134. this.GetUser();
  135. },
  136. watch:{
  137. meList(newValue, oldValue) {
  138. if(newValue != oldValue){
  139. this.mechanism = ''
  140. }
  141. },
  142. name(newValue, oldValue){
  143. if(newValue != oldValue){
  144. uni.setStorageSync('name', this.name);
  145. }
  146. },
  147. phone(newValue, oldValue){
  148. if(newValue != oldValue){
  149. uni.setStorageSync('phone', this.phone);
  150. console.log(uni.getStorageSync('phone'))
  151. }
  152. },
  153. addressDate(newValue, oldValue){
  154. if(newValue != oldValue){
  155. uni.setStorageSync('addressDate', this.addressDate);
  156. console.log(uni.getStorageSync('addressDate'))
  157. }
  158. },
  159. commonly_lat(newValue, oldValue){
  160. if(newValue != oldValue){
  161. uni.setStorageSync('commonly_lat', this.commonly_lat);
  162. console.log(uni.getStorageSync('commonly_lat'))
  163. }
  164. },
  165. commonly_lng(newValue, oldValue){
  166. if(newValue != oldValue){
  167. uni.setStorageSync('commonly_lng', this.commonly_lng);
  168. console.log(uni.getStorageSync('commonly_lng'))
  169. }
  170. },
  171. image2(newValue, oldValue){
  172. if(newValue != oldValue){
  173. uni.setStorageSync('image2', this.image2);
  174. console.log(uni.getStorageSync('image2'))
  175. }
  176. },
  177. },
  178. methods: {
  179. ...mapMutations(['setUserInfo']),
  180. GetUser(){
  181. let obj = this;
  182. getUserInfo({}).then(({ data }) => {
  183. obj.userInfo = data.user;
  184. console.log(obj.userInfo)
  185. obj.setUserInfo(obj.userInfo);
  186. }).catch((e) => {0
  187. console.log(e)
  188. });
  189. },
  190. ToKey(){
  191. let obj = this;
  192. uni.navigateTo({
  193. url:'/pages/rescuers/ToKey?mechanism='+this.mechanism
  194. })
  195. },
  196. // 请求载入数据
  197. loadData(){
  198. let obj = this;
  199. getAllHelper({}).then(({ data }) => {
  200. obj.total = data.total;
  201. obj.list = data.list
  202. uni.stopPullDownRefresh();
  203. // console.log(this.list)
  204. })
  205. },
  206. // 获取当前位置
  207. getLocation() {
  208. const obj = this;
  209. // #ifdef MP
  210. openMap().then(() => {
  211. uni.getLocation({
  212. type: 'gcj02',
  213. success(e) {
  214. uni.chooseLocation({
  215. latitude: e.latitude,
  216. longitude: e.longitude,
  217. success(e) {
  218. console.log(e)
  219. obj.commonly_lat = e.latitude;
  220. obj.commonly_lng = e.longitude;
  221. obj.addressDate = e.address;
  222. }
  223. });
  224. }
  225. });
  226. }).catch((e) => {
  227. uni.showModal({
  228. title: '提示',
  229. content: '您未授权无法调用地图定位功能!',
  230. showCancel: false,
  231. });
  232. })
  233. // #endif
  234. },
  235. //当键盘输入时,触发input事件
  236. onchance(e){
  237. this.keyword = e.detail.value;
  238. this.ListDate();
  239. this.handleTap('picker1');
  240. },
  241. //显示弹窗
  242. handleTap(name) {
  243. this.$refs[name].show();
  244. },
  245. //加载机构列表
  246. ListDate(){
  247. let obj = this;
  248. hospitalList({
  249. keyword:obj.keyword
  250. }).then(e => {
  251. obj.meList = e.data
  252. }).catch((e) => {
  253. console.log(e)
  254. });
  255. },
  256. handleChange (item) {
  257. },
  258. handleCancel (item) {
  259. },
  260. handleConfirm (item) {
  261. let obj = this;
  262. if(item != null){
  263. obj.keyword = item.item.name;
  264. obj.mechanism = item.item.name;
  265. obj.hospital_id = item.item.id;
  266. }else{
  267. obj.mechanism = '';
  268. obj.keyword = '';
  269. }
  270. },
  271. // // 选中城市切换
  272. // onCityClick({data}) {
  273. // this.region = data;
  274. // this.addr = this.region.map(item=>item.name).join('/');
  275. // this.code = this.region.map(item=>item.code).join('/');
  276. // this.ListDate();
  277. // },
  278. scImg() {
  279. let obj = this;
  280. upload({
  281. file: ''
  282. }).then(e => {
  283. obj.img1 = false;
  284. obj.img2 = true;
  285. obj.image2 = 'https://sos.liuniu946.com/'+e[0].url;
  286. }).catch((e) => {
  287. uni.showModal({
  288. title:'错误',
  289. content:e.message,
  290. })
  291. });
  292. },
  293. BeHelper(){
  294. let obj = this;
  295. if(!obj.name){
  296. obj.$api.msg('请填写姓名');
  297. return;
  298. }
  299. if(!obj.phone){
  300. obj.$api.msg('请填写联系方式');
  301. return;
  302. }
  303. if(obj.addressDate == '请选择地址'){
  304. obj.$api.msg('请选择地址');
  305. return;
  306. }
  307. console.log(obj.hospital_id)
  308. if(!obj.hospital_id){
  309. obj.$api.msg('请选择机构');
  310. return;
  311. }
  312. if(!obj.image2){
  313. obj.$api.msg('请上传资格证');
  314. return;
  315. }
  316. toBeHelper({
  317. // reason:'我自愿成为一名光荣的救援者!',
  318. // area_id:obj.code,
  319. name: obj.name,
  320. mobile:obj.phone,
  321. commonly_lat:obj.commonly_lat,
  322. commonly_lng:obj.commonly_lng,
  323. // area:obj.addr,//省市区
  324. commonly_address:obj.addressDate,
  325. hospital_id:obj.hospital_id,//机构
  326. credentials:obj.image2//资格证书
  327. }).then(e => {
  328. uni.showToast({
  329. title: e.msg,
  330. type: 'top',
  331. duration: 3000,
  332. icon: 'none'
  333. })
  334. setTimeout(function() {
  335. uni.switchTab({
  336. url: '/pages/user/user'
  337. })
  338. }, 3000);
  339. }).catch((e) => {
  340. uni.showToast({
  341. title: e.message,
  342. type: 'top',
  343. duration: 3000,
  344. icon: 'none'
  345. })
  346. setTimeout(function() {
  347. uni.switchTab({
  348. url: '/pages/user/user'
  349. })
  350. }, 3000);
  351. console.log(e)
  352. });
  353. },
  354. }
  355. };
  356. </script>
  357. <style lang="scss">
  358. page{
  359. width: 100%;
  360. background-color: #ffabab;
  361. height: 100%;
  362. .container{
  363. width: 100%;
  364. background-color: #ffabab;
  365. image{
  366. width: 100%;
  367. height: 927rpx;
  368. }
  369. .label-item{
  370. margin-top: -220rpx;
  371. margin-bottom: 80rpx;
  372. height: 100%;
  373. }
  374. }
  375. }
  376. .btn{
  377. width: 90%;
  378. margin: 25rpx auto;
  379. padding: 50rpx 0rpx;
  380. }
  381. .text-box{
  382. text-align: center;
  383. color: #FFFFFF;
  384. padding-top: 50rpx;
  385. padding-bottom: 100rpx;
  386. }
  387. .submit{
  388. border-radius: 50rpx;
  389. background:linear-gradient(0deg,rgba(231,57,50,1) 0%,rgba(254,78,78,1) 100%);
  390. text-align: center;
  391. padding: 30rpx 0rpx;
  392. color: #FFFFFF;
  393. }
  394. .content-box{
  395. position: relative;
  396. margin-bottom: 25rpx;
  397. .tip{
  398. width: 100%;
  399. height: 66rpx;
  400. text-align: center;
  401. z-index: 999;
  402. position: relative;
  403. top: 35rpx;
  404. image{
  405. width: 433rpx;
  406. height: 100%;
  407. z-index: 999;
  408. }
  409. }
  410. .number{
  411. position: absolute;
  412. color: #FFFFFF;
  413. top: 15rpx;
  414. text-align: center;
  415. width: 100%;
  416. z-index: 9999;
  417. padding-top: 25rpx;
  418. }
  419. .list{
  420. padding: 50rpx 40rpx;
  421. padding-right: 0rpx !important;
  422. padding-top: 80rpx;
  423. width: 92%;
  424. margin: 0rpx auto;
  425. min-height: 200rpx;
  426. background-color: #FFFFFF;
  427. border-radius: 25rpx;
  428. display: flex;
  429. flex-wrap: wrap;
  430. .noDate{
  431. width: 100%;
  432. text-align: center;
  433. font-size: 24rpx;
  434. }
  435. .list-item{
  436. width: 110rpx;
  437. text-align: center;
  438. color: #000000;
  439. font-size: 18rpx;
  440. margin-right: 20rpx;
  441. margin-top: 25rpx;
  442. .portrait{
  443. width: 110rpx;
  444. height: 110rpx;
  445. border-radius: 100%;
  446. image{
  447. width: 100%;
  448. height: 100%;
  449. border-radius: 100%;
  450. }
  451. }
  452. .name{
  453. margin-top: 10rpx;
  454. width: 110rpx;
  455. font-size: 17rpx;
  456. }
  457. }
  458. }
  459. }
  460. .seach-box{
  461. width: 82%;
  462. }
  463. .seach{
  464. width: 50rpx;
  465. height: 50rpx;
  466. .seach-icon{
  467. width: 50rpx;
  468. height: 50rpx;
  469. }
  470. }
  471. .address{
  472. font-size: 24rpx !important;
  473. color: #FF9797 !important;
  474. width: 80%;
  475. }
  476. .list-input{
  477. border: 2rpx solid #E73932;
  478. border-radius: 50rpx;
  479. padding: 25rpx 40rpx;
  480. margin-bottom: 35rpx;
  481. width: 92%;
  482. .lable{
  483. color: #E73932;
  484. font-size: 31rpx;
  485. }
  486. .input{
  487. color: #FF9797 !important;
  488. font-size: 24rpx !important;
  489. }
  490. .icon{
  491. margin: 25rpx auto;
  492. min-height: 140rpx;
  493. text-align: center;
  494. .image{
  495. width: 114rpx;
  496. height: 114rpx;
  497. }
  498. .image1{
  499. min-width: 114rpx;
  500. min-height: 114rpx;
  501. }
  502. }
  503. }
  504. .input-placeholder{
  505. color: #FF9797 !important;
  506. font-size: 28rpx;
  507. }
  508. .input-box{
  509. color: #FF9797 !important;
  510. font-size: 28rpx !important;
  511. width: 85%;
  512. }
  513. </style>