diff --git a/app.js b/app.js index 64ce063..f6474b6 100644 --- a/app.js +++ b/app.js @@ -5,6 +5,9 @@ App({ onLaunch() { }, globalData: { + INCOME_SETTING: 'INCOME_SETTING', + EXPEND_SETTING: 'EXPEND_SETTING', + ACCOUNT_SETTING: 'ACCOUNT_SETTING', billIcon : [ {label: '度假', icon: '/image/bill/0.png'}, {label: '电影', icon: '/image/bill/1.png'}, diff --git a/pages/settings/edit/index.js b/pages/settings/edit/index.js index 52024fb..6179f72 100644 --- a/pages/settings/edit/index.js +++ b/pages/settings/edit/index.js @@ -49,8 +49,9 @@ Page({ }) }, onConfirm (e) { + app.$api.deleteSetting(); wx.navigateBack(); - this.closeDialog() + this.closeDialog(); }, closeDialog() { this.setData({ diff --git a/pages/settings/expend/index.js b/pages/settings/expend/index.js index a51f099..fc1352f 100644 --- a/pages/settings/expend/index.js +++ b/pages/settings/expend/index.js @@ -1,13 +1,12 @@ +const app = getApp(); Page({ data: { - payList: [ - {"name":"数码产品","money":"5000.00"}, - {"name":"虚拟产品","money":"2000.00"}, - {"name":"红包","money":"0.23"} - ] + payList: null }, onLoad: function (options) { - + let payList = app.$api.getSettings('EXPEND_SETTING'); + app.$api. + this.setData({payList}) }, handleClick() { wx.navigateTo({ diff --git a/pages/settings/expend/index.wxml b/pages/settings/expend/index.wxml index 8c252af..4a22ce2 100644 --- a/pages/settings/expend/index.wxml +++ b/pages/settings/expend/index.wxml @@ -8,6 +8,7 @@ + + + + + diff --git a/utils/api.js b/utils/api.js index 9aa17e0..0eba398 100644 --- a/utils/api.js +++ b/utils/api.js @@ -17,7 +17,7 @@ function buildURL(url, needToken) { }) setTimeout(function () { wx.hideLoading() - }, 2000) + }, 4000) return; } if (url != '/user/login'){ @@ -265,10 +265,52 @@ export default { return fetchPost('/user/login',params,true,false); }, - /** - * 任务清单 - */ - taskList(params) { - return fetchPost('/test', params, true,false); + addSetting(params) { + return fetchPost('user/settings/add',params,true,false); + }, + deleteSetting(params) { + return fetchPost('user/settings/delete',params,true,false); + }, + getSettings(type) { + let result; + if (type == 'INCOME_SETTING'){ + result = wx.getStorageSync('INCOME_SETTING'); + } + if (type == 'EXPEND_SETTING'){ + result = wx.getStorageSync('INCOME_SETTING'); + } + if (type == 'ACCOUNT_SETTING'){ + result = wx.getStorageSync('INCOME_SETTING'); + } + if (result){ + return result; + } + let income; + let expend; + let account; + fetchPost('/user/settings', null, true,false).then(res => { + income = res.INCOME_SETTING; + expend = res.INCOME_SETTING; + account = res.INCOME_SETTING; + wx.setStorageSync('INCOME_SETTING',income) + wx.setStorageSync('EXPEND_SETTING',expend) + wx.setStorageSync('ACCOUNT_SETTING',account) + if (type == 'INCOME_SETTING'){ + return income; + } + if (type == 'EXPEND_SETTING'){ + return expend; + } + if (type == 'ACCOUNT_SETTING'){ + return account; + } + }) + }, + + getSettingsExpend(){ + return fetchPost('/user/settings/expend',null,true,false); + }, + getSettingsIncome(){ + return fetchPost('/user/settings/income',null,true,false); }, }