wx-web/pages/login/index.js

55 lines
1.8 KiB
JavaScript
Raw Normal View History

2024-05-22 10:14:19 +08:00
"use strict";
var common_vendor = require("../../common/vendor.js");
var api_index = require("../../api/index.js");
require("../../utils/request.js");
require("../../config/index.js");
const _sfc_main = {
setup(__props) {
common_vendor.index.hideHomeButton();
const agree = common_vendor.ref(false);
const showDialog = common_vendor.ref(false);
const loginByWechat = () => {
if (!agree.value) {
common_vendor.index.showToast({
title: "\u8BF7\u5148\u9605\u8BFB\u5E76\u540C\u610F\u534F\u8BAE",
icon: "none"
});
return;
}
wx.login({
success: async ({ code }) => {
try {
const { status, data } = await api_index.login({ code });
if (Number(status) === 200) {
common_vendor.index.setStorage({
key: "userData",
data,
success: () => {
common_vendor.index.switchTab({
url: "/pages/index/index"
});
}
});
}
} catch (e) {
}
}
});
};
return (_ctx, _cache) => {
return {
a: common_vendor.o(loginByWechat),
b: common_vendor.n(agree.value ? "radio iconfont icon-gou" : "radio"),
c: common_vendor.o(($event) => showDialog.value = true),
d: common_vendor.o(($event) => agree.value = !agree.value),
e: common_vendor.o(() => {
}),
f: showDialog.value,
g: common_vendor.o(($event) => showDialog.value = false)
};
};
}
};
var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4586967a"], ["__file", "C:/Users/bzm15/Desktop/ix/mini_web-develop/pages/login/index.vue"]]);
wx.createPage(MiniProgramPage);