index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. })
  135. }
  136. },
  137. wapperClick(e) {
  138. uni.navigateTo({ url: '/packageA/resourceLibrary/detail?id=' + e.sat_sharematerialid })
  139. },
  140. openFiltrate() {
  141. this.$refs.Filtrate.changeShow();
  142. },
  143. onSearch(condition) {
  144. this.content.where.condition = condition;
  145. this.getList(true)
  146. },
  147. onInterrupt({ item, index, option }) {
  148. let filtrateList = this.$refs.Filtrate.list;
  149. const i = filtrateList.findIndex(v => v.title == '下级分类');
  150. if (option.children.length) {
  151. const obj = {
  152. title: "下级分类",
  153. key: '二级分类',
  154. showKey: "classname",
  155. selected: "sat_sharematerial_classid",
  156. value: "",
  157. defaultVal: "",
  158. isAll: true,
  159. rang: [{ classname: "全部", sat_sharematerial_classid: "" }].concat(option.children),
  160. };
  161. i == -1 ? filtrateList.push(obj) : filtrateList[i] = obj;
  162. } else {
  163. i == -1 ? '' : filtrateList.pop();
  164. }
  165. this.$refs.Filtrate.list = filtrateList || JSON.parse(JSON.stringify());
  166. },
  167. onFiltration(e) {
  168. let crumbs = [this.crumbs[0]]
  169. crumbs.push({
  170. classname: e.一级分类.classname,
  171. parentid: e.一级分类.sat_sharematerial_classid
  172. })
  173. if (e.二级分类) crumbs.push({
  174. classname: e.二级分类.classname,
  175. parentid: e.二级分类.sat_sharematerial_classid
  176. })
  177. this.crumbs = crumbs;
  178. this.getList(true)
  179. },
  180. statusChange({ name }) {
  181. this.content.where.status = name == '全部' ? '' : name;
  182. this.getList(true)
  183. }
  184. }
  185. }
  186. </script>
  187. <style lang="scss" scoped >
  188. .head {
  189. padding: 10px;
  190. width: 100%;
  191. background: #fff;
  192. box-sizing: border-box;
  193. .filtrate {
  194. line-height: 30px;
  195. padding: 0 10px;
  196. font-family: PingFang SC, PingFang SC;
  197. font-size: 14px;
  198. color: #333333;
  199. border-radius: 3px;
  200. margin-left: 10px;
  201. .iconfont {
  202. margin-left: 3px;
  203. color: #BBBBBB;
  204. }
  205. }
  206. }
  207. .crumbs {
  208. display: flex;
  209. line-height: 17px;
  210. font-family: PingFang SC, PingFang SC;
  211. font-size: 12px;
  212. flex-wrap: wrap;
  213. width: 100%;
  214. margin-top: 10px;
  215. .crumb {
  216. flex-shrink: 0;
  217. }
  218. .crumb::after {
  219. content: ">";
  220. padding: 0 2px;
  221. }
  222. .crumb:last-child {
  223. font-weight: bold;
  224. }
  225. .crumb:last-child::after {
  226. content: "";
  227. }
  228. }
  229. .waterfalls {
  230. width: 100vw;
  231. padding: 10px;
  232. box-sizing: border-box;
  233. &-item {
  234. border-radius: 0 !important;
  235. &-title {
  236. text-align: center;
  237. line-height: 18.5px;
  238. width: 100%;
  239. background: #FFFFFF;
  240. font-family: PingFang SC, PingFang SC;
  241. font-size: 12px;
  242. color: #333333;
  243. }
  244. }
  245. }
  246. </style>