上一節(jié)我們完成了登錄頁(yè)面的實(shí)現(xiàn),這一節(jié)讓我們完成登錄后的錢包頁(yè)面和充值頁(yè)面
頁(yè)面分析
需要獲取錢包余額數(shù)據(jù)并顯示在頁(yè)面上,充值后數(shù)據(jù)會(huì)自動(dòng)更新
其他可點(diǎn)擊按鈕分別顯示對(duì)應(yīng)的模態(tài)框,因?yàn)槲⑿胖辉试S五個(gè)頁(yè)面層級(jí),避免過(guò)多頁(yè)面層級(jí)造成用戶迷失。
頁(yè)面結(jié)構(gòu)
-
<!--pages/wallet/index.wxml-->
-
<view class="container">
-
<view class="overage">
-
<view>
-
<text class="overage-header">我的余額(元)</text>
-
</view>
-
<view>
-
<text class="overage-amount">{{overage}}</text>
-
</view>
-
<view>
-
<text bindtap="overageDesc" class="overage-desc">余額說(shuō)明</text>
-
</view>
-
</view>
-
<button bindtap="movetoCharge" class="btn-charge">充值</button>
-
<view bindtap="showTicket" class="my-ticket tapbar">
-
<text>我的用車券</text>
-
<text><text class="c-g">{{ticket}}張</text>></text>
-
</view>
-
<view bindtap="showDeposit" class="my-deposit tapbar">
-
<text>我的押金</text>
-
<text><text class="c-y">99元,押金退款</text>></text>
-
</view>
-
<view bindtap="showInvcode" class="my-invcode tapbar">
-
<text>關(guān)于ofo</text>
-
<text>></text>
-
</view>
-
</view>
頁(yè)面樣式
-
/* pages/wallet/index.wxss */
-
.overage{
-
background-color: #fff;
-
padding: 40rpx 0;
-
text-align: center;
-
}
-
.overage-header{
-
font-size: 24rpx;
-
}
-
.overage-amount{
-
display: inline-block;
-
padding: 20rpx 0;
-
font-size: 100rpx;
-
font-weight: 700;
-
}
-
.overage-desc{
-
padding: 10rpx 30rpx;
-
font-size: 24rpx;
-
border-radius: 40rpx;
-
border: 1px solid #666;
-
}
-
.my-deposit{
-
margin-top: 2rpx;
-
}
-
.my-invcode{
-
margin-top: 40rpx;
-
}
-
.c-y{
-
color: #b9dd08;
-
padding-top: -5rpx;
-
padding-right: 10rpx;
-
}
-
.c-g{
-
padding-top: -5rpx;
-
padding-right: 10rpx;
-
}
頁(yè)面數(shù)據(jù)邏輯
-
// pages/wallet/index.js
-
Page({
-
data:{
-
overage: 0,
-
ticket: 0
-
},
-
// 頁(yè)面加載
-
onLoad:function(options){
-
wx.setNavigationBarTitle({
-
title: '我的錢包'
-
})
-
},
-
// 頁(yè)面加載完成,更新本地存儲(chǔ)的overage
-
onReady:function(){
-
wx.getStorage({
-
key: 'overage',
-
success: (res) => {
-
this.setData({
-
overage: res.data.overage
-
})
-
}
-
})
-
},
-
// 頁(yè)面顯示完成,獲取本地存儲(chǔ)的overage
-
onShow:function(){
-
wx.getStorage({
-
key: 'overage',
-
success: (res) => {
-
this.setData({
-
overage: res.data.overage
-
})
-
}
-
})
-
},
-
// 余額說(shuō)明
-
overageDesc: function(){
-
wx.showModal({
-
title: "",
-
content: "充值余額0.00元+活動(dòng)贈(zèng)送余額0.00元",
-
showCancel: false,
-
confirmText: "我知道了",
-
})
-
},
-
// 跳轉(zhuǎn)到充值頁(yè)面
-
movetoCharge: function(){
-
// 關(guān)閉當(dāng)前頁(yè)面,跳轉(zhuǎn)到指定頁(yè)面,返回時(shí)將不會(huì)回到當(dāng)前頁(yè)面
-
wx.redirectTo({
-
url: '../charge/index'
-
})
-
},
-
// 用車券
-
showTicket: function(){
-
wx.showModal({
-
title<
|