微信API 需要查看图片缺失问题

This commit is contained in:
limqhz
2023-02-06 18:51:37 +08:00
parent 23a10593c8
commit 40ca4223dd
8 changed files with 98 additions and 93 deletions

View File

@@ -18,7 +18,7 @@ Page({
onLoad: function (options) {
},
onShow: function () {
app.$api.taskList().then(x => {
app.$api.getSetting(1).then(x => {
console.log(x);
})
if (wx.canIUse('hideHomeButton')) {

View File

@@ -17,24 +17,33 @@ Page({
}
},
loginAcc () {
let that = this;
wx.login({
success (res) {
if (res.code) {
app.$api.getOpenId(res.code).then(res => {
wx.setStorageSync("openid",res.data.openid)
this.setData({
noLogin : false
})
}, err => {
console.log(err);
let param = {
appid:'wxb1f499f0a173865b',
secret:'833eefaf9206337d6c2d643f94baef7b',
js_code: res.code,
grant_type: 'authorization_code'
};
//发起网络请求
wx.request({
url: 'https://api.weixin.qq.com/sns/jscode2session',
data: param,
success: function(x) {
app.$api.loginAccount({"openId":x.data.openid}).then(t=>{
wx.setStorageSync("userId",t.data)
that.setData({
noLogin : false
})
})
}
})
} else {
console.log('登录失败!' + res.errMsg)
}
}
})
app.$api.loginAccount(wx.getStorageSync('openid')).then(res => {
wx.setStorageSync('userId',res.data)
});
}
});

View File

@@ -1,22 +1,24 @@
<view class="my_look">
<t-cell-group theme="card">
<t-cell wx:if="{{noLogin}}" title="点击登录" description="" bind:tap="loginAcc"/>
<t-cell wx:else title="登录成功" description="欢迎使用奎因记账!" image="/image/logo.png"/>
<t-cell title="预算管理" arrow url="/pages/budget/index" >
<t-icon name="tools" slot="left-icon" />
</t-cell>
<t-cell title="资产分类管理" arrow url="/pages/settings/account/index" >
<t-icon name="setting" slot="left-icon" />
</t-cell>
<t-cell title="支出分类管理" arrow url="/pages/settings/expend/index" >
<t-icon name="setting" slot="left-icon" />
</t-cell>
<t-cell title="收入分类管理" arrow url="/pages/settings/income/index" >
<t-icon name="setting" slot="left-icon" />
</t-cell>
<t-cell title="关于我们" arrow url="/pages/about/about" >
<t-icon name="gift" slot="left-icon" />
</t-cell>
<view wx:else>
<t-cell title="登录成功" description="欢迎使用奎因记账!" image="/image/logo.png"/>
<t-cell title="预算管理" arrow url="/pages/budget/index" >
<t-icon name="tools" slot="left-icon" />
</t-cell>
<t-cell title="资产分类管理" arrow url="/pages/settings/account/index" >
<t-icon name="setting" slot="left-icon" />
</t-cell>
<t-cell title="支出分类管理" arrow url="/pages/settings/expend/index" >
<t-icon name="setting" slot="left-icon" />
</t-cell>
<t-cell title="收入分类管理" arrow url="/pages/settings/income/index" >
<t-icon name="setting" slot="left-icon" />
</t-cell>
<t-cell title="关于我们" arrow url="/pages/about/about" >
<t-icon name="gift" slot="left-icon" />
</t-cell>
</view>
</t-cell-group>
</view>
<foot-tab value="label_4"/>

View File

@@ -7,7 +7,8 @@ Page({
isIncome: 0,
isAdd: 0,
showDeleteConfirm: false,
icon : null
icon : null,
accType: null
},
onLoad: function (options) {
this.setData({

View File

@@ -6,7 +6,7 @@
value="{{ '假的名称' }}"
/>
<t-input wx:if="{{ isAccount == 1 }}" label="分类" disabled>
<t-radio-group slot="suffix" default-value="0" borderless t-class="box">
<t-radio-group slot="suffix" default-value="{{accType}}" borderless t-class="box">
<t-radio block="{{ false }}" label="资产账户" value="0" />
<t-radio block="{{ false }}" label="负债账户" value="1" />
</t-radio-group>

View File

@@ -4,9 +4,24 @@ Page({
payList: null
},
onLoad: function (options) {
let payList = app.$api.getSettings('EXPEND_SETTING');
app.$api.
this.setData({payList})
app.$api.getSettings().then(setting => {
let payList = setting.data.EXPEND_SETTING;
app.$api.getSettingsExpend().then(res => {
let result = res.data;
payList.forEach(item => {
let money = 0
if (result[item.id]){
money = result[item.id];
}
if (!money){
money = 0
}
item.money = money;
})
console.log(payList);
this.setData({payList})
});
});
},
handleClick() {
wx.navigateTo({

View File

@@ -1,3 +1,4 @@
const app = getApp();
Page({
data: {
incomeList: [
@@ -6,7 +7,24 @@ Page({
]
},
onLoad: function (options) {
app.$api.getSettings().then(setting => {
let incomeList = setting.data.INCOME_SETTING;
app.$api.getSettingsIncome().then(res => {
let result = res.data;
incomeList.forEach(item => {
let money = 0
if (result[item.id]){
money = result[item.id];
}
if (!money){
money = 0
}
item.money = money;
})
console.log(incomeList);
this.setData({incomeList})
});
});
},
handleClick() {
wx.navigateTo({

View File

@@ -6,7 +6,6 @@ const LOGIN_URL = 'https://api.weixin.qq.com/sns/jscode2session';
// const BASE_URL = 'https://www.qnforever.top/wx';
function buildURL(url, needToken) {
let userId = wx.getStorageSync('userId');
console.log(url)
if (!userId && url != '/user/login') {
wx.redirectTo({
url: '../myself/index'
@@ -17,7 +16,7 @@ function buildURL(url, needToken) {
})
setTimeout(function () {
wx.hideLoading()
}, 4000)
}, 2000)
return;
}
if (url != '/user/login'){
@@ -239,72 +238,33 @@ export function fetchGet(url, params, needToken) {
// 暴露接口
export default {
/**
* 获取用户唯一标识openId
*/
getOpenId(code) {
let param = {
appid:'wxb1f499f0a173865b',
secret:'833eefaf9206337d6c2d643f94baef7b',
js_code: code,
grant_type: 'authorization_code'
};
//发起网络请求
return wx.request({
url: LOGIN_URL,
data: {
appid:'wxb1f499f0a173865b',
secret:'833eefaf9206337d6c2d643f94baef7b',
js_code: res.code,
grant_type: 'authorization_code'
}
})
},
loginAccount(params) {
return fetchPost('/user/login',params,true,false);
},
getSetting(params) {
return fetchPost('user/setting/' + params,true,false);
},
addSetting(params) {
return fetchPost('user/settings/add',params,true,false);
},
deleteSetting(params) {
return fetchPost('user/settings/delete',params,true,false);
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;
}
})
getSettings() {
// 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;
// }
return fetchPost('/user/settings', null, true, false);
},
getSettingsExpend(){