yydb.vue 11 KB

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