更换版本
This commit is contained in:
135
we7/pages/selectarea/selectarea.js
Normal file
135
we7/pages/selectarea/selectarea.js
Normal file
@@ -0,0 +1,135 @@
|
||||
var e, t, a;
|
||||
(e = require("../utils/util")),
|
||||
(t = "http://japi.zto.cn/zto/api_utf8/baseArea?msg_type=GET_AREA&data="),
|
||||
(a = {
|
||||
addDot: function (e) {
|
||||
e instanceof Array &&
|
||||
e.map(function (e) {
|
||||
return e.fullName.length > 4
|
||||
? ((e.fullNameDot = e.fullName.slice(0, 4) + "..."), e)
|
||||
: ((e.fullNameDot = e.fullName), e);
|
||||
});
|
||||
},
|
||||
load: function (d) {
|
||||
d.setData({ isShow: !1 }),
|
||||
(0, e.Promise)(wx.request, { url: t + "0", method: "GET" })
|
||||
.then(function (l) {
|
||||
var c = l.data.result[0];
|
||||
return (
|
||||
a.addDot(l.data.result),
|
||||
d.setData({
|
||||
proviceData: l.data.result,
|
||||
"selectedProvince.index": 0,
|
||||
"selectedProvince.code": c.code,
|
||||
"selectedProvince.fullName": c.fullName,
|
||||
}),
|
||||
(0, e.Promise)(wx.request, { url: t + c.code, method: "GET" })
|
||||
);
|
||||
})
|
||||
.then(function (l) {
|
||||
var c = l.data.result[0];
|
||||
return (
|
||||
a.addDot(l.data.result),
|
||||
d.setData({
|
||||
cityData: l.data.result,
|
||||
"selectedCity.index": 0,
|
||||
"selectedCity.code": c.code,
|
||||
"selectedCity.fullName": c.fullName,
|
||||
}),
|
||||
(0, e.Promise)(wx.request, { url: t + c.code, method: "GET" })
|
||||
);
|
||||
})
|
||||
.then(function (e) {
|
||||
var t = e.data.result[0];
|
||||
a.addDot(e.data.result),
|
||||
d.setData({
|
||||
districtData: e.data.result,
|
||||
"selectedDistrict.index": 0,
|
||||
"selectedDistrict.code": t.code,
|
||||
"selectedDistrict.fullName": t.fullName,
|
||||
});
|
||||
})
|
||||
.catch(function (e) {
|
||||
console.log(e);
|
||||
});
|
||||
},
|
||||
tapProvince: function (d, l) {
|
||||
var c = d.currentTarget.dataset;
|
||||
(0, e.Promise)(wx.request, { url: t + c.code, method: "GET" })
|
||||
.then(function (d) {
|
||||
return (
|
||||
a.addDot(d.data.result),
|
||||
l.setData({
|
||||
cityData: d.data.result,
|
||||
"selectedProvince.code": c.code,
|
||||
"selectedProvince.fullName": c.fullName,
|
||||
"selectedCity.code": d.data.result[0].code,
|
||||
"selectedCity.fullName": d.data.result[0].fullName,
|
||||
}),
|
||||
(0, e.Promise)(wx.request, {
|
||||
url: t + d.data.result[0].code,
|
||||
method: "GET",
|
||||
})
|
||||
);
|
||||
})
|
||||
.then(function (e) {
|
||||
a.addDot(e.data.result),
|
||||
l.setData({
|
||||
districtData: e.data.result,
|
||||
"selectedProvince.index": d.currentTarget.dataset.index,
|
||||
"selectedCity.index": 0,
|
||||
"selectedDistrict.index": 0,
|
||||
"selectedDistrict.code": e.data.result[0].code,
|
||||
"selectedDistrict.fullName": e.data.result[0].fullName,
|
||||
});
|
||||
})
|
||||
.catch(function (e) {
|
||||
console.log(e);
|
||||
});
|
||||
},
|
||||
tapCity: function (d, l) {
|
||||
var c = d.currentTarget.dataset;
|
||||
(0, e.Promise)(wx.request, { url: t + c.code, method: "GET" })
|
||||
.then(function (e) {
|
||||
a.addDot(e.data.result),
|
||||
l.setData({
|
||||
districtData: e.data.result,
|
||||
"selectedCity.index": d.currentTarget.dataset.index,
|
||||
"selectedCity.code": c.code,
|
||||
"selectedCity.fullName": c.fullName,
|
||||
"selectedDistrict.index": 0,
|
||||
"selectedDistrict.code": e.data.result[0].code,
|
||||
"selectedDistrict.fullName": e.data.result[0].fullName,
|
||||
});
|
||||
})
|
||||
.catch(function (e) {
|
||||
console.log(e);
|
||||
});
|
||||
},
|
||||
tapDistrict: function (e, t) {
|
||||
var a = e.currentTarget.dataset;
|
||||
t.setData({
|
||||
"selectedDistrict.index": e.currentTarget.dataset.index,
|
||||
"selectedDistrict.code": a.code,
|
||||
"selectedDistrict.fullName": a.fullName,
|
||||
});
|
||||
},
|
||||
confirm: function (e, t) {
|
||||
t.setData({
|
||||
address:
|
||||
t.data.selectedProvince.fullName +
|
||||
" " +
|
||||
t.data.selectedCity.fullName +
|
||||
" " +
|
||||
t.data.selectedDistrict.fullName,
|
||||
isShow: !1,
|
||||
});
|
||||
},
|
||||
cancel: function (e) {
|
||||
e.setData({ isShow: !1 });
|
||||
},
|
||||
choosearea: function (e) {
|
||||
e.setData({ isShow: !0 });
|
||||
},
|
||||
}),
|
||||
(module.exports = { SA: a });
|
19
we7/pages/selectarea/selectarea.wxml
Normal file
19
we7/pages/selectarea/selectarea.wxml
Normal file
@@ -0,0 +1,19 @@
|
||||
<view class="shade {{isShow?'show':''}}">
|
||||
<view class="selector-area box box-tb">
|
||||
<view class="handle-bar box box-lr box-align-center">
|
||||
<text bindtap="cancel" class="btn cancel flex">取消</text>
|
||||
<text bindtap="confirm" class="btn confirm flex">确定</text>
|
||||
</view>
|
||||
<view class="area-selector box box-lr">
|
||||
<scroll-view class="selector province flex" data-type="province" scrollY="true">
|
||||
<view bindtap="tapProvince" class="picker {{selectedProvince.index==index?'actived':''}}" data-code="{{item.code}}" data-full-name="{{item.fullName}}" data-index="{{index}}" wx:for="{{proviceData}}">{{item.fullNameDot}}</view>
|
||||
</scroll-view>
|
||||
<scroll-view class="selector city flex" data-type="city" scrollY="true">
|
||||
<view bindtap="tapCity" class="picker {{selectedCity.index==index?'actived':''}}" data-code="{{item.code}}" data-full-name="{{item.fullName}}" data-index="{{index}}" wx:for="{{cityData}}">{{item.fullNameDot}}</view>
|
||||
</scroll-view>
|
||||
<scroll-view class="selector district flex" data-type="district" scrollY="true">
|
||||
<view bindtap="tapDistrict" class="picker {{selectedDistrict.index==index?'actived':''}}" data-code="{{item.code}}" data-full-name="{{item.fullName}}" data-index="{{index}}" wx:for="{{districtData}}">{{item.fullNameDot}}</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
50
we7/pages/selectarea/selectarea.wxss
Normal file
50
we7/pages/selectarea/selectarea.wxss
Normal file
@@ -0,0 +1,50 @@
|
||||
.shade {
|
||||
background-color: #ccc;
|
||||
display: none;
|
||||
height: 100%;
|
||||
left: 0;
|
||||
opacity: 0.6;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.show {
|
||||
display: block;
|
||||
}
|
||||
.handle-bar {
|
||||
background-color: #eee;
|
||||
height: 80rpx;
|
||||
padding: 0 15px;
|
||||
}
|
||||
.confirm {
|
||||
text-align: right;
|
||||
}
|
||||
.selector-area {
|
||||
background-color: #e6ebf3;
|
||||
bottom: 0;
|
||||
height: 600rpx;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
}
|
||||
.selector {
|
||||
text-align: center;
|
||||
}
|
||||
.picker {
|
||||
font-size: 32rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
}
|
||||
.actived {
|
||||
color: blue;
|
||||
}
|
||||
.area-selector {
|
||||
height: 520rpx;
|
||||
}
|
||||
.white-shade {
|
||||
background-color: #fff;
|
||||
height: 60rpx;
|
||||
left: 0;
|
||||
margin-top: 240rpx;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
}
|
Reference in New Issue
Block a user