Commit 9c3426fe by 李嘉林

Revert "Revert "获取地址数据优化""

This reverts commit e52e2dbe.
parent e52e2dbe
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
</template> </template>
<script> <script>
import area from "@/utils/app.area.js"; import tool from "@/utils/tool"
import addres from "@/api/userAddress"; import addres from "@/api/userAddress";
export default { export default {
data() { data() {
...@@ -29,15 +29,21 @@ export default { ...@@ -29,15 +29,21 @@ export default {
cityName: "", cityName: "",
areaName: "" areaName: ""
}, },
areaList: area, areaList: [],
province_list: area.province_list, province_list: [],
city_list: area.city_list, city_list: [],
county_list: area.county_list, county_list: [],
provinceTwoKey: 0, provinceTwoKey: 0,
openSetting: false openSetting: false
}; };
}, },
onLoad(options) { onLoad(options) {
tool.appArea().then(res => {
this.areaList = res;
this.province_list = res.province_list;
this.city_list = res.city_list;
this.county_list = res.county_list;
})
Object.assign(this.$data, this.$options.data()); Object.assign(this.$data, this.$options.data());
this.options = options; this.options = options;
if(options.sessionid){ if(options.sessionid){
......
This source diff could not be displayed because it is too large. You can view the blob instead.
// 地址JSON
const appArea = () => {
let obj = "";
console.log("---appArea");
return new Promise(async (response, reject) => {
await wx.request({
url: `https://cdn.mayi888.com/static/js/app.area.json`,
success: res => {
obj = res.data;
response(obj);
console.log(obj, "--------appArea-success");
},
fail: err => {
console.log(err, "-------err");
reject(err);
}
});
});
};
/*函数节流*/ /*函数节流*/
function throttle(fn, interval) { function throttle(fn, interval) {
var enterTime = 0;//触发的时间 var enterTime = 0; //触发的时间
var gapTime = interval || 300;//间隔时间,如果interval不传,则默认300ms var gapTime = interval || 300; //间隔时间,如果interval不传,则默认300ms
return function () { return function() {
var context = this; var context = this;
var backTime = new Date();//第一次函数return即触发的时间 var backTime = new Date(); //第一次函数return即触发的时间
if (backTime - enterTime > gapTime) { if (backTime - enterTime > gapTime) {
fn.call(context, arguments); fn.call(context, arguments);
enterTime = backTime;//赋值给第一次触发的时间,这样就保存了第二次触发的时间 enterTime = backTime; //赋值给第一次触发的时间,这样就保存了第二次触发的时间
} }
}; };
} }
/*函数防抖*/ /*函数防抖*/
function debounce(fn, interval) { function debounce(fn, interval) {
console.log('防抖抖~~~'); console.log("防抖抖~~~");
var timer; var timer;
var gapTime = interval || 1000;//间隔时间,如果interval不传,则默认1000ms var gapTime = interval || 1000; //间隔时间,如果interval不传,则默认1000ms
return function () { return function() {
clearTimeout(timer); clearTimeout(timer);
var context = this; var context = this;
var args = arguments;//保存此处的arguments,因为setTimeout是全局的,arguments不是防抖函数需要的。 var args = arguments; //保存此处的arguments,因为setTimeout是全局的,arguments不是防抖函数需要的。
timer = setTimeout(function () { timer = setTimeout(function() {
fn.call(context, args); fn.call(context, args);
}, gapTime); }, gapTime);
}; };
} }
export default { export default {
throttle, throttle,
debounce debounce,
}; appArea
\ No newline at end of file };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment