仿互站小程序

This commit is contained in:
Drawfans
2020-06-09 16:17:23 +08:00
commit 7bfd53851e
321 changed files with 22890 additions and 0 deletions

155
vant/area/index.js Normal file
View File

@@ -0,0 +1,155 @@
var e = function() {
function e(e, t) {
var n = [], i = !0, r = !1, s = void 0;
try {
for (var c, u = e[Symbol.iterator](); !(i = (c = u.next()).done) && (n.push(c.value),
!t || n.length !== t); i = !0) ;
} catch (e) {
r = !0, s = e;
} finally {
try {
!i && u.return && u.return();
} finally {
if (r) throw s;
}
}
return n;
}
return function(t, n) {
if (Array.isArray(t)) return t;
if (Symbol.iterator in Object(t)) return e(t, n);
throw new TypeError("Invalid attempt to destructure non-iterable instance");
};
}(), t = require("../common/component"), n = require("../picker/shared");
(0, t.VantComponent)({
classes: [ "active-class", "toolbar-class", "column-class" ],
props: Object.assign({}, n.pickerProps, {
value: String,
areaList: {
type: Object,
value: {}
},
columnsNum: {
type: [ String, Number ],
value: 3
}
}),
data: {
columns: [ {
values: []
}, {
values: []
}, {
values: []
} ],
displayColumns: [ {
values: []
}, {
values: []
}, {
values: []
} ]
},
watch: {
value: function(e) {
this.code = e, this.setValues();
},
areaList: "setValues",
columnsNum: function(e) {
this.set({
displayColumns: this.data.columns.slice(0, +e)
});
}
},
mounted: function() {
this.setValues();
},
methods: {
getPicker: function() {
return null == this.picker && (this.picker = this.selectComponent(".van-area__picker")),
this.picker;
},
onCancel: function(e) {
this.emit("cancel", e.detail);
},
onConfirm: function(e) {
this.emit("confirm", e.detail);
},
emit: function(e, t) {
t.values = t.value, delete t.value, this.$emit(e, t);
},
onChange: function(e) {
var t = this, n = e.detail, i = n.index, r = n.picker, s = n.value;
this.code = s[i].code, this.setValues().then(function() {
t.$emit("change", {
picker: r,
values: r.getValues(),
index: i
});
});
},
getConfig: function(e) {
var t = this.data.areaList;
return t && t[e + "_list"] || {};
},
getList: function(e, t) {
var n = [];
if ("province" !== e && !t) return n;
var i = this.getConfig(e);
return n = Object.keys(i).map(function(e) {
return {
code: e,
name: i[e]
};
}), t && ("9" === t[0] && "city" === e && (t = "9"), n = n.filter(function(e) {
return 0 === e.code.indexOf(t);
})), n;
},
getIndex: function(e, t) {
var n = "province" === e ? 2 : "city" === e ? 4 : 6, i = this.getList(e, t.slice(0, n - 2));
"9" === t[0] && "province" === e && (n = 1), t = t.slice(0, n);
for (var r = 0; r < i.length; r++) if (i[r].code.slice(0, n) === t) return r;
return 0;
},
setValues: function() {
var t = this, n = this.getConfig("county"), i = this.code || Object.keys(n)[0] || "", r = this.getList("province"), s = this.getList("city", i.slice(0, 2)), c = this.getPicker();
if (c) {
var u = [];
if (u.push(c.setColumnValues(0, r, !1)), u.push(c.setColumnValues(1, s, !1)), s.length && "00" === i.slice(2, 4)) {
var o = e(s, 1);
i = o[0].code;
}
return u.push(c.setColumnValues(2, this.getList("county", i.slice(0, 4)), !1)),
Promise.all(u).catch(function() {}).then(function() {
return c.setIndexes([ t.getIndex("province", i), t.getIndex("city", i), t.getIndex("county", i) ]);
}).catch(function() {});
}
},
getValues: function() {
var e = this.getPicker();
return e ? e.getValues().filter(function(e) {
return !!e;
}) : [];
},
getDetail: function() {
var e = this.getValues(), t = {
code: "",
country: "",
province: "",
city: "",
county: ""
};
if (!e.length) return t;
var n = e.map(function(e) {
return e.name;
});
return t.code = e[e.length - 1].code, "9" === t.code[0] ? (t.country = n[1] || "",
t.province = n[2] || "") : (t.province = n[0] || "", t.city = n[1] || "", t.county = n[2] || ""),
t;
},
reset: function() {
return this.code = "", this.setValues();
}
}
});

14
vant/area/index.json Normal file
View File

@@ -0,0 +1,14 @@
{
"component": true,
"usingComponents": {
"van-picker": "../picker/index",
"forview": "/utils/forview/index",
"van-loading": "/vant/loading/index",
"van-dialog": "/vant/dialog/index",
"van-button": "/vant/button/index",
"van-icon": "/vant/icon/index",
"van-popup": "/vant/popup/index",
"van-tab": "/vant/tab/index",
"van-tabs": "/vant/tabs/index"
}
}

1
vant/area/index.wxml Normal file
View File

@@ -0,0 +1 @@
<van-picker showToolbar activeClass="active-class" bind:cancel="onCancel" bind:change="onChange" bind:confirm="onConfirm" cancelButtonText="{{cancelButtonText}}" class="van-area__picker" columnClass="column-class" columns="{{displayColumns}}" confirmButtonText="{{confirmButtonText}}" itemHeight="{{itemHeight}}" loading="{{loading}}" title="{{title}}" toolbarClass="toolbar-class" valueKey="name" visibleItemCount="{{visibleItemCount}}"></van-picker>

68
vant/area/index.wxss Normal file
View File

@@ -0,0 +1,68 @@
.van-ellipsis {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.van-multi-ellipsis--l2 {
-webkit-line-clamp: 2;
}
.van-multi-ellipsis--l2,.van-multi-ellipsis--l3 {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
}
.van-multi-ellipsis--l3 {
-webkit-line-clamp: 3;
}
.van-clearfix:after {
content: "";
display: table;
clear: both;
}
.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom {
position: relative;
}
.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after {
content: " ";
position: absolute;
pointer-events: none;
box-sizing: border-box;
transform-origin: center;
top: -50%;
left: -50%;
right: -50%;
bottom: -50%;
transform: scale(.5);
border: 0 solid #e5e5e5;
}
.van-hairline--top:after {
border-top-width: 1px;
}
.van-hairline--left:after {
border-left-width: 1px;
}
.van-hairline--right:after {
border-right-width: 1px;
}
.van-hairline--bottom:after {
border-bottom-width: 1px;
}
.van-hairline--top-bottom:after {
border-width: 1px 0;
}
.van-hairline--surround:after {
border-width: 1px;
}