|
|
@@ -1,6 +1,7 @@
|
|
|
"use strict";
|
|
|
const common_vendor = require("../../common/vendor.js");
|
|
|
const utils_api = require("../../utils/api.js");
|
|
|
+const utils_auth = require("../../utils/auth.js");
|
|
|
const _sfc_main = {
|
|
|
__name: "index",
|
|
|
setup(__props) {
|
|
|
@@ -11,7 +12,40 @@ const _sfc_main = {
|
|
|
const result = common_vendor.ref(null);
|
|
|
const suggestions = common_vendor.ref([]);
|
|
|
const showDropdown = common_vendor.ref(false);
|
|
|
+ const isLoggedIn = common_vendor.ref(false);
|
|
|
let timer = null;
|
|
|
+ common_vendor.onMounted(() => {
|
|
|
+ isLoggedIn.value = utils_auth.isLoggedIn();
|
|
|
+ console.log("=== 页面加载 ===");
|
|
|
+ console.log("登录状态:", isLoggedIn.value);
|
|
|
+ console.log("Token:", common_vendor.index.getStorageSync("user_token"));
|
|
|
+ });
|
|
|
+ common_vendor.onShow(() => {
|
|
|
+ isLoggedIn.value = utils_auth.isLoggedIn();
|
|
|
+ console.log("=== 页面显示 ===");
|
|
|
+ console.log("登录状态:", isLoggedIn.value);
|
|
|
+ });
|
|
|
+ const handleSearchClick = () => {
|
|
|
+ console.log("=== 点击搜索按钮 ===");
|
|
|
+ console.log("当前登录状态:", isLoggedIn.value);
|
|
|
+ if (!isLoggedIn.value) {
|
|
|
+ console.log("未登录,显示登录提示");
|
|
|
+ common_vendor.index.showModal({
|
|
|
+ title: "提示",
|
|
|
+ content: "查询股票信息需要先登录,是否前往登录?",
|
|
|
+ success: (res) => {
|
|
|
+ if (res.confirm) {
|
|
|
+ common_vendor.index.navigateTo({
|
|
|
+ url: "/pages/login/login"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log("已登录,执行搜索");
|
|
|
+ onSearch();
|
|
|
+ };
|
|
|
const onKeywordChange = (e) => {
|
|
|
const value = e.detail.value;
|
|
|
keyword.value = value;
|
|
|
@@ -30,8 +64,9 @@ const _sfc_main = {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
- const list = await utils_api.getSuggestions(kw.trim());
|
|
|
- console.log("模糊查询返回数据:", list);
|
|
|
+ const response = await utils_api.getSuggestions(kw.trim());
|
|
|
+ console.log("模糊查询返回数据:", response);
|
|
|
+ const list = response.data || [];
|
|
|
suggestions.value = Array.isArray(list) ? list : [];
|
|
|
showDropdown.value = suggestions.value.length > 0;
|
|
|
console.log("下拉框状态:", { showDropdown: showDropdown.value, suggestionsLength: suggestions.value.length });
|
|
|
@@ -95,7 +130,7 @@ const _sfc_main = {
|
|
|
b: common_vendor.o(onSearch),
|
|
|
c: common_vendor.o(onInputBlur),
|
|
|
d: keyword.value,
|
|
|
- e: common_vendor.o(onSearch),
|
|
|
+ e: common_vendor.o(handleSearchClick),
|
|
|
f: showDropdown.value && suggestions.value && suggestions.value.length > 0
|
|
|
}, showDropdown.value && suggestions.value && suggestions.value.length > 0 ? {
|
|
|
g: common_vendor.f(suggestions.value, (item, index, i0) => {
|
|
|
@@ -107,16 +142,17 @@ const _sfc_main = {
|
|
|
};
|
|
|
})
|
|
|
} : {}, {
|
|
|
- h: hasSearched.value
|
|
|
+ h: common_vendor.t(isLoggedIn.value ? "" : "(需登录)"),
|
|
|
+ i: hasSearched.value
|
|
|
}, hasSearched.value ? common_vendor.e({
|
|
|
- i: loading.value
|
|
|
+ j: loading.value
|
|
|
}, loading.value ? {} : errorMsg.value ? {
|
|
|
- k: common_vendor.t(errorMsg.value)
|
|
|
+ l: common_vendor.t(errorMsg.value)
|
|
|
} : result.value ? {
|
|
|
- m: common_vendor.t(result.value.stockName),
|
|
|
- n: common_vendor.t(result.value.stockCode),
|
|
|
- o: common_vendor.t(result.value.score),
|
|
|
- p: common_vendor.f(result.value.history, (item, index, i0) => {
|
|
|
+ n: common_vendor.t(result.value.stockName),
|
|
|
+ o: common_vendor.t(result.value.stockCode),
|
|
|
+ p: common_vendor.t(result.value.score),
|
|
|
+ q: common_vendor.f(result.value.history, (item, index, i0) => {
|
|
|
return {
|
|
|
a: common_vendor.t(item.date),
|
|
|
b: common_vendor.t(item.score),
|
|
|
@@ -124,7 +160,7 @@ const _sfc_main = {
|
|
|
d: index
|
|
|
};
|
|
|
}),
|
|
|
- q: common_vendor.f(result.value.factors, (item, index, i0) => {
|
|
|
+ r: common_vendor.f(result.value.factors, (item, index, i0) => {
|
|
|
return {
|
|
|
a: common_vendor.t(item.name),
|
|
|
b: common_vendor.t(item.value),
|
|
|
@@ -132,11 +168,11 @@ const _sfc_main = {
|
|
|
};
|
|
|
})
|
|
|
} : {}, {
|
|
|
- j: errorMsg.value,
|
|
|
- l: result.value
|
|
|
+ k: errorMsg.value,
|
|
|
+ m: result.value
|
|
|
}) : {});
|
|
|
};
|
|
|
}
|
|
|
};
|
|
|
-const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/program/miniprogram-1/src/pages/index/index.vue"]]);
|
|
|
+const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/program/gupiao-wx/src/pages/index/index.vue"]]);
|
|
|
wx.createPage(MiniProgramPage);
|