index.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const services_ams = require("../../services/ams.js");
  4. const utils_system = require("../../utils/system.js");
  5. if (!Array) {
  6. const _easycom_wd_swiper2 = common_vendor.resolveComponent("wd-swiper");
  7. _easycom_wd_swiper2();
  8. }
  9. const _easycom_wd_swiper = () => "../../node-modules/wot-design-uni/components/wd-swiper/wd-swiper.js";
  10. if (!Math) {
  11. (_easycom_wd_swiper + UserLoginPopup)();
  12. }
  13. const UserLoginPopup = () => "../../components/userLoginPopup.js";
  14. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  15. __name: "index",
  16. setup(__props) {
  17. const current = common_vendor.ref(0);
  18. const appid = common_vendor.index.getStorageSync("appid");
  19. const onLogin = () => {
  20. common_vendor.index.login({
  21. //获取code,
  22. success: (res) => {
  23. const params = {
  24. code: res.code,
  25. appid: common_vendor.index.getAccountInfoSync().miniProgram.appId
  26. };
  27. services_ams.getOpenId(params).then((res2) => {
  28. if (res2.code === 200) {
  29. common_vendor.index.setStorageSync("openid", res2.data.openid);
  30. } else {
  31. common_vendor.index.showToast({
  32. title: "获取openid失败",
  33. icon: "none"
  34. });
  35. }
  36. });
  37. }
  38. });
  39. };
  40. const bannerList = common_vendor.ref([]);
  41. const getBanner = () => {
  42. services_ams.getCarousel(appid).then((res) => {
  43. bannerList.value = res.data;
  44. });
  45. };
  46. const loginRef = common_vendor.ref(null);
  47. const toActivity = () => {
  48. const data = JSON.parse(common_vendor.index.getStorageSync("activityData")) || {};
  49. if (!data) {
  50. common_vendor.index.showToast({
  51. title: "当前暂无满返红包上传小票活动哦",
  52. icon: "none"
  53. });
  54. return;
  55. }
  56. if (!utils_system.isGetPhone()) {
  57. loginRef.value.show = true;
  58. } else {
  59. common_vendor.index.navigateTo({
  60. url: "/pagesOne/winner/index"
  61. });
  62. }
  63. };
  64. common_vendor.onLoad(() => {
  65. onLogin();
  66. getBanner();
  67. });
  68. common_vendor.onShow(() => {
  69. utils_system.getActivityData();
  70. });
  71. return (_ctx, _cache) => {
  72. return {
  73. a: common_vendor.p({
  74. customClass: "customSwiper",
  75. list: bannerList.value,
  76. autoplay: true,
  77. ["value-key"]: "imageUrl",
  78. value: current.value
  79. }),
  80. b: common_vendor.o(toActivity),
  81. c: common_vendor.sr(loginRef, "f5f2151a-1", {
  82. "k": "loginRef"
  83. }),
  84. d: common_vendor.p({
  85. path: "/pagesOne/winner/index"
  86. })
  87. };
  88. };
  89. }
  90. });
  91. wx.createPage(_sfc_main);