This commit is contained in:
张慢慢
2021-05-24 13:56:00 +08:00
commit a7995d90bc
208 changed files with 13143 additions and 0 deletions

102
pages/address/address.js Normal file
View File

@@ -0,0 +1,102 @@
// pages/address/address.js
Page({
/**
* 页面的初始数据
*/
data: {
type : '', //来源类型
addressArr : [] //收货地址
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
this.setData({
type: options.type
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow(){
this.addressInfo();
},
/* 地址列表
*/
addressInfo(){
wx.$api.address.index().then(res=>{
this.setData({
addressArr: res.data
})
})
},
/**
* 删除地址
*/
addressRemove(e){
let id = e.target.dataset.id,
index = e.target.dataset.index,
list = this.data.addressArr
list.splice(index,1)
wx.showModal({
title : '提示',
content : '是否删除地址',
success : res=> {
if (res.confirm) {
wx.showLoading({
title: '删除中',
})
wx.$api.address.remove(id).then(res=>{
this.setData({
addressArr: list
})
wx.showToast({
title: res.data,
icon : "none"
})
wx.hideLoading()
})
}
}
})
},
/**
* 设为默认地址
*/
addressDefault(e){
let id = e.currentTarget.dataset.id
wx.$api.address.setdef(id).then(res=>{
this.addressInfo();
wx.showToast({
title: res.data,
icon : "none"
})
})
},
/**
* 选择地址
*/
selectAddress(e){
let atAdds = this.data.addressArr[e.currentTarget.dataset.index]
let pages = getCurrentPages(),
prepage = pages[pages.length-2]
prepage.setData({
address: atAdds
})
wx.navigateBack()
}
})

View File

@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "我的地址"
}

View File

@@ -0,0 +1,40 @@
<view class="address-list" wx:if="{{addressArr != ''}}">
<view class="address" wx:for="{{addressArr}}" wx:key="addressList" wx:for-index="addressIndex">
<view class="address-name">{{item.name}}<text>{{item.mobile}}</text></view>
<view class="address-info">
<block wx:if="{{type == 'selectAddress'}}">
<text class="address-info-tag" wx:if="{{item.is_default}}">默认</text>
</block>
{{item.all_address}}
</view>
<view class="address-tool" wx:if="{{type == 'selectAddress'}}">
<view class="address-tool-btn yellow" bindtap="selectAddress" data-index="{{addressIndex}}">
<image src="/static/icon/choice.png"></image>
选择地址
</view>
</view>
<view class="address-tool" wx:else>
<view class="address-tool-btn" bindtap="addressRemove" data-index="{{addressIndex}}" data-id="{{item.id}}">删除</view>
<navigator class="address-tool-btn" url="/pages/address_form/address_form?type=Compile&id={{item.id}}">编辑</navigator>
<block wx:if="{{item.is_default == 0}}">
<view class="address-tool-btn acitve" bindtap="addressDefault" data-index="{{addressIndex}}" data-id="{{item.id}}">
<image src="/static/icon/select.png"></image>设为默认地址
</view>
</block>
<block wx:else>
<view class="address-tool-btn acitve">
<image src="/static/icon/select_avtive.png"></image>默认地址
</view>
</block>
</view>
</view>
</view>
<view class="pack-center pages-hint" wx:else>
<image src="https://www.lvmeimall.com/assets/mobile/img/address_null_icon.png"></image>
<view>还未添加收货地址</view>
</view>
<view class="address-footer">
<navigator url="/pages/address_form/address_form?type=Add">添加地址</navigator>
</view>

112
pages/address/address.wxss Normal file
View File

@@ -0,0 +1,112 @@
/**
* 亿时代
*/
.address-list{
border-bottom: 110rpx solid transparent;
}
.address{
padding: 20rpx 30rpx;
border-bottom: solid 20rpx #f2f2f2;
background: white;
}
.address-name{
font-size: 32rpx;
line-height: 50rpx;
}
.address-name text{
color: #747788;
padding-left: 10rpx;
font-size: 28rpx;
}
.address-info{
padding-bottom: 20rpx;
display: flex;
}
.address-tool{
overflow: hidden;
}
.address-info-tag{
background: #30bb29;
margin-right: 20rpx;
padding: 0 10rpx;
height: 32rpx;
line-height: 32rpx;
color: white;
font-size: 22rpx;
border-radius: 4rpx;
margin-top: 6rpx;
}
.address-tool-btn{
margin-left: 30rpx;
float: right;
border:solid 1rpx #c0c0c0;
height: 46rpx;
line-height: 44rpx;
padding: 0 30rpx;
border-radius: 6rpx;
font-size: 24rpx;
}
.address-tool-btn.yellow {
border:solid 1rpx #f57e32;
color: #f57e32;
padding: 0 14rpx;
height: 50rpx;
line-height: 50rpx;
}
.address-tool-btn.acitve{
float: left;
margin-left: 0;
padding: 0;
border: none;
color: #747788;
font-size: 26rpx;
}
.address-tool-btn.acitve image{
margin-right: 10rpx;
vertical-align: -7rpx;
}
.address-tool-btn image {
width: 30rpx;
height: 30rpx;
margin-right: 4rpx;
vertical-align: -6rpx;
}
/* footer */
.address-footer{
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding-left: 30rpx;
padding-right: 30rpx;
background: white;
z-index: 9;
height: 110rpx;
}
.address-footer navigator{
width: 100%;
line-height: 80rpx;
height: 80rpx;
margin: 15rpx 0;
text-align: center;
background: #f57e32;
font-size: 30rpx;
color: white;
border-radius: 10rpx
}