/**
 * 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: 10,
				total: 0
			}
		},
		mounted() {
			this.getList()
		},
		methods: {
			detail(index) {
				// this.list[index].currentUserRead = true
				// location.href = './law-list-detail.html?law_id='+this.list[index].lawId
				gemhoUtil.navigatePage('./law-list-detail.html?law_id=' + this.list[index].lawId)
			},
			getList() {
				// if(this.loading){
				// 	return
				// }
				// this.loading = true
				setTimeout(() => {


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

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

							var result = JSON.parse(res)
							this.list.push(...result.content);
							this.total = result.totalElements

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