test.vue 14 KB

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