testDetails.vue 4.2 KB

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