🌈 style(eslint): add eslint rules
This commit is contained in:
+21
-21
@@ -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 (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
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
|
||||
//该方法纯粹只是个Ts类型定义文件
|
||||
import { useSelector as useReduxSelector, TypedUseSelectorHook } from 'react-redux';
|
||||
import { DataParam as userInfoParam } from './userInfo';
|
||||
import { DataParam as commonDataParam } from './commonData';
|
||||
import { TabBarData as tabbarDataParam } from './tabBar';
|
||||
type Params = {
|
||||
// 该方法纯粹只是个Ts类型定义文件
|
||||
import type { TypedUseSelectorHook } from 'react-redux'
|
||||
import { useSelector as useReduxSelector } from 'react-redux'
|
||||
import type { DataParam as userInfoParam } from './userInfo'
|
||||
import type { DataParam as commonDataParam } from './commonData'
|
||||
import type { TabBarData as tabbarDataParam } from './tabBar'
|
||||
|
||||
interface Params {
|
||||
userInfoData: userInfoParam
|
||||
commonData: commonDataParam
|
||||
tabBarData: tabbarDataParam
|
||||
}
|
||||
export const useSelector: TypedUseSelectorHook<Params> = useReduxSelector;
|
||||
export const useSelector: TypedUseSelectorHook<Params> = useReduxSelector
|
||||
|
||||
@@ -3,7 +3,7 @@ import userInfoData from './userInfo'
|
||||
import commonData from './commonData'
|
||||
import tabBarReducer from './tabBar'
|
||||
|
||||
export type Reducers = {
|
||||
export interface Reducers {
|
||||
userInfoData: typeof userInfoData
|
||||
commonData: typeof commonData
|
||||
tabBarData: typeof tabBarReducer
|
||||
|
||||
+11
-14
@@ -1,26 +1,23 @@
|
||||
import { TabBarType } from '../constants/tabbar'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import type IconFont from '@/components/iconfont/iconfont'
|
||||
|
||||
type IconfontName = Parameters<typeof IconFont>['0']['name']
|
||||
|
||||
type TabBarIndexMap = {
|
||||
[Property: number]: {
|
||||
id: number
|
||||
pagePath: string
|
||||
text: string
|
||||
iconPath: IconfontName
|
||||
selectedIconPath: IconfontName
|
||||
}
|
||||
}
|
||||
type TabBarIndexMap = Record<number, {
|
||||
id: number
|
||||
pagePath: string
|
||||
text: string
|
||||
iconPath: IconfontName
|
||||
selectedIconPath: IconfontName
|
||||
}>
|
||||
|
||||
export enum TabBarIndex {
|
||||
INDEX = 1,
|
||||
SHOPPING = 2,
|
||||
ORDER = 3,
|
||||
USER = 4
|
||||
USER = 4,
|
||||
}
|
||||
|
||||
|
||||
const INITIAL_STATE = {
|
||||
selectedId: TabBarIndex.INDEX,
|
||||
tabItem: [
|
||||
@@ -55,12 +52,12 @@ const INITIAL_STATE = {
|
||||
],
|
||||
}
|
||||
|
||||
export type TabBarData = {
|
||||
export interface TabBarData {
|
||||
selectedId: number
|
||||
tabItem?: TabBarIndexMap[number][]
|
||||
}
|
||||
|
||||
export type TabBarAction = {
|
||||
export interface TabBarAction {
|
||||
type: TabBarType
|
||||
data: TabBarData
|
||||
}
|
||||
|
||||
+42
-43
@@ -2,7 +2,7 @@
|
||||
import Taro from '@tarojs/taro'
|
||||
import { UserInfoActionType } from '../constants/userInfo'
|
||||
|
||||
export type UserParam = {
|
||||
export interface UserParam {
|
||||
department_code?: string
|
||||
department_id?: string
|
||||
department_name?: string
|
||||
@@ -16,58 +16,57 @@ export type UserParam = {
|
||||
avatar_url?: 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?: boolean,
|
||||
is_authorize_phone?: boolean,
|
||||
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?: boolean
|
||||
is_authorize_phone?: boolean
|
||||
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?: boolean //登录状态 true 正在登录
|
||||
}
|
||||
export interface DataParam {
|
||||
token?: string
|
||||
session_key?: string
|
||||
userInfo: UserParam
|
||||
adminUserInfo: UserAdminParam
|
||||
sort_code: SortCodeParam
|
||||
logingStatus?: boolean // 登录状态 true 正在登录
|
||||
}
|
||||
|
||||
export type UserInfoAction = {
|
||||
export interface UserInfoAction {
|
||||
type: UserInfoActionType
|
||||
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 (state = INIT_USER, action: UserInfoAction) => {
|
||||
|
||||
Reference in New Issue
Block a user