|
|
|
var WXAPI = require('./server.js');
|
|
|
|
function formatTime(date) {
|
|
|
|
var year = date.getFullYear()
|
|
|
|
var month = date.getMonth() + 1
|
|
|
|
var day = date.getDate()
|
|
|
|
var hour = date.getHours()
|
|
|
|
var minute = date.getMinutes()
|
|
|
|
var second = date.getSeconds()
|
|
|
|
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatNumber(n) {
|
|
|
|
n = n.toString()
|
|
|
|
return n[1] ? n : '0' + n
|
|
|
|
}
|
|
|
|
|
|
|
|
function getUesrBg(that) {
|
|
|
|
WXAPI.appCart({
|
|
|
|
openid: app.globalData.userInfo.openid,
|
|
|
|
}).then(res => {
|
|
|
|
if (res.status == 1) {
|
|
|
|
var data = res;
|
|
|
|
var num = data.cart.toString()
|
|
|
|
if (num > 0) {
|
|
|
|
wx.setTabBarBadge({
|
|
|
|
index: 3,
|
|
|
|
text: num,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function getUesrBgplus(that, app, is) {
|
|
|
|
WXAPI.appCart({
|
|
|
|
openid: app.globalData.userInfo.openid,
|
|
|
|
}).then(res => {
|
|
|
|
if (res.status == 1) {
|
|
|
|
var data = res;
|
|
|
|
if (is) {
|
|
|
|
that.setData({
|
|
|
|
cart: data.cart
|
|
|
|
})
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.cart) {
|
|
|
|
wx.setTabBarBadge({
|
|
|
|
index: 3,
|
|
|
|
text: data.cart,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
wx.removeTabBarBadge({
|
|
|
|
index: 3
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 假设你访问的后台登录路径是:https://www.baidu.com/LKT/index.php?module=Login
|
|
|
|
* 那么你在这里填的路径应该是:https://www.baidu.com/LKT/index.php?module=api&software_name=3&edition=1.0
|
|
|
|
*/
|
|
|
|
function getUrl() {
|
|
|
|
//如果不想安装后台服务,请使用注释这一行做简单数据体验
|
|
|
|
return 'http://xiaochengxu.houjiemeishi.com/zhibo/LKT/index.php?module=api&software_name=3&edition=1.0'
|
|
|
|
// return 'http://localhost/open/app/LKT/index.php?module=api&software_name=3&edition=1.0'
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
formatTime: formatTime,
|
|
|
|
getUesrBg: getUesrBg,
|
|
|
|
getUesrBgplus: getUesrBgplus,
|
|
|
|
getUrl: getUrl
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkStringEmpty(data) {
|
|
|
|
if (null == data || "" == data) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|