<template>
	<view>
		<!--mine/help/help.wxml-->
		<view class="tit">常见问题</view>
		<view class="list">
		  <block v-for="(item, index) in pageList" :key="index">
		  <navigator :url="'/mine/page/page?id=' + item.id + '&title=' + item.title" hover-class="none" class="li">{{item.title}}<image src="/static/pages/images/more.png" class="rico"></image></navigator>
		  </block>
		</view>
		<!-- <button class="zixun" open-type="contact">咨询客服</button> -->
		<contact-button class-name="zixun" button-text="咨询客服"></contact-button>
	</view>
</template>

<script>
	// mine/help/help.js
	const app = getApp();
	const req = require("../../utils/request.js");

	export default {
		data() {
			return {
				form: {
					page: 1,
					limit: 15
				},
				pageList: [],
				isLoad: true
			};
		},

		components: {},
		props: {},
		onLoad: async function(options) {
			this.getData();
			// console.log(options);

			if (options.scene) {
				this.scene = options.scene;
			}

			await this.loadCodeParams();
		},
		onReachBottom() {
			this.form.page++;
			this.getData();
		},
		methods: {
			loadCodeParams() {
				let _ts = this;

				return new Promise((resolve, reject) => {
					if (!_ts.scene) {
						resolve();
						return false;
					}

					req.getRequest('/api/code/params', {
						scene: _ts.scene
					}, data => {
						req.setStorage('pidCode', data.userId);
						resolve();
					});
				});
			},

			getData() {
				// req.getRequest('/api/help/center', {}, data => {
				// 	if (data) {
				// 		this.setData({
				// 			pageList: data
				// 		});
				// 	}
				// });
				if (!this.isLoad) return false;
				this.isLoad = false;
				let form = this.form;
				form.code = 'help';
				req.getRequest('/api/content/list',form,res => {
					if (res && res.length >= 10) this.isLoad = true;
					if (this.form.page > 1) res = this.pageList.concat(res);
					this.pageList = res;
				});
			}

		}
	};
</script>
<style>
	@import "./help.css";
</style>
