index.vue 3.8 KB

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