This commit is contained in:
2024-03-20 11:39:05 +08:00
commit 6fe05463fa
198 changed files with 11274 additions and 0 deletions

View File

@@ -0,0 +1,175 @@
var t = getApp(), i = require("../../utils/login.js");
Page({
data: {
showLoding: !0,
loading: !1,
isrefusedAuthLocation: 0,
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: "",
id: ""
},
onLoad: function(t) {
console.log(t), wx.showLoading({
title: ""
}), this.setData({
id: t.id || "",
show: t.id ? "edit" : "plus"
}), this.getContent(), wx.setNavigationBarTitle({
title: t.id ? "编辑地址" : "新增地址"
});
},
getContent: function() {
var e = this;
i.request(t.globalData.config.address.plus, {
id: this.data.id
}).then(function(t) {
if (wx.hideLoading(), 200 != t.code) return wx.showToast({
title: t.message
}), !1;
e.setData({
showLoding: !1,
info: t.data,
isdefault: t.isdefault || 0,
token: t.token
});
}).catch(function(t) {
wx.hideLoading();
});
},
checkboxChange: function(t) {
this.setData({
isdefault: t.detail.value[0] || 0
});
},
bindRegionChange: function(t) {
this.data.info.provincename = t.detail.value[0], this.data.info.cityname = t.detail.value[1],
this.data.info.countryname = t.detail.value[2], this.setData({
info: this.data.info
});
},
input: function(t) {
var i = t.currentTarget.dataset.input;
this.data.info[i] = t.detail.value, this.setData({
info: this.data.info
});
},
submit: function() {
if (this.data.issubmit) return !1;
this.setData({
issubmit: !0
});
var e = this;
i.request(t.globalData.config.address.submit, {
session: wx.getStorageSync("session"),
info: this.data.info,
isdefault: this.data.isdefault,
token: this.data.token,
uniqid: this.data.uniqid
}).then(function(t) {
wx.hideLoading(), e.setData({
issubmit: !1
}), 200 == t.code ? wx.navigateBack() : wx.showToast({
title: t.message,
icon: "none"
});
}).catch(function(t) {
wx.hideLoading(), e.setData({
issubmit: !1
});
});
},
delAddress: function() {
if (this.data.issubmit) return !1;
var e = this;
wx.showModal({
title: "是否删除该地址?",
content: "",
confirmColor: "#EF8176",
cancelColor: "#999999",
success: function(a) {
a.confirm && (e.setData({
issubmit: !0
}), i.request(t.globalData.config.address.delete, {
id: e.data.id
}).then(function(t) {
200 == t.code ? (wx.showToast({
title: "删除成功"
}), wx.navigateBack()) : wx.showModal({
title: "提示",
content: t.message,
confirmColor: "#EF8176",
cancelColor: "#999999"
});
}).catch(function(t) {
e.setData({
issubmit: !1
});
}));
},
fail: function(t) {
console.log("fail");
}
});
},
getSystemAddress: function() {
var t = this;
wx.chooseAddress({
success: function(i) {
console.log(i), t.data.info = {
cityname: i.cityName,
countryname: i.countyName,
detailinfo: i.detailInfo,
provincename: i.provinceName,
telnumber: i.telNumber,
username: i.userName
}, t.setData({
info: t.data.info
});
},
fail: function(i) {
console.log(i), t.setData({
isrefusedAuthLocation: 1
}), wx.showToast({
title: "获取地址失败",
icon: "none"
});
}
});
},
bindopensetting: function(t) {
res.detail.authSetting["scope.address"] ? (wx.showToast({
title: "授权成功,请再次点击导入微信地址"
}), this.setData({
isrefusedAuthLocation: 0
})) : wx.showToast({
title: "授权失败",
icon: "none"
});
},
select: function(i) {
var e = i.currentTarget.dataset.index;
"user" != this.data.selectAddressUniqid && (this.setData({
selectAddressUniqid: i.currentTarget.dataset.uniqid
}), t.globalData.selectAddress = this.data.data[e], setTimeout(function(i) {
t.globalData.selectAddress = {};
}, 2e3), wx.navigateBack({}));
}
});

View File

@@ -0,0 +1,6 @@
{
"navigationBarTitleText": "地址",
"usingComponents": {
"page-loding": "../../template/pageLoding/pageLoding"
}
}

