From 402c519c3c87518c8fb2183cc801d151b8d54eb2 Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Sat, 13 Jan 2024 13:14:46 +0800 Subject: [PATCH] . --- src/components/popup/fade.css | 22 +++ src/components/popup/popup-site-swiper.less | 6 + src/components/popup/popup-site-swiper.tsx | 146 ++++++++++-------- src/components/popup/popup.less | 3 + src/pages/index/index.tsx | 44 +++++- src/pages/initiate/initiate.tsx | 1 - .../features/{global.js => globalStore.js} | 8 +- src/store/index.js | 4 +- src/utils/request.js | 2 +- 9 files changed, 158 insertions(+), 78 deletions(-) create mode 100644 src/components/popup/fade.css rename src/store/features/{global.js => globalStore.js} (75%) diff --git a/src/components/popup/fade.css b/src/components/popup/fade.css new file mode 100644 index 0000000..7820930 --- /dev/null +++ b/src/components/popup/fade.css @@ -0,0 +1,22 @@ +.FadeOutFrame { + opacity: 1; +} +.FadeOutFrame.fadeout { + -webkit-transition: all 1.5s; + -moz-transition: all 1.5s; + -ms-transition: all 1.5s; + -o-transition: all 1.5s; + transition: all 1.5s; + opacity: 0; +} +.FadeInFrame { + opacity: 0; +} +.FadeInFrame.fadein { + -webkit-transition: all 1.5s; + -moz-transition: all 1.5s; + -ms-transition: all 1.5s; + -o-transition: all 1.5s; + transition: all 1.5s; + opacity: 1; +} diff --git a/src/components/popup/popup-site-swiper.less b/src/components/popup/popup-site-swiper.less index e69de29..15e9059 100644 --- a/src/components/popup/popup-site-swiper.less +++ b/src/components/popup/popup-site-swiper.less @@ -0,0 +1,6 @@ +.site-popup-content-box { + margin: 0; +} +.van-popup { + background-color: transparent; +} diff --git a/src/components/popup/popup-site-swiper.tsx b/src/components/popup/popup-site-swiper.tsx index 2eff703..e3411e2 100644 --- a/src/components/popup/popup-site-swiper.tsx +++ b/src/components/popup/popup-site-swiper.tsx @@ -16,6 +16,7 @@ import { Popup } from "@antmjs/vantui"; import "./popup.less"; import "./popup-site-swiper.less"; +import "./fade.css"; import { go } from "../../utils/traoAPI"; @@ -34,6 +35,9 @@ export default class PopupSiteSwiper extends Component { super(props); this.state = { name: "确认组件", + current: 0, + toRight: false, + isClick: false, }; } @@ -46,7 +50,13 @@ export default class PopupSiteSwiper extends Component { componentDidHide() {} - async initData() {} + initData = () => { + console.log("this.props.siteData", this.props.siteData); + if (this.props.siteData) { + let arr = JSON.parse(JSON.stringify(this.props.siteData)); + this.setState({ siteList: arr }); + } + }; onClose = () => { this.props.close(); @@ -72,16 +82,45 @@ export default class PopupSiteSwiper extends Component { e.stopPropagation(); }; + onChange(event) { + const current = event.detail.current; + const { current: curCurrent } = this.state; + const { siteData } = this.props; + if (curCurrent + 2 === siteData.length && current + 1 === siteData.length) { + this.setState({ toRight: true }); + } + this.setState({ current }); + } + onClickSwiperItem() { + const { current } = this.state; + const { siteData } = this.props; + if (current < siteData.length - 1) { + this.setState({ + current: current + 1, + isClick: true, + }); + } else { + // this.toHomePage(); + } + } + onFinish(event) { + const { current } = event.detail; + const { toRight, isClick } = this.state; + const { siteData } = this.props; + if (current === siteData.length - 1) { + if (toRight || isClick) { + this.setState({ toRight: false, isClick: false }); + } else { + // this.toHomePage(); + } + } + } + render() { - let { - title, - content, - confirmButtonText, - textAlgin, - isShow, - isLarge, - // type, - } = this.props; + let { confirmButtonText, isShow, siteData } = this.props; + let { current } = this.state; + + console.log("siteData", siteData); return ( @@ -96,70 +135,51 @@ export default class PopupSiteSwiper extends Component { className="at-icon at-icon-close common-close" onClick={this.onClose} > - - {/* {title} - - + + - {content} - - */} - {/* - {welcomeList.map((item, index) => { - return ( - - { + return ( + - + - - {item.title} - {item.desc} - - - - ); - })} - */} + + ); + })} + + - + {/* - + */} diff --git a/src/components/popup/popup.less b/src/components/popup/popup.less index a95c868..1dc3d51 100644 --- a/src/components/popup/popup.less +++ b/src/components/popup/popup.less @@ -5,6 +5,9 @@ .large { width: 670rpx; } +.middle { + width: 580rpx; +} .common-box { padding: 38rpx 30rpx; diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index d4b7dde..24da325 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -8,7 +8,7 @@ import { Block, View, Text, Image, PageMeta, Button } from "@tarojs/components"; import { connect } from "react-redux"; import { userRefresh } from "../../store/features/userInfo"; import { otherSettingRefresh } from "../../store/features/otherSetting"; -import { setIndexFlag } from "../../store/features/global"; +import { setIndexFlag } from "../../store/features/globalStore"; /*** redux end ***/ /** 自定义组件 **/ @@ -32,7 +32,7 @@ import { // css引入 import "taro-ui/rn/style/components/calendar.scss"; import "./index.less"; -import { go } from "../../utils/traoAPI"; +import { go, msg } from "../../utils/traoAPI"; // PropsWithChildren class Index extends Component { @@ -41,6 +41,7 @@ class Index extends Component { constructor(props) { super(props); this.state = { + isShowIndexFlag: this.props.isShowIndexFlag, isShowPrivacyPopup: false, isShowSiteSwiper: false, isNotRegister: false, // 是否未注册 @@ -102,7 +103,13 @@ class Index extends Component { if (mobile) { this.GetNoReadMessageNum(); // 查询是否有消息 this.RefreshWxUserInfo(); + this.GetSitePopupList(); + // if (!this.state.isShowIndexFlag) { + // // 仅初次进入首页运行 + // this.GetSitePopupList(); + // this.props.setIndexFlag(true); + // } } } } @@ -159,13 +166,37 @@ class Index extends Component { // 获取站点管理-弹窗列表 1-首页 2-发现模块 3-活动模块 GetSitePopupList = async () => { + this.intData(); + // return; let res = await GetSitePopupList(1); if (res.data.code === 200) { // console.log("GetSitePopupList", res); - this.setState({ sitePopupList: res.data.data, isShowSiteSwiper: true }); + if (res.data.data) { + this.setState({ sitePopupList: res.data.data, isShowSiteSwiper: true }); + } else { + msg("暂无数据"); + } } }; + async intData() { + let MpSplashDetail_type1 = + Taro.getStorageSync("MpSplashDetail_type1") || undefined; + if (MpSplashDetail_type1) { + let detail = JSON.parse(MpSplashDetail_type1); + let list = detail.filter((item: any) => item.fileSuffix === "images"); + let welcomeList = list.map((item) => { + return { + image: item.filePath, + title: item.title, + desc: item.content, + }; + }); + console.log("welcomeList", welcomeList); + this.setState({ sitePopupList: welcomeList, isShowSiteSwiper: true }); + } + } + goRegister() { go("/pages/register/register"); } @@ -273,12 +304,10 @@ class Index extends Component { /> @@ -353,6 +382,7 @@ class Index extends Component { const mapStateToProps = (state) => ({ background: state.navigation.background, mobile: state.userInfo.mobile, + isShowIndexFlag: state.globalStore.isShowIndexFlag, }); const mapDispatchToProps = (dispatch) => ({ userRefresh(data) { diff --git a/src/pages/initiate/initiate.tsx b/src/pages/initiate/initiate.tsx index 59e25ab..51b7620 100644 --- a/src/pages/initiate/initiate.tsx +++ b/src/pages/initiate/initiate.tsx @@ -192,7 +192,6 @@ class Initiate extends Component { const mapStateToProps = (state) => ({ mobile: state.userInfo.mobile, - token: state.global.token, }); const mapDispatchToProps = (dispatch) => ({ userRefresh(value) { diff --git a/src/store/features/global.js b/src/store/features/globalStore.js similarity index 75% rename from src/store/features/global.js rename to src/store/features/globalStore.js index c3bd1c1..420b273 100644 --- a/src/store/features/global.js +++ b/src/store/features/globalStore.js @@ -2,8 +2,8 @@ import Taro from "@tarojs/taro"; import { createSlice } from "@reduxjs/toolkit"; // 全局变量 -const globalReducer = createSlice({ - name: "global", // store的名字 +const globalStoreReducer = createSlice({ + name: "globalStore", // store的名字 initialState: { domain: "http://110.41.134.131:8080", // 请求地址 // domain: "http://192.168.10.147:8080", // 请求地址 @@ -24,5 +24,5 @@ const globalReducer = createSlice({ }, }); -export const { setToken, setIndexFlag } = globalReducer.actions; -export default globalReducer.reducer; +export const { setToken, setIndexFlag } = globalStoreReducer.actions; +export default globalStoreReducer.reducer; diff --git a/src/store/index.js b/src/store/index.js index d016205..1f3c00f 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -3,7 +3,7 @@ import { configureStore } from "@reduxjs/toolkit"; import counterReducer from "./features/counter"; import navigationReducer from "./features/navigation"; import userInfoReducer from "./features/userInfo"; -import globalReducer from "./features/global"; +import globalStoreReducer from "./features/globalStore"; import otherSettingReducer from "./features/otherSetting"; const store = configureStore({ @@ -12,7 +12,7 @@ const store = configureStore({ counter: counterReducer, navigation: navigationReducer, userInfo: userInfoReducer, - global: globalReducer, + globalStore: globalStoreReducer, otherSetting: otherSettingReducer, }, }); diff --git a/src/utils/request.js b/src/utils/request.js index b91632f..5053841 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -5,7 +5,7 @@ import Taro from "@tarojs/taro"; import formdata from "./wxFormdata/formData"; import store from "../store"; -const global = store.getState().global; +const global = store.getState().globalStore; const global_requestUrlList = []; // 全局:正在请求的url地址,防止多次点击