testList.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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.$isLogin()){
  59. return {
  60. title: "健康自测",
  61. path: '/pages_index/testList',
  62. imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  63. }
  64. }
  65. },
  66. //分享到朋友圈
  67. onShareTimeline(res) {
  68. if(this.$isLogin()){
  69. return {
  70. title: "健康自测",
  71. path: '/pages_index/testList',
  72. imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  73. }
  74. }
  75. },
  76. methods:{
  77. mescrollInit(mescroll) {
  78. this.mescroll = mescroll;
  79. },
  80. /*下拉刷新的回调 */
  81. downCallback(mescroll) {
  82. mescroll.resetUpScroll()
  83. },
  84. upCallback(page) {
  85. //联网加载数据
  86. var that = this;
  87. var data = {
  88. pageNum: page.num,
  89. pageSize: page.size
  90. };
  91. getTestList(data).then(res => {
  92. if(res.code==200){
  93. //设置列表数据
  94. if (page.num == 1) {
  95. that.dataList = res.data.list;
  96. } else {
  97. that.dataList = that.dataList.concat(res.data.list);
  98. }
  99. that.mescroll.endBySize(res.data.list.length, res.data.total);
  100. }else{
  101. uni.showToast({
  102. icon:'none',
  103. title: "请求失败",
  104. });
  105. that.dataList = null;
  106. that.mescroll.endErr();
  107. }
  108. });
  109. },
  110. // 查看详情
  111. showDetail(item) {
  112. uni.navigateTo({
  113. url: '/pages/article/testDetails?tempId=' + item.tempId
  114. })
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss">
  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(195,154,88,0.35);
  141. box-shadow: -1px 4px 5px 0px rgba(153,102,51,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: #814E1B;
  160. }
  161. .subtitle{
  162. color: #814E1B;
  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: #C39A58;
  176. .num{
  177. font-weight: bold;
  178. color: #814E1B;
  179. }
  180. }
  181. .time{
  182. margin-left: 25upx;
  183. font-size: 24upx;
  184. font-family: PingFang SC;
  185. font-weight: 500;
  186. color: #C39A58;
  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>