<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> -->
		<view class="ddflex zixun-btn">
			<view class="fflex gfqw" v-if="config.WECOM_CODE" @click="isShowCodePop = true">添加官方企微</view>
			<view class="fflex">
				<contact-button class-name="zixun" button-text="咨询客服"></contact-button>
			</view>
		</view>
		
		
		<view class="ceng2" v-if="isShowCodePop" @click="isShowCodePop = false" @touchmove.stop.prevent="()=>{}">
		</view>
		<view :class="'code-pop ' +(config.greyTheme==1?'grayTheme':'')" v-if="isShowCodePop">
			<view class="code-content">
				<image :src="config.WECOM_CODE"
					show-menu-by-longpress="true"></image>
				<view style="text-align: center;font-size: 24rpx;color: #999;margin-bottom: 50rpx;">长按识别微信二维码</view>
			</view>
			<view class="code-btn" @click="isShowCodePop = false">
				取消
			</view>
		</view>
	</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,
				config:{},
				isShowCodePop:false
			};
		},

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

			if (options.scene) {
				this.scene = options.scene;
			}
			this.getAbout()
			// 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();
					});
				});
			},
			getAbout() {
				var _this = this;
			
				req.getRequest('/api/other/config', {}, function(res) {
					_this.config = res;
				});
			},
			
			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>
