index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const common_assets = require("../../common/assets.js");
  4. const _sfc_main = {
  5. data() {
  6. return {
  7. isAgreed: false
  8. };
  9. },
  10. methods: {
  11. // 处理协议勾选
  12. handleAgreementChange(e) {
  13. this.isAgreed = e.detail.value.length > 0;
  14. },
  15. // 微信登录
  16. async handleWechatLogin() {
  17. if (!this.isAgreed) {
  18. common_vendor.index.showToast({
  19. title: "请先同意服务协议和隐私政策",
  20. icon: "none"
  21. });
  22. return;
  23. }
  24. common_vendor.wx$1.login({
  25. success: function(res) {
  26. if (res.code) {
  27. common_vendor.index.__f__("log", "at pages/login/index.vue:79", res.code);
  28. common_vendor.wx$1.request({
  29. url: "http://localhost:9527/api/wx-login",
  30. method: "POST",
  31. // 设置请求头,指定请求体为 JSON 格式
  32. header: {
  33. "content-type": "application/json"
  34. },
  35. data: {
  36. code: res.code
  37. },
  38. success: function(response) {
  39. common_vendor.index.__f__("log", "at pages/login/index.vue:92", response.data);
  40. },
  41. fail: function(err) {
  42. common_vendor.index.__f__("error", "at pages/login/index.vue:95", err);
  43. }
  44. });
  45. } else {
  46. common_vendor.index.__f__("log", "at pages/login/index.vue:99", "获取 code 失败!" + res.errMsg);
  47. }
  48. }
  49. });
  50. },
  51. // // 跳转到密码登录页面
  52. // navigateToPasswordLogin() {
  53. // uni.navigateTo({
  54. // url: '/pages/login/password'
  55. // })
  56. // },
  57. // 跳转到验证码登录页面
  58. navigateToVerifyCodeLogin() {
  59. common_vendor.index.navigateTo({
  60. url: "/pages/login/verify-code"
  61. });
  62. },
  63. // 打开服务协议
  64. openServiceAgreement() {
  65. common_vendor.index.navigateTo({
  66. url: "/pages/agreement/service"
  67. });
  68. },
  69. // 打开隐私政策
  70. openPrivacyPolicy() {
  71. common_vendor.index.navigateTo({
  72. url: "/pages/agreement/privacy"
  73. });
  74. }
  75. }
  76. };
  77. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  78. return {
  79. a: common_assets._imports_0,
  80. b: common_vendor.o((...args) => $options.handleWechatLogin && $options.handleWechatLogin(...args)),
  81. c: common_vendor.o((...args) => $options.navigateToVerifyCodeLogin && $options.navigateToVerifyCodeLogin(...args)),
  82. d: $data.isAgreed,
  83. e: common_vendor.o((...args) => $options.openServiceAgreement && $options.openServiceAgreement(...args)),
  84. f: common_vendor.o((...args) => $options.openPrivacyPolicy && $options.openPrivacyPolicy(...args)),
  85. g: common_vendor.o((...args) => $options.handleAgreementChange && $options.handleAgreementChange(...args))
  86. };
  87. }
  88. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  89. wx.createPage(MiniProgramPage);
  90. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/login/index.js.map