testList.vue 5.2 KB

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