Commit 162d8903 authored by wangnf's avatar wangnf

wnf

parents 1961e60b 0372887c
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
/* eslint-disable*/
module.exports = {
extends: [ 'taro/react', 'standard', 'standard-jsx'],
rules: {
'react-hooks/exhaustive-deps': 0,
'array-bracket-spacing': [ 'error', 'always' ],
'space-before-function-paren': [ 'error', 'never' ],
'no-unused-vars': 1,
'import/first': 0
},
globals: {
my: true,
getApp: true,
Component: true,
Page: true
}
}
...@@ -13,7 +13,7 @@ const config = { ...@@ -13,7 +13,7 @@ const config = {
sourceRoot: 'src', sourceRoot: 'src',
outputRoot: 'dist', outputRoot: 'dist',
alias: { alias: {
'@': path.resolve(__dirname, '..', 'src') '@': path.resolve(__dirname, '..', 'src/')
}, },
plugins: [ plugins: [
[ [
......
{ {
"compilerOptions": { "compilerOptions": {
"baseUrl": ".", "target": "ES6",
"module": "commonjs",
"jsx": "react",
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"paths": { "paths": {
"@/*": [ "@/*": [
"./src/*" "src/*"
], ]
} }
} },
"exclude": [
"node_modules"
],
"include": [
"src/**/*"
]
} }
\ No newline at end of file
...@@ -15,11 +15,10 @@ class App extends Component { ...@@ -15,11 +15,10 @@ class App extends Component {
componentDidMount() {} componentDidMount() {}
onLaunch(options) { onLaunch(options) {
console.log(options, 'options') console.log('options :>> ', options);
const { activityId } = options.query || {} const { activityId } = options.query || {}
const app = getApp() const app = getApp()
app.activityId = activityId || config.defaultActivityId app.activityId = activityId || config.defaultActivityId
} }
...@@ -29,10 +28,6 @@ class App extends Component { ...@@ -29,10 +28,6 @@ class App extends Component {
componentDidCatchError() { } componentDidCatchError() { }
onGlobalClick(e) {
console.log('onGlobalClick :>> ', e)
}
// this.props.children 是将要会渲染的页面 // this.props.children 是将要会渲染的页面
render() { render() {
return this.props.children return this.props.children
......
import { noopFn } from '@/utils/util' import { noopFn } from '@/utils/util'
import { View } from '@tarojs/components' import { View, Icon } from '@tarojs/components'
import classnames from 'classnames' import classnames from 'classnames'
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import Overlay from '../Overlay/Overlay' import Overlay from '../Overlay/Overlay'
import styles from './Popup.module.less' import styles from './Popup.module.less'
export default function Popup(props) { export default function Popup(props) {
const { onClose = noopFn, position = 'bottom', height = '30%', width = '100%', closeOnClickOverlay = true } = props const {
onClose = noopFn,
position = 'bottom',
height = '30%',
width = '100%',
backgroundColor = '#fff',
closeOnClickOverlay = true,
closebale = false,
closeButtonStyle = { right: 6, top: -36 }
} = props
const [ isShowAnimate, setShowAnimate ] = useState(false) const [ isShowAnimate, setShowAnimate ] = useState(false)
const onCloseModal = () => { const onCloseModal = () => {
...@@ -33,8 +46,9 @@ export default function Popup(props) { ...@@ -33,8 +46,9 @@ export default function Popup(props) {
return ( return (
<View className={wrapClass}> <View className={wrapClass}>
<Overlay onTap={onClickOverlay} /> <Overlay onTap={onClickOverlay} />
<View className={contentClass} style={{ width, height }}> <View className={contentClass} style={{ width, height, backgroundColor }}>
{ closebale && <View className={styles.close_button} onClick={onCloseModal} style={closeButtonStyle}></View>}
{props.children} {props.children}
</View> </View>
......
...@@ -11,7 +11,10 @@ ...@@ -11,7 +11,10 @@
left: 0; left: 0;
transition: transform 0.3s; transition: transform 0.3s;
} }
.show { .close_button {
transform: translateY(0); .wh(50px, 50px);
transition: transform 0.3s; .image("//yun.duiba.com.cn/taobaomini/template/modal_close_btn.png", contain);
position: absolute;
// right: 20px;
// top: -70px;
} }
import { useState, useEffect } from 'react' import { useState, useEffect } from 'react'
import { getAuthUserInfo } from '../utils/tb' import { getAuthUserInfo } from '../utils/tb'
export function useAuthInfo() { // 授权
export function useAuth() {
const [ authInfo, setAuthInfo ] = useState({ const [ authInfo, setAuthInfo ] = useState({
nickName: '', nickName: '',
avatar: '' avatar: ''
......
...@@ -4,12 +4,18 @@ import { useLoginInfoModel } from '../store/loginInfo' ...@@ -4,12 +4,18 @@ import { useLoginInfoModel } from '../store/loginInfo'
import API from '../api' import API from '../api'
import { checkShopFavoredStatus } from '../utils/tb' import { checkShopFavoredStatus } from '../utils/tb'
import config from '../config' import config from '../config'
import { useAuthInfo } from './useAuth' import { useAuth } from './useAuth'
import { noopFn } from '@/utils/util' import { noopFn } from '@/utils/util'
const { login } = API const { login } = API
/**
* 授权登录
*
* @export
* @param {*} [callback=noopFn] 登录之后的回调
* @return {*} isLogin 是否登录
*/
export function useLogin(callback = noopFn) { export function useLogin(callback = noopFn) {
const { authorized, authInfo } = useAuthInfo()
const { loginInfo, setLoginInfo } = useLoginInfoModel() const { loginInfo, setLoginInfo } = useLoginInfoModel()
const [ isLogin, setLoginStatus ] = useState(false) const [ isLogin, setLoginStatus ] = useState(false)
...@@ -20,7 +26,6 @@ export function useLogin(callback = noopFn) { ...@@ -20,7 +26,6 @@ export function useLogin(callback = noopFn) {
const { nickName: userNick, avatar } = authInfo const { nickName: userNick, avatar } = authInfo
const { inviteId } = params const { inviteId } = params
const res = await login({ userNick, avatar, isFollow, inviteId }) const res = await login({ userNick, avatar, isFollow, inviteId })
if (res?.success) { if (res?.success) {
setLoginInfo({ setLoginInfo({
...res.data, ...res.data,
...@@ -34,6 +39,8 @@ export function useLogin(callback = noopFn) { ...@@ -34,6 +39,8 @@ export function useLogin(callback = noopFn) {
} }
} }
const { authorized, authInfo } = useAuth()
useEffect(() => { useEffect(() => {
if (authorized) { if (authorized) {
doLogin() doLogin()
......
import { useState, useEffect } from 'react' import { useState, useEffect } from 'react'
/**
* 请求
*
* @export
* @param {*} api 接口请求
* @param {*} [params={}] 请求参数
* @param {*} [config={}] {
method: 'GET',
showLoading: false,
toastError: true
}
* @return {*}
*/
export function useRequest(api, params = {}, config = {}) { export function useRequest(api, params = {}, config = {}) {
const [ data, setData ] = useState(null) const [ data, setData ] = useState(null)
const [ code, setCode ] = useState('') const [ code, setCode ] = useState('')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment