testList.vue 5.0 KB

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