index.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const pagesHome_city_components_cityData = require("./components/cityData.js");
  4. const pagesHome_city_components_hotData = require("./components/hotData.js");
  5. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  6. __name: "index",
  7. setup(__props) {
  8. const province = common_vendor.ref(pagesHome_city_components_cityData.cityData);
  9. const indexsp = common_vendor.ref("hot");
  10. const current = common_vendor.ref([]);
  11. const hotlist = common_vendor.ref(pagesHome_city_components_hotData.hotData);
  12. const city = common_vendor.ref("");
  13. common_vendor.onLoad((options) => {
  14. setCity(options.city);
  15. });
  16. const indexOfs = (list, name) => {
  17. return list.indexOf(name) != -1;
  18. };
  19. const setCity = (name) => {
  20. city.value = name;
  21. if (current.value.length === 0) {
  22. current.value.push(name);
  23. } else {
  24. current.value = [];
  25. current.value.push(name);
  26. }
  27. };
  28. const toBack = () => {
  29. if (city.value) {
  30. common_vendor.index.$emit("setCity", city.value);
  31. common_vendor.index.navigateBack({
  32. delta: 1
  33. });
  34. } else {
  35. common_vendor.index.showToast({
  36. title: "未选择城市",
  37. icon: "none"
  38. });
  39. }
  40. };
  41. const setProvince = (e) => {
  42. indexsp.value = e.currentTarget.dataset.index;
  43. };
  44. return (_ctx, _cache) => {
  45. return common_vendor.e({
  46. a: common_vendor.n(indexsp.value == "hot" ? "active" : ""),
  47. b: common_vendor.o(setProvince),
  48. c: common_vendor.f(province.value.a, (item, index, i0) => {
  49. return {
  50. a: common_vendor.t(item),
  51. b: common_vendor.n(indexsp.value == index ? "active" : ""),
  52. c: index
  53. };
  54. }),
  55. d: common_vendor.o(setProvince),
  56. e: common_vendor.t(city.value),
  57. f: indexsp.value == "hot"
  58. }, indexsp.value == "hot" ? {
  59. g: common_vendor.f(hotlist.value, (item, k0, i0) => {
  60. return {
  61. a: common_vendor.t(item.name),
  62. b: common_vendor.n(indexOfs(current.value, item.name) ? "active" : ""),
  63. c: common_vendor.o(($event) => setCity(item.name))
  64. };
  65. })
  66. } : {}, {
  67. h: common_vendor.f(province.value.o[indexsp.value], (item, k0, i0) => {
  68. return {
  69. a: common_vendor.t(item),
  70. b: common_vendor.o(($event) => setCity(item)),
  71. c: common_vendor.n(indexOfs(current.value, item) ? "active" : "")
  72. };
  73. }),
  74. i: common_vendor.o(toBack)
  75. });
  76. };
  77. }
  78. });
  79. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-3361df53"], ["__file", "D:/project/足球比赛/match_applet/pagesHome/city/index.vue"]]);
  80. wx.createPage(MiniProgramPage);