test.vue 14 KB

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