index.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  4. __name: "index",
  5. setup(__props) {
  6. var _a;
  7. const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  8. const openid = common_vendor.computed(() => {
  9. return common_vendor.index.getStorageSync("openid");
  10. });
  11. const agree = common_vendor.ref(false);
  12. const otherLogin = () => {
  13. if (agree.value) {
  14. if (openid.value) {
  15. common_vendor.index.getUserProfile({
  16. desc: "用于展示",
  17. success: async function(res) {
  18. let parmas = {
  19. openid: openid.value,
  20. nickname: res.userInfo.nickName + common_vendor.hooks().valueOf()
  21. };
  22. const arr = await $api(`/user`, "POST", parmas);
  23. if (arr.errcode == "0") {
  24. common_vendor.index.setStorageSync("user", arr.data);
  25. common_vendor.index.navigateBack({
  26. delta: 1
  27. });
  28. } else {
  29. common_vendor.index.showToast({
  30. title: arr.errmsg,
  31. icon: "error"
  32. });
  33. }
  34. },
  35. fail: function(err) {
  36. console.log(err);
  37. }
  38. });
  39. } else {
  40. common_vendor.index.showToast({
  41. title: "系统更新中,请稍后再试!",
  42. icon: "none"
  43. });
  44. }
  45. } else {
  46. common_vendor.index.showToast({
  47. title: "请阅读并同意用户协议和隐私政策",
  48. icon: "none"
  49. });
  50. }
  51. };
  52. const toAgree = () => {
  53. common_vendor.index.navigateTo({
  54. url: `/pagesHome/agree/index`
  55. });
  56. };
  57. const changeAgree = () => {
  58. agree.value = !agree.value;
  59. };
  60. return (_ctx, _cache) => {
  61. return {
  62. a: common_vendor.o(($event) => otherLogin()),
  63. b: agree.value,
  64. c: common_vendor.o(($event) => toAgree()),
  65. d: common_vendor.o(changeAgree)
  66. };
  67. };
  68. }
  69. });
  70. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7c2cfec5"], ["__file", "D:/project/赋强公证/notarization_applet/pagesHome/login/index.vue"]]);
  71. wx.createPage(MiniProgramPage);