index.vue 8.1 KB

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