微信API
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user