"use strict"; const common_vendor = require("../common/vendor.js"); const api_index = require("../api/index.js"); const Store = common_vendor.defineStore("counter", { state: () => { return { userId: "", userInfo: { inviteCode: "", nickname: "", mobile: "", avatar: "", puser: null, paywallet: { balance: 0 }, userRights: null }, // 用户信息 tem_list: [], // 临时列表(支持其他页面对该列表数据的更新) set_title: "", // 设置页面标题 set_options: [], // 设置详细参数 set_end_function: () => { } // 设置页面结束后执行的方法 }; }, actions: { setUserId(_id) { this.userId = _id; }, // 设置临时列表 setTemList(list = []) { this["tem_list"] = list; }, // 移除临时列表的某一项 removeTemList(_id) { if (!_id || this["tem_list"].length === 0) return; let _index = this["tem_list"].findIndex((item) => item._id === _id); this["tem_list"].splice(_index, 1); }, // 更新临时列表 updateTemList(_id, key, val) { if (!_id || !key || this["tem_list"].length === 0) return; let _index = this["tem_list"].findIndex((item) => item._id === _id); let obj = this["tem_list"][_index]; obj[key] = val; this["tem_list"].splice(_index, 1, obj); }, // 设置参数 setOptions({ set_title, set_options, set_end_function }) { if (!set_title) { set_title = "设置"; } if (!set_options || set_options.length === 0) { set_options = [ // 输入框 { type: "input", list: [ { title: "Breathe的主题配置一", value: "", type: "text" } ] }, // 开关 { type: "switch", list: [ { title: "自动(跟随系统)", value: false } ] }, // 选择 { type: "select", tip: "选择主题并应用到程序选择主题并应用到程序选择主题并应用到程序选择主题并应用到程序。", list: [ { title: "默认", value: true }, { title: "暗黑", value: false }, { title: "激光红", value: false }, { title: "天空蓝", value: false } ] } ]; } if (!set_end_function) { set_end_function = (e) => { common_vendor.index.__f__("log", "at store/index.ts:84", `------->默认的set_end_function,e:`, e); }; } this["set_title"] = set_title; this["set_options"] = set_options; this["set_end_function"] = set_end_function; const { type, path } = set_options[0]; if (set_options.length === 1 && type === "select-list") return common_vendor.index.navigateTo({ url: path }); common_vendor.index.navigateTo({ url: "/pages-system/set/set-options" }); }, // 同步本地数据 async syncStore() { }, // 获取用户信息 async logoutUser() { this["userInfo"] = { inviteCode: "", nickname: "", mobile: "", avatar: "", paywallet: { balance: 0 } }; common_vendor.index.clearStorage({ success() { common_vendor.index.switchTab({ url: "/pages/index/index" }); }, fail(err) { common_vendor.index.__f__("error", "at store/index.ts:117", "清除缓存失败", err); } }); }, async usersGetInfo() { try { let _res = {}; _res = await api_index.api.usersGetInfo(); common_vendor.index.__f__("log", "at store/index.ts:128", _res); this["userInfo"] = _res; } catch (e) { throw e; } } } }); exports.Store = Store; //# sourceMappingURL=../../.sourcemap/mp-weixin/store/index.js.map