0000
This commit is contained in:
132
pages/myAddress/myAddress.js
Normal file
132
pages/myAddress/myAddress.js
Normal file
@@ -0,0 +1,132 @@
|
||||
var t = getApp(), a = require("../../utils/login.js");
|
||||
|
||||
Page({
|
||||
data: {
|
||||
showLoding: !0,
|
||||
loading: !1,
|
||||
data: [],
|
||||
show: "index",
|
||||
isdefault: 0,
|
||||
region: [],
|
||||
info: {
|
||||
cityname: null,
|
||||
countryname: null,
|
||||
detailinfo: null,
|
||||
provincename: null,
|
||||
telnumber: null,
|
||||
username: null
|
||||
},
|
||||
issubmit: !1,
|
||||
show_comfirm: {
|
||||
show: !1,
|
||||
tips: ""
|
||||
},
|
||||
uniqid: "",
|
||||
selectAddressUniqid: ""
|
||||
},
|
||||
onLoad: function(i) {
|
||||
var e = this;
|
||||
wx.showLoading({
|
||||
title: ""
|
||||
}), this.setData({
|
||||
selectAddressUniqid: i.selectAddressUniqid || ""
|
||||
}), a.pageStart(t).then(function(t) {
|
||||
e.getData();
|
||||
});
|
||||
},
|
||||
onShow: function() {
|
||||
this.istoEdit && (this.istoEdit = !1, this.getData());
|
||||
},
|
||||
onShareAppMessage: function() {},
|
||||
istoEdit: !1,
|
||||
getData: function() {
|
||||
var i = this;
|
||||
if (this.data.loading) return !1;
|
||||
this.setData({
|
||||
loading: !0
|
||||
}), a.request(t.globalData.config.address.init, {}).then(function(t) {
|
||||
wx.hideLoading(), i.setData({
|
||||
data: t.data,
|
||||
loading: !1,
|
||||
showLoding: !1
|
||||
});
|
||||
}).catch(function(t) {
|
||||
wx.hideLoading(), i.setData({
|
||||
loading: !1
|
||||
});
|
||||
});
|
||||
},
|
||||
openEdit: function(t) {
|
||||
var a = t.currentTarget.dataset.uniqid || "";
|
||||
return t.currentTarget.dataset.index || 0, this.data.show = a ? "edit" : "add",
|
||||
wx.navigateTo({
|
||||
url: "/pages/addAddress/addAddress?id=" + a
|
||||
}), this.istoEdit = !0, !1;
|
||||
},
|
||||
select: function(t) {
|
||||
return console.log("select"), !1;
|
||||
},
|
||||
delAddress: function(i) {
|
||||
if (this.data.issubmit) return !1;
|
||||
var e = i.currentTarget.dataset, n = e.id, s = e.index, o = this;
|
||||
wx.showModal({
|
||||
title: "是否删除该地址?",
|
||||
content: "",
|
||||
confirmColor: "#EF8176",
|
||||
cancelColor: "#999999",
|
||||
success: function(i) {
|
||||
i.confirm && a.request(t.globalData.config.address.delete, {
|
||||
id: n
|
||||
}).then(function(t) {
|
||||
o.setData({
|
||||
issubmit: !1
|
||||
}), 200 == t.code ? (wx.showToast({
|
||||
title: "删除成功"
|
||||
}), o.data.data.splice(s, 1), o.setData({
|
||||
data: o.data.data
|
||||
})) : wx.showModal({
|
||||
title: "提示",
|
||||
content: t.message,
|
||||
confirmColor: "#EF8176",
|
||||
cancelColor: "#999999"
|
||||
});
|
||||
}).catch(function(t) {
|
||||
o.setData({
|
||||
issubmit: !1
|
||||
});
|
||||
});
|
||||
},
|
||||
fail: function(t) {
|
||||
console.log("fail"), o.setData({
|
||||
issubmit: !0
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
setDefault: function(i) {
|
||||
var e = i.currentTarget.dataset, n = e.id, s = e.index;
|
||||
if (e.isdefault) return !1;
|
||||
wx.showLoading({
|
||||
title: ""
|
||||
});
|
||||
var o = this;
|
||||
a.request(t.globalData.config.address.default, {
|
||||
id: n
|
||||
}).then(function(t) {
|
||||
200 == t.code ? (wx.hideLoading(), o.data.data.map(function(t) {
|
||||
t.isdefault = 0;
|
||||
}), o.data.data[s].isdefault = 1, o.setData({
|
||||
data: o.data.data
|
||||
}), wx.showToast({
|
||||
title: t.message
|
||||
})) : wx.showModal({
|
||||
title: "提示",
|
||||
content: t.message,
|
||||
confirmColor: "#EF8176",
|
||||
cancelColor: "#999999"
|
||||
});
|
||||
}).catch(function(t) {
|
||||
wx.hideLoading();
|
||||
});
|
||||
}
|
||||
});
|
||||
9
pages/myAddress/myAddress.json
Normal file
9
pages/myAddress/myAddress.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"navigationBarTitleText": "聚美汽服",
|
||||
"enablePullDownRefresh": false,
|
||||
"usingComponents": {
|
||||
"service-tel": "../../template/serviceTel/serviceTel",
|
||||
"my-money": "../../template/myMoney/myMoney",
|
||||
"page-loding": "../../template/pageLoding/pageLoding"
|
||||
}
|
||||
}
|
||||
27
pages/myAddress/myAddress.wxml
Normal file
27
pages/myAddress/myAddress.wxml
Normal file
@@ -0,0 +1,27 @@
|
||||
<page-loding wx:if="{{showLoding}}"></page-loding>
|
||||
<view class="{{types=='voucher'?'container voucher-container':'container'}}">
|
||||
<view class="list-box">
|
||||
<view catchtap="select" class="item" data-id="{{item.id}}" data-index="{{index}}" wx:for="{{data}}" wx:key="index">
|
||||
<view class="text">
|
||||
<view class="name">{{item.username}},{{item.telnumber}}</view>
|
||||
<view class="address"> {{item.provincename+item.cityname+item.countryname+' '+item.detailinfo}} </view>
|
||||
</view>
|
||||
<view class="footer">
|
||||
<view catchtap="setDefault" class="btn" data-id="{{item.id}}" data-index="{{index}}" data-isdefault="{{item.isdefault}}">
|
||||
<icon color="#ff6600" size="18" type="success" wx:if="{{item.isdefault}}"></icon>
|
||||
<view class="icon" wx:if="{{!item.isdefault}}"></view> 设为默认 </view>
|
||||
<view class="r">
|
||||
<view catchtap="openEdit" class="btn" data-uniqid="{{item.id}}">
|
||||
<image src="/img/edit.png"></image> 编辑 </view>
|
||||
<view catchtap="delAddress" class="btn" data-id="{{item.id}}" data-index="{{index}}">
|
||||
<image src="/img/delete.png"></image> 删除 </view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="no-content" wx:if="{{data.length==0&&!loading}}">
|
||||
<image src="/img/nocontent.png"></image>
|
||||
<view>赶紧新增地址吧</view>
|
||||
</view>
|
||||
<view bindtap="openEdit" class="scan-btn"> 新增地址 </view>
|
||||
</view>
|
||||
82
pages/myAddress/myAddress.wxss
Normal file
82
pages/myAddress/myAddress.wxss
Normal file
@@ -0,0 +1,82 @@
|
||||
.container {
|
||||
background: #fafafa;
|
||||
box-sizing: border-box;
|
||||
min-height: 100vh;
|
||||
padding: 0rpx 0 170rpx;
|
||||
}
|
||||
|
||||
.list-box {
|
||||
padding: 40rpx 27rpx 0rpx;
|
||||
}
|
||||
|
||||
.item {
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
border-bottom: 1px solid #eee;
|
||||
display: block;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10rpx;
|
||||
padding: 18rpx 18rpx 0;
|
||||
}
|
||||
|
||||
.item .name {
|
||||
color: #666;
|
||||
font-size: 26rpx;
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.item .address {
|
||||
color: #999;
|
||||
font-size: 22rpx;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.item .text {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.item .btn {
|
||||
align-items: center;
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.item .btn image {
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
border-top: 1px solid #eee;
|
||||
display: flex;
|
||||
font-size: 26rpx;
|
||||
justify-content: space-between;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.footer .icon,.footer icon,.footer image {
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.footer .icon {
|
||||
border: 1px solid #999;
|
||||
border-radius: 50%;
|
||||
box-sizing: border-box;
|
||||
flex: 0 0 18px;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
.footer .icon,.footer .r {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.footer .r {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.footer .r .btn {
|
||||
padding: 20rpx 0 20rpx 40rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
Reference in New Issue
Block a user