completeBuild.js 2.54 KB
// tabMine/pages/completeBuild/completeBuild.js
import api from '../../api.js'
import {
  ImgUrl
} from '~/config';
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    IMG_URL: ImgUrl,
    isYqdSuper: '',
    tipsProps: {
      tipsText: '小程序下单后,驻店员工需让客户在订单中签名确认订单,才可完结为最终施工单',
      showTips: true,
      type: 1
    },
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getMerchantConfiguration()
    this.setData({
      isYqdSuper: app.globalData.isYqdSuper,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {},

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

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {},

  // 获取商户配置
  getMerchantConfiguration() {
    let {
      saturdayFlag
    } = this.data
    let {
      shopMerchantId: merchantId
    } = wx.$util.getUserInfo()
    api.getMerchantConfiguration({
      merchantId,
      sceneType: '1'
    }).then(res => {
      let {
        code,
        data
      } = res
      if (code == '0') {
        if (data) {
          saturdayFlag = data.signatureSwitch ? true : false
        }
      } else {
        this.showToast(message)
      }
      this.setData({
        saturdayFlag
      })
    })
  },

  //是否开启电子签名
  changeSwitch(e) {
    let {
      userInfo
    } = this.data
    if (userInfo.userType == 2) return
    console.log('e', e);
    let {
      value
    } = e.detail
    let {
      target
    } = e.currentTarget.dataset
    this.setData({
      [target]: value
    })
    this.updateSignatureConfiguration()
  },

  // 修改配置
  updateSignatureConfiguration() {
    let {
      saturdayFlag
    } = this.data
    let {
      shopMerchantId: merchantId
    } = wx.$util.getUserInfo()
    let signatureSwitch = saturdayFlag ? 1 : 0
    api.updateSignatureConfiguration({
      merchantId,
      sceneType: '1',
      signatureSwitch
    }).then(res => {
      let {
        code,
        data
      } = res
      if (code == '0') {
        console.log('data', data);
      } else {
        this.showToast(message)
      }
    })
  },
})