healthTest.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view class="content">
  3. <view class="bg">
  4. <!-- <image src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/8e52ab17eabc4534b3ce56026fd5c624.jpg"></image> -->
  5. </view>
  6. <mescroll-body top="0rpx" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  7. <view class="test-list">
  8. <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
  9. <view class="left">
  10. <view class="title ellipsis2">{{ item.name }}</view>
  11. <view class="subtitle ellipsis2">{{ item.title }}</view>
  12. <view class="info-box">
  13. <view class="people-num"><text class="num">{{item.peopleNum}}W</text>人测过</view>
  14. <view class="time">{{item.num}}题 | {{item.time}}分钟</view>
  15. </view>
  16. </view>
  17. <view class="right">
  18. <image :src="item.img" mode="aspectFill"></image>
  19. </view>
  20. </view>
  21. </view>
  22. </mescroll-body>
  23. </view>
  24. </template>
  25. <script>
  26. import {getTestList,getTestDetails} from '@/api/test.js'
  27. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  28. export default {
  29. mixins: [MescrollMixin],
  30. data() {
  31. return {
  32. mescroll:null,
  33. downOption: { //下拉刷新
  34. use:true,
  35. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  36. },
  37. upOption: {
  38. onScroll:false,
  39. use: true, // 是否启用上拉加载; 默认true
  40. page: {
  41. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  42. size: 10 // 每页数据的数量,默认10
  43. },
  44. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  45. textNoMore:"已经到底了",
  46. empty: {
  47. icon:this.$store.state.imgpath+'/app/commonCourse/null-data.png',
  48. tip: '暂无数据'
  49. }
  50. },
  51. dataList: []
  52. };
  53. },
  54. onShow() {
  55. },
  56. //发送给朋友
  57. onShareAppMessage(res) {
  58. if(this.$isLogin()){
  59. return {
  60. title: "健康自测",
  61. path: '/pages_index/testList',
  62. imageUrl:this.$store.state.imgpath+'/app/image/logoshare.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  63. }
  64. }
  65. },
  66. //分享到朋友圈
  67. onShareTimeline(res) {
  68. if(this.utils.isLogin()){
  69. return {
  70. title: "健康自测",
  71. imageUrl: this.$store.state.imgpath+'/app/image/logoshare.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  72. }
  73. }
  74. },
  75. computed: {
  76. imgPath() {
  77. return this.$store.state.imgpath
  78. },
  79. },
  80. methods:{
  81. mescrollInit(mescroll) {
  82. this.mescroll = mescroll;
  83. },
  84. /*下拉刷新的回调 */
  85. downCallback(mescroll) {
  86. mescroll.resetUpScroll()
  87. },
  88. upCallback(page) {
  89. //联网加载数据
  90. var that = this;
  91. var data = {
  92. pageNum: page.num,
  93. pageSize: page.size
  94. };
  95. getTestList(data).then(res => {
  96. if(res.code==200){
  97. //设置列表数据
  98. if (page.num == 1) {
  99. that.dataList = res.data.list;
  100. } else {
  101. that.dataList = that.dataList.concat(res.data.list);
  102. }
  103. that.mescroll.endBySize(res.data.list.length, res.data.total);
  104. }else{
  105. uni.showToast({
  106. icon:'none',
  107. title: "请求失败",
  108. });
  109. that.dataList = null;
  110. that.mescroll.endErr();
  111. }
  112. });
  113. },
  114. // 查看详情
  115. showDetail(item) {
  116. uni.navigateTo({
  117. url: '/pages_index/testDetails?tempId=' + item.tempId
  118. })
  119. }
  120. }
  121. }
  122. </script>
  123. <style lang="scss">
  124. .content{
  125. position: relative;
  126. .bg{
  127. position: absolute;
  128. width: 100%;
  129. height: 100%;
  130. image{
  131. width: 100%;
  132. height: 100%;
  133. }
  134. }
  135. }
  136. .test-list{
  137. margin-top: 20upx;
  138. padding: 0 20upx;
  139. .item{
  140. width: 100%;
  141. box-sizing: border-box;
  142. height: 271upx;
  143. background: #FFFFFF;
  144. border: 2px solid rgba(195,154,88,0.35);
  145. box-shadow: -1px 4px 5px 0px rgba(153,102,51,0.25);
  146. border-radius: 12px;
  147. padding: 40upx 30upx;
  148. display: flex;
  149. align-items: center;
  150. justify-content: space-between;
  151. margin-bottom: 20upx;
  152. .left{
  153. flex: 1;
  154. padding-right: 40upx;
  155. display: flex;
  156. flex-direction: column;
  157. justify-content: space-between;
  158. .title{
  159. font-size: 40rpx;
  160. font-family: PingFang SC;
  161. line-height: 48upx;
  162. font-weight: bold;
  163. color: #814E1B;
  164. }
  165. .subtitle{
  166. color: #814E1B;
  167. font-size: 28rpx;
  168. font-family: PingFang SC;
  169. margin: 10rpx 0rpx;
  170. }
  171. .info-box{
  172. width: 100%;
  173. display: flex;
  174. align-items: center;
  175. justify-content: flex-start;
  176. .people-num{
  177. font-size: 24upx;
  178. font-family: PingFang SC;
  179. color: #C39A58;
  180. .num{
  181. font-weight: bold;
  182. color: #814E1B;
  183. }
  184. }
  185. .time{
  186. margin-left: 25upx;
  187. font-size: 24upx;
  188. font-family: PingFang SC;
  189. font-weight: 500;
  190. color: #C39A58;
  191. }
  192. }
  193. }
  194. .right{
  195. width: 250upx;
  196. height: 190upx;
  197. border-radius: 8upx;
  198. overflow: hidden;
  199. image{
  200. width: 100%;
  201. height: 100%;
  202. }
  203. }
  204. }
  205. }
  206. </style>