import Vue from 'vue'
import Vuex from 'vuex'
import settings from "@/settings.js"
import user from '@/store/modules/user'
import order from '@/store/modules/order'
import station from '@/store/modules/station'
import voucher from '@/store/modules/voucher'
import coupon from '@/store/modules/coupon'

Vue.use(Vuex)
export default new Vuex.Store({
  state: {
    appId: settings.appId,
    // stationId: settings.stationId,
    // phoneNumber:uni.getStorageSync('phoneNumber') || "",
    // countryCode:uni.getStorageSync('countryCode') || "",
    // purePhoneNumber:uni.getStorageSync('purePhoneNumber') || "",
    // openId: uni.getStorageSync('openId') || "",
    // unionId: uni.getStorageSync('unionId') || "",
    // userInfo: !uni.getStorageSync('userInfo') ? {} : JSON.parse(uni.getStorageSync('userInfo')),
    // orderInfo:undefined,
    // selectedGas:undefined,
    // labelId:undefined,
    // employeeId:undefined,
  },
  getters: {
  },
  mutations: {
    // updatePhoneNumber(state, phoneNumber) {
    //   uni.setStorageSync('phoneNumber', phoneNumber);
    //   state.phoneNumber = phoneNumber
    // },
    // updateCountryCode(state, countryCode) {
    //   uni.setStorageSync('countryCode', countryCode);
    //   state.countryCode = countryCode
    // },
    // updatePurePhoneNumber(state, purePhoneNumber) {
    //   uni.setStorageSync('phoneNumber', phoneNumber);
    //   state.purePhoneNumber = purePhoneNumber
    // },
    // updateOpenId(state, openId) { 
    //   uni.setStorageSync('openId', openId);
    //   state.openId = openId
    // },
    // updateUnionId(state, unionId) {
    //   uni.setStorageSync('unionId', unionId);
    //   state.unionId = unionId
    // },
    
    // clearUserAuthen(state){
    //   uni.removeStorageSync('phoneNumber')
    //   uni.removeStorageSync('countryCode')
    //   uni.removeStorageSync('purePhoneNumber')
    //   uni.removeStorageSync('openId')
    //   uni.removeStorageSync('unionId')
    //   state.phoneNumber = ''
    //   state.countryCode = ''
    //   state.purePhoneNumber = ''
    //   state.openId = ''
    //   state.unionId = ''
    // },
    
    // updateUserInfo(state, userInfo) {      
    //   uni.setStorageSync('userInfo', JSON.stringify(userInfo));
    //   state.userInfo = userInfo
    // },
    // clearUserInfo(state) {
    //   uni.removeStorageSync('userInfo')
    //   state.userInfo = {}
    // },
    
    // updateOrderInfo(state, orderInfo){
    //   state.orderInfo = orderInfo
    // },
    // updateSelectedGas(state, selectedGas){
    //   state.selectedGas = selectedGas
    // },
    // updateStationId(state, stationId){
    //   state.stationId = stationId
    // },
    // updateLabelId(state, labelId) {
    //   state.labelId = labelId
    // },
    // clearLabelId(state){
    //   state.labelId = undefined
    // },
    resetApplet(state){
      uni.clearStorageSync()
      state.user.phoneNumber = ''
      state.user.countryCode = ''
      state.user.purePhoneNumber = ''
      state.user.openId = ""
      state.user.unionId = ""
      state.user.userInfo = {}
      state.station.employeeId = undefined
    },
    // updateEmployeeId(state, employeeId){
    //   state.employeeId = employeeId
    // },
    // clearEmployeeId(state){
    //   state.employeeId = undefined
    // }
  },
  actions: {

  },
  modules: {
    user,
    order,
    station,
    voucher,
    coupon
  }
})
