index.vue 5.2 KB

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