user.js 1.82 KB
/*
 * @Description:
 * @Author: huyue
 * @Date: 2024-04-07 18:15:11
 * @LastEditors: 前端 qianduan01@didihu.com.cn
 * @LastEditTime: 2024-04-11 21:19:09
 */
// import { setToken, getToken, removeToken } from '@/utils/token';;

export default {
  state() {
    return {
      customerInfo: {
        customerName: "",
        carBrand: "",
        carModel: "",
        phoneNumber: "",
        salesUuid: "",
        staffName: "",
        newCarFare:''
      },
      historyStatus: Date.now(),
      carBrands: [],
      employeeList: [],
      paymentType: [],
    };
  },
  mutations: {
    getCustomerInfo(state) {
      return state.customerInfo;
    },
    setCustomerInfo(state, data) {
      // state.customerInfo = data;
      uni.$storage.set("customerInfo", JSON.stringify(data));
      state.customerInfo = JSON.parse(uni.$storage.get("customerInfo") || "{}");
    },
    clearCustomerInfo(state) {
      const info = {
        customerName: "",
        carBrand: "",
        carModel: "",
        phoneNumber: "",
        salesUuid: "",
        staffName: "",
        newCarFare:''
      };
      uni.$storage.set("customerInfo", JSON.stringify(info));
      state.customerInfo = JSON.parse(uni.$storage.get("customerInfo") || "{}");
    },
  },
  actions: {
    // 获取用户详情
    getCustomerInfo({ state }) {
      return state.customerInfo;
    },
    setCustomerInfo({ commit }, value) {
      commit("setCustomerInfo", value);
    },
    clearCustomerInfo({ commit }) {
      commit("clearCustomerInfo");
    },
    clearHistory({ state }) {
      state.historyStatus = Date.now();
    },
    setPaymentType({ state }, value) {
      state.paymentType = value;
    },
    setCarBrandsList({ state }, value) {
      state.carBrands = value;
    },
    setEmployeeList({ state }, value) {
      state.employeeList = value;
    },
  },
};