yydb.vue 14 KB

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