test.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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. console.log("qxj data:"+JSON.stringify(res))
  120. that.patient=res;
  121. })
  122. },
  123. onShow() {
  124. this.getTestTempDetails();
  125. this.getTestDetails();
  126. },
  127. //发送给朋友
  128. onShareAppMessage(res) {
  129. if(this.utils.isLogin()){
  130. return {
  131. title: "健康体质检测",
  132. path: '/pages_index/test?tempId='+this.tempId,
  133. imageUrl: 'https://beiliyo-2025.obs.cn-north-4.myhuaweicloud.com/fs/20250115/1736944490230.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  134. }
  135. }
  136. },
  137. //分享到朋友圈
  138. onShareTimeline(res) {
  139. if(this.utils.isLogin()){
  140. return {
  141. title: "健康体质检测",
  142. imageUrl: 'https://beiliyo-2025.obs.cn-north-4.myhuaweicloud.com/fs/20250115/1736944490230.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/user/patient?isFromTest=true'
  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:"./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:"./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. box-sizing: border-box;
  350. background-color: #fff;
  351. border-radius: 60rpx 60rpx 0rpx 0rpx;
  352. padding: 30rpx;
  353. .option-title{
  354. width: 100%;
  355. padding-bottom: 15rpx;
  356. display: flex;
  357. align-items: center;
  358. justify-content: center;
  359. font-size: 32upx;
  360. font-family: PingFang SC;
  361. color: #111;
  362. }
  363. .options{
  364. display: flex;
  365. flex-direction: column;
  366. justify-content: center;
  367. align-items: center;
  368. .option-item{
  369. display: flex;
  370. align-items: center;
  371. justify-content: center;
  372. width: 100%;
  373. border: 1rpx solid #eee;
  374. margin-bottom: 10rpx;
  375. padding: 15rpx;
  376. border-radius: 5rpx;
  377. }
  378. }
  379. }
  380. .title{
  381. padding: 15rpx 30rpx;
  382. display: flex;
  383. justify-content: center;
  384. align-items: center;
  385. width: 100%;
  386. background-color: #d3ad58;
  387. font-size: 24upx;
  388. font-family: PingFang SC;
  389. font-weight: bold;
  390. color: #fff;
  391. }
  392. .patient-cont{
  393. padding: 15rpx;
  394. .chose-patient{
  395. padding: 30rpx;
  396. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  397. background-color: #fff;
  398. border-radius: 15rpx;
  399. .patient-box{
  400. display: flex;
  401. align-items: center;
  402. justify-content: space-between;
  403. .patient-title{
  404. font-size: 32upx;
  405. font-family: PingFang SC;
  406. font-weight: bold;
  407. color: #111111;
  408. }
  409. .right{
  410. height: 100%;
  411. display: flex;
  412. align-items: center;
  413. justify-content: center;
  414. .value{
  415. font-size: 28upx;
  416. font-family: PingFang SC;
  417. color: #999;
  418. margin-right: 10rpx;
  419. }
  420. image{
  421. width: 15upx;
  422. height: 30upx;
  423. }
  424. }
  425. }
  426. .patient{
  427. display: flex;
  428. align-items: center;
  429. justify-content: space-between;
  430. height: 110upx;
  431. .left{
  432. .name{
  433. font-size: 30upx;
  434. line-height: 1;
  435. font-family: PingFang SC;
  436. font-weight: bold;
  437. color: #111111;
  438. }
  439. .info{
  440. margin-top: 30rpx;
  441. display: flex;
  442. align-items: center;
  443. .text{
  444. font-size: 26upx;
  445. font-family: PingFang SC;
  446. line-height: 1;
  447. font-weight: 500;
  448. color: #999;
  449. margin-right: 19upx;
  450. }
  451. }
  452. }
  453. .right{
  454. display: flex;
  455. align-items: center;
  456. image{
  457. width: 15upx;
  458. height: 30upx;
  459. }
  460. }
  461. }
  462. }
  463. }
  464. .items{
  465. padding: 15rpx;
  466. width: 100%;
  467. padding: 30rpx;
  468. border-radius: 15rpx;
  469. background-color: #fff;
  470. display: flex;
  471. flex-direction: column;
  472. align-items: flex-start;
  473. justify-content: flex-start;
  474. .item{
  475. display: flex;
  476. flex-direction: column;
  477. align-items: flex-start;
  478. justify-content: flex-start;
  479. width: 100%;
  480. background-color: #f8f8f8;
  481. margin-bottom: 15rpx;
  482. .name{
  483. font-size: 32upx;
  484. font-family: PingFang SC;
  485. color: #2a2b2e;
  486. font-weight: bold;
  487. margin-bottom: 15rpx;
  488. }
  489. .options{
  490. margin: 15rpx 0rpx;
  491. width: 100%;
  492. display: flex;
  493. align-items: center;
  494. justify-content: space-between;
  495. .option{
  496. margin-right: 10rpx;
  497. margin-bottom: 10rpx;
  498. display: flex;
  499. align-items: center;
  500. justify-content: center;
  501. border-radius: 10rpx;
  502. width:20%;
  503. height:80rpx;
  504. border: 1rpx solid #9b9b9b;
  505. font-size: 28upx;
  506. font-family: PingFang SC;
  507. color: #2a2b2e;
  508. background-color: #fff;
  509. &:last-child{
  510. margin-right: 0rpx;
  511. margin-bottom: 0rpx;
  512. }
  513. }
  514. .active{
  515. border: 1rpx solid #d3ad58;
  516. background-color: #d3ad58;
  517. color: #fff;
  518. }
  519. }
  520. }
  521. }
  522. .btns{
  523. display: flex;
  524. align-items: center;
  525. justify-content: space-between;
  526. width: 100%;
  527. padding: 30rpx;
  528. .btn{
  529. height:80rpx;
  530. margin: 0rpx 30rpx;
  531. border-radius: 60rpx;
  532. width: 100%;
  533. border: 1rpx solid #d3ad58;
  534. font-size: 32supx; font-family: PingFang SC; color: #fff;
  535. font-weight: bold;
  536. background-color: #d3ad58;
  537. display: flex;
  538. align-items: center;
  539. justify-content: center;
  540. }
  541. }
  542. .tips{
  543. flex-direction: column;
  544. display: flex;
  545. align-items: center;
  546. justify-content: center;
  547. width: 100%;
  548. padding: 30rpx;
  549. .tip-title{
  550. font-size: 26supx;
  551. font-family: PingFang SC;
  552. color: #888;
  553. font-weight: bold;
  554. }
  555. .desc{
  556. margin-top: 15rpx;
  557. font-size: 24rpx;
  558. font-family: PingFang SC;
  559. color: #b8bdb5;
  560. }
  561. }
  562. }
  563. </style>