testList.vue 5.3 KB

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