初始化参股

This commit is contained in:
2026-01-27 18:06:04 +08:00
commit 2774a539bf
254 changed files with 33255 additions and 0 deletions

View File

@@ -0,0 +1,228 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_config = require("../../utils/config.js");
class UserInfo extends UTS.UTSType {
static get$UTSMetadata$() {
return {
kind: 2,
get fields() {
return {
id: { type: String, optional: false },
nickName: { type: String, optional: false },
avatar: { type: String, optional: false },
phone: { type: String, optional: false }
};
},
name: "UserInfo"
};
}
constructor(options, metadata = UserInfo.get$UTSMetadata$(), isJSONParse = false) {
super();
this.__props__ = UTS.UTSType.initProps(options, metadata, isJSONParse);
this.id = this.__props__.id;
this.nickName = this.__props__.nickName;
this.avatar = this.__props__.avatar;
this.phone = this.__props__.phone;
delete this.__props__;
}
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "index",
setup(__props) {
const userInfo = common_vendor.ref(new UserInfo({
id: "",
nickName: "",
avatar: "",
phone: ""
}));
const isLoggedIn = common_vendor.ref(false);
const bookingCount = common_vendor.ref(0);
const favoriteCount = common_vendor.ref(0);
const cacheSize = common_vendor.ref("0KB");
const checkLoginStatus = () => {
var _a, _b, _c, _d;
const token = common_vendor.index.getStorageSync(utils_config.STORAGE_KEYS.TOKEN);
isLoggedIn.value = token != "";
if (isLoggedIn.value) {
const info = common_vendor.index.getStorageSync(utils_config.STORAGE_KEYS.USER_INFO);
if (info != null) {
userInfo.value = new UserInfo({
id: (_a = info["id"]) !== null && _a !== void 0 ? _a : "",
nickName: (_b = info["nickName"]) !== null && _b !== void 0 ? _b : "",
avatar: (_c = info["avatar"]) !== null && _c !== void 0 ? _c : "",
phone: (_d = info["phone"]) !== null && _d !== void 0 ? _d : ""
});
}
}
};
const getCacheSize = () => {
common_vendor.index.getStorageInfo(new UTSJSONObject({
success: (res) => {
const size = res.currentSize;
if (size < 1024) {
cacheSize.value = `${size}KB`;
} else {
cacheSize.value = `${(size / 1024).toFixed(2)}MB`;
}
}
}));
};
const handleLogin = () => {
common_vendor.index.getUserProfile(new UTSJSONObject({
desc: "用于完善用户资料",
success: (res = null) => {
userInfo.value = new UserInfo(
{
id: "",
nickName: res.userInfo.nickName,
avatar: res.userInfo.avatarUrl,
phone: ""
}
// 保存用户信息
);
common_vendor.index.setStorageSync(utils_config.STORAGE_KEYS.USER_INFO, new UTSJSONObject({
nickName: res.userInfo.nickName,
avatar: res.userInfo.avatarUrl
}));
common_vendor.index.setStorageSync(utils_config.STORAGE_KEYS.TOKEN, "mock_token_" + Date.now().toString());
isLoggedIn.value = true;
common_vendor.index.showToast({
title: "登录成功",
icon: "success"
});
},
fail: () => {
common_vendor.index.showToast({
title: "登录失败",
icon: "none"
});
}
}));
};
const handleLogout = () => {
common_vendor.index.showModal(new UTSJSONObject({
title: "提示",
content: "确定要退出登录吗?",
success: (res) => {
if (res.confirm) {
common_vendor.index.removeStorageSync(utils_config.STORAGE_KEYS.TOKEN);
common_vendor.index.removeStorageSync(utils_config.STORAGE_KEYS.USER_INFO);
isLoggedIn.value = false;
userInfo.value = new UserInfo({
id: "",
nickName: "",
avatar: "",
phone: ""
});
common_vendor.index.showToast({
title: "已退出登录",
icon: "success"
});
}
}
}));
};
const goToBookingList = () => {
common_vendor.index.showToast({
title: "功能开发中",
icon: "none"
});
};
const goToFavorites = () => {
common_vendor.index.showToast({
title: "功能开发中",
icon: "none"
});
};
const goToAbout = () => {
common_vendor.index.navigateTo({
url: "/pages/about/index"
});
};
const callService = () => {
common_vendor.index.makePhoneCall({
phoneNumber: "400-888-8888",
fail: () => {
common_vendor.index.showToast({
title: "拨打电话失败",
icon: "none"
});
}
});
};
const openFeedback = () => {
common_vendor.index.showToast({
title: "功能开发中",
icon: "none"
});
};
const checkUpdate = () => {
common_vendor.index.showToast({
title: "已是最新版本",
icon: "success"
});
};
const clearCache = () => {
common_vendor.index.showModal(new UTSJSONObject({
title: "提示",
content: "确定要清除缓存吗?",
success: (res) => {
if (res.confirm) {
common_vendor.index.clearStorage(new UTSJSONObject({
success: () => {
cacheSize.value = "0KB";
common_vendor.index.showToast({
title: "清除成功",
icon: "success"
});
}
}));
}
}
}));
};
common_vendor.onShow(() => {
checkLoginStatus();
getCacheSize();
});
return (_ctx, _cache) => {
"raw js";
const __returned__ = common_vendor.e({
a: common_vendor.unref(userInfo).avatar || "/static/images/default-avatar.png",
b: common_vendor.t(common_vendor.unref(userInfo).nickName || "点击登录"),
c: common_vendor.unref(userInfo).phone
}, common_vendor.unref(userInfo).phone ? {
d: common_vendor.t(common_vendor.unref(userInfo).phone)
} : {}, {
e: !common_vendor.unref(isLoggedIn)
}, !common_vendor.unref(isLoggedIn) ? {
f: common_vendor.o(handleLogin)
} : {}, {
g: common_vendor.unref(bookingCount) > 0
}, common_vendor.unref(bookingCount) > 0 ? {
h: common_vendor.t(common_vendor.unref(bookingCount))
} : {}, {
i: common_vendor.o(goToBookingList),
j: common_vendor.unref(favoriteCount) > 0
}, common_vendor.unref(favoriteCount) > 0 ? {
k: common_vendor.t(common_vendor.unref(favoriteCount))
} : {}, {
l: common_vendor.o(goToFavorites),
m: common_vendor.o(goToAbout),
n: common_vendor.o(callService),
o: common_vendor.o(openFeedback),
p: common_vendor.o(checkUpdate),
q: common_vendor.t(common_vendor.unref(cacheSize)),
r: common_vendor.o(clearCache),
s: common_vendor.unref(isLoggedIn)
}, common_vendor.unref(isLoggedIn) ? {
t: common_vendor.o(handleLogout)
} : {}, {
v: common_vendor.sei(common_vendor.gei(_ctx, ""), "view")
});
return __returned__;
};
}
});
wx.createPage(_sfc_main);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/user/index.js.map