完成简易版的充值和充值记录查询页面,简单的我的页面
This commit is contained in:
@@ -58,4 +58,71 @@ export function getConfigByEnv() {
|
||||
export function getGlobalData() {
|
||||
const app = getApp();
|
||||
return app.globalData;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 节流
|
||||
* @param fn 需要节流的函数
|
||||
* @param interval 时间
|
||||
*/
|
||||
|
||||
export function throttle(fn, interval = 500) {
|
||||
let flag = false;
|
||||
return function() {
|
||||
if(!flag) {
|
||||
flag = true
|
||||
fn.apply(this, arguments);
|
||||
setTimeout(() => {
|
||||
flag = false
|
||||
}, interval)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 将微信弹框确认异步变成同步 */
|
||||
export function showModal({
|
||||
title, content
|
||||
}) {
|
||||
return new Promise((resolve) => {
|
||||
wx.showModal({
|
||||
title,
|
||||
content,
|
||||
complete: (res) => {
|
||||
if (res.cancel) {
|
||||
resolve(false)
|
||||
}
|
||||
|
||||
if (res.confirm) {
|
||||
resolve(true)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/** 获取可选年份 */
|
||||
export function getYears() {
|
||||
const years = [];
|
||||
const currentYear = new Date().getFullYear();
|
||||
const minYear = 2023;
|
||||
for(let i = currentYear; i >= minYear; i--) {
|
||||
years.push(i);
|
||||
}
|
||||
return years;
|
||||
}
|
||||
|
||||
/**
|
||||
* 防抖
|
||||
* @param fn 需要防抖的函数
|
||||
* @param interval 时间
|
||||
*/
|
||||
function debounce(fn, interval) {
|
||||
var timer;
|
||||
var gapTime = interval || 500
|
||||
return function() {
|
||||
clearTimeout(timer)
|
||||
var that = this;
|
||||
timer = setTimeout(function (){
|
||||
fn.call(that);
|
||||
}, gapTime);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user