index.vue 8.7 KB

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