const wx2my = require('../../wx2my');
const Behavior = require('../../Behavior');
// pages/memberRules.js
const app = getApp();

const wxService = require('../../utils/wxService');

const utils = require('../../utils/util');

const envInfo = require('../../config/index').envInfo;

wxService.page({
  /**
   * 页面的初始数据
   */
  data: {
    ruleImg: '',
    type: ''
  },

  onLoad(options) {
    const {
      type
    } = options;

    if (type == 1) {
      wx2my.setNavigationBarTitle({
        title: '积分规则'
      });
    } else if (type == 3) {
      wx2my.setNavigationBarTitle({
        title: '激活领卡规则'
      });
    }

    this.setData({
      type: type
    });
    this.getRule(type);
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  //获取规则
  getRule(TYPE) {
    wxService.get(`/merchant/brandRuleDescSet/get?type=${TYPE}&brandId=${app.globalData.brandId}`).then(res => {
      this.setData({
        ruleImg: res.data && res.data.data && res.data.data.content || ''
      });
    });
  }

});