🌈 style(eslint): 新增eslint规则
This commit is contained in:
+23
-23
@@ -1,34 +1,34 @@
|
||||
//公共数据,什么都可往里面传,可用于临时传参
|
||||
// 公共数据,什么都可往里面传,可用于临时传参
|
||||
import Taro from '@tarojs/taro'
|
||||
import {
|
||||
SET_SHOPCOUNT,
|
||||
CLEAR_SHOPCOUNT,
|
||||
STORAGE_SHOPCOUNT
|
||||
import {
|
||||
CLEAR_SHOPCOUNT,
|
||||
SET_SHOPCOUNT,
|
||||
STORAGE_SHOPCOUNT,
|
||||
} from '../constants/common'
|
||||
|
||||
export type DataParam = {
|
||||
shopCount: number //购物车数量
|
||||
export interface DataParam {
|
||||
shopCount: number // 购物车数量
|
||||
}
|
||||
|
||||
type Action = {
|
||||
type?: string,
|
||||
interface Action {
|
||||
type?: string
|
||||
data?: DataParam
|
||||
}
|
||||
|
||||
const INIT = {
|
||||
shopCount: Taro.getStorageSync(STORAGE_SHOPCOUNT)?JSON.parse(Taro.getStorageSync(STORAGE_SHOPCOUNT)).shopCount:0,
|
||||
shopCount: Taro.getStorageSync(STORAGE_SHOPCOUNT) ? JSON.parse(Taro.getStorageSync(STORAGE_SHOPCOUNT)).shopCount : 0,
|
||||
}
|
||||
|
||||
export default function counter (state = INIT, action: Action) {
|
||||
const {type, data} = action
|
||||
switch (type) {
|
||||
case SET_SHOPCOUNT:
|
||||
Taro.setStorageSync(STORAGE_SHOPCOUNT,JSON.stringify(data?.shopCount))
|
||||
return {...state,...data}
|
||||
case CLEAR_SHOPCOUNT:
|
||||
Taro.removeStorageSync(STORAGE_SHOPCOUNT)
|
||||
return {...state, shopCount: 0}
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
export default function counter(state = INIT, action: Action) {
|
||||
const { type, data } = action
|
||||
switch (type) {
|
||||
case SET_SHOPCOUNT:
|
||||
Taro.setStorageSync(STORAGE_SHOPCOUNT, JSON.stringify(data?.shopCount))
|
||||
return { ...state, ...data }
|
||||
case CLEAR_SHOPCOUNT:
|
||||
Taro.removeStorageSync(STORAGE_SHOPCOUNT)
|
||||
return { ...state, shopCount: 0 }
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
+10
-8
@@ -1,10 +1,12 @@
|
||||
|
||||
//该方法纯粹只是个Ts类型定义文件
|
||||
import { useSelector as useReduxSelector, TypedUseSelectorHook } from 'react-redux';
|
||||
import { DataParam } from './userInfo';
|
||||
import { DataParam as commonDataParam } from './commonData';
|
||||
type Params = {
|
||||
userInfo: DataParam,
|
||||
commonData: commonDataParam
|
||||
// 该方法纯粹只是个Ts类型定义文件
|
||||
import type { TypedUseSelectorHook } from 'react-redux'
|
||||
import { useSelector as useReduxSelector } from 'react-redux'
|
||||
import type { DataParam } from './userInfo'
|
||||
import type { DataParam as commonDataParam } from './commonData'
|
||||
|
||||
interface Params {
|
||||
userInfo: DataParam
|
||||
commonData: commonDataParam
|
||||
}
|
||||
export const useSelector: TypedUseSelectorHook<Params> = useReduxSelector;
|
||||
export const useSelector: TypedUseSelectorHook<Params> = useReduxSelector
|
||||
|
||||
@@ -3,6 +3,6 @@ import userInfo from './userInfo'
|
||||
import commonData from './commonData'
|
||||
|
||||
export default combineReducers({
|
||||
userInfo,
|
||||
commonData
|
||||
})
|
||||
userInfo,
|
||||
commonData,
|
||||
})
|
||||
|
||||
+105
-106
@@ -1,123 +1,122 @@
|
||||
|
||||
import Taro from '@tarojs/taro'
|
||||
import {
|
||||
SET_USERINFO,
|
||||
SET_ADMINUSERINFO,
|
||||
SET_TOKEN,
|
||||
SET_SESSIONKEY,
|
||||
SET_SORTCODE,
|
||||
CLEAR_TOKEN,
|
||||
CLEAR_USERINFO,
|
||||
CLEAR_SESSIONKEY,
|
||||
CLEAR_ADMINUSERINFO,
|
||||
CLEAR_SORTCODE,
|
||||
LOGIN_STATUS
|
||||
import {
|
||||
CLEAR_ADMINUSERINFO,
|
||||
CLEAR_SESSIONKEY,
|
||||
CLEAR_SORTCODE,
|
||||
CLEAR_TOKEN,
|
||||
CLEAR_USERINFO,
|
||||
LOGIN_STATUS,
|
||||
SET_ADMINUSERINFO,
|
||||
SET_SESSIONKEY,
|
||||
SET_SORTCODE,
|
||||
SET_TOKEN,
|
||||
SET_USERINFO,
|
||||
} from '../constants/userInfo'
|
||||
|
||||
export type UserParam = {
|
||||
nickName?:string,
|
||||
phone?:string,
|
||||
avatarUrl?:string,
|
||||
city?: string,
|
||||
country?: string,
|
||||
province?: string,
|
||||
gender?: number,
|
||||
language?: string,
|
||||
timestamp?: number,
|
||||
physical_warehouse?: number,
|
||||
physical_warehouse_name?: string,
|
||||
export interface UserParam {
|
||||
nickName?: string
|
||||
phone?: string
|
||||
avatarUrl?: string
|
||||
city?: string
|
||||
country?: string
|
||||
province?: string
|
||||
gender?: number
|
||||
language?: string
|
||||
timestamp?: number
|
||||
physical_warehouse?: number
|
||||
physical_warehouse_name?: string
|
||||
}
|
||||
|
||||
export type UserAdminParam = {
|
||||
avatar_url?: string,
|
||||
open_id?: string,
|
||||
physical_warehouse?: number,
|
||||
physical_warehouse_name?: string,
|
||||
union_id?: string,
|
||||
user_code?: string,
|
||||
user_id?: number,
|
||||
user_name?: string,
|
||||
wechat_user_open_id?: number
|
||||
is_authorize_name?: false|true,
|
||||
is_authorize_phone?: false|true,
|
||||
phone?:string,
|
||||
authentication_status?:number,
|
||||
authentication_status_name: string,
|
||||
company_id?: number,
|
||||
company_name?: string,
|
||||
founder_user_id?: string,
|
||||
founder_user_name?: string,
|
||||
order_access_status?: number,
|
||||
order_access_status_name?: string,
|
||||
purchaser_type?: number,
|
||||
purchaser_type_name?: string
|
||||
export interface UserAdminParam {
|
||||
avatar_url?: string
|
||||
open_id?: string
|
||||
physical_warehouse?: number
|
||||
physical_warehouse_name?: string
|
||||
union_id?: string
|
||||
user_code?: string
|
||||
user_id?: number
|
||||
user_name?: string
|
||||
wechat_user_open_id?: number
|
||||
is_authorize_name?: false|true
|
||||
is_authorize_phone?: false|true
|
||||
phone?: string
|
||||
authentication_status?: number
|
||||
authentication_status_name: string
|
||||
company_id?: number
|
||||
company_name?: string
|
||||
founder_user_id?: string
|
||||
founder_user_name?: string
|
||||
order_access_status?: number
|
||||
order_access_status_name?: string
|
||||
purchaser_type?: number
|
||||
purchaser_type_name?: string
|
||||
}
|
||||
|
||||
export type SortCodeParam = {
|
||||
shareShortDetail?: {title:string, code: string, img: string}, //详情分享页面短码
|
||||
shareShortPage?: {title:string, code: string, img: string}, //右上角分享页面短码
|
||||
export interface SortCodeParam {
|
||||
shareShortDetail?: { title: string; code: string; img: string } // 详情分享页面短码
|
||||
shareShortPage?: { title: string; code: string; img: string } // 右上角分享页面短码
|
||||
}
|
||||
|
||||
export type DataParam = {
|
||||
token?: string
|
||||
session_key?: string,
|
||||
userInfo: UserParam,
|
||||
adminUserInfo: UserAdminParam,
|
||||
sort_code: SortCodeParam
|
||||
logingStatus?: false //登录状态 true 正在登录
|
||||
}
|
||||
export interface DataParam {
|
||||
token?: string
|
||||
session_key?: string
|
||||
userInfo: UserParam
|
||||
adminUserInfo: UserAdminParam
|
||||
sort_code: SortCodeParam
|
||||
logingStatus?: false // 登录状态 true 正在登录
|
||||
}
|
||||
|
||||
type Action = {
|
||||
type?: string,
|
||||
interface Action {
|
||||
type?: string
|
||||
data?: DataParam
|
||||
}
|
||||
|
||||
|
||||
const INIT_USER = {
|
||||
userInfo: Taro.getStorageSync('userInfo')?JSON.parse(Taro.getStorageSync('userInfo')):null,
|
||||
adminUserInfo: Taro.getStorageSync('adminUserInfo')?JSON.parse(Taro.getStorageSync('adminUserInfo')):null,
|
||||
token: Taro.getStorageSync('token')||'',
|
||||
session_key: Taro.getStorageSync('session_key')||'',
|
||||
sort_code: Taro.getStorageSync('sort_code')?JSON.parse(Taro.getStorageSync('sort_code')):null,
|
||||
logingStatus: false
|
||||
userInfo: Taro.getStorageSync('userInfo') ? JSON.parse(Taro.getStorageSync('userInfo')) : null,
|
||||
adminUserInfo: Taro.getStorageSync('adminUserInfo') ? JSON.parse(Taro.getStorageSync('adminUserInfo')) : null,
|
||||
token: Taro.getStorageSync('token') || '',
|
||||
session_key: Taro.getStorageSync('session_key') || '',
|
||||
sort_code: Taro.getStorageSync('sort_code') ? JSON.parse(Taro.getStorageSync('sort_code')) : null,
|
||||
logingStatus: false,
|
||||
}
|
||||
|
||||
export default function counter (state = INIT_USER, action: Action) {
|
||||
const {type, data} = action
|
||||
switch (type) {
|
||||
case SET_USERINFO:
|
||||
Taro.setStorageSync('userInfo',JSON.stringify(data?.userInfo))
|
||||
return {...state,...data}
|
||||
case SET_ADMINUSERINFO:
|
||||
Taro.setStorageSync('adminUserInfo',JSON.stringify(data?.adminUserInfo))
|
||||
return {...state,...data}
|
||||
case SET_TOKEN:
|
||||
Taro.setStorageSync('token',data?.token)
|
||||
return {...state,...data}
|
||||
case SET_SESSIONKEY:
|
||||
Taro.setStorageSync('session_key',data?.session_key)
|
||||
return {...state,...data}
|
||||
case SET_SORTCODE:
|
||||
Taro.setStorageSync('sort_code',JSON.stringify(data?.sort_code))
|
||||
return {...state,...data}
|
||||
case CLEAR_TOKEN:
|
||||
Taro.removeStorageSync('token')
|
||||
return {...state, token:''}
|
||||
case CLEAR_SESSIONKEY:
|
||||
Taro.removeStorageSync('session_key')
|
||||
return {...state, session_key:''}
|
||||
case CLEAR_USERINFO:
|
||||
Taro.removeStorageSync('userInfo')
|
||||
return {...state, userInfo: null}
|
||||
case CLEAR_ADMINUSERINFO:
|
||||
Taro.removeStorageSync('adminUserInfo')
|
||||
return {...state, adminUserInfo: null}
|
||||
case CLEAR_SORTCODE:
|
||||
Taro.removeStorageSync('sort_code')
|
||||
return {...state, sortCode: null}
|
||||
case LOGIN_STATUS:
|
||||
return {...state, ...data}
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
export default function counter(state = INIT_USER, action: Action) {
|
||||
const { type, data } = action
|
||||
switch (type) {
|
||||
case SET_USERINFO:
|
||||
Taro.setStorageSync('userInfo', JSON.stringify(data?.userInfo))
|
||||
return { ...state, ...data }
|
||||
case SET_ADMINUSERINFO:
|
||||
Taro.setStorageSync('adminUserInfo', JSON.stringify(data?.adminUserInfo))
|
||||
return { ...state, ...data }
|
||||
case SET_TOKEN:
|
||||
Taro.setStorageSync('token', data?.token)
|
||||
return { ...state, ...data }
|
||||
case SET_SESSIONKEY:
|
||||
Taro.setStorageSync('session_key', data?.session_key)
|
||||
return { ...state, ...data }
|
||||
case SET_SORTCODE:
|
||||
Taro.setStorageSync('sort_code', JSON.stringify(data?.sort_code))
|
||||
return { ...state, ...data }
|
||||
case CLEAR_TOKEN:
|
||||
Taro.removeStorageSync('token')
|
||||
return { ...state, token: '' }
|
||||
case CLEAR_SESSIONKEY:
|
||||
Taro.removeStorageSync('session_key')
|
||||
return { ...state, session_key: '' }
|
||||
case CLEAR_USERINFO:
|
||||
Taro.removeStorageSync('userInfo')
|
||||
return { ...state, userInfo: null }
|
||||
case CLEAR_ADMINUSERINFO:
|
||||
Taro.removeStorageSync('adminUserInfo')
|
||||
return { ...state, adminUserInfo: null }
|
||||
case CLEAR_SORTCODE:
|
||||
Taro.removeStorageSync('sort_code')
|
||||
return { ...state, sortCode: null }
|
||||
case LOGIN_STATUS:
|
||||
return { ...state, ...data }
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user