Commit 055f9ecb authored by wildfirecode13's avatar wildfirecode13

1

parent 53484277
No preview for this file type
No preview for this file type
This diff is collapsed.
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
"css-loader": "^3.6.0", "css-loader": "^3.6.0",
"duiba-utils": "^1.0.2", "duiba-utils": "^1.0.2",
"fyge-tbmini": "^1.3.1", "fyge-tbmini": "^1.3.1",
"mobx": "^6.0.4",
"mobx-react-lite": "^3.1.6",
"postcss-loader": "^3.0.0", "postcss-loader": "^3.0.0",
"prettier": "^2.0.5", "prettier": "^2.0.5",
"qs": "^6.9.4", "qs": "^6.9.4",
...@@ -28,7 +30,8 @@ ...@@ -28,7 +30,8 @@
"redux-thunk": "^2.3.0", "redux-thunk": "^2.3.0",
"spark-utils": "^0.0.12", "spark-utils": "^0.0.12",
"style-loader": "^1.2.1", "style-loader": "^1.2.1",
"svgaplayerweb": "^2.3.1" "svgaplayerweb": "^2.3.1",
"teddi": "git+ssh://git@gitlab2.dui88.com:wildfirecode13/teddi.git"
}, },
"devDependencies": { "devDependencies": {
"mockjs": "^1.1.0" "mockjs": "^1.1.0"
......
File mode changed from 100644 to 100755
...@@ -7,6 +7,7 @@ import Detail2 from "./pages/detail2/detail2.jsx"; ...@@ -7,6 +7,7 @@ import Detail2 from "./pages/detail2/detail2.jsx";
//此处为spark-cli动态生成 //此处为spark-cli动态生成
import Loading from "./pages/loading/loading.jsx"; import Loading from "./pages/loading/loading.jsx";
import Main3 from "./pages/main3/main3.jsx"; import Main3 from "./pages/main3/main3.jsx";
import { AUPOP, AUP_MBX_STATE } from './pop';
MOCK_STATUS && (require('../mock/index')); MOCK_STATUS && (require('../mock/index'));
MD(); MD();
...@@ -20,6 +21,9 @@ class App extends Component { ...@@ -20,6 +21,9 @@ class App extends Component {
} }
componentDidMount() { componentDidMount() {
// setTime`out(() => {
// Aup.show('PopRule', {}, this)
// }, 1000);`
} }
eventHandler=()=>{ eventHandler=()=>{
...@@ -37,6 +41,7 @@ class App extends Component { ...@@ -37,6 +41,7 @@ class App extends Component {
{page == 'loading' && <Loading data={pagedata} navigateTo={this.navigateTo}></Loading>} {page == 'loading' && <Loading data={pagedata} navigateTo={this.navigateTo}></Loading>}
{page == 'mainpage' && <Main3 data={pagedata} navigateTo={this.navigateTo}></Main3>} {page == 'mainpage' && <Main3 data={pagedata} navigateTo={this.navigateTo}></Main3>}
{page == 'detail' && <Detail2 data={pagedata} navigateTo={this.navigateTo}></Detail2>} {page == 'detail' && <Detail2 data={pagedata} navigateTo={this.navigateTo}></Detail2>}
<AUPOP eventHandler={this.eventHandler} AUPopState={AUP_MBX_STATE} ></AUPOP>
</> </>
); );
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import resList2 from '../../resconfig/resList2'; import resList2 from '../../resconfig/resList2';
import { Aup } from '../../pop';
import './prize.less'; import './prize.less';
class Comprize extends Component { class Comprize extends Component {
constructor(props) { constructor(props) {
...@@ -13,7 +14,7 @@ class Comprize extends Component { ...@@ -13,7 +14,7 @@ class Comprize extends Component {
} }
onCloseCustom = () => { onCloseCustom = () => {
// Aup.clear() Aup.clear()
} }
render() { render() {
......
File mode changed from 100644 to 100755
...@@ -4,7 +4,7 @@ import { Toast } from '@spark/ui'; ...@@ -4,7 +4,7 @@ import { Toast } from '@spark/ui';
import React, { Component } from 'react'; import React, { Component } from 'react';
import dataCenter, { getAPIdata, getHomeInfo, netErrMsg, Role, Store } from '../../dataCenter'; import dataCenter, { getAPIdata, getHomeInfo, netErrMsg, Role, Store } from '../../dataCenter';
import resList from '../../resconfig/resList'; //import API from '../../api'; import resList from '../../resconfig/resList'; //import API from '../../api';
import { debounce } from '../../ui'; import { debounce, Countdown } from "teddi";
import './select.less'; import './select.less';
const startselidx = 1; const startselidx = 1;
......
...@@ -4,9 +4,10 @@ import { Toast } from '@spark/ui'; ...@@ -4,9 +4,10 @@ import { Toast } from '@spark/ui';
import React, { Component } from 'react'; import React, { Component } from 'react';
import API from '../../api'; import API from '../../api';
import { getHomeInfo } from '../../dataCenter'; import { getHomeInfo } from '../../dataCenter';
import { Aup } from '../../pop';
import resList from '../../resconfig/resList'; //import API from '../../api'; import resList from '../../resconfig/resList'; //import API from '../../api';
import { debounce } from '../../ui';
import './sign.less'; import './sign.less';
import { debounce, Countdown } from "teddi";
class Sign extends Component { class Sign extends Component {
constructor(props) { constructor(props) {
...@@ -34,7 +35,7 @@ class Sign extends Component { ...@@ -34,7 +35,7 @@ class Sign extends Component {
getHomeInfo(); getHomeInfo();
if (res.data.type !== 'joyBean') { if (res.data.type !== 'joyBean') {
// Aup.show('PrizeRule', res.data, this); Aup.show('PrizeRule', res.data, this);
} else { } else {
this.props.onClose(); this.props.onClose();
Toast(`恭喜你成功领取${res.data.awardName}`) Toast(`恭喜你成功领取${res.data.awardName}`)
......
...@@ -5,8 +5,8 @@ import React, { Component } from 'react'; ...@@ -5,8 +5,8 @@ import React, { Component } from 'react';
import API from '../../api'; import API from '../../api';
import { getHomeInfo } from '../../dataCenter'; import { getHomeInfo } from '../../dataCenter';
import resList from '../../resconfig/resList'; import resList from '../../resconfig/resList';
import { debounce } from '../../ui';
import './userinfo.less'; import './userinfo.less';
import { debounce, Countdown } from "teddi";
class Userinfo extends Component { class Userinfo extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
......
'use strict'; 'use strict';
import { appID } from 'duiba-utils'; import { appID } from 'duiba-utils';
import React, { Component } from 'react'; import React, { Component } from 'react'; // import { Timer } from 'teddi';
import resList from '../../resconfig/resList'; //import API from '../../api'; import resList from '../../resconfig/resList'; //import API from '../../api';
import API from '../../api'; import API from '../../api';
import './loading.less'; import './loading.less';
import { Aup } from '../../pop';
import dataCenter, { getAPIdata, getHomeInfo, Store } from '../../dataCenter'; import dataCenter, { getAPIdata, getHomeInfo, Store } from '../../dataCenter';
class Loading extends Component { class Loading extends Component {
...@@ -107,7 +108,7 @@ class Loading extends Component { ...@@ -107,7 +108,7 @@ class Loading extends Component {
if (newUser) { if (newUser) {
//新用户,走选择,然后再走引导,引导结束后,走签到 //新用户,走选择,然后再走引导,引导结束后,走签到
// Aup.show('Select', {}, this); Aup.show('Select', {}, this);
isnewUser = 1; isnewUser = 1;
} }
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import resList from '../../resconfig/resList'; //import API from '../../api'; import resList from '../../resconfig/resList'; //import API from '../../api';
import API from '../../api'; import API from '../../api';
import { Aup, AUPOP, AUP_MBX_STATE } from '../../pop';
import './main3.less'; import './main3.less';
import { CanvasWidget } from 'spark-utils'; import { CanvasWidget } from 'spark-utils';
import { Guideact } from '@spark/guideact';//'./bundle';// import { Guideact } from '@spark/guideact';//'./bundle';//
...@@ -11,8 +12,6 @@ import { GDispatcher } from "spark-wrapper-fyge" ...@@ -11,8 +12,6 @@ import { GDispatcher } from "spark-wrapper-fyge"
import dataCenter, { Store } from '../../dataCenter'; import dataCenter, { Store } from '../../dataCenter';
import { getSVGA } from '../../svga'; import { getSVGA } from '../../svga';
import { Toast } from '@spark/ui'; import { Toast } from '@spark/ui';
import ViewCtrl from "../../util/viewCtrl";
import Enum from '../../util/enum';
let _widget; let _widget;
class Main3 extends Component { class Main3 extends Component {
...@@ -33,7 +32,6 @@ class Main3 extends Component { ...@@ -33,7 +32,6 @@ class Main3 extends Component {
setTimeout(() => { setTimeout(() => {
this.setState({rolepop:0}) this.setState({rolepop:0})
}, 3000); }, 3000);
} }
gotoURL=(type)=>{ gotoURL=(type)=>{
...@@ -53,13 +51,12 @@ class Main3 extends Component { ...@@ -53,13 +51,12 @@ class Main3 extends Component {
} }
onClick_userinfo = () => { onClick_userinfo = () => {
// Aup.show('Userinfo', {figureId:this.state.figureId}, this); Aup.show('Userinfo', {figureId:this.state.figureId}, this);
ViewCtrl.showWin(Enum.Com.Userinfo, {figureId:this.state.figureId});
} }
onClick_signBtn = () => { onClick_signBtn = () => {
API.signInfo().then((res) => { API.signInfo().then((res) => {
// Aup.show('Sign', res.data, this); Aup.show('Sign', res.data, this);
}) })
} }
...@@ -73,7 +70,7 @@ class Main3 extends Component { ...@@ -73,7 +70,7 @@ class Main3 extends Component {
onClick_rulebtn = () => { onClick_rulebtn = () => {
// console.log('onClick_rulebtn') // console.log('onClick_rulebtn')
// Aup.show('PopRule', {}, this) Aup.show('PopRule', {}, this)
} }
onclick_jingcai = () => { onclick_jingcai = () => {
...@@ -91,13 +88,11 @@ class Main3 extends Component { ...@@ -91,13 +88,11 @@ class Main3 extends Component {
if( this.props.data &&!this.props.data.isnewUser) { //不是新用户 if( this.props.data &&!this.props.data.isnewUser) { //不是新用户
API.signInfo().then((res)=>{ API.signInfo().then((res)=>{
const {needPopup} =res.data; const {needPopup} =res.data;
if(needPopup) { if(needPopup)
// Aup.show('Sign', res.data, this); Aup.show('Sign', res.data, this);
}
}); });
} }
} }
initEvent() { initEvent() {
GDispatcher.addEventListener(Store.homeinfo, this.freshHomeInfo, this); GDispatcher.addEventListener(Store.homeinfo, this.freshHomeInfo, this);
GDispatcher.addEventListener(Store.needguide, this.changeGuideShow, this); GDispatcher.addEventListener(Store.needguide, this.changeGuideShow, this);
...@@ -150,9 +145,8 @@ class Main3 extends Component { ...@@ -150,9 +145,8 @@ class Main3 extends Component {
dataCenter.setData(Store.needguide, false); dataCenter.setData(Store.needguide, false);
API.signInfo().then((res) => { API.signInfo().then((res) => {
const { needPopup } = res.data; const { needPopup } = res.data;
if (needPopup){ if (needPopup)
// Aup.show('Sign', res.data, this); Aup.show('Sign', res.data, this);
}
}) })
break; break;
......
import React, { Component } from 'react';
import popMap from '../PopMap.js'
import { observer } from 'mobx-react-lite'
import { toJS } from "mobx";
import { Aup } from "../index.js"
import { ConsoleStyleComponents, ConsoleStyleFlagColor } from '../api/tools.js';
import './AUPopMobx.less'
class AUPopMobx extends Component {
constructor (props) {
super(props)
this.state = this.state || {
popArr: []
}
this.auPopRef = React.createRef()
this.closeFlagRef = React.createRef()
}
static getDerivedStateFromProps(nextProprs, preState) {
console.log(`%c AUPopMobx nextProprs is: \n`, ConsoleStyleComponents, nextProprs)
if (nextProprs.popArr.length === 0) {
allowScroll()
} else if (nextProprs.popArr.length && preState.popArr.length == 0) {
disableScroll()
}
return {
popArr: nextProprs.popArr
}
}
closePop = (index) => {
// TODO: not complete
// TODO: inject some animation function in there:
if (!this.state.popArr.length) return
else if (this.state.popArr.length == 1) {
if (this.auPopRef.current) {
this.auPopRef.current.style.transition = `opacity 350ms`
this.auPopRef.current.style.opacity = '0'
this.closeFlagRef.current && (this.closeFlagRef.current.style.display = 'block')
setTimeout(() => {
Aup.close()
this.closeFlagRef.current && (this.closeFlagRef.current.style.display = 'none')
}, 400);
} else {
Aup.close()
this.closeFlagRef.current.style.display = 'none'
}
}
else if (this.state.popArr.length > 1) {
this.closeFlagRef.current && (this.closeFlagRef.current.style.display = 'block')
setTimeout(() => {
Aup.close()
this.closeFlagRef.current && (this.closeFlagRef.current.style.display = 'none')
}, 400);
}
}
render() {
console.log('%c ----------------- AUtest - RENDER RUN FLAG ----------------- ----------------- ----------------- -----------------', ConsoleStyleFlagColor)
const { popArr } = this.state
let Pop = []
popArr.forEach((item, index) => {
const { showPop, popData, fn, ctx } = item
let PItem = popMap.get(showPop)
if(!PItem)console.error(`没有类型为${showPop}的弹窗`)
Pop.push(
<div className={showPop === 'PopLightCard' ? 'compop_content comPop_zoom_from0' : 'compop_content comPop_zoom'}>
<PItem onClose={this.closePop} data={popData} fn={fn} ctx={ctx} type='spot'/>
</div>
)
})
const Com = (popArr.length && popArr[0].showPop) ? (
<div className='compop_back' ref={this.auPopRef}>
<div className='compop_mask'></div>
{/* 关闭-禁止点击 */}
<div ref={this.closeFlagRef} className='compop_transparent'></div>
{Pop.map((It, index) => {
return (
<React.Fragment key={index}>
<div className={(index !== Pop.length - 1) ? 'Fragment-wrapper Fragment-small-opacity' : 'Fragment-wrapper'}>
{(index !== Pop.length - 1) ? <div className="Fragment-wrapper-mask"></div> : null }
{It}
</div>
</React.Fragment>)
})}
</div>
) : null
return (
Com
);
}
}
export const AUPOP = observer(({ AUPopState }) => {
console.log(AUPopState)
return <AUPopMobx popArr={toJS(AUPopState.popArr)}/>
})
const debounce = (fn, wait, immediate = false) => {
let timer
return function () {
if (timer) clearTimeout(timer)
if (immediate) {
// 如果已经执行过,不再执行
var callNow = !timer
timer = setTimeout(() => {
timer = null
}, wait)
if (callNow) {
fn()
}
} else {
timer = setTimeout(() => {
fn()
}, wait)
}
}
}
let top = 0
const disableScroll = debounce(() => {
var top_ = window.scrollY;
// console.log('ScrollScroll disableScroll', top_)
document.body.style.position = "fixed";
document.body.style.overflow = "hidden";
top = top_
document.body.style.top = -top + "px";
}, 300, 1)
const allowScroll = debounce(() => {
// console.log('ScrollScroll allowScroll', top)
document.body.style.top = "0px";
document.body.style.position = "relative";
document.body.style.overflow = "auto";
window.scrollTo(0, top);
}, 300, 1)
.compop_back {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 99;
touch-action: none;
.compop_mask {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .7);
position: absolute;
top: 0;
left: 0;
z-index: -1;
touch-action: none;
}
.compop_transparent {
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0);
position: absolute;
top: 0;
left: 0;
z-index: 9;
touch-action: none;
display: none;
}
}
.pop_mask {
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 100;
position: fixed;
background: transparent;
}
.compop_content {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
right: 0;
left: 0;
z-index: 2;
}
.comPop_close_btn {
position: absolute;
display: block;
z-index: 1;
width: 102px;
height: 102px;
left: calc(49% - (102px / 2));
bottom: -160px;
z-index: 3;
}
.comPop_back_light {
position: absolute;
display: block;
z-index: -1;
width: 883px;
height: 883px;
left: calc(50% - (883px / 2));
top: -200px;
bottom: -144px;
}
.comPop_back_head {
position: absolute;
display: block;
z-index: 2;
width: 567px;
height: 140px;
left: 5px;
top: 20px;
animation: floatAni 3000ms infinite linear;
transform-origin: center center center;
position: relative;
}
@keyframes floatAni {
0% {
transform: skewX(-1deg) skewY(0.8deg) scaleX(1.05) translateY(-30px) rotate(-3deg);
}
25% {
transform: skewX(-0.5deg) skewY(0.3deg) scaleX(1.02) translateY(-20px) rotate(-2deg);
}
50% {
transform: skewX(0deg) skewY(0deg) scaleX(1) translateY(-15px) rotate(-2deg);
}
75% {
transform: skewX(-0.5deg) skewY(0.3deg) scaleX(1.02) translateY(-20px) rotate(-2deg);
}
100% {
transform: skewX(-1deg) skewY(0.8deg) scaleX(1.05) translateY(-30px) rotate(-3deg);
}
}
.comPop_zoom {
transform-origin: center center;
animation: zoom 0.24s linear 0s 1;
}
.comPop_zoom_from0 {
transform-origin: center center;
opacity: 0;
transform: scale(0);
animation: zoomfrom0 0.22s linear 0.44s 1 forwards;
}
.Fragment-wrapper-mask {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: transparent;
z-index: 99;
touch-action: none;
}
.Fragment-small-opacity {
transition: transform 300ms ease-in, opacity 200ms linear !important;
transform: scale(0.5) !important;
opacity: 0 !important;
}
.Fragment-wrapper {
opacity: 1;
transition: transform 200ms ease-out, opacity 200ms linear;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
transform: scale(1);
transform-origin: center center;
}
@keyframes zoom {
0% {
transform: scale(0.75);
}
50% {
transform: scale(1.08)
}
100% {
transform: scale(1)
}
}
@keyframes zoomfrom0 {
0% {
opacity: 0;
transform: scale(0.2);
}
80% {
opacity: 1;
transform: scale(1.12)
}
100% {
opacity: 1;
transform: scale(1)
}
}
.comPop_fadeout {
opacity: 0;
transition: opacity 300ms linear;
}
\ No newline at end of file
'use strict';
import { makeAutoObservable, observable, computed, action, runInAction, autorun, reaction, configure, toJS } from 'mobx'
import { CONSO_START_mark, ConsoleStyleTitle, ConsoFunc } from './api/tools'
// configure({
// useProxies: "never"
// })
class PopState {
nowShow
popArr
constructor() {
this.popArr = []
this.nowShow = arguments[0]
// makeAutoObservable(this)
makeAutoObservable(this, {
nowShow: observable,
popArr: observable,
addPop: action.bound,
changePop: action.bound,
popArrLength: computed
})
}
// 添加一个弹窗
addPop = (data) => {
this.nowShow = data.type
this.popArr.push(data)
// console.log(`${CONSO_START_mark}\n addPop:`, ConsoleStyleTitle, toJS(this.popArr))
}
// 改变数组中的第一个弹窗
changePop = (data) => {
this.nowShow = data.type
this.popArr.push(data)
// console.log(`${CONSO_START_mark}\n changePop:`, ConsoleStyleTitle, toJS(this.popArr))
// this.popArr = [data]
}
// 删除弹窗
delePop = (long) => {
this.popArr.splice(this.popArr.length - long, long)
if (this.popArr.length) this.nowShow = this.popArr[this.popArr.length - 1].type
}
// 清空 弹窗
clearPop = () => {
this.popArr = []
}
get popArrLength () {
// console.log(`${CONSO_START_mark}\n this.popArr:`, ConsoleStyleTitle, toJS(this.popArr))
return this.popArr.length
}
}
export const AUP_MBX_STATE = new PopState('init')
autorun(() => {
let tempLastComPop = toJS(AUP_MBX_STATE.popArr)
let last = tempLastComPop.length ? tempLastComPop[tempLastComPop.length - 1] : undefined
console.log(`${CONSO_START_mark}\n AUTORUN::: the last Pop`, ConsoleStyleTitle, last)
return last
})
// ready code for mobx can't use
// author: 沈阳楠
// export const EventDispatcher = (function () {
// function EventDispatcher() {
// this._events = {}
// }
// EventDispatcher.ins = function () {
// if (EventDispatcher.ins == null) {
// EventDispatcher.ins = new EventDispatcher()
// }
// return EventDispatcher.ins
// }()
// EventDispatcher.prototype.dispatch = function (eventName, data) {
// for (let i in this._events[eventName]) {
// var _event = this._events[eventName][i]
// _event.callback.call(_event.target.context, data)
// }
// }
// EventDispatcher.prototype.addEventListener = function (eventName, callback, target) {
// var _events = this._events[eventName]
// if (_events) {
// _events.push({
// callback: callback,
// target: target
// })
// } else {
// this._events[eventName] = [{
// callback: callback,
// target: target
// }]
// }
// }
// EventDispatcher.prototype.removeEventListener = function (eventName, callback, target) {
// for (let i = this._events[eventName].length - 1; i >= 0; i--) {
// var _event = this._events[eventName][i]
// if (_event.callback == callback && _event.target == target) {
// this._events[eventName].splice(i, 1)
// }
// }
// }
// EventDispatcher.prototype.removeAllEventListener = function (eventName) {
// this._events[eventName] = null
// }
// return EventDispatcher
// }())
// EventDispatcher.ins.addEventListener("aaaa", this.isStart, this)
// EventDispatcher.ins.addEventListener("aaaa", () => {
// EventDispatcher.ins.removeEventListener("aaaa", this.isStart, this)
// }, this)
// EventDispatcher.ins.dispatch("aaaa", 3213123)
\ No newline at end of file
'use strict';
import { AUP_MBX_STATE } from '../AUState'
import { CONSO_START_mark, ConsoleStyleTitle } from './tools'
/**
* 清空页面弹窗
*/
export const clear = () => {
if (AUP_MBX_STATE.popArrLength === 0) return
else AUP_MBX_STATE.clearPop()
}
'use strict';
import { AUP_MBX_STATE } from '../AUState'
import { CONSO_START_mark, ConsoleStyleTitle } from './tools'
/**
* 关闭弹窗
* @param {Number} length 关闭的数量
*/
export const close = (length = 1) => {
if (AUP_MBX_STATE.popArrLength === 0) {
console.warn(`弹窗数组无储存的弹窗, \n 勿重复调用 close()`)
return
}
else if (AUP_MBX_STATE.popArrLength >= length) {
AUP_MBX_STATE.delePop(length)
}
else {
console.warn(`传入的关闭弹窗数量 ${length},大于弹窗数组所储存的数量 ${AUP_MBX_STATE.popArrLength}, \n 执行清空操作`)
AUP_MBX_STATE.clearPop()
}
}
'use strict';
import { AUP_MBX_STATE } from '../AUState'
import { CONSO_START_mark, ConsoleStyleTitle } from './tools'
/**
* 显示弹窗
* @param {String} type 弹窗类型
* @param {Object} data 传递数据
* @param {Fucntion} fn 定义更多 需要执行的方法 (context 来自父组件)
* @param {Context} ctx 传递 父组件 Context
*/
export const cover = (type, data = {}, option = null) => {
const pData = {
showPop: type,
popData: data || null,
fn: fn || null,
ctx: ctx || null
}
// console.log(`${CONSO_START_mark}\n AupopShow data is:`, ConsoleStyleTitle, data)
// 覆盖弹窗
if (type && AUP_MBX_STATE.popArrLength) AUP_MBX_STATE.addPop(pData)
// 出现弹窗 - ps: 首个弹窗
else AUP_MBX_STATE.addPop(pData)
}
'use strict';
import { AUP_MBX_STATE } from '../AUState'
import { CONSO_START_mark, ConsoleStyleTitle } from './tools'
/**
* 获取弹窗数组
*/
export const getArr = () => {
return new Promise((resolve, reject) => {
let popArrTmp = deepCopy(AUP_MBX_STATE.popArr)
resolve(popArrTmp)
})
}
function deepCopy(source){
if (typeof source != "object") {
return source
}
if (source == null) {
return source
}
var newObj = source.constructor === Array ? [] : {} //开辟一块新的内存空间
for (var i in source) {
newObj[i] = deepCopy(source[i])
}
return newObj
}
// IntersectionObserver
\ No newline at end of file
export { show } from './show'
export { cover } from './cover'
export { close } from './close'
export { clear } from './clear'
export { getArr } from './getArr'
\ No newline at end of file
'use strict';
import { AUP_MBX_STATE } from '../AUState'
import { CONSO_START_mark, ConsoleStyleTitle } from './tools'
/**
* 显示弹窗
* @param {String} type 弹窗类型
* @param {Object} data 传递数据
* @param {Fucntion} fn 定义更多 需要执行的方法 (context 来自父组件)
* @param {Context} ctx 传递 父组件 Context
*/
export const show = (type, data = {}, ctx, fn) => {
const pData = {
showPop: type,
popData: data || null,
fn: fn || null,
ctx: ctx || null
}
// console.log(`${CONSO_START_mark}\n AupopShow data is:`, ConsoleStyleTitle, data)
// 添加弹窗 没有弹窗
if (type && !AUP_MBX_STATE.popArrLength) AUP_MBX_STATE.addPop(pData)
// 替换弹窗
else if (type && AUP_MBX_STATE.popArrLength) AUP_MBX_STATE.changePop(pData)
}
export function ConsoFunc() {
console.log(
CONSO_START_mark, ConsoleStyleTitle,
...arguments
)
// console.log(END_mark, ConsoleStyleDetail)
}
export const ConsoleStyleTitle = [
'color: #94c902',
'font-size: 12px',
'font-weight: 500',
'text-shadow: 1px 1px rgba(200, 200, 200, 0.2)',
].join(';')
export const ConsoleStyleDetail = [
'color: #94c902',
'font-size: 8px',
'font-weight: 200'
].join(';')
export const ConsoleStyleComponents = [
'color: #a591ff',
'font-size: 12px',
'font-weight: 400'
].join(';')
export const ConsoleStyleFlagColor = [
'color: #fda300',
'font-size: 6px',
'font-weight: 900'
].join(';')
export const CONSO_END_mark = `%c end --------\n`
export const CONSO_START_mark = `%c------- ~ (๑• . •๑) ~ ------- AUPOP -------- \n`
\ No newline at end of file
export * as Aup from './api'
export { AUP_MBX_STATE } from './AUState'
export { AUPOP } from './AUPopMobx/AUPopMobx.jsx'
\ No newline at end of file
File mode changed from 100644 to 100755
/**
* 防连点
* @param fn 点击处理方法
* @param wait 等待时间,单位毫秒,默认2000
*/
export const debounce = (fn, wait=2000, immediate = true) => {
let timer;
return function () {
if (timer) clearTimeout(timer)
if (immediate) {
// 如果已经执行过,不再执行
var callNow = !timer
timer = setTimeout(() => {
timer = null
}, wait)
if (callNow) {
fn()
}
} else {
timer = setTimeout(() => {
fn()
}, wait)
}
}
}
\ No newline at end of file
import Userinfo from "../components/userinfo/userinfo.jsx";
// import Comtask from '../components/comtask/comtask.jsx';
// import ComconfirmExchange from '../components/comconfirmExcahnge/comconfirmExcahnge.jsx';
// import ComExchangesuccess from '../components/comexchangesuccess/comexchangesuccess.jsx';
const { default: Enum } = require("./enum");
let comMap = new Map();
comMap.set(Enum.Com.Userinfo, Userinfo);
// comMap.set(Enum.Com.comtask, Comtask);
// comMap.set(Enum.Com.comconfirmExchange, ComconfirmExchange);
// comMap.set(Enum.Com.comExchangesuccess, ComExchangesuccess);
const config = {
comMap:comMap,
netError:"网络异常,请稍后重试"
}
export default config
\ No newline at end of file
const Enum = {
//页面
Page: {
// 宠物详情页
Pagepet: 1001,
// 活动页
PageIndex:1002,
// loading页面
PageLoading:1003,
// 宠物选择页
PageChoose:1004,
// 兑换订单页
Pageexchangeorder:1005,
//兑换列表页
Pageexchangegoodslist:1006
},
//弹窗
Com: {
//toast
toast: 2000,
comshopmall:2001,
comtask:2002,
comconfirmExchange:2003,
comExchangesuccess:2004,
Userinfo:2005,
},
Store:{
}
}
export default Enum;
import React from 'react';
import ReactDOM from "react-dom";
import config from './config';
const ViewCtrl = {
/**控制显示隐藏,name:节点的类名,value为布尔值 */
changeVisible: (name, value) => {
let node;
node = document.getElementsByClassName(name)[0]
if (value == true) {
node.style.display = ''
} else if (value == false) {
node.style.display = 'none'
}
},
// clickZoom:(className)=>{
// let node;
// node = document.getElementsByClassName(className)[0];
// if(node){
// node.style = "transform-origin:50% 50% 0px";
// new TWEEN.Tween(node)
// // .to({node.})
// }
// },
/**弹出弹窗 */
showWin: (enumComKey, data = {},call) => {
let T = config.comMap.get(enumComKey)
var m = document.createElement('div');
m.className = "popcontainer"
// m.addEventListener()
document.body.appendChild(m);
m.addEventListener('click',(e)=>{
// console.log(e.target.className,'mengceng e');
if(e.target.className.trim() == 'popcontainer'){
document.body.removeChild(m);
}
},false);
/**
* @param {function} cb
*/
const closeWin = (cb) => {
document.body.removeChild(m);
if (typeof cb == 'function') {
try {
cb()
} catch (error) {
console.log(error)
}
}
}
T = <T closeWin={closeWin} data={data} call={call} />
ReactDOM.render(T, m);
},
/**刷新页面 */
flushPage: () => {
let event = new Event("flushPage");
document.dispatchEvent(event)
},
/**切换页面 */
// changePage: (enumPageKey = -1) => {
// // if(enumPageKey == Enum.Page.Pageindex){
// // document.dispatchEvent(new Event("remove"))
// // }
// let event = new CustomEvent("changePage", { detail: { id: enumPageKey } });
// document.dispatchEvent(event)
// }
changePage: (enumPageKey = -1,data) => {
let event = new CustomEvent("changePage", { detail: { id: enumPageKey,data:data } });
document.dispatchEvent(event)
}
}
export default ViewCtrl
\ No newline at end of file
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