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