testResult.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <view class="content">
  3. <view class="cont">
  4. <view class="bg">
  5. <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/8e52ab17eabc4534b3ce56026fd5c624.jpg" ></image>
  6. </view>
  7. <view class="cont-box" v-if="report!=null">
  8. <view class="user">
  9. <image :src="JSON.parse(report.patientJson).avatar==null?'https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/22cb9518a55040dea74d8f730551a7a2.jpg':JSON.parse(report.patientJson).avatar"></image>
  10. <view class="user-box">
  11. <view class="sex">性别 {{JSON.parse(report.patientJson).sex==1?"男":"女"}}</view>
  12. <view class="username">年龄 {{JSON.parse(report.patientJson).age}}岁</view>
  13. </view>
  14. </view>
  15. <view class="items">
  16. <view class="result-box">
  17. <view class="time">检测时间 {{report.createTime}}</view>
  18. <view class="title">您属于{{report.testResult}}</view>
  19. <view class="name">{{report.testResult}}</view>
  20. <!-- <view class="descs">{{report.testResult}}是一种身心和谐的表现,努力保持吧!</view> -->
  21. </view>
  22. <view class="item-box" v-for="(item,index) in JSON.parse(report.conditioningPlanJson) ">
  23. <view class="item">
  24. <view class="title-box">
  25. <view class="title">{{item.name}}</view>
  26. </view>
  27. <view class="descs" >{{item.value.replace(/\\n/g, '<br>')}}</view>
  28. </view>
  29. <view v-if="index<JSON.parse(report.conditioningPlanJson).length-2" class="line"></view>
  30. </view>
  31. </view>
  32. <view class="tips">
  33. 注:报告内容仅供参考,具体情况以医生建议为准
  34. </view>
  35. <view class="banner" v-if="advImgs.length>0">
  36. <u-swiper
  37. :list="advImgs"
  38. circular
  39. @click="handleAdvClick"
  40. ></u-swiper>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- #ifndef H5 -->
  45. <view class="share" @click="shareImg()">
  46. <text>分享</text>
  47. </view>
  48. <!-- #endif -->
  49. <!-- 分享弹窗 -->
  50. <u-popup :show="showShare" @close="showShare = false" >
  51. <share-box :shareItem="shareItem" @closeShare='showShare = false' ></share-box>
  52. </u-popup>
  53. <h5-down-app-tip :pageUrl="pageUrl"/>
  54. </view>
  55. </template>
  56. <script>
  57. import {getAdvList} from '@/api/adv.js'
  58. import {getTestReport,getTestReportImg} from '@/api/test.js'
  59. export default {
  60. data() {
  61. return {
  62. advImgs:[],
  63. advs:[],
  64. reportId:null,
  65. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  66. report:null,
  67. img: "",
  68. showShare:false,
  69. shareItem:{ imageUrl:"",title:"",path:"",isMini:true },
  70. pageUrl: ''
  71. };
  72. },
  73. onShareAppMessage(res) {
  74. if(this.$isLogin()){
  75. return {
  76. title: "测试结果",
  77. path: '/pages_index/testResult?reportId='+this.reportId,
  78. imageUrl: this.img //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  79. }
  80. }
  81. },
  82. //分享到朋友圈
  83. onShareTimeline(res) {
  84. if(this.$isLogin()){
  85. return {
  86. title: "测试结果",
  87. path: '/pages_index/testResult?reportId='+this.reportId,
  88. imageUrl: this.img //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  89. }
  90. }
  91. },
  92. onLoad(option) {
  93. this.reportId=option.reportId;
  94. this.getTestReport();
  95. },
  96. onShow() {
  97. if(!this.$isLogin()) {
  98. uni.navigateTo({
  99. url: '/pages/auth/loginIndex'
  100. })
  101. return
  102. }
  103. this.pageUrl = '/pages/article/testResult?reportId='+this.reportId;
  104. this.getAdvList();
  105. },
  106. methods:{
  107. shareImg(){
  108. var data={reportId:this.reportId}
  109. getTestReportImg(data).then(
  110. res => {
  111. if(res.code==200){
  112. // console.log('测试结果分享',res)
  113. this.img = res.img
  114. // #ifdef APP-PLUS
  115. this.shareItem.title= "测试结果";
  116. this.shareItem.imageUrl=res.img;
  117. this.shareItem.compressImage = 1
  118. this.shareItem.isMini=true;
  119. this.shareItem.path='/pages_index/testResult?reportId='+this.reportId;
  120. let cdn=uni.getStorageSync('h5Path');
  121. this.shareItem.url=cdn+'/pages/article/testResult?reportId='+this.reportId;
  122. this.showShare=true;
  123. // #endif
  124. // console.log(res)
  125. // wx.downloadFile({
  126. // url: res.img,
  127. // success: (res1) => {
  128. // console.log(res1)
  129. // wx.showShareImageMenu({
  130. // path: res1.tempFilePath
  131. // })
  132. // },
  133. // fail:(res2)=>{
  134. // console.log(res2)
  135. // }
  136. // })
  137. }
  138. },
  139. err => {
  140. }
  141. );
  142. // uni.navigateTo({
  143. // url: '/pages_index/testResultImg?reportId=' + this.reportId
  144. // })
  145. },
  146. handleAdvClick(index){
  147. var ad=this.advs[index];
  148. if(ad.showType==1){
  149. uni.setStorageSync('url',ad.appAdvUrl);
  150. uni.navigateTo({
  151. url:"h5"
  152. })
  153. }
  154. else if(ad.showType==3){
  155. uni.setStorageSync('content',ad.appAdvUrl);
  156. uni.navigateTo({
  157. url:"content"
  158. })
  159. }
  160. else{
  161. uni.navigateTo({
  162. url:ad.appAdvUrl
  163. })
  164. }
  165. },
  166. getAdvList() {
  167. //联网加载数据
  168. var that = this;
  169. var data = {
  170. advType:3
  171. };
  172. getAdvList(data).then(res => {
  173. if(res.code==200){
  174. that.advImgs=[];
  175. that.advs=res.data;
  176. that.advs.forEach(function(element) {
  177. if(element.imageUrl!=null&&element.imageUrl!=""){
  178. that.advImgs.push(element.imageUrl);
  179. }
  180. });
  181. console.log(that.advImgs)
  182. }else{
  183. uni.showToast({
  184. icon:'none',
  185. title: "请求失败",
  186. });
  187. }
  188. });
  189. },
  190. getTestReport(){
  191. var data={reportId:this.reportId}
  192. getTestReport(data).then(
  193. res => {
  194. if(res.code==200){
  195. this.report=res.report;
  196. }
  197. },
  198. err => {
  199. }
  200. );
  201. },
  202. goBack(){
  203. uni.navigateBack()
  204. }
  205. }
  206. }
  207. </script>
  208. <style lang="scss">
  209. page{
  210. background-color: #FDF7F0;
  211. height: 100%;
  212. }
  213. .content{
  214. .cont{
  215. position: relative;
  216. width: 100%;
  217. display: flex;
  218. flex-direction: column;
  219. .bg{
  220. width: 100%;
  221. height:100%;
  222. // background-color: #2BC7B9;
  223. // background: linear-gradient(#2BC7B9, #88e2da);
  224. position: fixed;
  225. image{
  226. width: 100%;
  227. height:100%;
  228. }
  229. z-index: 1;
  230. }
  231. .cont-box{
  232. z-index: 1000;
  233. margin-top: 88rpx;
  234. .user{
  235. width: 100%;
  236. display: flex;
  237. flex-direction: column;
  238. align-items: center;
  239. justify-content: center;
  240. padding: 30rpx;
  241. image{
  242. border-radius: 50%;
  243. border: 2rpx solid #ffffff;
  244. width:120rpx;
  245. height:120rpx;
  246. }
  247. .user-box{
  248. padding: 30rpx;
  249. display: flex;
  250. align-items: center;
  251. justify-content: center;
  252. .sex{
  253. font-weight: bold;
  254. font-size: 40supx;
  255. font-family: PingFang SC;
  256. color: #925924;
  257. }
  258. .username{
  259. margin-left: 15rpx;
  260. font-size: 40supx;
  261. font-family: PingFang SC;
  262. color: #FF5C03;
  263. }
  264. }
  265. }
  266. .items{
  267. width: 100%;
  268. display: flex;
  269. flex-direction: column;
  270. align-items: flex-start;
  271. justify-content: flex-start;
  272. padding: 20rpx;
  273. .result-box{
  274. width: 100%;
  275. display: flex;
  276. flex-direction: column;
  277. align-items:center;
  278. justify-content: center;
  279. padding: 30rpx;
  280. background-color: #fff;
  281. border-radius: 15rpx;
  282. margin-bottom: 15rpx;
  283. .time{
  284. margin-top: 15rpx;
  285. font-family: PingFang SC;
  286. font-size: 24rpx;
  287. color: #9B9B9B;
  288. }
  289. .title{
  290. margin-top: 15rpx;
  291. font-family: PingFang SC;
  292. font-size: 28rpx;
  293. color: #626468;
  294. }
  295. .name{
  296. margin-top: 30rpx;
  297. font-family: PingFang SC;
  298. font-weight: bold;
  299. font-size: 60rpx;
  300. color: #FF5C03;
  301. }
  302. .descs{
  303. font-family: PingFang SC;
  304. font-size: 28rpx;
  305. color: #2A2B2E;
  306. padding: 30rpx;
  307. margin-top: 30rpx;
  308. background-color: #F5F6F6;
  309. border-radius: 10rpx;
  310. }
  311. }
  312. .item-box{
  313. width: 100%;
  314. .item{
  315. width: 100%;
  316. padding: 30rpx;
  317. background-color: #fff;
  318. border-radius:30rpx;
  319. .title-box{
  320. display: flex;
  321. align-items:center;
  322. justify-content: flex-start;
  323. .title{
  324. margin-left: 10rpx;
  325. font-size: 32supx;
  326. font-family: PingFang SC;
  327. color: #FF5C03;
  328. font-weight: bold;
  329. }
  330. .title-line{
  331. width: 8rpx;
  332. height: 28rpx;
  333. background: #2BC7B9;
  334. border-radius: 2px 2px 2px 2px;
  335. opacity: 1;
  336. }
  337. }
  338. .descs{
  339. white-space: pre-line;
  340. margin-top: 10rpx;
  341. font-size: 28supx;
  342. font-family: PingFang SC;
  343. color: #2A2B2E;
  344. }
  345. }
  346. .line{
  347. margin: 0rpx 30rpx;
  348. border-bottom: #b5b5b5 3rpx dashed;
  349. }
  350. }
  351. }
  352. .tips{
  353. width: 100%;
  354. display: flex;
  355. align-items: center;
  356. justify-content: center;
  357. margin: 15rpx 0rpx;
  358. color: #9B9B9B;
  359. font-size: 24rpx;
  360. }
  361. .banner{
  362. height:250rpx;
  363. width: 100%;
  364. padding: 15rpx 20upx;
  365. }
  366. }
  367. }
  368. }
  369. .share{
  370. width: 100rpx;
  371. height:100rpx;
  372. z-index: 9999;
  373. border-radius: 50%;
  374. position: fixed;
  375. bottom: 100rpx;
  376. right:50rpx;
  377. background-color: #FF5C03;
  378. color: #fff;
  379. font-weight: bold;
  380. font-size: 28rpx;
  381. display: flex;
  382. flex-direction: column;
  383. align-items: center;
  384. justify-content: center;
  385. }
  386. </style>