微信接口
This commit is contained in:
3
app.js
3
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'},
|
||||
|
||||
@@ -49,8 +49,9 @@ Page({
|
||||
})
|
||||
},
|
||||
onConfirm (e) {
|
||||
app.$api.deleteSetting();
|
||||
wx.navigateBack();
|
||||
this.closeDialog()
|
||||
this.closeDialog();
|
||||
},
|
||||
closeDialog() {
|
||||
this.setData({
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{payList != null && payList.length > 0}}">
|
||||
<t-cell-group theme="card">
|
||||
<t-cell wx:for="{{payList}}" wx:key="index"
|
||||
title="{{item.name}}"
|
||||
@@ -17,4 +18,8 @@
|
||||
url="../edit/index?isAccount=0&isIncome=0&isAdd=0"
|
||||
/>
|
||||
</t-cell-group>
|
||||
</view>
|
||||
<view wx:else class="empty-view" >
|
||||
<t-empty icon="chart-bubble" description="暂无支出分类" />
|
||||
</view>
|
||||
<t-fab icon="add" bind:click="handleClick" aria-label="新增支出类型"/>
|
||||
|
||||
54
utils/api.js
54
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);
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user