微信API

This commit is contained in:
2023-01-31 14:58:42 +08:00
parent 13cf902ce2
commit c8a16e91b6
6 changed files with 128 additions and 35 deletions

View File

@@ -1,3 +1,4 @@
const app = getApp()
Page({
data: {
progress: 89,
@@ -17,6 +18,9 @@ Page({
onLoad: function (options) {
},
onShow: function () {
app.$api.taskList().then(x => {
console.log(x);
})
if (wx.canIUse('hideHomeButton')) {
wx.hideHomeButton()
}

View File

@@ -1,11 +1,40 @@
const app = getApp()
Page({
data: {},
data: {
noLogin: true,
},
onLoad: function (options) {
let openId = wx.getStorageSync("userId");
if (openId) {
this.setData({
noLogin : false
})
}
},
onShow: function () {
if (wx.canIUse('hideHomeButton')) {
wx.hideHomeButton()
}
},
loginAcc () {
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);
})
} else {
console.log('登录失败!' + res.errMsg)
}
}
})
app.$api.loginAccount(wx.getStorageSync('openid')).then(res => {
wx.setStorageSync('userId',res.data)
});
}
});

View File

@@ -1,10 +1,7 @@
<view class="my_look">
<t-cell-group theme="card">
<t-cell title="浙A88FU7" description="下午好!">
<view class="avatar" slot="left-icon">
<open-data type="userAvatarUrl" />
</view>
</t-cell>
<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>