/**
 * author: dabao
 */
var VUE = null
window.addEventListener("load", function() {
	VUE = new Vue({
		el: '#app',
		data() {
			return {
				companyName: '',
				value: '',
				list: [],
				loading: false,
				finished: false,
				page: 0,
				size: 20,
				total: 0
			}
		},
		mounted() {
			this.getList()
		},
		methods: {
			nav(item) {
				// location.href='./law-lv2.html?pid=' + item.id
				gemhoUtil.navigatePage('./law-lv2.html?pid=' + item.id)
			},
			getList() {
				// if(this.loading){
				// 	return
				// }
				// this.loading = true
				setTimeout(() => {


					http2.post({
						serviceId: API_KEY_MAP["law-lv"]['id'],
						interfacePublicKey: API_KEY_MAP["law-lv"]["publicKey"],
						interfacePrivateKey: API_KEY_MAP["law-lv"]["privateKey"],
						reqParams: {
							page: this.page++, // 每次请求增加下一页
							size: this.size,
							// sort: 'createTime,desc',
						}
					}, (res) => {

						if (res) {
							console.log('接口回调数据', JSON.parse(res))

							var result = JSON.parse(res)
							this.loading = false; // 加载状态结束
							this.list.push(...result.content);
							this.total = result.totalElements

							if (this.page * this.size >= this.total) {
								this.finished = true; // 下滑不在刷新数据
							}
						}
						this.loading = false
					})
				}, 0)
			}
		},
	});
});