/** * 提示框 * @param {string} title 显示的标题 * @param {string} icon 显示的 icon * @param {number} icon 显示的毫秒数 */ export const showToast = (title, icon = "none", time = 2000) => { uni.showToast({ title: title, icon: icon, duration: time, }); }; /** * 显示隐藏加载的 loading 状态 * @param {string} title 显示的标题 */ export const loading = { show(title) { uni.showLoading({ title: title || "加载中", }); }, hide() { uni.hideLoading(); }, }; /** * @param {number} number 判断需要返回的数据 2 为 2019-01 3为 2019-01-01 * 显获取当前日期 要求2019-01-01 格式 */ export const getNowDate = (number) => { let date = new Date(); let year = date.getFullYear(); let month = date.getMonth() + 1; let day = date.getDate(); if (number == 2) { return `${year}-${month < 10? '0'+month:month}`; } else if (number == 3) { return `${year}-${month < 10? '0'+month:month}-${day < 10? '0'+day:day}`; } };