testList.vue 5.2 KB

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