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 = {
sourceRoot: 'src',
outputRoot: 'dist',
alias: {
'@': path.resolve(__dirname, '..', 'src')
'@': path.resolve(__dirname, '..', 'src/')
},
plugins: [
[
......
{
"compilerOptions": {
"baseUrl": ".",
"target": "ES6",
"module": "commonjs",
"jsx": "react",
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"paths": {
"@/*": [
"./src/*"
],
}
"src/*"
]
}
},
"exclude": [
"node_modules"
],
"include": [
"src/**/*"
]
}
\ No newline at end of file
......@@ -15,11 +15,10 @@ class App extends Component {
componentDidMount() {}
onLaunch(options) {
console.log(options, 'options')
console.log('options :>> ', options);
const { activityId } = options.query || {}
const app = getApp()
app.activityId = activityId || config.defaultActivityId
}
......@@ -29,10 +28,6 @@ class App extends Component {
componentDidCatchError() { }
onGlobalClick(e) {
console.log('onGlobalClick :>> ', e)
}
// this.props.children 是将要会渲染的页面
render() {
return this.props.children
......
import { noopFn } from '@/utils/util'
import { View } from '@tarojs/components'
import { View, Icon } from '@tarojs/components'
import classnames from 'classnames'
import React, { useEffect, useState } from 'react'
import Overlay from '../Overlay/Overlay'
import styles from './Popup.module.less'
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 onCloseModal = () => {
......@@ -34,7 +47,8 @@ export default function Popup(props) {
<View className={wrapClass}>
<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}
</View>
......
......@@ -11,7 +11,10 @@
left: 0;
transition: transform 0.3s;
}
.show {
transform: translateY(0);
transition: transform 0.3s;
.close_button {
.wh(50px, 50px);
.image("//yun.duiba.com.cn/taobaomini/template/modal_close_btn.png", contain);
position: absolute;
// right: 20px;
// top: -70px;
}
import { useState, useEffect } from 'react'
import { getAuthUserInfo } from '../utils/tb'
export function useAuthInfo() {
// 授权
export function useAuth() {
const [ authInfo, setAuthInfo ] = useState({
nickName: '',
avatar: ''
......
......@@ -4,12 +4,18 @@ import { useLoginInfoModel } from '../store/loginInfo'
import API from '../api'
import { checkShopFavoredStatus } from '../utils/tb'
import config from '../config'
import { useAuthInfo } from './useAuth'
import { useAuth } from './useAuth'
import { noopFn } from '@/utils/util'
const { login } = API
/**
* 授权登录
*
* @export
* @param {*} [callback=noopFn] 登录之后的回调
* @return {*} isLogin 是否登录
*/
export function useLogin(callback = noopFn) {
const { authorized, authInfo } = useAuthInfo()
const { loginInfo, setLoginInfo } = useLoginInfoModel()
const [ isLogin, setLoginStatus ] = useState(false)
......@@ -20,7 +26,6 @@ export function useLogin(callback = noopFn) {
const { nickName: userNick, avatar } = authInfo
const { inviteId } = params
const res = await login({ userNick, avatar, isFollow, inviteId })
if (res?.success) {
setLoginInfo({
...res.data,
......@@ -34,6 +39,8 @@ export function useLogin(callback = noopFn) {
}
}
const { authorized, authInfo } = useAuth()
useEffect(() => {
if (authorized) {
doLogin()
......
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 = {}) {
const [ data, setData ] = useState(null)
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