index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view>
  3. <view class="head" catchtouchmove="true" @touchmove.stop.prevent="() => { }">
  4. <My_search :value="content.where.condition" @onSearch="onSearch">
  5. <view class="filtrate" v-if="filtrateList.length" hover-class="navigator-hover" @click="openFiltrate">
  6. 筛选
  7. <text class="iconfont icon-shaixuan" />
  8. </view>
  9. </My_search>
  10. <view class="crumbs">
  11. <view class="crumb" v-for="item in crumbs" :key="item.classname">{{ item.classname }}</view>
  12. </view>
  13. </view>
  14. <view style="height: 1px;" />
  15. <filtrate ref="Filtrate" :filtrateList="filtrateList" @onFiltration="onFiltration" @onInterrupt="onInterrupt" />
  16. <view style="height: 9px;" />
  17. <My_listbox ref="List" @getlist="getList" boxBackground="#fff">
  18. <view class="waterfalls">
  19. <custom-waterfalls-flow ref="waterfallsFlowRef" :value="list" :column="2" :columnSpace="1.5" :seat="2"
  20. @wapperClick="wapperClick" @imageClick="wapperClick">
  21. <!-- #ifdef MP-WEIXIN -->
  22. <view class="waterfalls-item" v-for="(item, index) in list" :key="index" slot="slot{{index}}">
  23. <view class="waterfalls-item-title u-line-2">{{ item.title }}</view>
  24. </view>
  25. <!-- #endif -->
  26. <!-- #ifndef MP-WEIXIN -->
  27. <template v-slot:default="item">
  28. <view class="waterfalls-item">
  29. <view class="waterfalls-item-title u-line-2">{{ item.title }}</view>
  30. </view>
  31. </template>
  32. <!-- #endif -->
  33. </custom-waterfalls-flow>
  34. </view>
  35. </My_listbox>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. crumbs: [],
  43. list: [],
  44. "content": {
  45. "isDataAuth": true,//小程序默认传true
  46. "where": {
  47. "condition": "",
  48. "status": "发布",
  49. "type": "",//1:图片,2:视频,3:图文
  50. "sat_sharematerial_classids": [[]],
  51. "begindate_create": "",//创建时间
  52. "enddate_create": "",//创建时间
  53. "begindate": "",//发布时间
  54. "enddate": ""//发布时间
  55. }
  56. },
  57. filtrateList: []
  58. }
  59. },
  60. onLoad(options) {
  61. this.crumbs = [{
  62. classname: options.name,
  63. parentid: options.id
  64. }, {
  65. classname: "全部",
  66. parentid: ''
  67. }]
  68. this.getType()
  69. this.getList(true)
  70. uni.setNavigationBarTitle({
  71. title: '装备资源库',
  72. })
  73. },
  74. onShow() {
  75. this.updateList()
  76. },
  77. methods: {
  78. getType() {
  79. this.$Http.basic({
  80. "id": "20221102143202",
  81. content: {
  82. pageSize: 9999,
  83. parentid: this.crumbs[0].parentid,
  84. "where": {
  85. "isenable": 1
  86. }
  87. }
  88. }).then(res => {
  89. console.log("获取分类列表", res)
  90. if (this.cutoff(res.msg)) return;
  91. this.filtrateList = [{
  92. title: "分类",
  93. key: '一级分类',//提交时返回的Key
  94. showKey: "classname",//显示的key
  95. selected: "sat_sharematerial_classid",//选择时选择的字段
  96. value: "",//提交时选中的value
  97. defaultVal: "",//返回的默认值
  98. isAll: true,
  99. interrupt: true,
  100. rang: [{ classname: "全部", sat_sharematerial_classid: "", children: [] }].concat(res.data),//选择的范围
  101. }]
  102. })
  103. },
  104. getList(init = false) {
  105. if (this.paging(this.content, init)) return;
  106. let ids = this.crumbs.map(v => v.parentid).filter(v => v);
  107. this.content.where.sat_sharematerial_classids = ids.length ? [[ids[ids.length - 1]]] : []
  108. this.$Http.basic({
  109. "id": 20240407094702,
  110. content: this.content
  111. }).then(res => {
  112. this.$refs.List.RefreshToComplete()
  113. console.log("获取装备资源库列表", res)
  114. if (this.cutoff(res.msg)) return;
  115. res.data = res.data.map(v => {
  116. v.image = v.attinfos.length ? this.getSpecifiedImage(v.attinfos.find(s => s.usetype == "avatar") || v.attinfos[0]) : ''
  117. return v
  118. })
  119. this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data);
  120. if (init) this.$refs.waterfallsFlowRef.refresh()
  121. this.content = this.$refs.List.paging(this.content, res)
  122. })
  123. },
  124. updateList() {
  125. if (this.content.pageNumber && this.content.pageNumber >= 2) {
  126. let content = this.paging(this.content, true, true)
  127. this.$Http.basic({
  128. "id": "20240407094702",
  129. content
  130. }).then(res => {
  131. console.log("更新装备资源库列表", res)
  132. if (this.cutoff(res.msg)) return;
  133. this.list = res.data;
  134. this.$refs.List.paging(content, res, true)
  135. })
  136. }
  137. },
  138. wapperClick(e) {
  139. let url = e.ispicture ? '/packageA/resourceLibrary/picture?id=' : '/packageA/resourceLibrary/detail?id='
  140. uni.navigateTo({ url: url + e.sat_sharematerialid })
  141. },
  142. openFiltrate() {
  143. this.$refs.Filtrate.changeShow();
  144. },
  145. onSearch(condition) {
  146. this.content.where.condition = condition;
  147. this.getList(true)
  148. },
  149. onInterrupt({ item, index, option }) {
  150. let filtrateList = this.$refs.Filtrate.list;
  151. const i = filtrateList.findIndex(v => v.title == '下级分类');
  152. if (option.children.length) {
  153. const obj = {
  154. title: "下级分类",
  155. key: '二级分类',
  156. showKey: "classname",
  157. selected: "sat_sharematerial_classid",
  158. value: "",
  159. defaultVal: "",
  160. isAll: true,
  161. rang: [{ classname: "全部", sat_sharematerial_classid: "" }].concat(option.children),
  162. };
  163. i == -1 ? filtrateList.push(obj) : filtrateList[i] = obj;
  164. } else {
  165. i == -1 ? '' : filtrateList.pop();
  166. }
  167. this.$refs.Filtrate.list = filtrateList || JSON.parse(JSON.stringify());
  168. },
  169. onFiltration(e) {
  170. let crumbs = [this.crumbs[0]]
  171. crumbs.push({
  172. classname: e.一级分类.classname,
  173. parentid: e.一级分类.sat_sharematerial_classid
  174. })
  175. if (e.二级分类) crumbs.push({
  176. classname: e.二级分类.classname,
  177. parentid: e.二级分类.sat_sharematerial_classid
  178. })
  179. this.crumbs = crumbs;
  180. this.getList(true)
  181. },
  182. statusChange({ name }) {
  183. this.content.where.status = name == '全部' ? '' : name;
  184. this.getList(true)
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="scss" scoped >
  190. .head {
  191. padding: 10px;
  192. width: 100%;
  193. background: #fff;
  194. box-sizing: border-box;
  195. .filtrate {
  196. line-height: 30px;
  197. padding: 0 10px;
  198. font-family: PingFang SC, PingFang SC;
  199. font-size: 14px;
  200. color: #333333;
  201. border-radius: 3px;
  202. margin-left: 10px;
  203. .iconfont {
  204. margin-left: 3px;
  205. color: #BBBBBB;
  206. }
  207. }
  208. }
  209. .crumbs {
  210. display: flex;
  211. line-height: 17px;
  212. font-family: PingFang SC, PingFang SC;
  213. font-size: 12px;
  214. flex-wrap: wrap;
  215. width: 100%;
  216. margin-top: 10px;
  217. .crumb {
  218. flex-shrink: 0;
  219. }
  220. .crumb::after {
  221. content: ">";
  222. padding: 0 2px;
  223. }
  224. .crumb:last-child {
  225. font-weight: bold;
  226. }
  227. .crumb:last-child::after {
  228. content: "";
  229. }
  230. }
  231. .waterfalls {
  232. width: 100vw;
  233. padding: 10px;
  234. box-sizing: border-box;
  235. &-item {
  236. border-radius: 0 !important;
  237. &-title {
  238. text-align: center;
  239. line-height: 18.5px;
  240. width: 100%;
  241. background: #FFFFFF;
  242. font-family: PingFang SC, PingFang SC;
  243. font-size: 12px;
  244. color: #333333;
  245. }
  246. }
  247. }
  248. </style>