base.css
common.css
image {vertical-align: middle;}
button {margin: 0; padding: 0;border: 0 none;}
button::after { border: 0;}
/**清除浮动***/
.g_clearfix::before,.g_clearfix::after {content: "";height: 0;line-height: 0; visibility: hidden; display: block;clear: both;}
.g_clearfix {zoom: 1;}
.g_clear {clear: both; height: 0;font-size: 0; line-height: 0; visibility: hidden; overflow: hidden;}
/** 全局按钮样式 */
.g_btn {
width: 60%; height: 80rpx; margin: 0 auto; line-height: 80rpx;
font-size: 28rpx;color: white; text-align: center;border-radius: 10rpx;
background: -webkit-linear-gradient(left, #fdd73a, #fab033);
background: -o-linear-gradient(right, #fdd73a, #fab033);
background: -moz-linear-gradient(right, #fdd73a, #fab033);
background: linear-gradient(to right, #fdd73a, #fab033);
}
/** 全局弹窗遮幕 */
.g_modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, .5);
z-index: 10;
}
.g_mask {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 100;
}
/**flex弹性盒子***/
.g_display_flex {display: -webkit-box;display: -ms-flexbox; display: -webkit-flex;display: flex;}
.g_display_flex .g_flex_1 { width: 0; -webkit-box-flex: 1; -ms-flex: 1; -webkit-flex: 1; flex: 1;}
/*侧轴居中对齐*/
.g_align-items_center { -webkit-box-align: center; -ms-flex-align: center; -webkit-align-items: center;align-items: center;}
/*主轴居中对齐*/
.g_justify-content_flex-center { -webkit-box-pack: center; -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center;}
.g_hid { display: none;}
utils.js
/**
* [formatDate description]
* @param {[String]} fmt [格式化模版]
* @param {[String | Object]} date [时间戳或者日期对象]
* @return {[String]} [格式后的时间字符串]
*/
function formatDate(fmt, date) {
date = typeof date == 'object' ? date : new Date();
var o = {
'M+': date.getMonth() + 1, //月份
'd+': date.getDate(), //日
'h+': date.getHours(), //小时
'm+': date.getMinutes(), //分
's+': date.getSeconds(), //秒
'q+': Math.floor((date.getMonth() + 3) / 3), //季度
'S': date.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
}
for (var k in o) {
if (new RegExp('(' + k + ')').test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
}
}
return fmt;
}
/**
*加法
* @return: 返回a+b的值
*/
function addFun(a, b) {
var c, d, e;
try {
c = a.toString().split(".")[1].length;
} catch (f) {
c = 0;
}
try {
d = b.toString().split(".")[1].length;
} catch (f) {
d = 0;
}
return e = Math.pow(10, Math.max(c, d)), (mul(a, e) + mul(b, e)) / e;
}
/**//减法
* @return: 返回a-b的值
*/
function subFun(a, b) {
var c, d, e;
try {
c = a.toString().split(".")[1].length;
} catch (f) {
c = 0;
}
try {
d = b.toString().split(".")[1].length;
} catch (f) {
d = 0;
}
return e = Math.pow(10, Math.max(c, d)), (mul(a, e) - mul(b, e)) / e;
}
/**//乘法
* @return: 返回a*b的值
*/
function mul(a, b) {
let c = 0
let d = a.toString()
let e = b.toString()
try {
c += d.split(".")[1].length;
} catch (f) {}
try {
c += e.split(".")[1].length;
} catch (f) {}
return Number(d.replace(".", "")) * Number(e.replace(".", "")) / Math.pow(10, c);
}
/**
*//除法
* @return: 返回a/b的值
*/
function divFun(a, b) {
var c, d, e = 0,
f = 0;
try {
e = a.toString().split(".")[1].length;
} catch (g) {}
try {
f = b.toString().split(".")[1].length;
} catch (g) {}
return c = Number(a.toString().replace(".", "")), d = Number(b.toString().replace(".", "")), mul(c / d, Math.pow(10, f - e));
}
/**
* [formatDate description]
* // 判断是否是整数
* @return {[Boolean]} [格式后的时间字符串]
*/
function isInt(num) {
var reg = new RegExp("^[0-9]*$");
return reg.test(num);
}
// 判断是否是数字
function isNum(num) {
var reg = new RegExp("^(\-)?[0-9]+(\.[0-9]+)?$");
return reg.test(num);
}
// 判断是否是手机号码
function isPhone(phone) {
var reg = new RegExp("^1[0-9]{10}$");
return reg.test(phone);
}
//只能输入有两位小数的正实数,多用于价格
function isFloat(num) {
var reg = new RegExp("^[0-9]+(\\.[0-9]{1,2})?$");
return reg.test(num);
}
//只能输入有1位小数的正实数,多用于打折
function isFloat1(num) {
var reg = new RegExp("^[0-9]+(\\.[0-9]{1})?$");
return reg.test(num);
}