View File

@@ -0,0 +1,42 @@
<view class="edit-box">
<page-loding wx:if="{{showLoding}}"></page-loding>
<view class="add-form">
<picker bindchange="bindRegionChange" customItem="{{customItem}}" mode="region" value="{{region}}">
<view class="item">
<view class="name">所在地区</view>
<view class="content">
<view class="placeholder" wx:if="{{!info.provincename}}">所在地区</view>
<view wx:if="{{info.provincename}}">{{info.provincename}} {{info.cityname}} {{info.countryname}}</view>
</view>
</view>
</picker>
<view class="item">
<view class="name">详细地址</view>
<view class="content">
<input bindinput="input" data-input="detailinfo" placeholder="详细地址" placeholderClass="placeholder" value="{{info.detailinfo}}"></input>
</view>
</view>
<view class="item">
<view class="name">姓名</view>
<view class="content">
<input bindinput="input" data-input="username" placeholder="姓名" placeholderClass="placeholder" value="{{info.username}}"></input>
</view>
</view>
<view class="item">
<view class="name">手机号码</view>
<view class="content">
<input bindinput="input" data-input="telnumber" placeholder="手机号码" placeholderClass="placeholder" value="{{info.telnumber}}"></input>
</view>
</view>
</view>
<view class="btn-box">
<button bindopensetting="bindopensetting" class="btn" openType="openSetting" wx:if="{{isrefusedAuthLocation==1}}"> 导入微信地址 </button>
<view bindtap="getSystemAddress" class="btn" wx:if="{{isrefusedAuthLocation==0}}">导入微信地址</view>
<view bindtap="submit" class="btn submit">立即保存</view>
</view>
</view>
<view bindtap="close_alert" class="alert-comfirm-box" hidden="{{!show_comfirm.show}}">
<view class="reminder_box">
<view class="tips">{{show_comfirm.tips}}</view>
</view>
</view>

View File

@@ -0,0 +1,134 @@
.edit-box {
background: #fafafa;
box-sizing: border-box;
min-height: 100vh;
padding: 20rpx;
}
.edit-box .del {
height: 70rpx;
line-height: 70rpx;
margin: 20px;
padding: 20px;
}
.add-form {
background: #fff;
border: 1px solid #f2f2f2;
border-radius: 20rpx;
font-size: 28rpx;
padding: 20px;
}
.placeholder {
color: #ccc;
}
.add-form .item {
align-items: center;
border-bottom: 1px solid #f2f2f2;
display: flex;
padding: 44rpx 0;
position: relative;
}
.add-form .item .name {
width: 150rpx;
}
.add-form .item .content,.add-form .item .name {
align-items: center;
display: inline-flex;
}
.add-form .item .content {
flex: 1;
height: 70rpx;
}
.add-form .item input {
width: 100%;
}
.add-form .item .right {
position: absolute;
right: 0;
top: 49rpx;
}
.add-form .item .right image {
height: 40rpx;
transform: rotateZ(-90deg);
width: 40rpx;
}
.add-form .checkbox {
color: #999;
font-size: 28rpx;
margin: 20rpx 0;
padding: 20rpx 0;
text-align: left;
}
.add-form .btn {
background-color: #4cadf1;
border-radius: 90rpx;
color: #fff;
font-size: 44rpx;
line-height: 90rpx;
margin: 0 auto;
text-align: center;
width: 372rpx;
}
checkbox {
transform: scale(.7);
}
.add-form .btn.submit {
opacity: .5;
}
.edit-box .del {
background: #fff;
border: 1px solid #f2f2f2;
border-radius: 20rpx;
color: #333;
font-size: 32rpx;
margin: 20px auto;
padding: 20rpx;
text-align: center;
width: 200rpx;
}
.edit-box .del image {
display: inline-block;
height: 30rpx;
margin-right: 10rpx;
position: relative;
top: -2rpx;
vertical-align: middle;
width: 30rpx;
}
.btn-box {
display: flex;
justify-content: space-between;
margin-top: 30rpx;
}
.btn-box .btn {
align-items: center;
background: #f60;
border-radius: 10rpx;
color: #fff;
display: inline-flex;
font-size: 34rpx;
height: 100rpx;
justify-content: center;
width: calc(50% - 10rpx);
}
.btn-box .btn.submit {
background: #4cadf1;
}