login.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const utils_assets = require("../../utils/assets.js");
  4. const _sfc_main = {
  5. data() {
  6. return {
  7. assets: utils_assets.assets,
  8. isAgreed: false,
  9. activeModal: "",
  10. userAvatar: "",
  11. userName: "微信用户",
  12. redirectUrl: "",
  13. currentProtocol: { title: "", content: "" },
  14. protocols: {
  15. user: { title: "用户服务协议", content: '<div style="line-height:1.8;"><h4 style="margin-bottom:10px;">服务内容</h4><p>欢迎使用ERP系统,我们将为您提供高效的下单管理服务。本协议旨在明确双方权利与义务...</p></div>' },
  16. privacy: { title: "隐私政策", content: '<div style="line-height:1.8;"><h4 style="margin-bottom:10px;">隐私保护</h4><p>我们非常重视您的个人信息保护。我们会按照法律法规要求,采取相应的安全保护措施...</p></div>' }
  17. }
  18. };
  19. },
  20. onLoad(options) {
  21. if (options.redirect) {
  22. this.redirectUrl = decodeURIComponent(options.redirect);
  23. }
  24. },
  25. methods: {
  26. toggleAgreed() {
  27. this.isAgreed = !this.isAgreed;
  28. },
  29. startLoginFlow() {
  30. if (!this.isAgreed)
  31. this.activeModal = "confirm";
  32. else
  33. this.activeModal = "profile";
  34. },
  35. agreeAndClose() {
  36. this.isAgreed = true;
  37. this.activeModal = "";
  38. },
  39. completeLogin() {
  40. common_vendor.index.showLoading({ title: "登录中..." });
  41. common_vendor.index.setStorageSync("isLogin", true);
  42. setTimeout(() => {
  43. common_vendor.index.hideLoading();
  44. this.activeModal = "";
  45. const targetUrl = this.redirectUrl || "/pages/index/index";
  46. common_vendor.index.reLaunch({ url: targetUrl });
  47. }, 1e3);
  48. },
  49. onChooseAvatar(e) {
  50. this.userAvatar = e.detail.avatarUrl;
  51. },
  52. onNicknameBlur(e) {
  53. this.userName = e.detail.value;
  54. },
  55. onNicknameChange(e) {
  56. this.userName = e.detail.value;
  57. },
  58. showProtocol(type) {
  59. this.currentProtocol = this.protocols[type];
  60. this.activeModal = "protocol";
  61. },
  62. closeAllModals() {
  63. this.activeModal = "";
  64. }
  65. }
  66. };
  67. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  68. return common_vendor.e({
  69. a: $data.assets.logo,
  70. b: $data.assets.wechat,
  71. c: common_vendor.o((...args) => $options.startLoginFlow && $options.startLoginFlow(...args)),
  72. d: $data.isAgreed,
  73. e: common_vendor.o(($event) => $options.showProtocol("user")),
  74. f: common_vendor.o(($event) => $options.showProtocol("privacy")),
  75. g: common_vendor.o((...args) => $options.toggleAgreed && $options.toggleAgreed(...args)),
  76. h: $data.activeModal
  77. }, $data.activeModal ? {
  78. i: common_vendor.o((...args) => $options.closeAllModals && $options.closeAllModals(...args))
  79. } : {}, {
  80. j: $data.activeModal === "confirm"
  81. }, $data.activeModal === "confirm" ? {
  82. k: common_vendor.o(($event) => $data.activeModal = ""),
  83. l: common_vendor.o((...args) => $options.agreeAndClose && $options.agreeAndClose(...args))
  84. } : {}, {
  85. m: $data.activeModal === "profile"
  86. }, $data.activeModal === "profile" ? {
  87. n: common_vendor.o(($event) => $data.activeModal = ""),
  88. o: common_vendor.o(($event) => $data.activeModal = "phone"),
  89. p: $data.userAvatar || "https://img.icons8.com/color/144/user.png",
  90. q: common_vendor.o((...args) => $options.onChooseAvatar && $options.onChooseAvatar(...args)),
  91. r: $data.userName,
  92. s: common_vendor.o((...args) => $options.onNicknameBlur && $options.onNicknameBlur(...args)),
  93. t: common_vendor.o((...args) => $options.onNicknameChange && $options.onNicknameChange(...args)),
  94. v: common_vendor.o(($event) => $data.activeModal = "phone")
  95. } : {}, {
  96. w: $data.activeModal === "phone"
  97. }, $data.activeModal === "phone" ? {
  98. x: $data.assets.logo,
  99. y: common_vendor.o(($event) => $data.activeModal = ""),
  100. z: common_vendor.o((...args) => $options.completeLogin && $options.completeLogin(...args))
  101. } : {}, {
  102. A: $data.activeModal === "protocol"
  103. }, $data.activeModal === "protocol" ? {
  104. B: common_vendor.t($data.currentProtocol.title),
  105. C: common_vendor.o(($event) => $data.activeModal = ""),
  106. D: $data.currentProtocol.content,
  107. E: common_vendor.o(($event) => $data.activeModal = "")
  108. } : {});
  109. }
  110. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-e4e4508d"]]);
  111. wx.createPage(MiniProgramPage);
  112. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/login/login.js.map