index.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const api_list = require("../../api/list.js");
  4. const _sfc_main = {
  5. data() {
  6. return {
  7. list: null,
  8. liveId: null
  9. };
  10. },
  11. onLoad(option) {
  12. this.getList();
  13. },
  14. methods: {
  15. goLive(item) {
  16. this.liveId = item.liveId;
  17. console.log("要传的liveId", this.liveId);
  18. common_vendor.index.navigateTo({
  19. url: "/pages/home/living?liveId=" + this.liveId
  20. // url: `/pages/home/living?liveId=${encodeURIComponent(JSON.stringify(liveId))}`
  21. });
  22. },
  23. getList() {
  24. const data = {
  25. page: 1,
  26. page_size: 10
  27. };
  28. common_vendor.index.showLoading({
  29. title: "处理中..."
  30. });
  31. api_list.liveList(data).then((res) => {
  32. if (res.code == 200) {
  33. this.list = res.rows;
  34. console.log("list>>", this.list);
  35. } else {
  36. common_vendor.index.showToast({
  37. title: res.msg,
  38. icon: "none"
  39. });
  40. }
  41. }).catch((rej) => {
  42. console.log("请求失败:", JSON.stringify(rej));
  43. }).finally(() => {
  44. common_vendor.index.hideLoading();
  45. });
  46. }
  47. }
  48. };
  49. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  50. return {
  51. a: common_vendor.f($data.list, (item, index, i0) => {
  52. return {
  53. a: item.liveImgUrl,
  54. b: common_vendor.t(item.liveName),
  55. c: common_vendor.o(($event) => $options.goLive(item), index),
  56. d: index
  57. };
  58. })
  59. };
  60. }
  61. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-7bd28468"]]);
  62. wx.createPage(MiniProgramPage);