| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const _sfc_main = {
- __name: "points",
- setup(__props) {
- const records = common_vendor.ref([]);
- const handleBack = () => {
- const pages = getCurrentPages();
- if (pages.length > 1) {
- common_vendor.index.navigateBack();
- } else {
- common_vendor.index.switchTab({
- url: "/pages/mine/mine"
- });
- }
- };
- const groupedRecords = common_vendor.computed(() => {
- const groups = {};
- records.value.forEach((item) => {
- const dateKey = formatDate(item.timestamp);
- if (!groups[dateKey]) {
- groups[dateKey] = [];
- }
- groups[dateKey].push(item);
- });
- return groups;
- });
- const formatDate = (timestamp) => {
- const date = new Date(timestamp);
- const today = /* @__PURE__ */ new Date();
- const yesterday = new Date(today);
- yesterday.setDate(yesterday.getDate() - 1);
- const dateStr = date.toLocaleDateString("zh-CN", {
- year: "numeric",
- month: "2-digit",
- day: "2-digit"
- });
- const todayStr = today.toLocaleDateString("zh-CN", {
- year: "numeric",
- month: "2-digit",
- day: "2-digit"
- });
- const yesterdayStr = yesterday.toLocaleDateString("zh-CN", {
- year: "numeric",
- month: "2-digit",
- day: "2-digit"
- });
- if (dateStr === todayStr) {
- return "今天";
- } else if (dateStr === yesterdayStr) {
- return "昨天";
- } else {
- return dateStr;
- }
- };
- const formatTime = (timestamp) => {
- const date = new Date(timestamp);
- const hours = String(date.getHours()).padStart(2, "0");
- const minutes = String(date.getMinutes()).padStart(2, "0");
- return `${hours}:${minutes}`;
- };
- const loadRecords = () => {
- try {
- const storedRecords = common_vendor.index.getStorageSync("points_records") || [];
- records.value = storedRecords.sort((a, b) => b.timestamp - a.timestamp);
- } catch (e) {
- console.error("加载积分记录失败:", e);
- records.value = [];
- }
- };
- const initMockData = () => {
- const mockRecords = [
- {
- title: "每日签到",
- points: 10,
- type: "add",
- timestamp: Date.now() - 1e3 * 60 * 30
- },
- {
- title: "完成交易",
- points: 5,
- type: "add",
- timestamp: Date.now() - 1e3 * 60 * 60 * 2
- },
- {
- title: "查询股票",
- points: 2,
- type: "use",
- timestamp: Date.now() - 1e3 * 60 * 60 * 5
- },
- {
- title: "邀请好友",
- points: 20,
- type: "add",
- timestamp: Date.now() - 1e3 * 60 * 60 * 24
- },
- {
- title: "解锁超短池",
- points: 18,
- type: "use",
- timestamp: Date.now() - 1e3 * 60 * 60 * 24 * 2
- }
- ];
- if (records.value.length === 0) {
- records.value = mockRecords;
- common_vendor.index.setStorageSync("points_records", mockRecords);
- }
- };
- common_vendor.onMounted(() => {
- loadRecords();
- initMockData();
- });
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: common_vendor.o(handleBack),
- b: common_vendor.f(common_vendor.unref(groupedRecords), (group, dateKey, i0) => {
- return {
- a: common_vendor.t(dateKey),
- b: common_vendor.f(group, (item, index, i1) => {
- return {
- a: common_vendor.t(item.title),
- b: common_vendor.t(formatTime(item.timestamp)),
- c: common_vendor.t(item.type === "add" ? "+" : "-"),
- d: common_vendor.t(item.points),
- e: common_vendor.n(item.type === "add" ? "amount-sell" : "amount-buy"),
- f: common_vendor.t(item.type === "add" ? "获得" : "消耗"),
- g: common_vendor.n(item.type === "add" ? "status-sell" : "status-buy"),
- h: index
- };
- }),
- c: dateKey
- };
- }),
- c: records.value.length === 0
- }, records.value.length === 0 ? {} : {});
- };
- }
- };
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-9b5c2d6e"], ["__file", "D:/program/gupiao-wx/src/pages/points/points.vue"]]);
- wx.createPage(MiniProgramPage);
|