Commit 9c3426fe by 李嘉林

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

This reverts commit e52e2dbe.
parent e52e2dbe
......@@ -4,7 +4,7 @@
</template>
<script>
import area from "@/utils/app.area.js";
import tool from "@/utils/tool"
import addres from "@/api/userAddress";
export default {
data() {
......@@ -29,15 +29,21 @@ export default {
cityName: "",
areaName: ""
},
areaList: area,
province_list: area.province_list,
city_list: area.city_list,
county_list: area.county_list,
areaList: [],
province_list: [],
city_list: [],
county_list: [],
provinceTwoKey: 0,
openSetting: false
};
},
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());
this.options = options;
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) {
var enterTime = 0;//触发的时间
var gapTime = interval || 300;//间隔时间,如果interval不传,则默认300ms
return function () {
var context = this;
var backTime = new Date();//第一次函数return即触发的时间
if (backTime - enterTime > gapTime) {
fn.call(context, arguments);
enterTime = backTime;//赋值给第一次触发的时间,这样就保存了第二次触发的时间
}
};
var enterTime = 0; //触发的时间
var gapTime = interval || 300; //间隔时间,如果interval不传,则默认300ms
return function() {
var context = this;
var backTime = new Date(); //第一次函数return即触发的时间
if (backTime - enterTime > gapTime) {
fn.call(context, arguments);
enterTime = backTime; //赋值给第一次触发的时间,这样就保存了第二次触发的时间
}
};
}
/*函数防抖*/
function debounce(fn, interval) {
console.log('防抖抖~~~');
var timer;
var gapTime = interval || 1000;//间隔时间,如果interval不传,则默认1000ms
return function () {
clearTimeout(timer);
var context = this;
var args = arguments;//保存此处的arguments,因为setTimeout是全局的,arguments不是防抖函数需要的。
timer = setTimeout(function () {
fn.call(context, args);
}, gapTime);
};
console.log("防抖抖~~~");
var timer;
var gapTime = interval || 1000; //间隔时间,如果interval不传,则默认1000ms
return function() {
clearTimeout(timer);
var context = this;
var args = arguments; //保存此处的arguments,因为setTimeout是全局的,arguments不是防抖函数需要的。
timer = setTimeout(function() {
fn.call(context, args);
}, gapTime);
};
}
export default {
throttle,
debounce
};
\ No newline at end of file
throttle,
debounce,
appArea
};
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