test.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <template>
  2. <view class="content">
  3. <view class="patient-cont">
  4. <view class="chose-patient">
  5. <view class="patient-box" @click="addPatient()" v-if="patient==null">
  6. <text class="patient-title">选择体验者</text>
  7. <view class="right" >
  8. <text class="value">请点击添加</text>
  9. <image src="https://kntobs.jnmyunl.com/shop/images/arrow_gray.png" mode=""></image>
  10. </view>
  11. </view>
  12. <view class="patient" @click="addPatient()" v-if="patient!=null">
  13. <view class="left">
  14. <view class="name">{{patient.patientName}}</view>
  15. <view class="info">
  16. <text class="text" v-if="patient.sex==1">男</text>
  17. <text class="text" v-if="patient.sex==2">女</text>
  18. <text class="text">{{utils.getAge(patient.birthday)}}岁</text>
  19. <text class="text">{{utils.parseIdCard(patient.idCard)}}</text>
  20. </view>
  21. </view>
  22. <view class="right" >
  23. <image src="https://kntobs.jnmyunl.com/shop/images/arrow_gray.png" mode=""></image>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="msg-cont">
  29. <scroll-view
  30. class="msg-scroll"
  31. :scroll-top="scrollTop"
  32. scroll-y="true"
  33. :scroll-with-animation="true">
  34. <view class="msgs">
  35. <view class="msg-item" v-for="(item,index) in msgs" >
  36. <view class="left" v-if="item.type==1">
  37. <image class="img" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/5fd36547a3ca4d0b9935e623d3d8e1c5.png"></image>
  38. <view class="msg-content">{{item.content}}</view>
  39. </view>
  40. <view class="right" v-if="item.type==2">
  41. <view class="msg-content">{{item.content}}</view>
  42. <image class="img" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/d7d49263e2e04f56a7a86fa7bfd35687.jpg"></image>
  43. </view>
  44. </view>
  45. </view>
  46. </scroll-view>
  47. </view>
  48. <view class="option-cont" v-if="item!=null">
  49. <view class="option-title" >{{item.title}}</view>
  50. <view class="options" >
  51. <view class="option-item" @click="optionClick(item,option)" v-for="(option) in JSON.parse(item.scoreJson)" >{{option.name}}</view>
  52. </view>
  53. </view>
  54. <!-- <view class="title">
  55. 体质测试以当下感受为准作答,人的体质有可能会随季节变化。
  56. </view>
  57. <view class="chose-patient">
  58. <view class="patient-box" @click="addPatient()" v-if="patient==null">
  59. <text class="patient-title">选择体验者</text>
  60. <view class="right" >
  61. <image src="https://kntobs.jnmyunl.com/shop/images/arrow_gray.png" mode=""></image>
  62. </view>
  63. </view>
  64. <view class="patient" @click="addPatient()" v-if="patient!=null">
  65. <view class="left">
  66. <view class="name">{{patient.patientName}}</view>
  67. <view class="info">
  68. <text class="text" v-if="patient.sex==1">男</text>
  69. <text class="text" v-if="patient.sex==2">女</text>
  70. <text class="text">{{$getAge(patient.birthday)}}岁</text>
  71. <text class="text">{{$parseIdCard(patient.idCard)}}</text>
  72. </view>
  73. </view>
  74. <view class="right" >
  75. <image src="https://kntobs.jnmyunl.com/shop/images/arrow_gray.png" mode=""></image>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="items">
  80. <view class="item" v-for="(item,index) in items">
  81. <view class="name">{{index+1}}{{item.title}}?</view>
  82. <view class="options">
  83. <view :class="item.option!=null&&item.option==option.name?'option active':'option'" @click="optionClick(item,option)" v-for="(option) in JSON.parse(item.scoreJson)">
  84. {{option.name}}
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="btns">
  90. <view class="btn" @click="submit()">提交</view>
  91. </view>
  92. <view class="tips">
  93. <view class="tip-title">提交代表你已接受以下声明</view>
  94. <view class="desc">
  95. 本测试不作为诊断和治疗的依据,对于已经医生确诊的疾病,应按照医嘱积极治疗。所提及的内容仅作为生活保健的咨询建议。如遇不适请及时就医。
  96. </view>
  97. </view> -->
  98. </view>
  99. </template>
  100. <script>
  101. import {getTestTempDetails,getTestDetails ,doReport} from '@/api/test.js'
  102. import { mapGetters } from 'vuex';
  103. export default {
  104. data() {
  105. return {
  106. scrollTop:0,//滚动条位置
  107. formJson:null,
  108. tempId:null,
  109. patient:null,
  110. items:{},
  111. msgs:[],
  112. index:0,
  113. item:null,
  114. };
  115. },
  116. onLoad(option) {
  117. this.tempId=option.tempId;
  118. var that=this;
  119. uni.$on('refreshOrderPatient', (res) => {
  120. console.log("qxj data:"+JSON.stringify(res))
  121. that.patient=res;
  122. })
  123. },
  124. onShow() {
  125. this.getTestTempDetails();
  126. this.getTestDetails();
  127. },
  128. computed: {
  129. ...mapGetters(['logoimg']),
  130. },
  131. watch: {
  132. logoimg: {
  133. immediate: true, // 页面一进入就检查一次
  134. handler(val) {
  135. return val
  136. }
  137. },
  138. },
  139. //发送给朋友
  140. onShareAppMessage(res) {
  141. if(this.utils.isLogin()){
  142. return {
  143. title: "健康体质检测",
  144. path: '/pages_index/test?tempId='+this.tempId,
  145. imageUrl: this.logoimg //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  146. }
  147. }
  148. },
  149. //分享到朋友圈
  150. onShareTimeline(res) {
  151. if(this.utils.isLogin()){
  152. return {
  153. title: "健康体质检测",
  154. imageUrl: this.logoimg //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  155. }
  156. }
  157. },
  158. methods:{
  159. getTestDetails(){
  160. let data = {tempId:this.tempId};
  161. getTestDetails(data).then(
  162. res => {
  163. if(res.code==200){
  164. uni.setNavigationBarTitle({
  165. title: res.data.name+"自测"
  166. });
  167. }else{
  168. uni.showToast({
  169. icon:'none',
  170. title: "请求失败",
  171. });
  172. }
  173. },
  174. rej => {}
  175. );
  176. },
  177. addMsg(type,content){
  178. var msg={type:type,content:content}
  179. this.msgs.push(msg)
  180. var that=this;
  181. uni
  182. .createSelectorQuery()
  183. .select(".msgs")
  184. .boundingClientRect((res) => {
  185. const scrollH = res.height;
  186. that.scrollTop = scrollH;
  187. console.log(that.scrollTop)
  188. })
  189. .exec();
  190. },
  191. optionClick(item,option){
  192. if(this.patient==null){
  193. uni.showToast({
  194. icon:'none',
  195. title: "请选择体验者",
  196. });
  197. return;
  198. }
  199. item.option=option.name;
  200. console.log(item.option);
  201. this.addMsg(2,option.name);
  202. this.index++;
  203. if(this.index<=this.items.length-1){
  204. this.item=this.items[this.index];
  205. this.addMsg(1,this.item.title)
  206. }
  207. else{
  208. //提交
  209. this.submit();
  210. }
  211. },
  212. getTestTempDetails(){
  213. var data={tempId:this.tempId}
  214. getTestTempDetails(data).then(
  215. res => {
  216. if(res.code==200){
  217. this.items=res.items;
  218. if(this.items.length>0){
  219. this.item=this.items[0];
  220. this.addMsg(1,this.item.title)
  221. }
  222. }
  223. },
  224. err => {
  225. }
  226. );
  227. },
  228. addPatient(){
  229. uni.navigateTo({
  230. url: '/pages_user/user/patient?isFromTest=true'
  231. })
  232. },
  233. submit(){
  234. var data={
  235. tempId:this.tempId,
  236. patientId:this.patient.patientId,
  237. formJson:JSON.stringify(this.items),
  238. }
  239. var that=this;
  240. doReport(data).then(res => {
  241. if(res.code==200){
  242. uni.redirectTo({
  243. url:"./testResult?reportId="+res.reportId
  244. })
  245. }else{
  246. uni.showToast({
  247. icon:'none',
  248. title: res.msg,
  249. });
  250. }
  251. });
  252. // uni.showModal({
  253. // title: '提示',
  254. // content: '确定提交吗',
  255. // success: function (res) {
  256. // if (res.confirm) {
  257. // doReport(data).then(res => {
  258. // if(res.code==200){
  259. // uni.navigateTo({
  260. // url:"./testResult?reportId="+res.reportId
  261. // })
  262. // }else{
  263. // uni.showToast({
  264. // icon:'none',
  265. // title: res.msg,
  266. // });
  267. // }
  268. // });
  269. // }
  270. // else if (res.cancel) {
  271. // }
  272. // }
  273. // });
  274. }
  275. }
  276. }
  277. </script>
  278. <style lang="scss">
  279. page{
  280. height: 100%;
  281. }
  282. .content{
  283. height: 100vh;
  284. .msg-cont{
  285. padding-bottom: 550rpx;
  286. width: 100%;
  287. height: calc(100vh - 760rpx);
  288. .msg-scroll{
  289. height: calc(100vh - 760rpx);
  290. .msgs{
  291. overflow: hidden;
  292. width: 100%;
  293. .msg-item{
  294. padding: 10rpx 15rpx;
  295. display: flex;
  296. flex-direction: column;
  297. justify-content: center;
  298. align-items: flex-start;
  299. width: 100%;
  300. .left{
  301. width: 100%;
  302. display: flex;
  303. justify-content: flex-start;
  304. align-items: flex-start;
  305. .img{
  306. min-width: 100rpx;
  307. width: 100rpx;
  308. height:100rpx;
  309. border-radius: 50%;
  310. image{
  311. width: 100%;
  312. height:100%;
  313. }
  314. }
  315. .msg-content{
  316. margin-top: 15rpx;
  317. margin-left: 10rpx;
  318. border-radius: 15rpx;
  319. padding: 15rpx;
  320. background-color: #fff;
  321. color: #111;
  322. font-size: 28upx;
  323. font-family: PingFang SC;
  324. }
  325. }
  326. .right{
  327. width: 100%;
  328. display: flex;
  329. justify-content: flex-end;
  330. align-items: flex-start;
  331. .msg-content{
  332. margin-top: 15rpx;
  333. margin-right: 10rpx;
  334. border-radius: 15rpx;
  335. padding: 15rpx;
  336. background-color: #d3ad58;
  337. color: #fff;
  338. font-size: 28upx;
  339. font-family: PingFang SC;
  340. }
  341. .img{
  342. min-width: 100rpx;
  343. width: 100rpx;
  344. height:100rpx;
  345. border-radius: 50%;
  346. image{
  347. width: 100%;
  348. height:100%;
  349. }
  350. }
  351. }
  352. }
  353. }
  354. }
  355. }
  356. .option-cont{
  357. position: fixed;
  358. bottom: 0rpx;
  359. height: 550rpx;
  360. width: 100%;
  361. box-sizing: border-box;
  362. background-color: #fff;
  363. border-radius: 60rpx 60rpx 0rpx 0rpx;
  364. padding: 30rpx;
  365. .option-title{
  366. width: 100%;
  367. padding-bottom: 15rpx;
  368. display: flex;
  369. align-items: center;
  370. justify-content: center;
  371. font-size: 32upx;
  372. font-family: PingFang SC;
  373. color: #111;
  374. }
  375. .options{
  376. display: flex;
  377. flex-direction: column;
  378. justify-content: center;
  379. align-items: center;
  380. .option-item{
  381. display: flex;
  382. align-items: center;
  383. justify-content: center;
  384. width: 100%;
  385. border: 1rpx solid #eee;
  386. margin-bottom: 10rpx;
  387. padding: 15rpx;
  388. border-radius: 5rpx;
  389. }
  390. }
  391. }
  392. .title{
  393. padding: 15rpx 30rpx;
  394. display: flex;
  395. justify-content: center;
  396. align-items: center;
  397. width: 100%;
  398. background-color: #d3ad58;
  399. font-size: 24upx;
  400. font-family: PingFang SC;
  401. font-weight: bold;
  402. color: #fff;
  403. }
  404. .patient-cont{
  405. padding: 15rpx;
  406. .chose-patient{
  407. padding: 30rpx;
  408. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  409. background-color: #fff;
  410. border-radius: 15rpx;
  411. .patient-box{
  412. display: flex;
  413. align-items: center;
  414. justify-content: space-between;
  415. .patient-title{
  416. font-size: 32upx;
  417. font-family: PingFang SC;
  418. font-weight: bold;
  419. color: #111111;
  420. }
  421. .right{
  422. height: 100%;
  423. display: flex;
  424. align-items: center;
  425. justify-content: center;
  426. .value{
  427. font-size: 28upx;
  428. font-family: PingFang SC;
  429. color: #999;
  430. margin-right: 10rpx;
  431. }
  432. image{
  433. width: 15upx;
  434. height: 30upx;
  435. }
  436. }
  437. }
  438. .patient{
  439. display: flex;
  440. align-items: center;
  441. justify-content: space-between;
  442. height: 110upx;
  443. .left{
  444. .name{
  445. font-size: 30upx;
  446. line-height: 1;
  447. font-family: PingFang SC;
  448. font-weight: bold;
  449. color: #111111;
  450. }
  451. .info{
  452. margin-top: 30rpx;
  453. display: flex;
  454. align-items: center;
  455. .text{
  456. font-size: 26upx;
  457. font-family: PingFang SC;
  458. line-height: 1;
  459. font-weight: 500;
  460. color: #999;
  461. margin-right: 19upx;
  462. }
  463. }
  464. }
  465. .right{
  466. display: flex;
  467. align-items: center;
  468. image{
  469. width: 15upx;
  470. height: 30upx;
  471. }
  472. }
  473. }
  474. }
  475. }
  476. .items{
  477. padding: 15rpx;
  478. width: 100%;
  479. padding: 30rpx;
  480. border-radius: 15rpx;
  481. background-color: #fff;
  482. display: flex;
  483. flex-direction: column;
  484. align-items: flex-start;
  485. justify-content: flex-start;
  486. .item{
  487. display: flex;
  488. flex-direction: column;
  489. align-items: flex-start;
  490. justify-content: flex-start;
  491. width: 100%;
  492. background-color: #f8f8f8;
  493. margin-bottom: 15rpx;
  494. .name{
  495. font-size: 32upx;
  496. font-family: PingFang SC;
  497. color: #2a2b2e;
  498. font-weight: bold;
  499. margin-bottom: 15rpx;
  500. }
  501. .options{
  502. margin: 15rpx 0rpx;
  503. width: 100%;
  504. display: flex;
  505. align-items: center;
  506. justify-content: space-between;
  507. .option{
  508. margin-right: 10rpx;
  509. margin-bottom: 10rpx;
  510. display: flex;
  511. align-items: center;
  512. justify-content: center;
  513. border-radius: 10rpx;
  514. width:20%;
  515. height:80rpx;
  516. border: 1rpx solid #9b9b9b;
  517. font-size: 28upx;
  518. font-family: PingFang SC;
  519. color: #2a2b2e;
  520. background-color: #fff;
  521. &:last-child{
  522. margin-right: 0rpx;
  523. margin-bottom: 0rpx;
  524. }
  525. }
  526. .active{
  527. border: 1rpx solid #d3ad58;
  528. background-color: #d3ad58;
  529. color: #fff;
  530. }
  531. }
  532. }
  533. }
  534. .btns{
  535. display: flex;
  536. align-items: center;
  537. justify-content: space-between;
  538. width: 100%;
  539. padding: 30rpx;
  540. .btn{
  541. height:80rpx;
  542. margin: 0rpx 30rpx;
  543. border-radius: 60rpx;
  544. width: 100%;
  545. border: 1rpx solid #d3ad58;
  546. font-size: 32supx; font-family: PingFang SC; color: #fff;
  547. font-weight: bold;
  548. background-color: #d3ad58;
  549. display: flex;
  550. align-items: center;
  551. justify-content: center;
  552. }
  553. }
  554. .tips{
  555. flex-direction: column;
  556. display: flex;
  557. align-items: center;
  558. justify-content: center;
  559. width: 100%;
  560. padding: 30rpx;
  561. .tip-title{
  562. font-size: 26supx;
  563. font-family: PingFang SC;
  564. color: #888;
  565. font-weight: bold;
  566. }
  567. .desc{
  568. margin-top: 15rpx;
  569. font-size: 24rpx;
  570. font-family: PingFang SC;
  571. color: #b8bdb5;
  572. }
  573. }
  574. }
  575. </style>