<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.name" hover-class="none" class="li">{{item.name}}<image src="/static/pages/images/more.png" class="rico"></image></navigator>
  </block>
</view>
<button class="zixun" open-type="contact">咨询客服</button>
</view>
</template>

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

export default {
  data() {
    return {
      pageList: []
    };
  },

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

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

    await this.loadCodeParams();
  },
  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
          });
        }
      });
    }

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