<!-- 收货地址开始 -->
<view class="receive_address_row">
<view class="address_btn" wx:if="{{!address}}">
<button type="warn" plain bindtap="handleChooseAddress">获取收货地址</button>
</view>
<view wx:else class="user_info_row">
<view class="user_info">
<view>收货人:{{address.userName}},{{address.telNumber}}</view>
<view>{{address.provinceName+address.cityName+address.countyName+address.detailInfo}}</view>
</view>
<view class="change_address_btn">
<button size="mini" plain>更换地址</button>
</view>
</view>
</view>
<!-- 收货地址结束 -->
.receive_address_row{
.address_btn{
padding: 20rpx;
button{
width: 60%;
}
}
.user_info_row{
display: flex;
padding: 20rpx ;
.user_info{
flex: 5;
}
.change_address_btn{
flex: 3;
text-align: right;
button{
border: 1px solid gray;
font-weight: normal;
}
}
}
}
// pages/cart/index.js
Page({
/**
* 页面的初始数据
*/
data: {
address:{}
},
handleChooseAddress(){
wx.chooseAddress({
success:(result)=>{
console.log(result)
wx.setStorageSync('address', result)
},
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
console.log("show")
const address=wx.getStorageSync('address');
this.setData({
address
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
{
"usingComponents": {},
"navigationBarTitleText": "购物车"
}