import { SY } from "./index.js" import { MY } from "./my.js" const HTTP = { SY: SY, //首页的接口 MY: MY, //我的,接口 jsonf: (json) => { //处理json字符串 if (json) { return encodeURIComponent(JSON.stringify(json)) } else { return json } }, jsonp: (json) => { //恢复处理后的json字符串 if (json) { return JSON.parse(decodeURIComponent(json)) } else { return json } }, name: (str) => { //处理姓名 if (str.length <= 4) { // 根据长度不同进行不同的替换 switch (str.length) { case 2: return str[0] + "*"; case 3: return str[0] + "*" + str[2]; case 4: return str.slice(0, 2) + "**"; default: return str; } } else { // 长度超过4个,替换中间的字符 return str[0] + "**" + str[str.length - 1]; } }, jfs: () => { //统一处理名称,方便后续改动 return "积分" }, uns: (e) => { //接口提示 uni.showToast({ duration: 2000, icon: "none", title: e }) }, tm1: (e) => { //时间戳转字符串时间 // 创建一个 Date 对象 const date = new Date(e); // 获取年份、月份和日期 const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以要加1 const day = String(date.getDate()).padStart(2, '0'); // 返回格式化后的日期字符串 return `${year}-${month}-${day}`; }, tm2:e=>{//秒级时间搓 // 将秒级时间戳转换成毫秒级时间戳 const milliseconds = e * 1000; // 创建一个 Date 对象 const date = new Date(milliseconds); // 获取年份、月份和日期 const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以要加1 const day = String(date.getDate()).padStart(2, '0'); // 返回格式化后的日期字符串 return `${year}-${month}-${day}`; } } export { HTTP }