mine.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. __name: "mine",
  5. setup(__props) {
  6. const isLoggedIn = common_vendor.ref(false);
  7. const userInfo = common_vendor.ref({
  8. nickName: "",
  9. avatarUrl: ""
  10. });
  11. const points = common_vendor.ref(900);
  12. const toggleLogin = () => {
  13. if (isLoggedIn.value) {
  14. isLoggedIn.value = false;
  15. userInfo.value = { nickName: "", avatarUrl: "" };
  16. common_vendor.index.showToast({ title: "已退出登录", icon: "none" });
  17. } else {
  18. isLoggedIn.value = true;
  19. userInfo.value = {
  20. nickName: "测试用户",
  21. // Using a placeholder or one of the existing images as a mock avatar
  22. avatarUrl: "/static/images/tab_mine_active.png"
  23. };
  24. common_vendor.index.showToast({ title: "登录成功", icon: "success" });
  25. }
  26. };
  27. const handleRecharge = () => {
  28. if (!isLoggedIn.value) {
  29. common_vendor.index.showToast({ title: "请先登录", icon: "none" });
  30. return;
  31. }
  32. common_vendor.index.showToast({ title: "充值功能开发中", icon: "none" });
  33. };
  34. const handleHistory = () => {
  35. if (!isLoggedIn.value) {
  36. common_vendor.index.showToast({ title: "请先登录", icon: "none" });
  37. return;
  38. }
  39. common_vendor.index.showToast({ title: "记录功能开发中", icon: "none" });
  40. };
  41. return (_ctx, _cache) => {
  42. return {
  43. a: isLoggedIn.value && userInfo.value.avatarUrl ? userInfo.value.avatarUrl : "/static/images/tab_mine_active.png",
  44. b: common_vendor.t(isLoggedIn.value ? userInfo.value.nickName || "微信用户" : "游客"),
  45. c: common_vendor.t(isLoggedIn.value ? points.value : 0),
  46. d: common_vendor.o(handleRecharge),
  47. e: common_vendor.o(handleHistory),
  48. f: common_vendor.t(isLoggedIn.value ? "退出登录" : "登录"),
  49. g: common_vendor.o(toggleLogin)
  50. };
  51. };
  52. }
  53. };
  54. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/program/miniprogram-1/src/pages/mine/mine.vue"]]);
  55. wx.createPage(MiniProgramPage);