index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. <template>
  2. <view>
  3. <!--prescription/dialogue/index.wxml-->
  4. <view>
  5. <scroll-view scroll-y :scroll-into-view="toView" :style="hind?'':'height:'+ scrollHeight">
  6. <!-- <view class='scrollMsg'> -->
  7. <view class="top bgfff pdlr20 dflex">
  8. <view class="topcon">
  9. <image :src="doctor.img?doctor.img:'/prescription/static/prescription/image/ys.png'"
  10. mode="aspectFit" class="logo r50 bgfff mr20"></image>
  11. <view class="area flex" @tap="merchant">
  12. <view class="areas f28 dflex">
  13. <view class="doctor">{{doctor.name}}</view>
  14. <view class="subject">{{doctor.depart}}</view>
  15. <view>{{doctor.title}}</view>
  16. </view>
  17. <view v-if="doctor.goodAt">擅长:{{doctor.goodAt}}</view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="tips">
  22. <view class="txt">根据国家相关规定,互联网医疗只能为患者提供处方服务,若您不是复诊患者,我们只能提供咨询服务。在线咨询不能代替面诊,继续咨询表示您已知晓并同意该条款。</view>
  23. <view class="dflex authorization">《互联网医疗风险告知及知情同意书》<view class="underline" @tap="goUrl">点击查看</view>
  24. </view>
  25. </view>
  26. <block v-for="(item, index) in msgList" :key="index">
  27. <!-- 单个消息1 客服发出(左) -->
  28. <view v-if="item.isMember=='0'" :id="'msg-' + index"
  29. style="display: flex; padding: 2vw 11vw 2vw 2vw;">
  30. <view style="width: 11vw; height: 11vw;">
  31. <image class="logo r50 bgfff"
  32. :src="doctor.img?doctor.img:'/prescription/static/prescription/image/ys.png'"></image>
  33. </view>
  34. <!-- <view class="test-step">
  35. <image style='width: 4vw;' src='../../images/left_msg.png' mode='widthFix'></image>
  36. </view> -->
  37. <view class="leftMsg">{{item.msg}}</view>
  38. </view>
  39. <!-- 单个消息2 用户发出(右) -->
  40. <view v-else :id="'msg-' + index"
  41. style="display: flex; justify-content: flex-end; padding: 2vw 2vw 2vw 11vw;">
  42. <view class="rightMsg">{{item.msg}}</view>
  43. <!-- <view style='width: 4vw; height: 11vw; margin-right: 0.5vw; display: flex; align-items: center; z-index: 9;'>
  44. <image style='width: 4vw;' src='../../images/right_msg.png' mode='widthFix'></image>
  45. </view> -->
  46. <view style="width: 11vw; height: 11vw;">
  47. <image class="logo r50 bgfff" :src="cusHeadIcon"></image>
  48. </view>
  49. </view>
  50. </block>
  51. <!-- </view> -->
  52. <!-- 占位 -->
  53. <view style="width: 100%; height: 18vw;"></view>
  54. </scroll-view>
  55. <view class="inputRoom" :style="'bottom: ' + inputBottom">
  56. <!-- <image style='width: 7vw; margin-left: 3.2vw;' src='../../images/pic_icon.png' mode='widthFix'></image> -->
  57. <!-- <input class="ipt" bindconfirm='sendClick' adjust-position='{{false}}' value='{{inputVal}}' confirm-type='send' bindfocus='focus' bindblur='blur'></input> -->
  58. <block v-if="msgList.length<8">
  59. <view class="no" @tap="disable?'':negative()" :style="allergy?'background:#FE0419':''">否</view>
  60. <view class="confirm" @tap="disable?'':suer()" :style="allergy?'background:#BDC2C9':''">是,我确定</view>
  61. </block>
  62. <block v-else>
  63. <view class="confirm" @tap="disable?'':suer()" :style="allergy?'background:#BDC2C9':''">
  64. {{msgList.length>=10?"有":"是"}}
  65. </view>
  66. <view class="no" @tap="disable?'':negative()" :style="allergy?'background:#FE0419':''">
  67. {{msgList.length>=10?"没有":"否"}}
  68. </view>
  69. </block>
  70. </view>
  71. </view>
  72. <view class="mask" :hidden="isHide"></view>
  73. <view class="suc" :hidden="isHide">
  74. <view class="title">输入过敏药品</view>
  75. <input placeholder="请输入过敏源" @input="abnormal" data-index="1" :value="inputVal" adjust-position="false"
  76. @focus="focus" @blur="blur"></input>
  77. <view class="btn dflex">
  78. <view class="cancel" @tap="hidePop">取消</view>
  79. <view class="queren" @tap="abnormalClick" data-index="1">确认</view>
  80. </view>
  81. </view>
  82. <view class="mask" :hidden="isShow"></view>
  83. <view class="suc" :hidden="isShow">
  84. <view class="title">身体异常项</view>
  85. <input placeholder="请输入身体异常项" @input="abnormal" data-index="2" :value="inputVal" adjust-position="false"
  86. @focus="focus" @blur="blur"></input>
  87. <view class="btn dflex">
  88. <view class="cancel" @tap="hideShow">取消</view>
  89. <view class="queren" @tap="abnormalClick" data-index="2">确认</view>
  90. </view>
  91. </view>
  92. </view>
  93. </template>
  94. <script>
  95. const app = getApp();
  96. var windowWidth = uni.getSystemInfoSync().windowWidth;
  97. var windowHeight = uni.getSystemInfoSync().windowHeight;
  98. var keyHeight = 0;
  99. var inputVal = '';
  100. var msgList = [];
  101. const req = require("../../utils/request.js");
  102. const util = require("../../utils/util.js");
  103. /**
  104. * 初始化数据
  105. */
  106. /**
  107. * 初始化数据
  108. */
  109. function initData(that) {
  110. inputVal = '';
  111. msgList = [{
  112. isMember: "1",
  113. msg: that.doctor.name + '医生,您好。我是:' + that.drugUsers.name + ',' + that.drugUsers.sex + ',' + that
  114. .drugUsers.age + '岁, 我的病情是:' + that.jibing + ' ,病情已确定,本次问诊为复诊',
  115. type: "TIMTextElem",
  116. flow: "out"
  117. }, {
  118. isMember: "1",
  119. msg: "目前发病情况:未知;既往病史:未知;用药史:未知;药物过敏情况:无;用药禁忌情况:未知。",
  120. type: "TIMTextElem",
  121. flow: "out"
  122. }, {
  123. isMember: "1",
  124. msg: '我需要以下:' + JSON.parse(that.query.txtdrugs).length + '种药品:(' + that.drugs + ')',
  125. type: "TIMTextElem",
  126. flow: "out"
  127. }, {
  128. isMember: '0',
  129. msg: '您描述的患有' + that.jibing + '是否在线下医院确诊过?',
  130. type: "TIMTextElem",
  131. flow: "in",
  132. nextShow: true
  133. }];
  134. that.setData({
  135. msgList,
  136. inputVal
  137. });
  138. }
  139. /**
  140. * 计算msg总高度
  141. */
  142. // function calScrollHeight(that, keyHeight) {
  143. // var query = wx.createSelectorQuery();
  144. // query.select('.scrollMsg').boundingClientRect(function(rect) {
  145. // }).exec();
  146. // }
  147. export default {
  148. data() {
  149. return {
  150. scrollHeight: '100vh',
  151. inputBottom: 0,
  152. isHide: true,
  153. isShow: true,
  154. allergen: "",
  155. msgList: "",
  156. inputVal: "",
  157. jibing: "",
  158. drugs: "",
  159. drugsName: "",
  160. doctor: "",
  161. cusHeadIcon: "",
  162. drugUsers: "",
  163. allergy: false,
  164. hind: false,
  165. toView: "",
  166. disable: false,
  167. malaise: ""
  168. };
  169. },
  170. components: {},
  171. props: {},
  172. /**
  173. * 生命周期函数--监听页面加载
  174. */
  175. onLoad: function(options) {
  176. this.query = options; // JSON.parse(options.diagnosis)
  177. // console.log(options)
  178. if (options.diagnosis) {
  179. let arr = [];
  180. JSON.parse(options.diagnosis).map(it => {
  181. arr.push(it.name);
  182. });
  183. this.setData({
  184. jibing: arr.toString()
  185. });
  186. }
  187. if (options.txtdrugs) {
  188. let drugs = [];
  189. let drugsName = [];
  190. JSON.parse(options.txtdrugs).map(it => {
  191. // console.log(it);
  192. let txt = it.drugName + it.number + it.unit + it.spec;
  193. let name = it.drugName;
  194. drugs.push(txt);
  195. drugsName.push(name);
  196. });
  197. this.setData({
  198. drugs: drugs.toString(),
  199. drugsName: drugsName.toString()
  200. });
  201. }
  202. if (options.doctor) {
  203. // console.log(options.doctor);
  204. this.setData({
  205. doctor: JSON.parse(options.doctor)
  206. });
  207. }
  208. // console.log(options);
  209. this.init();
  210. this.setData({
  211. cusHeadIcon: req.getStorage('userInfo').avatar
  212. });
  213. },
  214. /**
  215. * 生命周期函数--监听页面显示
  216. */
  217. onShow: function() {
  218. uni.enableAlertBeforeUnload({
  219. message: '确认返回?',
  220. success: function(res) {
  221. // console.log(res);
  222. },
  223. fail: console.error
  224. });
  225. },
  226. /**
  227. * 页面相关事件处理函数--监听用户下拉动作
  228. */
  229. onPullDownRefresh: function() {},
  230. /**
  231. * 页面上拉触底事件的处理函数
  232. */
  233. onReachBottom: function() {},
  234. onUnload() {
  235. if (this.out) return false;
  236. let chats = this.msgList;
  237. let diagnosis = JSON.parse(this.query.diagnosis);
  238. let txtdrugs = JSON.parse(this.query.txtdrugs);
  239. let from = {
  240. peopleId: this.drugUsers.id,
  241. allergy: this.allergen,
  242. orderId: this.query.orderId,
  243. //订单id
  244. doctorId: this.doctor.id ? this.doctor.id : '',
  245. chats: chats,
  246. diagnosis: diagnosis,
  247. //症状
  248. txtdrugs: txtdrugs,
  249. //产品规格
  250. state: 3
  251. };
  252. // console.log(from, typeof from.chats, typeof from.diagnosis, typeof from.txtdrugs, JSON.stringify(from));
  253. req.postRequest('/api/userDrugPeople/simple', {
  254. from: JSON.stringify(from)
  255. }, res => {});
  256. },
  257. methods: {
  258. async init() {
  259. await this.getdrugUsers(this.query.uId); // await this.getDoctor()
  260. },
  261. // 获取用药人详情
  262. getdrugUsers(id) {
  263. req.getRequest('/api/userDrugPeople/get', {
  264. id: id
  265. }, data => {
  266. if (data) {
  267. data.sex = data.sex == 1 ? '男' : '女';
  268. // console.log(this.data);
  269. this.setData({
  270. drugUsers: data
  271. });
  272. initData(this);
  273. }
  274. });
  275. },
  276. // 获取病症和医生
  277. // getDoctor() {
  278. // req.postRequest('/api/userDrugPeople/getHntyAndDoctor', {}, data => {
  279. // console.log(data);
  280. // if (data) {
  281. // // console.log(JSON.parse(data.hnty.data));
  282. // if (!data.doctor || data.doctor.code != 0) {
  283. // wx.showModal({
  284. // content: '当前医师不在线,请稍后再试',
  285. // showCancel: false,
  286. // success(res) {
  287. // if (res.confirm) {
  288. // console.log('用户点击确定')
  289. // // that.setData({ cancel: true })
  290. // }
  291. // }
  292. // })
  293. // } else {
  294. // initData(this, JSON.parse(data.doctor.data));
  295. // // initData(this);
  296. // this.setData({ doctor: JSON.parse(data.doctor.data) })
  297. // }
  298. // }
  299. // })
  300. // },
  301. // 页面跳转
  302. goUrl() {
  303. app.globalData.openPage('prescription/riskNotification/index');
  304. },
  305. suer: util.throttle(function() {
  306. // console.log(this.disable);
  307. if (this.disable) return false;
  308. let arr = [];
  309. msgList.map(it => {
  310. if (it.isMember == "0") arr.push(it);
  311. });
  312. let that = this;
  313. if (arr.length <= 2) {
  314. msgList.push({
  315. isMember: '1',
  316. msg: '是,我确定',
  317. nextShow: true,
  318. type: "TIMTextElem",
  319. flow: "out"
  320. });
  321. }
  322. setTimeout(function() {
  323. //要延时执行的代码
  324. if (arr.length == 1) {
  325. msgList.push({
  326. isMember: '0',
  327. msg: '您确定使用过' + that.drugsName + ',使用后并无不适症状?',
  328. nextShow: true,
  329. type: "TIMTextElem",
  330. flow: "in"
  331. });
  332. }
  333. if (arr.length == 2) {
  334. msgList.push({
  335. isMember: '0',
  336. msg: '您是否有药物过敏?',
  337. nextShow: true,
  338. type: "TIMTextElem",
  339. flow: "in"
  340. });
  341. that.setData({
  342. allergy: true
  343. });
  344. }
  345. if (arr.length == 3) {
  346. that.setData({
  347. isHide: false,
  348. hind: true
  349. });
  350. }
  351. if (arr.length == 4) {
  352. that.setData({
  353. isShow: false,
  354. hind: true
  355. });
  356. }
  357. inputVal = '';
  358. that.setData({
  359. msgList,
  360. inputVal,
  361. toView: 'msg-' + (that.msgList.length - 1)
  362. });
  363. // console.log(that.msgList);
  364. if (that.msgList.length == 11) {
  365. that.save();
  366. }
  367. }, 500); //延迟时间 这里是1秒
  368. }, 1000),
  369. negative: util.throttle(function() {
  370. if (this.disable) {
  371. return false;
  372. }
  373. let that = this;
  374. let arr = [];
  375. msgList.map(it => {
  376. if (it.isMember == "0") arr.push(it);
  377. });
  378. // console.log(arr);
  379. if (arr.length == 3) {
  380. msgList.push({
  381. isMember: '1',
  382. msg: '无',
  383. nextShow: true,
  384. type: "TIMTextElem",
  385. flow: "out"
  386. });
  387. }
  388. if (arr.length == 4) {
  389. msgList.push({
  390. isMember: '1',
  391. msg: '没有',
  392. nextShow: true,
  393. type: "TIMTextElem",
  394. flow: "out"
  395. });
  396. }
  397. setTimeout(function() {
  398. //要延时执行的代码
  399. if (arr.length == 1) {
  400. uni.showModal({
  401. title: "提示",
  402. content: '根据互联网医院相关规定,在线问诊仅适合复诊患者,如您是初诊请到就近医院就医。',
  403. // showCancel: false,
  404. success(res) {
  405. if (res.confirm) {
  406. // console.log('用户点击确定'); // that.setData({ cancel: true })
  407. }
  408. }
  409. });
  410. }
  411. if (arr.length == 2) {
  412. uni.showModal({
  413. title: "提示",
  414. content: '根据互联网医院相关规定,若您需要的药品未服用过,医生不能为您进行在线问诊开具处方。',
  415. // showCancel: false,
  416. success(res) {
  417. if (res.confirm) {
  418. // console.log('用户点击确定'); // that.setData({ cancel: true })
  419. }
  420. }
  421. });
  422. }
  423. if (arr.length == 3) {
  424. msgList.push({
  425. isMember: '0',
  426. msg: '请问有无肝、肾功能异常?',
  427. nextShow: true,
  428. type: "TIMTextElem",
  429. flow: "in"
  430. });
  431. }
  432. if (arr.length == 4) {
  433. that.setData({
  434. disable: true
  435. });
  436. }
  437. inputVal = '';
  438. that.setData({
  439. msgList,
  440. inputVal,
  441. toView: 'msg-' + (that.msgList.length - 1)
  442. });
  443. }, 500); //延迟时间 这里是1秒
  444. inputVal = ''; // console.log(msgList)
  445. this.setData({
  446. msgList,
  447. inputVal,
  448. toView: 'msg-' + (that.msgList.length - 1)
  449. });
  450. if (that.msgList.length == 11) {
  451. that.save();
  452. }
  453. }, 1000),
  454. hidePop() {
  455. this.setData({
  456. isHide: true
  457. });
  458. },
  459. hideShow() {
  460. this.setData({
  461. isShow: true
  462. });
  463. },
  464. // 2身体异常 1过敏源
  465. abnormal(e) {
  466. let content = e.detail.value;
  467. let index = e.target.dataset.index; // if()
  468. // console.log(e.target.dataset.index);
  469. if (index == 1) {
  470. this.setData({
  471. allergen: content,
  472. toView: 'msg-' + (this.msgList.length - 1)
  473. });
  474. }
  475. if (index == 2) {
  476. this.setData({
  477. malaise: content,
  478. toView: 'msg-' + (this.msgList.length - 1)
  479. });
  480. }
  481. },
  482. // 2身体异常 1过敏源
  483. abnormalClick(e) {
  484. let index = e.target.dataset.index;
  485. if (index == 1) {
  486. if (!this.allergen) {
  487. this.setData({
  488. isHide: true,
  489. hind: false
  490. });
  491. return false;
  492. }
  493. msgList.push({
  494. isMember: '1',
  495. msg: this.allergen,
  496. nextShow: true,
  497. type: "TIMTextElem",
  498. flow: "out"
  499. });
  500. msgList.push({
  501. isMember: '0',
  502. msg: '请问有无肝、肾功能异常?',
  503. nextShow: true,
  504. type: "TIMTextElem",
  505. flow: "in"
  506. });
  507. }
  508. if (index == 2) {
  509. if (!this.malaise) {
  510. this.setData({
  511. isShow: true,
  512. hind: false
  513. });
  514. return false;
  515. }
  516. msgList.push({
  517. isMember: '1',
  518. msg: this.malaise,
  519. nextShow: true,
  520. type: "TIMTextElem",
  521. flow: "out"
  522. });
  523. this.setData({
  524. disable: true
  525. });
  526. }
  527. // console.log(msgList);
  528. inputVal = '';
  529. this.setData({
  530. msgList,
  531. inputVal,
  532. isShow: true,
  533. isHide: true,
  534. hind: false,
  535. toView: 'msg-' + (msgList.length - 1)
  536. });
  537. if (this.msgList.length == 11) {
  538. this.save();
  539. }
  540. },
  541. // /**
  542. // * 获取聚焦
  543. // */
  544. focus: function(e) {
  545. // keyHeight = e.detail.height;
  546. // this.setData({
  547. // scrollHeight: (windowHeight - keyHeight) + 'px'
  548. // });
  549. // this.setData({
  550. // toView: 'msg-' + (msgList.length - 1),
  551. // inputBottom: keyHeight + 'px'
  552. // })
  553. this.setData({
  554. hind: true,
  555. inputBottom: 0
  556. }); //计算msg高度
  557. // calScrollHeight(this, keyHeight);
  558. },
  559. //失去聚焦(软键盘消失)
  560. blur: function(e) {
  561. // this.setData({
  562. // hind: false,
  563. // scrollHeight: '100vh',
  564. // inputBottom: 0,
  565. // // toView: 'msg-' + (msgList.length - 1)
  566. // })
  567. this.setData({
  568. toView: 'msg-' + (this.msgList.length - 1)
  569. });
  570. },
  571. /**
  572. * 退回上一页
  573. */
  574. toBackClick: function() {
  575. uni.navigateBack({});
  576. },
  577. save() {
  578. let chats = this.msgList;
  579. let diagnosis = JSON.parse(this.query.diagnosis);
  580. let txtdrugs = JSON.parse(this.query.txtdrugs);
  581. let from = {
  582. peopleId: this.drugUsers.id,
  583. allergy: this.allergen,
  584. orderId: this.query.orderId,
  585. //订单id
  586. doctorId: this.doctor.id,
  587. chats: chats,
  588. diagnosis: diagnosis,
  589. //症状
  590. txtdrugs: txtdrugs,
  591. //产品规格
  592. state: 4
  593. };
  594. this.out = true;
  595. // console.log(from, typeof from.chats, typeof from.diagnosis, typeof from.txtdrugs, JSON.stringify(from));
  596. req.postRequest('/api/userDrugPeople/simple', {
  597. from: JSON.stringify(from)
  598. }, res => {
  599. let identifier;
  600. if (res.healthInfo) {
  601. identifier = JSON.parse(res.healthInfo);
  602. // console.log(identifier);
  603. }
  604. uni.reLaunch({
  605. url: "/prescription/inquiry/index?comunicationid=" + res.comunicationid +
  606. '&sdkAppID=' + res.sdkAppID + '&userSig=' + res.userSig + '&identifier=' +
  607. identifier.uuid + '&doctor=' + JSON.stringify(this.doctor) + '&orderId=' + this
  608. .query.orderId + '&msg=' + JSON.stringify(this.msgList)
  609. });
  610. });
  611. }
  612. }
  613. };
  614. </script>
  615. <style>
  616. @import "./index.css";
  617. </style>