index.vue 5.1 KB

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