packageForm.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. <template>
  2. <view>
  3. <view class="content">
  4. <choosePatient ref="choosePatient" class="patient" :patient="patient" @addPatient="addPatient"></choosePatient>
  5. <!-- <view class="patient-cont">
  6. <view class="chose-patient">
  7. <view class="patient-box" @click="addPatient()" v-if="patient==null">
  8. <view class="patient-item">
  9. <view class="patient-tip">*</view>
  10. <view class="patient-title">选择就诊人</view>
  11. </view>
  12. <view class="right" >
  13. <image src="/static/images/arrow_gray.png" mode=""></image>
  14. </view>
  15. </view>
  16. <view class="patient" @click="addPatient()" v-if="patient!=null">
  17. <view class="left">
  18. <view class="name">{{patient.patientName}}</view>
  19. <view class="info">
  20. <text class="text" v-if="patient.sex==1">男</text>
  21. <text class="text" v-if="patient.sex==2">女</text>
  22. <text class="text">{{$getAge(patient.birthday)}}岁</text>
  23. <text class="text">{{$parseIdCard(patient.idCard)}}</text>
  24. </view>
  25. </view>
  26. <view class="right" >
  27. <image src="/static/images/arrow_gray.png" mode=""></image>
  28. </view>
  29. </view>
  30. </view>
  31. </view> -->
  32. <view class="msg-cont">
  33. <scroll-view
  34. class="msg-scroll"
  35. :scroll-top="scrollTop"
  36. scroll-y="true"
  37. :scroll-with-animation="true"
  38. >
  39. <view class="msgs">
  40. <view class="msg-item" v-for="(item,index) in msgs" >
  41. <view class="left" v-if="item.type==1">
  42. <!-- <image class="img" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/be32b8d2ae9f497297d10327656bb43c.png"></image> -->
  43. <image class="img" mode="aspectFill" :src="agreement.avatar?agreement.avatar:'https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/1d7eb0607a074892964dd32e8735e540.jpg'"></image>
  44. <view class="msg-content">{{item.content}}</view>
  45. </view>
  46. <view class="right" v-if="item.type==2">
  47. <view class="msg-content">{{item.content}}</view>
  48. <image class="img" mode="aspectFill" :src="avatar?avatar:'https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/1d7eb0607a074892964dd32e8735e540.jpg'"></image>
  49. </view>
  50. </view>
  51. </view>
  52. </scroll-view>
  53. </view>
  54. <view class="option-cont" v-if="item!=null">
  55. <view class="option-title" >{{item.title}}</view>
  56. <view class="options" >
  57. <view :class="option.color=='red'?'option-item red':'option-item green'" @click="optionClick(item,option)" v-for="(option,opIndex) in item.options" >{{option.name}}</view>
  58. </view>
  59. </view>
  60. </view>
  61. <!-- <u-modal @cancel="close()" @confirm="confirm()" :show="show" title="温馨提示" :content='content'></u-modal> -->
  62. <u-modal @cancel="close()" @confirm="confirm()" :show="show" title="温馨提示" :content='content' :showConfirmButton="percentage==100||isComplete==0">
  63. <view class="slot-content">
  64. <view>{{content}}</view>
  65. <view style="margin-top: 24rpx;" v-if="isComplete==1">
  66. <u-line-progress :percentage="percentage" activeColor="#FF5C03"></u-line-progress>
  67. <view style="margin-top: 16rpx;color: red;text-align: center;" v-show="percentage<100">医生正在为您开具处方,请耐心等候!</view>
  68. </view>
  69. </view>
  70. </u-modal>
  71. </view>
  72. </template>
  73. <script>
  74. import {getIcdNameByPackageId} from '@/api/package.js'
  75. import {create,giftCreate,getAgreement} from '@/api/packageOrder.js'
  76. export default {
  77. data() {
  78. return {
  79. content:null,
  80. show:false,
  81. scrollTop:0,//滚动条位置
  82. patient:null,
  83. items:[
  84. {
  85. title:"您是否因慢病在线下就诊?且对该处方内的产品无过敏或不良反应?",
  86. options:[
  87. {name:"是,我线下就诊过",value:1,color:'green'},
  88. {name:"无,从未就诊",value:0,color:'red'},
  89. ]
  90. },
  91. {
  92. title:"您是否已详细阅读疗法说明,确认自己符合疗法产品的适用人群,并了解使用方法,使用禁忌等?",
  93. options:[
  94. {name:"是,我已充分了解",value:1,color:'green'},
  95. {name:"否,未阅读",value:0,color:'red'},
  96. ]
  97. },
  98. {
  99. title:"请选择线下已确诊疾病",
  100. options:[]
  101. }
  102. ],
  103. msgs:[],
  104. index:0,
  105. item:null,
  106. notice:[
  107. {title:"好的。我将根据您提交的复诊信息开具处方,请详细阅读药品说明书,遵医嘱用药。"},
  108. {title:"您存在用药禁忌证,目前不推荐购买此套餐包。建议您尽早就医,在医生指导下采取针对性的治疗措施!在改善相关禁忌证后,也可以再次咨询,重新评估是否可以使用该套餐包。"}
  109. ],
  110. packageId:null,
  111. doctorId:null,
  112. isComplete:0,
  113. companyUserId:null,
  114. companyId:null,
  115. choose: 0, // 1:付邮费领取 2:加粉领取
  116. docAvatar:'',
  117. avatar: '',
  118. paddingTop: 130,
  119. agreement: {},
  120. percentage: 0,
  121. showConfirmButton: false,
  122. interval: null
  123. };
  124. },
  125. onLoad(option) {
  126. this.avatar = uni.getStorageSync('userInfo')&&JSON.parse(uni.getStorageSync('userInfo')).avatar
  127. this.choose = option.choose || 0
  128. this.packageId=option.packageId
  129. this.doctorId=option.doctorId
  130. if(!this.$isEmpty(option.companyId)){
  131. this.companyId=option.companyId
  132. }
  133. if(!this.$isEmpty(option.companyUserId)){
  134. this.companyUserId=option.companyUserId
  135. }
  136. var that=this;
  137. uni.$on('refreshOrderPatient', (res) => {
  138. that.patient=res
  139. setTimeout(()=>{
  140. this.getpaddingTop()
  141. },100)
  142. })
  143. this.item=this.items[0];
  144. this.addMsg(1,this.item.title);
  145. this.getAgreement()
  146. this.getIcdName()
  147. },
  148. onShow() {
  149. this.$nextTick(()=>{
  150. this.$refs.choosePatient.getPatientList()
  151. })
  152. },
  153. onUnload() {
  154. if(this.interval) {
  155. clearInterval(this.interval);
  156. }
  157. },
  158. methods:{
  159. animatePercentage() {
  160. const duration = Math.floor(Math.random() * (10000 - 4000 + 1)) + 4000; // 4-10秒,单位毫秒
  161. const steps = 100;
  162. const intervalTime = duration / steps;
  163. this.percentage = 0;
  164. this.interval = setInterval(() => {
  165. this.percentage++;
  166. if (this.percentage >= 100) {
  167. clearInterval(this.interval);
  168. }
  169. }, intervalTime);
  170. },
  171. getIcdName() {
  172. this.items[2].options = []
  173. getIcdNameByPackageId({packageId:this.packageId}).then(res=>{
  174. if(res.code == 200&&res.icdNames.length>0) {
  175. this.items[2].options= res.icdNames.map((item,i)=>({
  176. name:item,
  177. value:i+1,
  178. color:'green'
  179. }))
  180. const obj = {
  181. name: '其他',
  182. value: this.items[2].options.length+1,
  183. color: 'green'
  184. }
  185. this.items[2].options.push(obj)
  186. } else {
  187. this.items[2].options = [{
  188. name: '其他',
  189. value: 1,
  190. color: 'green'
  191. }]
  192. }
  193. })
  194. },
  195. getpaddingTop() {
  196. uni
  197. .createSelectorQuery().in(this)
  198. .select(".patient")
  199. .boundingClientRect((res) => {
  200. this.paddingTop = res&&res.height;
  201. })
  202. .exec();
  203. },
  204. getAgreement() {
  205. getAgreement().then(res=>{
  206. if(res.code==200) {
  207. this.agreement = res.doctor || {}
  208. uni.setNavigationBarTitle({
  209. title: this.agreement.doctorName || '问答'
  210. });
  211. }
  212. })
  213. },
  214. close(){
  215. this.show=false;
  216. },
  217. confirm(){
  218. if(this.isComplete==1){
  219. this.submit()
  220. }
  221. else{
  222. uni.navigateBack()
  223. }
  224. },
  225. addMsg(type,content){
  226. var msg={type:type,content:content}
  227. this.msgs.push(msg)
  228. var that=this;
  229. setTimeout(()=>{
  230. uni.createSelectorQuery().in(this)
  231. .select(".msgs")
  232. .boundingClientRect((res) => {
  233. if(res) {
  234. const scrollH = res.height;
  235. that.scrollTop = scrollH;
  236. console.log(that.scrollTop,res)
  237. }
  238. })
  239. .exec();
  240. },100)
  241. },
  242. optionClick(item,option){
  243. if(this.patient==null){
  244. uni.showToast({
  245. icon:'none',
  246. title: "请选择就诊人",
  247. });
  248. return;
  249. }
  250. if(option.value==0){
  251. this.content=this.notice[1].title;
  252. this.show=true;
  253. this.isComplete=0;
  254. return;
  255. }
  256. item.option=option.name;
  257. console.log(item.option);
  258. this.addMsg(2,option.name);
  259. this.index++;
  260. if(this.index<=this.items.length-1){
  261. this.item=this.items[this.index];
  262. this.addMsg(1,this.item.title)
  263. }
  264. else{
  265. this.content=this.notice[0].title;
  266. this.show=true;
  267. this.isComplete=1;
  268. if(this.interval) {
  269. clearInterval(this.interval);
  270. }
  271. this.animatePercentage()
  272. return;
  273. }
  274. },
  275. addPatient(){
  276. uni.navigateTo({
  277. url: '/pages/user/patient'
  278. })
  279. },
  280. submit(){
  281. uni.showLoading({
  282. title:"处理中..."
  283. });
  284. const num = Math.floor(Math.random() * (this.items[2].options.length-1));
  285. this.items = this.items.map(item=>({
  286. ...item,
  287. option: item.title == "请选择线下已确诊疾病"&&item.option =='其他' ? item.options[num].name:item.option
  288. }))
  289. var data={
  290. companyId:this.companyId,
  291. companyUserId:this.companyUserId,
  292. patientId:this.patient.patientId,
  293. patientJson:JSON.stringify(this.patient),
  294. packageId:this.packageId,
  295. doctorId:this.doctorId,
  296. formJson:JSON.stringify(this.items),
  297. }
  298. //#ifdef APP-PLUS
  299. data.source=2;
  300. //#endif
  301. //#ifdef H5
  302. data.source=3;
  303. //#endif
  304. if(this.choose == 1 || this.choose == 2) {
  305. this.giftCreateOrder(data)
  306. return
  307. }
  308. var that=this;
  309. create(data).then(res => {
  310. uni.hideLoading()
  311. if(res.code==200){
  312. setTimeout(function(){
  313. uni.navigateTo({
  314. url: '/pages/store/packageOrderPay?orderId='+res.order.orderId
  315. })
  316. },200);
  317. // var temps=['jARl4BpoBkRu-2MxPMkQVhIfGMG0V9qW-X3V_7NtEOU']
  318. // uni.requestSubscribeMessage({
  319. // tmplIds: temps,
  320. // success(e) {
  321. // },
  322. // fail(e) {
  323. // setTimeout(function(){
  324. // uni.navigateTo({
  325. // url: '/pages_order/packageOrderPay?orderId='+res.order.orderId
  326. // })
  327. // },200);
  328. // }
  329. // })
  330. }else{
  331. uni.showToast({
  332. icon:'none',
  333. title: res.msg,
  334. });
  335. }
  336. });
  337. },
  338. giftCreateOrder(data) {
  339. var that=this;
  340. const param = {
  341. ...data,
  342. choose: this.choose, //1:付邮费领取 2:加粉领取
  343. }
  344. giftCreate(param).then(res => {
  345. uni.hideLoading()
  346. if(res.code==200){
  347. setTimeout(function(){
  348. uni.navigateTo({
  349. url: '/pages/store/packageOrderPay?orderId='+res.order.orderId+'&choose='+that.choose
  350. })
  351. },200);
  352. // var temps=['jARl4BpoBkRu-2MxPMkQVhIfGMG0V9qW-X3V_7NtEOU']
  353. // uni.requestSubscribeMessage({
  354. // tmplIds: temps,
  355. // success(e) {
  356. // },
  357. // fail(e) {
  358. // setTimeout(function(){
  359. // uni.navigateTo({
  360. // url: '/pages_order/packageOrderPay?orderId='+res.order.orderId
  361. // })
  362. // },200);
  363. // }
  364. // })
  365. }else{
  366. uni.showToast({
  367. icon:'none',
  368. title: res.msg,
  369. });
  370. }
  371. });
  372. }
  373. }
  374. }
  375. </script>
  376. <style lang="scss" scoped>
  377. .content{
  378. flex: 1;
  379. width: 100%;
  380. // #ifdef H5
  381. height: calc(100vh - 44px - var(--status-bar-height));
  382. // #endif
  383. // #ifndef H5
  384. height: 100vh;
  385. // #endif
  386. display: flex;
  387. flex-direction: column;
  388. overflow: hidden;
  389. position: relative;
  390. .msg-cont{
  391. width: 100%;
  392. flex: 1;
  393. overflow: hidden;
  394. .msg-scroll{
  395. height: 100%;
  396. .msgs{
  397. width: 100%;
  398. padding: 6rpx 0;
  399. .msg-item{
  400. padding: 10rpx 15rpx;
  401. display: flex;
  402. flex-direction: column;
  403. justify-content: center;
  404. align-items: flex-start;
  405. width: 100%;
  406. .left{
  407. width: 100%;
  408. display: flex;
  409. justify-content: flex-start;
  410. align-items: flex-start;
  411. .img{
  412. min-width: 100rpx;
  413. width: 100rpx;
  414. height:100rpx;
  415. border-radius: 50%;
  416. image{
  417. width: 100%;
  418. height:100%;
  419. }
  420. }
  421. .msg-content{
  422. margin-top: 15rpx;
  423. margin-left: 10rpx;
  424. border-radius: 15rpx;
  425. padding: 15rpx;
  426. background-color: #fff;
  427. color: #111;
  428. font-size: 32upx;
  429. font-family: PingFang SC;
  430. }
  431. }
  432. .right{
  433. width: 100%;
  434. display: flex;
  435. justify-content: flex-end;
  436. align-items: flex-start;
  437. .msg-content{
  438. margin-top: 15rpx;
  439. margin-right: 10rpx;
  440. border-radius: 15rpx;
  441. padding: 15rpx;
  442. background-color: #FF5C03;
  443. color: #fff;
  444. font-size: 32upx;
  445. font-family: PingFang SC;
  446. }
  447. .img{
  448. min-width: 100rpx;
  449. width: 100rpx;
  450. height:100rpx;
  451. border-radius: 50%;
  452. image{
  453. width: 100%;
  454. height:100%;
  455. }
  456. }
  457. }
  458. }
  459. }
  460. }
  461. }
  462. .option-cont{
  463. flex-shrink: 0;
  464. // position: fixed;
  465. // bottom: 0rpx;
  466. // #ifndef APP-PLUS
  467. max-height: 90vh;
  468. overflow-y: auto;
  469. // #endif
  470. // #ifdef APP-PLUS
  471. // height: 380rpx;
  472. // #endif
  473. width: 100%;
  474. background-color: #fff;
  475. border-radius: 60rpx 60rpx 0rpx 0rpx;
  476. padding: 24rpx 30rpx;
  477. .option-title{
  478. width: 100%;
  479. padding-bottom: 15rpx;
  480. display: flex;
  481. align-items: center;
  482. justify-content: center;
  483. font-size: 32upx;
  484. font-family: PingFang SC;
  485. color: #111;
  486. }
  487. .options{
  488. margin-top: 20rpx;
  489. display: flex;
  490. flex-direction: column;
  491. justify-content: center;
  492. align-items: center;
  493. .option-item{
  494. display: flex;
  495. align-items: center;
  496. justify-content: center;
  497. width: 100%;
  498. border: 1rpx solid #eee;
  499. margin-bottom: 20rpx;
  500. padding: 15rpx;
  501. border-radius: 5rpx;
  502. color: #ffffff;
  503. font-size: 32upx;
  504. }
  505. .green{
  506. background-color: #588e31;
  507. }
  508. .red{
  509. background-color: #c00000;
  510. }
  511. }
  512. }
  513. .title{
  514. padding: 15rpx 30rpx;
  515. display: flex;
  516. justify-content: center;
  517. align-items: center;
  518. width: 100%;
  519. background-color: #FF5C03;
  520. font-size: 24upx;
  521. font-family: PingFang SC;
  522. font-weight: bold;
  523. color: #fff;
  524. }
  525. .patient-cont{
  526. padding: 15rpx;
  527. .chose-patient{
  528. padding: 30rpx;
  529. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  530. background-color: #fff;
  531. border-radius: 15rpx;
  532. .patient-box{
  533. display: flex;
  534. align-items: center;
  535. justify-content: space-between;
  536. .patient-item{
  537. display: flex;
  538. align-items: center;
  539. justify-content: flex-start;
  540. .patient-tip{
  541. margin-top:6rpx;
  542. display: flex;
  543. align-items: center;
  544. justify-content: center;
  545. font-size: 32upx;
  546. font-family: PingFang SC;
  547. color: #ff0000;
  548. }
  549. .patient-title{
  550. margin-left: 10rpx;
  551. font-size: 32upx;
  552. font-family: PingFang SC;
  553. font-weight: bold;
  554. color: #111111;
  555. }
  556. }
  557. .right{
  558. display: flex;
  559. align-items: center;
  560. image{
  561. width: 15upx;
  562. height: 30upx;
  563. }
  564. }
  565. }
  566. .patient{
  567. display: flex;
  568. align-items: center;
  569. justify-content: space-between;
  570. height: 110upx;
  571. .left{
  572. .name{
  573. font-size: 30upx;
  574. line-height: 1;
  575. font-family: PingFang SC;
  576. font-weight: bold;
  577. color: #111111;
  578. }
  579. .info{
  580. margin-top: 30rpx;
  581. display: flex;
  582. align-items: center;
  583. .text{
  584. font-size: 26upx;
  585. font-family: PingFang SC;
  586. line-height: 1;
  587. font-weight: 500;
  588. color: #999;
  589. margin-right: 19upx;
  590. }
  591. }
  592. }
  593. .right{
  594. display: flex;
  595. align-items: center;
  596. image{
  597. width: 15upx;
  598. height: 30upx;
  599. }
  600. }
  601. }
  602. }
  603. }
  604. .items{
  605. padding: 15rpx;
  606. width: 100%;
  607. padding: 30rpx;
  608. border-radius: 15rpx;
  609. background-color: #fff;
  610. display: flex;
  611. flex-direction: column;
  612. align-items: flex-start;
  613. justify-content: flex-start;
  614. .item{
  615. display: flex;
  616. flex-direction: column;
  617. align-items: flex-start;
  618. justify-content: flex-start;
  619. width: 100%;
  620. background-color: #f8f8f8;
  621. margin-bottom: 15rpx;
  622. .name{
  623. font-size: 32upx;
  624. font-family: PingFang SC;
  625. color: #2a2b2e;
  626. font-weight: bold;
  627. margin-bottom: 15rpx;
  628. }
  629. .options{
  630. margin: 15rpx 0rpx;
  631. width: 100%;
  632. display: flex;
  633. align-items: center;
  634. justify-content: space-between;
  635. margin-bottom: 10rpx;
  636. .option{
  637. margin-bottom: 20rpx;
  638. display: flex;
  639. align-items: center;
  640. justify-content: center;
  641. border-radius: 10rpx;
  642. width:20%;
  643. height:100rpx;
  644. border: 1rpx solid #9b9b9b;
  645. font-size: 28upx;
  646. font-family: PingFang SC;
  647. color: #2a2b2e;
  648. background-color: #fff;
  649. &:last-child{
  650. margin-right: 0rpx;
  651. margin-bottom: 0rpx;
  652. }
  653. }
  654. .active{
  655. border: 1rpx solid #FF5C03;
  656. background-color: #FF5C03;
  657. color: #fff;
  658. }
  659. }
  660. }
  661. }
  662. .btns{
  663. display: flex;
  664. align-items: center;
  665. justify-content: space-between;
  666. width: 100%;
  667. padding: 30rpx;
  668. .btn{
  669. height:80rpx;
  670. margin: 0rpx 30rpx;
  671. border-radius: 60rpx;
  672. width: 100%;
  673. border: 1rpx solid #FF5C03;
  674. font-size: 32supx; font-family: PingFang SC; color: #fff;
  675. font-weight: bold;
  676. background-color: #FF5C03;
  677. display: flex;
  678. align-items: center;
  679. justify-content: center;
  680. }
  681. }
  682. .tips{
  683. flex-direction: column;
  684. display: flex;
  685. align-items: center;
  686. justify-content: center;
  687. width: 100%;
  688. padding: 30rpx;
  689. .tip-title{
  690. font-size: 26supx;
  691. font-family: PingFang SC;
  692. color: #888;
  693. font-weight: bold;
  694. }
  695. .desc{
  696. margin-top: 15rpx;
  697. font-size: 24rpx;
  698. font-family: PingFang SC;
  699. color: #b8bdb5;
  700. }
  701. }
  702. }
  703. </style>