test.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  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. })
  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. this.addMsg(2,option.name);
  188. this.index++;
  189. if(this.index<=this.items.length-1){
  190. this.item=this.items[this.index];
  191. this.addMsg(1,this.item.title)
  192. }
  193. else{
  194. //提交
  195. this.submit();
  196. }
  197. },
  198. getTestTempDetails(){
  199. var data={tempId:this.tempId}
  200. getTestTempDetails(data).then(
  201. res => {
  202. if(res.code==200){
  203. this.items=res.items;
  204. if(this.items.length>0){
  205. this.item=this.items[0];
  206. this.addMsg(1,this.item.title)
  207. }
  208. }
  209. },
  210. err => {
  211. }
  212. );
  213. },
  214. addPatient(){
  215. uni.navigateTo({
  216. url: '/pages_user/user/patient?isFromTest=true'
  217. })
  218. },
  219. submit(){
  220. var data={
  221. tempId:this.tempId,
  222. patientId:this.patient.patientId,
  223. formJson:JSON.stringify(this.items),
  224. }
  225. var that=this;
  226. doReport(data).then(res => {
  227. if(res.code==200){
  228. uni.redirectTo({
  229. url:"./testResult?reportId="+res.reportId
  230. })
  231. }else{
  232. uni.showToast({
  233. icon:'none',
  234. title: res.msg,
  235. });
  236. }
  237. });
  238. // uni.showModal({
  239. // title: '提示',
  240. // content: '确定提交吗',
  241. // success: function (res) {
  242. // if (res.confirm) {
  243. // doReport(data).then(res => {
  244. // if(res.code==200){
  245. // uni.navigateTo({
  246. // url:"./testResult?reportId="+res.reportId
  247. // })
  248. // }else{
  249. // uni.showToast({
  250. // icon:'none',
  251. // title: res.msg,
  252. // });
  253. // }
  254. // });
  255. // }
  256. // else if (res.cancel) {
  257. // }
  258. // }
  259. // });
  260. }
  261. }
  262. }
  263. </script>
  264. <style lang="scss">
  265. page{
  266. height: 100%;
  267. }
  268. .content{
  269. height: 100vh;
  270. .msg-cont{
  271. padding-bottom: 550rpx;
  272. width: 100%;
  273. height: calc(100vh - 760rpx);
  274. .msg-scroll{
  275. height: calc(100vh - 760rpx);
  276. .msgs{
  277. overflow: hidden;
  278. width: 100%;
  279. .msg-item{
  280. padding: 10rpx 15rpx;
  281. display: flex;
  282. flex-direction: column;
  283. justify-content: center;
  284. align-items: flex-start;
  285. width: 100%;
  286. .left{
  287. width: 100%;
  288. display: flex;
  289. justify-content: flex-start;
  290. align-items: flex-start;
  291. .img{
  292. min-width: 100rpx;
  293. width: 100rpx;
  294. height:100rpx;
  295. border-radius: 50%;
  296. image{
  297. width: 100%;
  298. height:100%;
  299. }
  300. }
  301. .msg-content{
  302. margin-top: 15rpx;
  303. margin-left: 10rpx;
  304. border-radius: 15rpx;
  305. padding: 15rpx;
  306. background-color: #fff;
  307. color: #111;
  308. font-size: 28upx;
  309. font-family: PingFang SC;
  310. }
  311. }
  312. .right{
  313. width: 100%;
  314. display: flex;
  315. justify-content: flex-end;
  316. align-items: flex-start;
  317. .msg-content{
  318. margin-top: 15rpx;
  319. margin-right: 10rpx;
  320. border-radius: 15rpx;
  321. padding: 15rpx;
  322. background-color: #d3ad58;
  323. color: #fff;
  324. font-size: 28upx;
  325. font-family: PingFang SC;
  326. }
  327. .img{
  328. min-width: 100rpx;
  329. width: 100rpx;
  330. height:100rpx;
  331. border-radius: 50%;
  332. image{
  333. width: 100%;
  334. height:100%;
  335. }
  336. }
  337. }
  338. }
  339. }
  340. }
  341. }
  342. .option-cont{
  343. position: fixed;
  344. bottom: 0rpx;
  345. height: 550rpx;
  346. width: 100%;
  347. box-sizing: border-box;
  348. background-color: #fff;
  349. border-radius: 60rpx 60rpx 0rpx 0rpx;
  350. padding: 30rpx;
  351. .option-title{
  352. width: 100%;
  353. padding-bottom: 15rpx;
  354. display: flex;
  355. align-items: center;
  356. justify-content: center;
  357. font-size: 32upx;
  358. font-family: PingFang SC;
  359. color: #111;
  360. }
  361. .options{
  362. display: flex;
  363. flex-direction: column;
  364. justify-content: center;
  365. align-items: center;
  366. .option-item{
  367. display: flex;
  368. align-items: center;
  369. justify-content: center;
  370. width: 100%;
  371. border: 1rpx solid #eee;
  372. margin-bottom: 10rpx;
  373. padding: 15rpx;
  374. border-radius: 5rpx;
  375. }
  376. }
  377. }
  378. .title{
  379. padding: 15rpx 30rpx;
  380. display: flex;
  381. justify-content: center;
  382. align-items: center;
  383. width: 100%;
  384. background-color: #d3ad58;
  385. font-size: 24upx;
  386. font-family: PingFang SC;
  387. font-weight: bold;
  388. color: #fff;
  389. }
  390. .patient-cont{
  391. padding: 15rpx;
  392. .chose-patient{
  393. padding: 30rpx;
  394. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  395. background-color: #fff;
  396. border-radius: 15rpx;
  397. .patient-box{
  398. display: flex;
  399. align-items: center;
  400. justify-content: space-between;
  401. .patient-title{
  402. font-size: 32upx;
  403. font-family: PingFang SC;
  404. font-weight: bold;
  405. color: #111111;
  406. }
  407. .right{
  408. height: 100%;
  409. display: flex;
  410. align-items: center;
  411. justify-content: center;
  412. .value{
  413. font-size: 28upx;
  414. font-family: PingFang SC;
  415. color: #999;
  416. margin-right: 10rpx;
  417. }
  418. image{
  419. width: 15upx;
  420. height: 30upx;
  421. }
  422. }
  423. }
  424. .patient{
  425. display: flex;
  426. align-items: center;
  427. justify-content: space-between;
  428. height: 110upx;
  429. .left{
  430. .name{
  431. font-size: 30upx;
  432. line-height: 1;
  433. font-family: PingFang SC;
  434. font-weight: bold;
  435. color: #111111;
  436. }
  437. .info{
  438. margin-top: 30rpx;
  439. display: flex;
  440. align-items: center;
  441. .text{
  442. font-size: 26upx;
  443. font-family: PingFang SC;
  444. line-height: 1;
  445. font-weight: 500;
  446. color: #999;
  447. margin-right: 19upx;
  448. }
  449. }
  450. }
  451. .right{
  452. display: flex;
  453. align-items: center;
  454. image{
  455. width: 15upx;
  456. height: 30upx;
  457. }
  458. }
  459. }
  460. }
  461. }
  462. .items{
  463. padding: 15rpx;
  464. width: 100%;
  465. padding: 30rpx;
  466. border-radius: 15rpx;
  467. background-color: #fff;
  468. display: flex;
  469. flex-direction: column;
  470. align-items: flex-start;
  471. justify-content: flex-start;
  472. .item{
  473. display: flex;
  474. flex-direction: column;
  475. align-items: flex-start;
  476. justify-content: flex-start;
  477. width: 100%;
  478. background-color: #f8f8f8;
  479. margin-bottom: 15rpx;
  480. .name{
  481. font-size: 32upx;
  482. font-family: PingFang SC;
  483. color: #2a2b2e;
  484. font-weight: bold;
  485. margin-bottom: 15rpx;
  486. }
  487. .options{
  488. margin: 15rpx 0rpx;
  489. width: 100%;
  490. display: flex;
  491. align-items: center;
  492. justify-content: space-between;
  493. .option{
  494. margin-right: 10rpx;
  495. margin-bottom: 10rpx;
  496. display: flex;
  497. align-items: center;
  498. justify-content: center;
  499. border-radius: 10rpx;
  500. width:20%;
  501. height:80rpx;
  502. border: 1rpx solid #9b9b9b;
  503. font-size: 28upx;
  504. font-family: PingFang SC;
  505. color: #2a2b2e;
  506. background-color: #fff;
  507. &:last-child{
  508. margin-right: 0rpx;
  509. margin-bottom: 0rpx;
  510. }
  511. }
  512. .active{
  513. border: 1rpx solid #d3ad58;
  514. background-color: #d3ad58;
  515. color: #fff;
  516. }
  517. }
  518. }
  519. }
  520. .btns{
  521. display: flex;
  522. align-items: center;
  523. justify-content: space-between;
  524. width: 100%;
  525. padding: 30rpx;
  526. .btn{
  527. height:80rpx;
  528. margin: 0rpx 30rpx;
  529. border-radius: 60rpx;
  530. width: 100%;
  531. border: 1rpx solid #d3ad58;
  532. font-size: 32supx; font-family: PingFang SC; color: #fff;
  533. font-weight: bold;
  534. background-color: #d3ad58;
  535. display: flex;
  536. align-items: center;
  537. justify-content: center;
  538. }
  539. }
  540. .tips{
  541. flex-direction: column;
  542. display: flex;
  543. align-items: center;
  544. justify-content: center;
  545. width: 100%;
  546. padding: 30rpx;
  547. .tip-title{
  548. font-size: 26supx;
  549. font-family: PingFang SC;
  550. color: #888;
  551. font-weight: bold;
  552. }
  553. .desc{
  554. margin-top: 15rpx;
  555. font-size: 24rpx;
  556. font-family: PingFang SC;
  557. color: #b8bdb5;
  558. }
  559. }
  560. }
  561. </style>