testDetails.vue 4.2 KB

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