index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view>
  3. <view class="task-list">
  4. <view class="item" v-for="(item,index) in tabs" :key="index" >
  5. <view class="left">
  6. <image :src="item.icon" mode=""></image>
  7. <view class="title-l">{{item.name}}</view>
  8. </view>
  9. <view class="right" @click="showDetail(item.url)">
  10. <view class="num" v-if="item.num!==0">{{item.num}}</view>
  11. <image src="@/static/image/icon_more.png" mode=""></image>
  12. </view>
  13. </view>
  14. </view>
  15. <Server/>
  16. </view>
  17. </template>
  18. <script>
  19. import {getDictByKey} from '@/api/common.js'
  20. import {getQuestionsList} from '@/api/index.js'
  21. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  22. import Server from '@/components/Server.vue'
  23. export default {
  24. mixins: [MescrollMixin],
  25. components: {
  26. Server
  27. },
  28. data() {
  29. return {
  30. tabs:[
  31. {name:'在线讲座',num:12,icon:'/static/image/icon_task_zxjz.png',url:'/pages_task/onlineLecture'},
  32. {name:'空中课堂',num:3,icon:'/static/image/icon_task_kzkt.png',url:'/pages_task/airClassroom'},
  33. {name:'用药调研',num:8,icon:'/static/image/icon_task_yydy.png',url:''},
  34. {name:'问卷调查',num:0,icon:'/static/image/icon_task_wjdc.png',url:''},
  35. {name:'科普创作',num:0,icon:'/static/image/icon_task_kpcz.png',url:'/pages_task/science'},
  36. ],
  37. typeOptions:[],
  38. questionsType:0,
  39. keyword: '',
  40. mescroll:null,
  41. downOption: { //下拉刷新
  42. use:true,
  43. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  44. },
  45. upOption: {
  46. onScroll:false,
  47. use: true, // 是否启用上拉加载; 默认true
  48. page: {
  49. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  50. size: 10 // 每页数据的数量,默认10
  51. },
  52. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  53. textNoMore:"已经到底了",
  54. empty: {
  55. icon:'https://user.test.ylrztop.com/images/empty_icon.png',
  56. tip: '暂无数据'
  57. }
  58. },
  59. dataList: []
  60. };
  61. },
  62. onShow() {
  63. this.getDictByKey("sys_questions_type");
  64. },
  65. methods:{
  66. getDictByKey(key){
  67. var data={key:key}
  68. getDictByKey(data).then(
  69. res => {
  70. if(res.code==200){
  71. if(key=="sys_questions_type"){
  72. this.typeOptions=res.data;
  73. }
  74. }
  75. },
  76. err => {
  77. }
  78. );
  79. },
  80. doSearch(){
  81. this.mescroll.resetUpScroll()
  82. },
  83. mescrollInit(mescroll) {
  84. this.mescroll = mescroll;
  85. },
  86. /*下拉刷新的回调 */
  87. downCallback(mescroll) {
  88. mescroll.resetUpScroll()
  89. },
  90. upCallback(page) {
  91. //联网加载数据
  92. var that = this;
  93. var data = {
  94. keyword:this.keyword,
  95. questionsType:this.questionsType,
  96. pageNum: page.num,
  97. pageSize: page.size
  98. };
  99. getQuestionsList(data).then(res => {
  100. if(res.code==200){
  101. //设置列表数据
  102. if (page.num == 1) {
  103. that.dataList = res.data.list;
  104. } else {
  105. that.dataList = that.dataList.concat(res.data.list);
  106. }
  107. that.mescroll.endBySize(res.data.list.length, res.data.total);
  108. }else{
  109. uni.showToast({
  110. icon:'none',
  111. title: "请求失败",
  112. });
  113. that.dataList = null;
  114. that.mescroll.endErr();
  115. }
  116. });
  117. },
  118. // 关键词选择
  119. choseType(item) {
  120. this.questionsType = item.dictValue;
  121. this.mescroll.resetUpScroll()
  122. },
  123. // 查看详情
  124. showDetail(url) {
  125. uni.navigateTo({
  126. url: url
  127. })
  128. }
  129. }
  130. }
  131. </script>
  132. <style lang="scss">
  133. .task-list{
  134. padding: 24rpx;
  135. display: flex;
  136. align-items: center;
  137. flex-direction: column;
  138. justify-content: flex-start;
  139. width: 100%;
  140. box-sizing: border-box;
  141. .item{
  142. width: 100%;
  143. display: flex;
  144. align-items: center;
  145. justify-content: space-between;
  146. background: #FFFFFF;
  147. box-shadow: 0rpx 8rpx 16rpx 0rpx rgba(199,226,254,0.22);
  148. border-radius: 24rpx 24rpx 24rpx 24rpx;
  149. padding:28rpx 32rpx;
  150. box-sizing: border-box; // 核心:padding不撑宽item
  151. margin-bottom: 24rpx;
  152. .left{
  153. display: flex;
  154. align-items: center;
  155. justify-content: center;
  156. image{
  157. width: 72rpx;
  158. height: 72rpx;
  159. margin-right: 28rpx;
  160. }
  161. .title-l{
  162. font-family: PingFang SC, PingFang SC;
  163. font-weight: 400;
  164. font-size: 28rpx;
  165. color: #333333;
  166. }
  167. }
  168. .right{
  169. display: flex;
  170. align-items: center;
  171. .num{
  172. text-align: center;
  173. width: 50rpx;
  174. height: 36rpx;
  175. line-height: 36rpx;
  176. background: rgba(56,139,255,0.16);
  177. border-radius: 34rpx 34rpx 34rpx 34rpx;
  178. font-family: PingFang SC, PingFang SC;
  179. font-weight: 400;
  180. font-size: 24rpx;
  181. color: #388BFF;
  182. }
  183. image{
  184. width: 32rpx;
  185. height: 32rpx;
  186. margin-left: 12rpx;
  187. }
  188. }
  189. }
  190. }
  191. </style>