index.ts 912 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { httpImages } from "../../../api/serverResource";
  2. import {
  3. createStoreBindings
  4. } from 'mobx-miniprogram-bindings'
  5. import {
  6. store
  7. } from "../../../store/index";
  8. Page({
  9. data: {
  10. id: "",
  11. list: []
  12. },
  13. onLoad(options: object) {
  14. this.storeBindings = createStoreBindings(this, {
  15. store,
  16. fields: ["token"],
  17. actions: ["setStore"],
  18. });
  19. const {
  20. id
  21. } = options
  22. this.setData({
  23. id
  24. })
  25. this.getResourceDetails()
  26. },
  27. onUnload() {
  28. this.storeBindings.destroyStoreBindings();
  29. },
  30. async getResourceDetails() {
  31. const {
  32. id
  33. } = this.data
  34. const {
  35. code,
  36. data
  37. } = await httpImages({
  38. store_id: id,
  39. page: 1,
  40. limit: 9999999,
  41. type: "详情图片"
  42. })
  43. if (code !== 1) {
  44. await this.setStore("", "");
  45. }
  46. this.setData({
  47. list: code === 1 ? data.list : []
  48. })
  49. },
  50. })