"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const PrivacyPopup = () => "../../wxcomponents/privacy-popup/privacy-popup.js";
|
|
const ProtocolDialog = () => "../../wxcomponents/protocol-dialog/protocol-dialog.js";
|
|
const _sfc_main = {
|
|
components: {
|
|
PrivacyPopup,
|
|
ProtocolDialog
|
|
},
|
|
data() {
|
|
return {
|
|
agreed: false,
|
|
showProtocolDialog: false,
|
|
protocolDialogTitle: "",
|
|
protocolDialogContent: "",
|
|
configData: [],
|
|
// 存储 getConfig 返回的 result
|
|
needPhone: false
|
|
// 控制是否需要手机号授权
|
|
};
|
|
},
|
|
computed: {
|
|
logoImage() {
|
|
const item = this.configData.find((i) => i.keyName === "logo_image");
|
|
return item ? item.keyContent : "";
|
|
},
|
|
logoName() {
|
|
const item = this.configData.find((i) => i.keyName === "logo_name");
|
|
return item ? item.keyContent : "";
|
|
}
|
|
},
|
|
onLoad() {
|
|
this.getConfigData();
|
|
},
|
|
methods: {
|
|
getConfigData() {
|
|
this.$api("getConfig", {}, (res) => {
|
|
if (res && res.success && Array.isArray(res.result)) {
|
|
this.configData = res.result;
|
|
}
|
|
});
|
|
},
|
|
getConfigByKey(key) {
|
|
const item = this.configData.find((i) => i.keyName === key);
|
|
return item ? item.keyContent : "";
|
|
},
|
|
handleLogin() {
|
|
if (!this.agreed) {
|
|
common_vendor.index.showToast({
|
|
title: "请阅读并勾选服务协议和隐私声明",
|
|
icon: "none"
|
|
});
|
|
return;
|
|
}
|
|
this.$refs.privacyPopup.open();
|
|
},
|
|
handleCancel() {
|
|
common_vendor.index.navigateBack();
|
|
},
|
|
handleAgreementChange(e) {
|
|
if (this.agreed) {
|
|
this.agreed = false;
|
|
} else {
|
|
this.agreed = true;
|
|
}
|
|
},
|
|
openProtocol(type) {
|
|
common_vendor.index.__f__("log", "at pages/index/index.vue:141", "Opening protocol:", type);
|
|
common_vendor.index.__f__("log", "at pages/index/index.vue:142", "Current configData:", this.configData);
|
|
let protocol = null;
|
|
if (type === "privacy") {
|
|
protocol = this.configData.find((i) => i.keyName === "user_ys");
|
|
} else if (type === "service") {
|
|
protocol = this.configData.find((i) => i.keyName === "user_xy");
|
|
}
|
|
common_vendor.index.__f__("log", "at pages/index/index.vue:149", "Found protocol:", protocol);
|
|
this.protocolDialogTitle = protocol ? protocol.keyValue : type === "privacy" ? "隐私政策" : "服务协议";
|
|
this.protocolDialogContent = protocol && protocol.keyContent ? protocol.keyContent : type === "privacy" ? '<div style="padding: 20rpx;">暂无隐私政策内容</div>' : '<div style="padding: 20rpx;">暂无服务协议内容</div>';
|
|
this.showProtocolDialog = true;
|
|
common_vendor.index.__f__("log", "at pages/index/index.vue:156", "Dialog state:", {
|
|
title: this.protocolDialogTitle,
|
|
content: this.protocolDialogContent,
|
|
show: this.showProtocolDialog
|
|
});
|
|
},
|
|
goToAdminLogin() {
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/component/admin_login"
|
|
});
|
|
},
|
|
// 同意隐私政策
|
|
handleAgreePrivacy() {
|
|
common_vendor.index.showLoading({
|
|
title: "登录中..."
|
|
});
|
|
let self = this;
|
|
common_vendor.wx$1.login({
|
|
success(res) {
|
|
if (res.code) {
|
|
self.$api("wxLogin", { code: res.code }, (res2) => {
|
|
common_vendor.index.__f__("log", "at pages/index/index.vue:183", res2, "login");
|
|
if (res2.code == 200) {
|
|
common_vendor.index.hideLoading();
|
|
common_vendor.index.setStorageSync("token", res2.result.token);
|
|
common_vendor.index.setStorageSync("openid", res2.result.userInfo && res2.result.userInfo.appletOpenid);
|
|
getApp().globalData.login_status = true;
|
|
if (res2.result.userInfo) {
|
|
const userInfo = res2.result.userInfo;
|
|
common_vendor.index.__f__("log", "at pages/index/index.vue:192", userInfo, "userInfo");
|
|
if (!userInfo.headImage || !userInfo.nickName) {
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/wxUserInfo"
|
|
});
|
|
} else {
|
|
common_vendor.index.reLaunch({
|
|
url: "/pages/component/home"
|
|
});
|
|
}
|
|
} else {
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/wxUserInfo"
|
|
});
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
common_vendor.index.hideLoading();
|
|
common_vendor.index.__f__("log", "at pages/index/index.vue:211", "登录失败!" + res.errMsg);
|
|
}
|
|
}
|
|
});
|
|
},
|
|
// 拒绝隐私政策
|
|
handleRejectPrivacy() {
|
|
common_vendor.index.reLaunch({ url: "/pages/component/home" });
|
|
},
|
|
// 打开协议页面
|
|
openProtocolPage(type) {
|
|
this.openProtocol(type);
|
|
},
|
|
handleProtocolAgree() {
|
|
this.showProtocolDialog = false;
|
|
this.agreed = true;
|
|
},
|
|
handleProtocolReject() {
|
|
this.showProtocolDialog = false;
|
|
if (this.agreed) {
|
|
this.agreed = false;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _component_PrivacyPopup = common_vendor.resolveComponent("PrivacyPopup");
|
|
const _component_ProtocolDialog = common_vendor.resolveComponent("ProtocolDialog");
|
|
(_component_PrivacyPopup + _component_ProtocolDialog)();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return {
|
|
a: $options.logoImage,
|
|
b: common_vendor.t($options.logoName),
|
|
c: common_vendor.o((...args) => $options.handleLogin && $options.handleLogin(...args)),
|
|
d: common_vendor.o((...args) => $options.handleCancel && $options.handleCancel(...args)),
|
|
e: $data.agreed,
|
|
f: common_vendor.o(($event) => $options.openProtocol("service")),
|
|
g: common_vendor.o(($event) => $options.openProtocol("privacy")),
|
|
h: common_vendor.o((...args) => $options.handleAgreementChange && $options.handleAgreementChange(...args)),
|
|
i: common_vendor.sr("privacyPopup", "1cf27b2a-0"),
|
|
j: common_vendor.o($options.handleAgreePrivacy),
|
|
k: common_vendor.o($options.handleRejectPrivacy),
|
|
l: common_vendor.o($options.openProtocol),
|
|
m: common_vendor.p({
|
|
needPhone: $data.needPhone
|
|
}),
|
|
n: common_vendor.sr("protocolDialog", "1cf27b2a-1"),
|
|
o: common_vendor.o(($event) => $data.showProtocolDialog = false),
|
|
p: common_vendor.o($options.handleProtocolAgree),
|
|
q: common_vendor.o($options.handleProtocolReject),
|
|
r: common_vendor.p({
|
|
show: $data.showProtocolDialog,
|
|
title: $data.protocolDialogTitle,
|
|
content: $data.protocolDialogContent
|
|
})
|
|
};
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-1cf27b2a"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map
|