import lib from '../lib/lib'; export default { getUser(callback, loading = true) { let url = "user/home"; let gym_id = lib.getParam('gym_id'); let data = {gym_id}; lib.post(url, data, (ret) => { if (ret.code == 0) { callback(ret.data); } else { lib.showErrorTip(ret.msg); } }, { loading, cache : true }); }, card(uid, callback, loading = true) { let url = "user/card"; let gym_id = lib.getParam('gym_id'); let data = {uid, gym_id}; lib.post(url, data, (ret) => { if (ret.code == 0) { callback(ret.data); } else { lib.showErrorTip(ret.msg); } }, { loading, cache : true }); }, detailInfo(uid, callback, loading = true) { let url = "user/detailInfo"; let data = {uid}; lib.post(url, data, (ret) => { if (ret.code == 0) { callback(ret.data); } else { lib.showErrorTip(ret.msg); } }, { loading, cache : true }); }, redPoint() { let url = "user/redPoint"; lib.get(url, (ret) => { if (ret.code == 0) { let localData = localStorage.getItem('redPoint'); if (localData) { localData = JSON.parse(localData); } localData = localData || {}; for (let name in ret.data) { if (ret.data[name]) { if (localData[name]) { if (ret.data[name] > localData[name]) { $(`[data-redPointName='${name}']`).find('.weui-badge_dot').show(); } } else { $(`[data-redPointName='${name}']`).find('.weui-badge_dot').show(); } } $(`[data-redPointName='${name}']`).attr('data-redPointVal', ret.data[name]); } } else { lib.showErrorTip(ret.msg); } }, { cache : true }); } }