index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view>
  3. <view class="top-sort ddflex">
  4. <view :class="'top-sort-item flex '+(tabCode=='poster'?'top-sort-item-active':'')" @click="tabChange('poster')">海报</view>
  5. <view :class="'top-sort-item flex '+(tabCode=='poster_product'?'top-sort-item-active':'')" @click="tabChange('poster_product')">产品宣传</view>
  6. </view>
  7. <view style="height: 85rpx;"></view>
  8. <view style="border-top: 20rpx solid #F4F5F9;">
  9. <view class="search-box ddflex">
  10. <view class="search-input ddflex fflex">
  11. <image src="/static/images/ssico.png"></image>
  12. <input @confirm="searchFn" confirm-type="search" @input="searchFn" v-model="searchVal" class="fflex"
  13. placeholder="请输入关键词" />
  14. </view>
  15. </view>
  16. <view class="ddflex" style="padding: 0 30rpx;">
  17. <view :class="'search-tag '+(!categoryId?'search-tag-active':'')" @click="categoryChange({id:null})">全部</view>
  18. <view :class="'search-tag '+(categoryId==item.id?'search-tag-active':'')" v-for="item in posterCategory" @click="categoryChange(item)">{{item.name}}</view>
  19. </view>
  20. <view class="ddflex" style="padding: 30rpx;">
  21. <view class="poster-item" v-for="item in pageList" @click="jumpUrl('/library/posterService/posterService?id='+item.id+'&code='+tabCode)">
  22. <image class="poster-item-pic" :src="item.pic" mode="aspectFill"></image>
  23. <view class="poster-item-title tover">{{item.title}}</view>
  24. <view class="poster-item-use">{{item.shareCount?item.shareCount:0}} 人正在使用</view>
  25. </view>
  26. </view>
  27. <view class="nodata" v-if="pageList.length==0">
  28. <image :src="picUrlss+'empty_dd.png'" mode="aspectFill"></image>
  29. <text>暂无数据</text>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. const app = getApp();
  36. const req = require("../../utils/request.js");
  37. export default {
  38. components: {},
  39. props: {},
  40. data() {
  41. return {
  42. systems: {},
  43. isTop:0,
  44. picUrlss: req.public.picUrls,
  45. searchVal:'',
  46. isShow: false,
  47. pageList: [],
  48. isLoad: true,
  49. form: {
  50. page: 1,
  51. limit: 10
  52. },
  53. posterCategory:[],
  54. categoryId:null,
  55. tabCode:'poster'
  56. }
  57. },
  58. onLoad(options) {
  59. this.getPageList(true);
  60. },
  61. onShow() {
  62. this.getCategory()
  63. },
  64. onReachBottom: function() {
  65. this.form.page++;
  66. this.getPageList(false);
  67. },
  68. methods: {
  69. jumpUrl(url){
  70. uni.navigateTo({
  71. url:url
  72. })
  73. },
  74. // 切换海报类型
  75. tabChange(code){
  76. if(code==this.tabCode) return false
  77. this.tabCode = code
  78. this.categoryId = null
  79. this.getCategory()
  80. this.isLoad = true
  81. this.form.page = 1
  82. this.getPageList()
  83. },
  84. // 获取分类
  85. getCategory(){
  86. req.getRequest('/api/material/posterCategory',{code:this.tabCode},res => {
  87. this.posterCategory = res?res.list:[]
  88. });
  89. },
  90. // 选择分类
  91. categoryChange(item){
  92. if(item.id==this.categoryId) return false
  93. this.categoryId = item.id
  94. this.isLoad = true
  95. this.form.page = 1
  96. this.getPageList()
  97. },
  98. // 获取海报
  99. getPageList(isShow){
  100. if (!this.isLoad) return false;
  101. this.isLoad = false;
  102. let form = this.form;
  103. form.code = this.tabCode
  104. form.categoryId = this.categoryId
  105. form.search = this.searchVal?this.searchVal:null
  106. req.loadIng('加载中')
  107. req.getRequest('/api/material/library',form,res => {
  108. this.isShow = true;
  109. res = res?res.list:[]
  110. if (res && res.length == 10) {
  111. this.isLoad = true;
  112. }
  113. if (this.form.page > 1) {
  114. res = this.pageList.concat(res);
  115. }
  116. this.pageList = res;
  117. uni.hideLoading()
  118. },isShow);
  119. },
  120. // 搜索
  121. searchFn(){
  122. this.isLoad = true
  123. this.form.page = 1
  124. this.getPageList()
  125. }
  126. },
  127. mounted() {
  128. }
  129. }
  130. </script>
  131. <style>
  132. @import "./index.css";
  133. </style>