const Constants = require('@/utils/Constants.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    stepsText: '录入商品信息是进行店铺管理的第一步，店铺信息的完善是精细化运营的必经之路',
    steps: [
      {
        no: 1,
        title: '录入资料',
        status: 1
      },
      {
        no: 2,
        title: '开单记账',
        status: 0
      },
      {
        no: 3,
        title: '分析报表',
        status: 0
      },
    ],
    stepsItems: [
      {
        title: '添加商品',
        label: '管理你的商品信息',
        desc: '演示教程',
        url:'https://scrm.hegii.com'
      },
      {
        title: '添加客户',
        label: '维护你的客户资料',
        desc: '演示教程'
      },
      {
        title: '添加供应商',
        label: '维护你的供应商',
        desc: ''
      },
      {
        title: '添加营业员',
        label: '多人看店不忙碌',
        desc: '演示教程'
      },

    ]
  },
  /**
   * @desc :顶部步骤点击事件
   * @date : 2024/6/13 08:49
   * @author : 于继渤
   */
  handleClickStep(e) {
    let steps = this.data.steps
    let stepsItems = this.data.stepsItems
    let stepsText = this.data.stepsText
    let index = e.currentTarget.dataset.index
    console.log(e.currentTarget.dataset.index)
    steps.forEach(res => {
      res.status = 0
    })
    steps[index].status = 1
    if (steps[index].no == 1) {
      stepsText = '录入商品信息是进行店铺管理的第一步，店铺信息的完善是精细化运营的必经之路'
      stepsItems = [
        {
          title: '添加商品',
          label: '管理你的商品信息',
          desc: '演示教程'
        },
        {
          title: '添加客户',
          label: '维护你的客户资料',
          desc: '演示教程'
        },
        {
          title: '添加供应商',
          label: '维护你的供应商',
          desc: ''
        },
        {
          title: '添加营业员',
          label: '多人看店不忙碌',
          desc: '演示教程'
        }
      ]

    } else if (steps[index].no == 2) {
      stepsText = '记录单据让每笔交易有速可循，告别手工记录，数字化管理店铺'
      stepsItems = [
        {
          title: '销售单',
          label: '卖一笔记一笔',
          desc: '演示教程'
        },
        {
          title: '进货单',
          label: '记录每次进货',
          desc: '演示教程'
        },
        {
          title: '收款单',
          label: '不忘每笔应收款',
          desc: ''
        },
        {
          title: '付款单',
          label: '记录每笔应付款',
          desc: ''
        },
      ]
    } else if (steps[index].no == 3) {
      stepsText = '系统自动生成数据报表，数据辅助决策，助力生意增长'
      stepsItems = [
        {
          title: '利润统计',
          label: '查看店铺盈利情况',
          desc: '演示教程'
        },
        {
          title: '销售统计',
          label: '掌握商品销售排名',
          desc: ''
        },
        {
          title: '库存统计',
          label: '库存清晰不错乱',
          desc: ''
        }
      ]
    }

    this.setData({
      steps: steps,
      stepsItems: stepsItems,
      stepsText: stepsText
    })
  },


  /**
   * @desc :列表点击事件
   * @date : 2024/6/13 08:49
   * @author : 于继渤
   */
  chickStepsItem(e) {
    let item = e.currentTarget.dataset.item
    let url = ''
    if (item.title == '添加商品') {
      url = '/package-basic-data/pages/product-file/add/add'
    }
    if (item.title == '添加客户') {
      url = '/package-basic-data/pages/customer-list/add/add'
    }
    if (item.title == '添加供应商') {
      url = '/package-purchase/pages/supplier-list/add/add'
    }
    if (item.title == '添加营业员') {
      url = '/package-basic-data/pages/staff/add/add'
    }
    if (item.title == '销售单') {
      url = '/package-sales/pages/order-billing/add/add'
    }
    if (item.title == '进货单') {
      url = '/package-purchase/pages/purchase-order/add/add'
    }
    if (item.title == '收款单') {
      url = '/package-accounts-manage/pages/receipt/add/add'
    }
    if (item.title == '付款单') {
      url = '/package-accounts-manage/pages/payment-order/add/add'
    }
    if (item.title == '利润统计') {
      url = '/'
    }
    if (item.title == '销售统计') {
      url = '/'
    }
    if (item.title == '库存统计') {
      url = '/package-inventory/pages/ivt-detail-report/ivt-detail-report'
    }
    this.setData({
      loading: true
    })
    let _this = this
    wx.navigateTo({
      url: url,
      events: {
        bandData: function (e) {
        }
      },
      success: function (res) {
        res.eventChannel.emit('params', {
          formMode: Constants.formMode.add,
          formReturnMode: Constants.formReturnMode.beginnerGuide
        })
        setTimeout(() => {
          _this.setData({
            loading: false
          })
        }, 1000)
      }
    })
  },

  /**
   * @desc :演示教程
   * @date : 2024/6/13 08:49
   * @author : 于继渤
   */
  openBeginnerGuide(e) {
    let item = e.currentTarget.dataset.item
    console.log('演示教程', item)


    this.setData({
      loading: true
    })
    let _this = this
    wx.navigateTo({
      url: '/package-basic-data/pages/beginner-guide/demo-tutorial/demo-tutorial',
      events: {
        bandData: function (e) {
        }
      },
      success: function (res) {
        res.eventChannel.emit('params', {
          item: item
        })
        setTimeout(() => {
          _this.setData({
            loading: false
          })
        }, 1000)
      }
    })
  },



  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },


})