testDetails.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view class="content">
  3. <view class="bg-box">
  4. <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/71014b69fdcc4b56ae2a84bdc28f11c3.png"></image>
  5. <view class="title-box">
  6. <view class="title">
  7. {{item.name}}
  8. </view>
  9. </view>
  10. </view>
  11. <view class="cont">
  12. <view class="msg-box">
  13. <view class="msg">{{item.msg}}</view>
  14. </view>
  15. <view class="line"></view>
  16. <view class="desc-box">
  17. <view class="desc" v-html="item.descs"> </view>
  18. </view>
  19. <view class="btn-box">
  20. <view class="btn" @click="navTo('./test?tempId='+item.tempId)">立即开始测试</view>
  21. </view>
  22. <!-- <view class="logo">
  23. <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/b95950e4208c493d8b74ce0de220c65c.png"></image>
  24. </view> -->
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import {getTestDetails} from '@/api/test.js'
  30. import { mapGetters } from 'vuex';
  31. export default {
  32. data() {
  33. return {
  34. tempId:null,
  35. item:{},
  36. };
  37. },
  38. onLoad(option) {
  39. this.tempId=option.tempId;
  40. },
  41. onShow() {
  42. this.getTestDetails();
  43. },
  44. computed: {
  45. ...mapGetters(['logoimg']),
  46. },
  47. watch: {
  48. logoimg: {
  49. immediate: true, // 页面一进入就检查一次
  50. handler(val) {
  51. return val
  52. }
  53. },
  54. },
  55. //发送给朋友
  56. onShareAppMessage(res) {
  57. if(this.$isLogin()){
  58. return {
  59. title: "健康自测",
  60. path: '/pages_index/testDetails?tempId='+this.tempId,
  61. imageUrl: this.logoimg //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  62. }
  63. }
  64. },
  65. //分享到朋友圈
  66. onShareTimeline(res) {
  67. if(this.utils.isLogin()){
  68. return {
  69. title: "健康自测",
  70. imageUrl: this.logoimg //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  71. }
  72. }
  73. },
  74. methods:{
  75. navTo(url) {
  76. if(this.utils.isLogin()){
  77. uni.navigateTo({
  78. url: url
  79. })
  80. }else{
  81. uni.navigateTo({
  82. url:'/pages/auth/login'
  83. })
  84. }
  85. // this.$isLogin().then(
  86. // res => {
  87. // console.log(res)
  88. // if(res){
  89. // uni.navigateTo({
  90. // url: url
  91. // })
  92. // }
  93. // else{
  94. // uni.navigateTo({
  95. // url:'/pages/auth/login'
  96. // })
  97. // }
  98. // }
  99. // );
  100. },
  101. getTestDetails(){
  102. let data = {tempId:this.tempId};
  103. getTestDetails(data).then(
  104. res => {
  105. if(res.code==200){
  106. this.item=res.data;
  107. uni.setNavigationBarTitle({
  108. title: this.item.name+"自测"
  109. });
  110. }else{
  111. uni.showToast({
  112. icon:'none',
  113. title: "请求失败",
  114. });
  115. }
  116. },
  117. rej => {}
  118. );
  119. },
  120. }
  121. }
  122. </script>
  123. <style lang="scss">
  124. page{
  125. height: 100%;
  126. }
  127. .content{
  128. position: relative;
  129. height: 100%;
  130. display: flex;
  131. flex-direction: column;
  132. .bg-box{
  133. position: absolute;
  134. width: 100%;
  135. height: 600rpx;
  136. .title-box{
  137. top: 50rpx;
  138. left:50rpx;
  139. position: absolute;
  140. .title{
  141. border-radius: 5rpx;
  142. border: 1rpx solid #fff;
  143. padding: 20rpx 30rpx;
  144. font-size: 36rpx;
  145. font-family: Source Han Sans CN;
  146. font-weight: bold;
  147. color: #fff;
  148. }
  149. }
  150. image{
  151. position: absolute;
  152. width: 100%;
  153. height: 100%;
  154. }
  155. }
  156. .cont{
  157. position: relative;
  158. margin-top: 550rpx;
  159. z-index: 9999;
  160. padding: 30rpx;
  161. height: 100%;
  162. display: flex;
  163. flex-direction: column;
  164. padding: 30rpx;
  165. background-color: #fff;
  166. border-radius: 30rpx 30rpx 0rpx 0rpx;
  167. .msg-box{
  168. .msg{
  169. font-size: 36rpx;
  170. font-family: Source Han Sans CN;
  171. font-weight: bold;
  172. color: #111;
  173. }
  174. }
  175. .line{
  176. margin: 15rpx 0rpx;
  177. background-color: #F6F6F6;
  178. height:5rpx;
  179. width: 100%;
  180. }
  181. .desc-box{
  182. margin-top: 20rpx;
  183. background: #FFFFFF;
  184. .desc{
  185. color: #814E1B;
  186. }
  187. }
  188. .logo{
  189. display: flex;
  190. align-items: center;
  191. justify-content: center;
  192. margin: 60rpx 0rpx;
  193. width: 100%;
  194. image{
  195. width: 200rpx;
  196. height:100rpx;
  197. }
  198. }
  199. .btn-box{
  200. margin-top: 60rpx;
  201. height: 140upx;
  202. width: 100%;
  203. box-sizing: border-box;
  204. display: flex;
  205. align-items: center;
  206. justify-content: center;
  207. .btn{
  208. width: 100%;
  209. height: 88upx;
  210. line-height: 88upx;
  211. text-align: center;
  212. font-size: 34upx;
  213. font-family: PingFang SC;
  214. font-weight: bold;
  215. color: #FFFFFF;
  216. background: #2BC7B9;
  217. border-radius: 50upx;
  218. }
  219. }
  220. }
  221. }
  222. </style>