test.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  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">{{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="/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. <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="/static/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="/static/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. export default {
  103. data() {
  104. return {
  105. scrollTop:0,//滚动条位置
  106. formJson:null,
  107. tempId:null,
  108. patient:null,
  109. items:{},
  110. msgs:[],
  111. index:0,
  112. item:null,
  113. };
  114. },
  115. onLoad(option) {
  116. this.tempId=option.tempId;
  117. var that=this;
  118. uni.$on('refreshOrderPatient', (res) => {
  119. that.patient=res;
  120. })
  121. },
  122. onShow() {
  123. this.getTestTempDetails();
  124. this.getTestDetails();
  125. },
  126. //发送给朋友
  127. onShareAppMessage(res) {
  128. if(this.utils.isLogin()){
  129. return {
  130. title: "健康体质检测",
  131. path: '/pages_index/test?tempId='+this.tempId,
  132. imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20241018/b810f26926904253ae46ea4e93b71dee.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  133. }
  134. }
  135. },
  136. //分享到朋友圈
  137. onShareTimeline(res) {
  138. if(this.utils.isLogin()){
  139. return {
  140. title: "健康体质检测",
  141. imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20241018/b810f26926904253ae46ea4e93b71dee.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  142. }
  143. }
  144. },
  145. methods:{
  146. getTestDetails(){
  147. let data = {tempId:this.tempId};
  148. getTestDetails(data).then(
  149. res => {
  150. if(res.code==200){
  151. uni.setNavigationBarTitle({
  152. title: res.data.name+"自测"
  153. });
  154. }else{
  155. uni.showToast({
  156. icon:'none',
  157. title: "请求失败",
  158. });
  159. }
  160. },
  161. rej => {}
  162. );
  163. },
  164. addMsg(type,content){
  165. var msg={type:type,content:content}
  166. this.msgs.push(msg)
  167. var that=this;
  168. uni
  169. .createSelectorQuery()
  170. .select(".msgs")
  171. .boundingClientRect((res) => {
  172. const scrollH = res.height;
  173. that.scrollTop = scrollH;
  174. console.log(that.scrollTop)
  175. })
  176. .exec();
  177. },
  178. optionClick(item,option){
  179. if(this.patient==null){
  180. uni.showToast({
  181. icon:'none',
  182. title: "请选择体验者",
  183. });
  184. return;
  185. }
  186. item.option=option.name;
  187. console.log(item.option);
  188. this.addMsg(2,option.name);
  189. this.index++;
  190. if(this.index<=this.items.length-1){
  191. this.item=this.items[this.index];
  192. this.addMsg(1,this.item.title)
  193. }
  194. else{
  195. //提交
  196. this.submit();
  197. }
  198. },
  199. getTestTempDetails(){
  200. var data={tempId:this.tempId}
  201. getTestTempDetails(data).then(
  202. res => {
  203. if(res.code==200){
  204. this.items=res.items;
  205. if(this.items.length>0){
  206. this.item=this.items[0];
  207. this.addMsg(1,this.item.title)
  208. }
  209. }
  210. },
  211. err => {
  212. }
  213. );
  214. },
  215. addPatient(){
  216. uni.navigateTo({
  217. url: '/pages_user/user/patient?isFromTest=true'
  218. })
  219. },
  220. submit(){
  221. var data={
  222. tempId:this.tempId,
  223. patientId:this.patient.patientId,
  224. formJson:JSON.stringify(this.items),
  225. }
  226. var that=this;
  227. doReport(data).then(res => {
  228. if(res.code==200){
  229. uni.redirectTo({
  230. url:"./testResult?reportId="+res.reportId
  231. })
  232. }else{
  233. uni.showToast({
  234. icon:'none',
  235. title: res.msg,
  236. });
  237. }
  238. });
  239. // uni.showModal({
  240. // title: '提示',
  241. // content: '确定提交吗',
  242. // success: function (res) {
  243. // if (res.confirm) {
  244. // doReport(data).then(res => {
  245. // if(res.code==200){
  246. // uni.navigateTo({
  247. // url:"./testResult?reportId="+res.reportId
  248. // })
  249. // }else{
  250. // uni.showToast({
  251. // icon:'none',
  252. // title: res.msg,
  253. // });
  254. // }
  255. // });
  256. // }
  257. // else if (res.cancel) {
  258. // }
  259. // }
  260. // });
  261. }
  262. }
  263. }
  264. </script>
  265. <style lang="scss">
  266. page{
  267. height: 100%;
  268. }
  269. .content{
  270. height: 100vh;
  271. .msg-cont{
  272. padding-bottom: 550rpx;
  273. width: 100%;
  274. height: calc(100vh - 760rpx);
  275. .msg-scroll{
  276. height: calc(100vh - 760rpx);
  277. .msgs{
  278. overflow: hidden;
  279. width: 100%;
  280. .msg-item{
  281. padding: 10rpx 15rpx;
  282. display: flex;
  283. flex-direction: column;
  284. justify-content: center;
  285. align-items: flex-start;
  286. width: 100%;
  287. .left{
  288. width: 100%;
  289. display: flex;
  290. justify-content: flex-start;
  291. align-items: flex-start;
  292. .img{
  293. min-width: 100rpx;
  294. width: 100rpx;
  295. height:100rpx;
  296. border-radius: 50%;
  297. image{
  298. width: 100%;
  299. height:100%;
  300. }
  301. }
  302. .msg-content{
  303. margin-top: 15rpx;
  304. margin-left: 10rpx;
  305. border-radius: 15rpx;
  306. padding: 15rpx;
  307. background-color: #fff;
  308. color: #111;
  309. font-size: 28upx;
  310. font-family: PingFang SC;
  311. }
  312. }
  313. .right{
  314. width: 100%;
  315. display: flex;
  316. justify-content: flex-end;
  317. align-items: flex-start;
  318. .msg-content{
  319. margin-top: 15rpx;
  320. margin-right: 10rpx;
  321. border-radius: 15rpx;
  322. padding: 15rpx;
  323. background-color: #d3ad58;
  324. color: #fff;
  325. font-size: 28upx;
  326. font-family: PingFang SC;
  327. }
  328. .img{
  329. min-width: 100rpx;
  330. width: 100rpx;
  331. height:100rpx;
  332. border-radius: 50%;
  333. image{
  334. width: 100%;
  335. height:100%;
  336. }
  337. }
  338. }
  339. }
  340. }
  341. }
  342. }
  343. .option-cont{
  344. position: fixed;
  345. bottom: 0rpx;
  346. height: 550rpx;
  347. width: 100%;
  348. box-sizing: border-box;
  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>