index.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. (_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. icon: res.userInfo.avatarUrl,
  21. nickname: res.userInfo.nickName + common_vendor.hooks().valueOf()
  22. };
  23. const arr = await that.$api(`matchUser`, "POST", parmas);
  24. if (arr.code === 200) {
  25. common_vendor.index.setStorage({
  26. key: "user",
  27. data: arr.data,
  28. success: function() {
  29. common_vendor.index.navigateBack({
  30. delta: 1
  31. });
  32. }
  33. });
  34. } else {
  35. common_vendor.index.showToast({
  36. title: arr.msg,
  37. icon: "error"
  38. });
  39. }
  40. },
  41. fail: function(err) {
  42. console.log(err);
  43. }
  44. });
  45. } else {
  46. common_vendor.index.showToast({
  47. title: "系统更新中,请稍后再试!",
  48. icon: "none"
  49. });
  50. }
  51. } else {
  52. common_vendor.index.showToast({
  53. title: "请阅读并同意用户协议和隐私政策",
  54. icon: "none"
  55. });
  56. }
  57. };
  58. const toAgree = () => {
  59. common_vendor.index.navigateTo({
  60. url: `/pagesHome/agree/index`
  61. });
  62. };
  63. return (_ctx, _cache) => {
  64. return {
  65. a: common_vendor.o(($event) => otherLogin()),
  66. b: agree.value,
  67. c: common_vendor.o(($event) => toAgree()),
  68. d: common_vendor.o(
  69. //@ts-ignore
  70. (...args) => _ctx.changeAgree && _ctx.changeAgree(...args)
  71. )
  72. };
  73. };
  74. }
  75. });
  76. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d08ef7d4"], ["__file", "D:/project/足球比赛/match_applet/pages/login/index.vue"]]);
  77. wx.createPage(MiniProgramPage);