// 鎸夐挳active
$('body').on('touchstart', '.btn', function () {
var $this = $(this);
$this.addClass('f-active');
setTimeout(function () {
$this.removeClass('f-active');
}, 100)
})
// 寮瑰嚭鍏抽棴
$('body').on('click', '.m-popup .close, .m-popup .j-close', function () {
$(this).parents('.m-popup').hide();
})
// loading
function showLoading(text) {
var info = text ? '
' + text + '
' : '';
hideLoading();
$('body').append('');
}
function hideLoading() {
$('.f-loading').remove();
}
// 娑堟伅鎻愮ず
function showToast(text, duration) {
$('body').append('');
window.toastTimer = setTimeout(function () {
$('.f-toast').remove();
}, duration || 2000)
}
function hideToast() {
clearTimeout(window.toastTimer);
$('.f-toast').remove();
}
function ajax(options) {
var data = {
type: options.type || 'POST',
url: apiUrl + (options.url || ''),
data: options.data || {},
dataType: 'json',
success: function (res) {
if (options.success) {
options.success(res);
}
},
error: function (res) {
console.log(res)
hideLoading();
showToast(data.url + '璇锋眰澶辫触');
}
}
$.ajax(data)
}