yypz.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. <template>
  2. <view class="content">
  3. <view class="top" v-if="!show"><image class="top-bg" src="../../static/img/dbbg.png" mode=""></image></view>
  4. <scroll-view scroll-y="true" class="scrollList" :style="{ height: height }">
  5. <view class="main">
  6. <view class="info-item flex">
  7. <view class="info-left">陪诊类型</view>
  8. <view class="info-right">
  9. <picker @change="bindPickerType" :value="index" :range="pzTypelist" range-key="name">
  10. <view>{{ pzType.name }}</view>
  11. </picker>
  12. </view>
  13. </view>
  14. <view class="info-item flex">
  15. <view class="info-left">基础费用</view>
  16. <view class="info-right">¥{{ pzType.price }}</view>
  17. </view>
  18. <view class="info-item flex" v-if="cardprice > 0">
  19. <view class="info-left">优惠卡优惠</view>
  20. <view class="info-right">-¥{{ cardprice }}</view>
  21. </view>
  22. <view class="info-item flex">
  23. <view class="info-left">预约日期</view>
  24. <view class="info-right">
  25. <picker mode="date" :start="startDate" :end="endDate" :value="date" @change="bindDateChange" class="box-right">
  26. <view>{{ date }}</view>
  27. </picker>
  28. </view>
  29. </view>
  30. <view class="info-item flex">
  31. <view class="info-left">预约时间</view>
  32. <view class="info-right">
  33. <picker mode="time" :value="time" @change="bindTimeChange" class="box-right">
  34. <view>{{ time }}</view>
  35. </picker>
  36. </view>
  37. </view>
  38. <view class="info-item flex">
  39. <view class="info-left">姓名</view>
  40. <view class="info-right"><input class="list-input" type="text" v-model="name" placeholder="请填写姓名" /></view>
  41. </view>
  42. <view class="info-item flex">
  43. <view class="info-left">年龄</view>
  44. <view class="info-right"><input class="list-input" type="number" v-model="age" placeholder="请填写年龄" /></view>
  45. </view>
  46. <view class="info-item flex">
  47. <view class="info-left">性别</view>
  48. <view class="info-right">
  49. <picker @change="bindPickerSex" :value="index" :range="array">
  50. <view>{{ sex }}</view>
  51. </picker>
  52. </view>
  53. </view>
  54. <view class="info-item flex">
  55. <view class="info-left">联系电话</view>
  56. <view class="info-right"><input class="list-input" type="number" v-model="phone" placeholder="请填写联系电话" /></view>
  57. </view>
  58. <view class="info-item flex" @tap="Toshow">
  59. <view class="info-left">陪诊医院</view>
  60. <view class="info-right">{{ hospital || '请选择医院名称' }}</view>
  61. </view>
  62. <zhilin-picker
  63. v-model="show"
  64. :title="title"
  65. :data="list"
  66. :initSelected="initSelected"
  67. :showSearch="true"
  68. @change="onChange"
  69. @searchInput="onSearchInput"
  70. @confirm="onConfirm1"
  71. @shua="shua"
  72. />
  73. <view class="info-item flex">
  74. <view class="info-left">紧急联系人姓名</view>
  75. <view class="info-right"><input class="list-input" type="text" v-model="jjname" placeholder="请填写紧急联系人姓名" /></view>
  76. </view>
  77. <view class="info-item flex">
  78. <view class="info-left">紧急联系人电话</view>
  79. <view class="info-right"><input class="list-input" type="number" v-model="jjphone" placeholder="请填写紧急联系人电话" /></view>
  80. </view>
  81. <view class="info-type">
  82. <view class="info-type-title">
  83. 服务项目
  84. <text class="info-type-tip">(可多选)</text>
  85. </view>
  86. <view class="info-type-main">
  87. <view class="info-type-main-item" :class="{ current: item.chose == 2 }" v-for="(item, index) in typelist" :key="index" @click="choose(item)">
  88. {{ item.name }}
  89. <text>¥{{ item.price }}</text>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="info-item flex" v-if="type == 2">
  94. <text class="info-left">上门接送地址</text>
  95. <view class="info-right">
  96. <pickerAddress class="input" @change="onCityClick">{{ addressDetail || '请选择地址' }}</pickerAddress>
  97. </view>
  98. </view>
  99. <view class="info-item flex" v-if="type == 2">
  100. <view class="info-left">详细地址</view>
  101. <view class="info-right"><input class="list-input" type="text" v-model="addressD" placeholder="请填写详细地址" /></view>
  102. </view>
  103. </view>
  104. <view class="info-bz">
  105. <view class="info-type-title">
  106. 备注说明
  107. <text class="info-type-tip">(选填)</text>
  108. </view>
  109. <textarea v-model="remarks" class="text-box" name="" id="" cols="30" rows="10"></textarea>
  110. </view>
  111. </scroll-view>
  112. <view class="btn" @click="buy()">立即下单(¥{{ price }})</view>
  113. <uni-popup ref="popup" type="center">
  114. <view class="popup-box">
  115. <view class="img"><image src="../../static/img/popup.png" mode=""></image></view>
  116. <view class="mian">
  117. <view class="title">暂不提供跨区域接送服务</view>
  118. <view class="nocancel">您所在的地区与医院所在地区不符合请重新填写</view>
  119. <view class="comfirm-box" @click="cancel">知道了</view>
  120. </view>
  121. </view>
  122. </uni-popup>
  123. </view>
  124. </template>
  125. <script>
  126. import { cate, service, getHospitalList, equity } from '@/api/index.js';
  127. import { Diagnosisconfirm } from '@/api/order.js';
  128. import pickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
  129. import zhilinPicker from '@/components/zhilin-picker/zhilin-picker.vue';
  130. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  131. export default {
  132. components: {
  133. pickerAddress,
  134. uniPopup
  135. },
  136. data() {
  137. return {
  138. type: 1,
  139. price: 0,
  140. height: '0px',
  141. id: '',
  142. cardprice: '',
  143. index: '',
  144. pzType: '', //陪诊类型
  145. pzTypelist: [],
  146. date: '请选择预约日期',
  147. time: '请选择预约时间',
  148. name: '',
  149. age: '',
  150. array: ['男', '女'],
  151. sex: '请选择你的性别',
  152. phone: '',
  153. jjname: '',
  154. jjphone: '',
  155. show: false,
  156. initSelected: [],
  157. title: '选择医院',
  158. hospital: '', //医院
  159. list: [], //医院列表
  160. typelist: [],
  161. addressD: '',
  162. addressDetail: '',
  163. addr: '',
  164. address: {
  165. province: '',
  166. city: '',
  167. district: ''
  168. },
  169. remarks: '',
  170. province: '',
  171. city: '',
  172. hospital_id: '',
  173. searchVal: '',
  174. page: 1,
  175. cardList: []
  176. };
  177. },
  178. onReady(res) {
  179. var _this = this;
  180. uni.getSystemInfo({
  181. success: resu => {
  182. const query = uni.createSelectorQuery();
  183. query.select('.scrollList').boundingClientRect();
  184. query.exec(function(res) {
  185. _this.height = resu.windowHeight - res[0].top + 'px';
  186. console.log('打印页面的剩余高度', _this.height);
  187. });
  188. },
  189. fail: res => {}
  190. });
  191. },
  192. computed: {
  193. startDate() {
  194. return this.getDate('start');
  195. },
  196. endDate() {
  197. return this.getDate('end');
  198. }
  199. },
  200. onLoad(opt) {
  201. if (opt.type) {
  202. this.id = opt.type;
  203. }
  204. this.loadData();
  205. this.ListDate();
  206. },
  207. methods: {
  208. Toshow() {
  209. this.show = true;
  210. },
  211. //加载医院列表
  212. ListDate() {
  213. let obj = this;
  214. let data = '';
  215. console.log(obj.searchVal);
  216. if (!obj.searchVal) {
  217. data = {
  218. keyword: '',
  219. // province_id: obj.province_id,
  220. // city_id: obj.city_id,
  221. // district_id: obj.district_id,
  222. sort: 'id desc',
  223. page: obj.page,
  224. limit: 10
  225. };
  226. } else {
  227. data = {
  228. keyword: obj.searchVal,
  229. sort: 'id desc',
  230. page: obj.page,
  231. limit: 10
  232. };
  233. }
  234. getHospitalList(data)
  235. .then(e => {
  236. obj.list = obj.list.concat(e.data.list);
  237. console.log(obj.list);
  238. })
  239. .catch(e => {
  240. console.log(e);
  241. });
  242. },
  243. // 选择预约时间
  244. bindDateChange: function(e) {
  245. this.date = e.target.value;
  246. },
  247. // 选择预约时间
  248. bindTimeChange: function(e) {
  249. this.time = e.target.value;
  250. },
  251. // 选择性别
  252. bindPickerSex: function(e) {
  253. console.log(this.array[e.target.value]);
  254. this.sex = this.array[e.target.value];
  255. },
  256. // 选择类型
  257. bindPickerType: function(e) {
  258. if (this.cardList.indexOf(this.pzType.name) == -1) {
  259. this.price -= this.pzType.price * 1;
  260. } else {
  261. this.cardprice -= this.pzType.price * 1;
  262. }
  263. this.pzType = this.pzTypelist[e.target.value];
  264. if (this.cardList.indexOf(this.pzType.name) == -1) {
  265. this.price += this.pzType.price * 1;
  266. } else {
  267. this.cardprice += this.pzType.price * 1;
  268. }
  269. },
  270. onChange(val) {
  271. let obj = this;
  272. console.log(val, 'onChange');
  273. let arr = val.split(',');
  274. obj.hospital = arr[1];
  275. let city = arr[2];
  276. let district = arr[4];
  277. let province = arr[6];
  278. obj.province = province;
  279. obj.city = city;
  280. obj.hospital_id = arr[0];
  281. obj.addr = province + city + district;
  282. console.log(obj.addr);
  283. },
  284. shua() {
  285. this.page += 1;
  286. this.ListDate();
  287. },
  288. onConfirm1(val) {},
  289. onSearchInput(val) {
  290. this.page = 1;
  291. this.list = [];
  292. console.log('val223', this.list);
  293. this.searchVal = val;
  294. this.ListDate();
  295. },
  296. loadData() {
  297. const obj = this;
  298. equity({}).then(({ data }) => {
  299. obj.cardList = data.map(e => {
  300. return e.name;
  301. });
  302. console.log(obj.cardList, '123456');
  303. cate({ type: 1 }).then(({ data }) => {
  304. this.pzTypelist = data;
  305. data.forEach(e => {
  306. if (e.id == obj.id) {
  307. console.log(obj.cardList.indexOf(e.id));
  308. if (obj.cardList.indexOf(e.name) == -1) {
  309. obj.price += e.price * 1;
  310. } else {
  311. obj.cardprice = e.price * 1;
  312. }
  313. obj.pzType = e;
  314. }
  315. });
  316. });
  317. service({}).then(({ data }) => {
  318. data.forEach(e => {
  319. e.chose = 1;
  320. });
  321. obj.typelist = data;
  322. });
  323. });
  324. },
  325. outFocus(e) {
  326. console.log(event.target);
  327. event.target.blur();
  328. },
  329. getDate(type) {
  330. const date = new Date();
  331. let year = date.getFullYear();
  332. let month = date.getMonth() + 1;
  333. let day = date.getDate();
  334. if (type === 'start') {
  335. year = year - 60;
  336. } else if (type === 'end') {
  337. year = year + 2;
  338. }
  339. month = month > 9 ? month : '0' + month;
  340. day = day > 9 ? day : '0' + day;
  341. return `${year}-${month}-${day}`;
  342. },
  343. choose(opt) {
  344. if (opt.chose == 1) {
  345. if (opt.name == '上门接送') {
  346. this.type = 2;
  347. }
  348. opt.chose = 2;
  349. this.price += opt.price * 1;
  350. } else {
  351. if (opt.name == '上门接送') {
  352. this.type = 1;
  353. }
  354. opt.chose = 1;
  355. this.price -= opt.price * 1;
  356. }
  357. console.log(this.typelist);
  358. },
  359. openPopup() {
  360. this.$refs.popup.open();
  361. },
  362. cancel() {
  363. this.$refs.popup.close();
  364. },
  365. // 选中城市切换
  366. onCityClick({ data }) {
  367. let address = this.address;
  368. address.province = data[0];
  369. address.city = data[1];
  370. address.district = data[2];
  371. this.addressDetail = data.join('');
  372. },
  373. buy() {
  374. const obj = this;
  375. let cate = '';
  376. console.log(typeof cate);
  377. cate = obj.pzType.id + '';
  378. let service_id = '';
  379. obj.typelist.forEach(e => {
  380. if (e.chose == 2) {
  381. if (service_id != '') {
  382. service_id = service_id + ',' + e.id;
  383. } else {
  384. service_id = e.id;
  385. }
  386. }
  387. });
  388. if (obj.date == '请选择预约日期') {
  389. return this.$api.msg('请选择预约日期');
  390. }
  391. if (obj.time == '请选择预约时间') {
  392. return this.$api.msg('请选择预约时间');
  393. }
  394. let time = obj.date + ' ' + obj.time + ':00';
  395. if (obj.name == '') {
  396. return this.$api.msg('请填写你的姓名');
  397. }
  398. if (obj.sex == '请选择你的性别') {
  399. return this.$api.msg('请选择你的性别');
  400. }
  401. if (obj.age == '') {
  402. return this.$api.msg('请填写你的年龄');
  403. }
  404. if (obj.phone == '') {
  405. return this.$api.msg('请填写你的联系电话');
  406. }
  407. if (this.phone.length != 11) {
  408. this.$api.msg('请输入正确的联系方式');
  409. return;
  410. }
  411. if (obj.hospital == '') {
  412. return this.$api.msg('请选择医院');
  413. }
  414. if (obj.jjname == '') {
  415. return this.$api.msg('请填写紧急联系人姓名');
  416. }
  417. if (obj.jjphone == '') {
  418. return this.$api.msg('请填写紧急联系人电话');
  419. }
  420. if (obj.jjphone.length != 11) {
  421. this.$api.msg('请输入正确的紧急联系人电话');
  422. return;
  423. }
  424. // if (obj.addressDetail == '') {
  425. // return this.$api.msg('请选择上门接送地址');
  426. // }
  427. // if (obj.addressD == '') {
  428. // return this.$api.msg('请填写详细地址');
  429. // }
  430. console.log(cate, service_id, '1111');
  431. console.log(typeof cate, typeof service_id, '2222');
  432. Diagnosisconfirm({
  433. type: 1,
  434. cate: cate,
  435. service_id: service_id,
  436. time: time,
  437. name: obj.name,
  438. sex: obj.sex == '男' ? 1 : 2,
  439. age: obj.age,
  440. phone: obj.phone,
  441. province: obj.province,
  442. city: obj.city,
  443. hospital_id: obj.hospital_id,
  444. hospital: obj.addr + ':' + obj.hospital,
  445. urgent_name: obj.jjname,
  446. urgent_phone: obj.jjphone,
  447. transfer_address: obj.addressDetail + obj.addressD,
  448. remarks: obj.remarks
  449. })
  450. .then(e => {
  451. console.log(e, '1111');
  452. uni.navigateTo({
  453. url: '/pages/money/pay?orderId=' + e.data.cache + '&money=' + e.data.pay_price
  454. });
  455. })
  456. .catch(e => {
  457. this.openPopup();
  458. });
  459. }
  460. }
  461. };
  462. </script>
  463. <style lang="scss">
  464. .content,
  465. page {
  466. min-height: 100%;
  467. height: auto;
  468. background: #f8f8f8;
  469. }
  470. .top {
  471. position: relative;
  472. z-index: 0;
  473. width: 750rpx;
  474. height: 287rpx;
  475. .top-bg {
  476. width: 750rpx;
  477. height: 287rpx;
  478. }
  479. }
  480. .main {
  481. height: auto;
  482. background: #ffffff;
  483. }
  484. .info-item {
  485. padding: 40rpx 0 38rpx;
  486. margin: 0 24rpx;
  487. border-bottom: 1px solid #ececec;
  488. .info-left {
  489. font-size: 30rpx;
  490. font-family: PingFang SC;
  491. font-weight: 500;
  492. color: #222222;
  493. }
  494. .info-right {
  495. font-size: 28rpx;
  496. font-family: PingFang SC;
  497. font-weight: 500;
  498. color: #999999;
  499. }
  500. }
  501. .list-input {
  502. text-align: right;
  503. font-size: 28rpx;
  504. font-family: PingFang SC;
  505. font-weight: 500;
  506. color: #999999;
  507. }
  508. .info-type-title {
  509. font-size: 30rpx;
  510. font-family: PingFang SC;
  511. font-weight: 500;
  512. color: #222222;
  513. .info-type-tip {
  514. font-size: 24rpx;
  515. font-family: PingFang SC;
  516. font-weight: 500;
  517. color: #666666;
  518. }
  519. }
  520. .info-type {
  521. border-bottom: 1px solid #ececec;
  522. padding: 38rpx 24rpx 50rpx;
  523. .info-type-main {
  524. display: flex;
  525. flex-wrap: wrap;
  526. .current {
  527. background: #24a17d !important;
  528. color: #ffffff !important;
  529. text {
  530. color: #ffffff !important;
  531. }
  532. }
  533. .info-type-main-item {
  534. margin: 30rpx 10rpx 0 0;
  535. padding: 10rpx 20rpx;
  536. background: #ffffff;
  537. border: 2rpx solid #e7e7e7;
  538. border-radius: 15rpx;
  539. font-size: 26rpx;
  540. font-family: PingFang SC;
  541. font-weight: 500;
  542. color: #333333;
  543. text {
  544. color: #ff6f0f;
  545. }
  546. }
  547. }
  548. }
  549. .info-bz {
  550. margin: 15rpx 0 0;
  551. padding: 40rpx 30rpx;
  552. background: #ffffff;
  553. .text-box {
  554. margin: 10rpx 0 0;
  555. width: 690rpx;
  556. height: 100rpx;
  557. font-size: 30rpx;
  558. font-family: PingFang SC;
  559. font-weight: 500;
  560. color: #666666;
  561. }
  562. }
  563. .btn {
  564. position: fixed;
  565. bottom: 40rpx;
  566. left: 50%;
  567. margin-left: -311rpx;
  568. width: 622rpx;
  569. height: 85rpx;
  570. background: #24a17d;
  571. border-radius: 15rpx;
  572. text-align: center;
  573. line-height: 85rpx;
  574. font-size: 32rpx;
  575. font-family: PingFang SC;
  576. font-weight: bold;
  577. color: #ffffff;
  578. }
  579. .popup-box {
  580. width: 527rpx;
  581. height: 602rpx;
  582. background: #ffffff;
  583. border-radius: 28rpx;
  584. position: relative;
  585. .img {
  586. position: relative;
  587. top: -56rpx;
  588. left: 0;
  589. width: 527rpx;
  590. height: 280rpx;
  591. display: flex;
  592. justify-content: center;
  593. image {
  594. border-radius: 20rpx 20rpx 0 0;
  595. width: 477rpx;
  596. height: 280rpx;
  597. }
  598. }
  599. .mian {
  600. margin-top: -44rpx;
  601. display: flex;
  602. flex-direction: column;
  603. align-items: center;
  604. // padding: 32rpx 32rpx;
  605. background-color: #ffffff;
  606. border-radius: 0 0 20rpx 20rpx;
  607. padding: 0 42rpx;
  608. text-align: center;
  609. .title {
  610. font-size: 33rpx;
  611. font-family: PingFang SC;
  612. font-weight: 800;
  613. color: #333333;
  614. }
  615. .nocancel {
  616. font-size: 28rpx;
  617. font-family: PingFang SC;
  618. font-weight: 500;
  619. color: #7b95a9;
  620. }
  621. .comfirm-box {
  622. margin: 52rpx auto;
  623. width: 403rpx;
  624. height: 83rpx;
  625. background: #24a17d;
  626. border-radius: 42rpx;
  627. text-align: center;
  628. line-height: 83rpx;
  629. font-size: 32rpx;
  630. font-family: PingFang SC;
  631. font-weight: bold;
  632. color: #ffffff;
  633. }
  634. }
  635. }
  636. .scrollList {
  637. padding-bottom: 150rpx;
  638. }
  639. </style>