import {
  updateConfig
} from '../../../utils/api/api'
import {
  getWaterDrop
} from '../../../utils/index/index'
const app = getApp()
Page({
  data: {
    password: '',
  },
  onLoad() {
    my.hideBackHome();
  },
  clickAudio(){
    getWaterDrop()
  },
  getVal(e) {
    this.setData({
      password: e.detail.value
    })
  },
  async sure() {
    let mpassword = this.data.password
    if (mpassword) {
      my.showLoading()
      let form = {
        mpassword,
        sn: app.globalData.sn,
        modifyType: app.globalData.modifyType[4],
        token: app.globalData.FKJConfiguration
      }
      try {
        let data = await updateConfig(form)
        app.globalData.snDisposition.mpassword = form.mpassword;
        // console.log(app.globalData.snDisposition);
        my.setStorageSync({
          data: app.globalData.snDisposition,
          key: 'snDisposition'
        });
        my.reLaunch({
          url: "/pages/settings/index/index"
        })
      } catch (error) {
        console.log(error);
      } finally {
        my.hideLoading()
      }
    }
  },
});
