var app = getApp();
var $ = require('../../../js/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    info: [],
    other: [],
    user: [],
    param: {
    },
    header_img: '/images/header_1.jpg',
    is_true:0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getIndex();
  },
  getIndex: function () {
    var self = this;
    var action = 'c=LittleShop&a=index';
    app.showLoading('加载中...');
    app.ajaxRequest(action, 'GET', '', function (ret) {
      // console.log(ret); console.log('3-----------');
      if (ret.status == 1 && ret.data.info) {
        self.setData({
          info: ret.data.info,
          header_img: ret.data.info.logo,
          index_img: ret.data.info.surface_plot,
          is_true:1,

        });
      }
    }, true);
  },
  //修改资料
  formSubmit: function (event) {
    var self = this;
    var value = event.detail.value;
    value.logo = self.data.header_img;
    value.index_img = self.data.index_img;
    var action = 'c=LittleShop&a=sub_shop';
    app.showLoading('加载中...');
    app.ajaxRequest(action, 'GET', $.ObjectToStr(value), function (ret) {
      // console.log(ret); console.log('5+++++++'); return false;
      if (ret.status == 1) {
        app.HCtoast('操作成功！');
        // self.getIndex();
      } else {
        app.HCerror('提示', ret.msg, false); return;
      }
    }, true)
   
  },
  uploadimg_index: function () {
    var self = this;
    app.HCaddimg(function (ret, res) {
      if (ret.status == 1) {
        self.setData({
          index_img: ret.data
        });
      }
    });
  },
  uploadimg_logo:function(){
    var self = this;
    app.HCaddimg(function (ret, res) {
      if (ret.status == 1) {
        self.setData({
          header_img: ret.data
        });
      }
    });
  },
  //店铺装修
  go_fixup: function () {
    app.HCnavigateTo('../editinfo/editinfo');
  },
  //商品管理
  go_goods: function () {
    app.HCnavigateTo('../my_goods_up/my_goods_up');

  },
  //我的小店
  go_myshop: function () {
    app.HCswitchTab('../../../pages/choice_list/choice_list');
  },
})