export default {
  state: {
    text: "我是user模块下state.text的值",
    //手机号
    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')),
  },
  getters: {
    getText(state) {
      return 12
    }
  },
  mutations: {
    updateText(state) {
      console.log(12222222)
      console.log(state)
    },
    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 = {}
    },

  },
  actions: {

  }
}
