From fb085d4bb9fb28735ce2fd6d7fbfe9100681ec24 Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Sat, 13 Jan 2024 11:15:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E4=B8=8A=E4=BC=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/popup/popup-site-swiper.less | 0 src/components/popup/popup-site-swiper.tsx | 168 ++++++++++++++++++++ src/pages/index/index.tsx | 42 ++++- src/pages/userInfo/userInfo.tsx | 4 +- src/store/features/global.js | 9 +- src/store/features/userInfo.js | 20 +++ src/utils/Interface.js | 4 +- src/utils/request.js | 8 +- 8 files changed, 242 insertions(+), 13 deletions(-) create mode 100644 src/components/popup/popup-site-swiper.less create mode 100644 src/components/popup/popup-site-swiper.tsx diff --git a/src/components/popup/popup-site-swiper.less b/src/components/popup/popup-site-swiper.less new file mode 100644 index 0000000..e69de29 diff --git a/src/components/popup/popup-site-swiper.tsx b/src/components/popup/popup-site-swiper.tsx new file mode 100644 index 0000000..2eff703 --- /dev/null +++ b/src/components/popup/popup-site-swiper.tsx @@ -0,0 +1,168 @@ +import classnames from "classnames"; +import { Component } from "react"; + +import { + Block, + View, + Image, + Text, + Button, + PageMeta, + Swiper, + SwiperItem, +} from "@tarojs/components"; + +import { Popup } from "@antmjs/vantui"; + +import "./popup.less"; +import "./popup-site-swiper.less"; + +import { go } from "../../utils/traoAPI"; + +/*** props + * isLarge 是否大尺寸 + * isShow 是否显示 + * isClose 右上角关闭图标 + * content 弹窗内容 + * confirmButtonText 确定按钮 + * textAlgin 文本对齐 left right center + * data 数据 + * @confirm 关闭回调 + * ***/ +export default class PopupSiteSwiper extends Component { + constructor(props) { + super(props); + this.state = { + name: "确认组件", + }; + } + + async onLoad() {} + componentDidMount() {} + + componentWillUnmount() {} + + componentDidShow() {} + + componentDidHide() {} + + async initData() {} + + onClose = () => { + this.props.close(); + }; + + onConfirm = () => { + let { type } = this.props; + + // switch (type) { + // case "1": // 未注册 + // go("/pages/register/register"); + // break; + // case "2": // 登录过期 + // go("/pages/login/login"); + // break; + // case "3": // 前端提示-关注公众号 + // break; + // } + this.props.confirm(); + }; + + onClickStop = (e) => { + e.stopPropagation(); + }; + + render() { + let { + title, + content, + confirmButtonText, + textAlgin, + isShow, + isLarge, + // type, + } = this.props; + return ( + + + + + + {/* {title} + + + {content} + + */} + {/* + {welcomeList.map((item, index) => { + return ( + + + + + + + {item.title} + {item.desc} + + + + ); + })} + */} + + + + + + + + ); + } +} diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 150f8bc..d4b7dde 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -8,12 +8,14 @@ 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"; /*** redux end ***/ /** 自定义组件 **/ import AtCalendar from "../../components/calendar"; import PopupPrivacy from "../../components/popup/popup-privacy"; import PopupAlert from "../../components/popup/popup-alert"; +import PopupSiteSwiper from "../../components/popup/popup-site-swiper"; import type CustomTabBar from "../../custom-tab-bar"; import Navbar from "../../components/navbar/navbar"; /** 自定义组件 **/ @@ -24,6 +26,7 @@ import { RefreshWxUserInfo, GetNoReadMessageNum, GetOtherSetting, + GetSitePopupList, } from "../../utils/Interface"; // css引入 @@ -39,6 +42,10 @@ class Index extends Component { super(props); this.state = { isShowPrivacyPopup: false, + isShowSiteSwiper: false, + isNotRegister: false, // 是否未注册 + isDev: false, // 正在开发提示 + sitePopupList: [], // 站点管理列表 // imgUrl: this.app.globalData.imgUrl, userinfo: { mobile: this.props.mobile, @@ -59,9 +66,6 @@ class Index extends Component { info: {}, // 护理推荐点击参与活动的信息 weekinfo: undefined, currentDate: dayjs().format("YYYY-MM-DD"), - - isNotRegister: false, // 是否未注册 - isDev: false, // 正在开发提示 }; } @@ -98,6 +102,7 @@ class Index extends Component { if (mobile) { this.GetNoReadMessageNum(); // 查询是否有消息 this.RefreshWxUserInfo(); + this.GetSitePopupList(); } } } @@ -152,6 +157,15 @@ class Index extends Component { } }; + // 获取站点管理-弹窗列表 1-首页 2-发现模块 3-活动模块 + GetSitePopupList = async () => { + let res = await GetSitePopupList(1); + if (res.data.code === 200) { + // console.log("GetSitePopupList", res); + this.setState({ sitePopupList: res.data.data, isShowSiteSwiper: true }); + } + }; + goRegister() { go("/pages/register/register"); } @@ -218,12 +232,18 @@ class Index extends Component { this.setState({ isDev: false }); }; + closeSiteSwiper = () => { + this.setState({ isShowSiteSwiper: false }); + }; + render() { let { currentDate, + messagecount, + sitePopupList, isShowPrivacyPopup, isNotRegister, - messagecount, + isShowSiteSwiper, isDev, } = this.state; return ( @@ -251,6 +271,17 @@ class Index extends Component { isShow={isShowPrivacyPopup} closePrivacy={this.closePrivacy} /> + @@ -330,5 +361,8 @@ const mapDispatchToProps = (dispatch) => ({ otherSettingRefresh(data) { dispatch(otherSettingRefresh(data)); }, + setIndexFlag(data) { + dispatch(setIndexFlag(data)); + }, }); export default connect(mapStateToProps, mapDispatchToProps)(Index); diff --git a/src/pages/userInfo/userInfo.tsx b/src/pages/userInfo/userInfo.tsx index a7a4f74..d5ffe09 100644 --- a/src/pages/userInfo/userInfo.tsx +++ b/src/pages/userInfo/userInfo.tsx @@ -241,8 +241,8 @@ class UserInfo extends Component { }; onSkip = () => { - go("/pages/instrument/instrument"); - // this.goUser(); + // go("/pages/instrument/instrument"); + this.goUser(); }; pickerChange = (event) => { diff --git a/src/store/features/global.js b/src/store/features/global.js index 5d3166b..c3bd1c1 100644 --- a/src/store/features/global.js +++ b/src/store/features/global.js @@ -8,14 +8,21 @@ const globalReducer = createSlice({ domain: "http://110.41.134.131:8080", // 请求地址 // domain: "http://192.168.10.147:8080", // 请求地址 token: "", + + // 是否首次进入首页 + isShowIndexFlag: false, }, reducers: { setToken(state, { payload }) { // Taro.setStorageSync.setItem("token", payload); state.token = payload; }, + setIndexFlag(state, { payload }) { + // Taro.setStorageSync.setItem("token", payload); + state.isShowIndexFlag = payload; + }, }, }); -export const { setToken } = globalReducer.actions; +export const { setToken, setIndexFlag } = globalReducer.actions; export default globalReducer.reducer; diff --git a/src/store/features/userInfo.js b/src/store/features/userInfo.js index 6125436..8cfe66e 100644 --- a/src/store/features/userInfo.js +++ b/src/store/features/userInfo.js @@ -52,6 +52,26 @@ const userInfoReducer = createSlice({ Taro.setStorageSync("mobile", state.mobile); // Taro.setStorageSync("token", state.token); }, + tokenRefresh(state, { payload }) { + state.id = payload.id || "001"; + state.mobile = payload.mobile || ""; + state.nickname = payload.nickname || ""; + state.headimg = payload.headimg || ""; + state.birthday = payload.birthday || dayjs().format("YYYY-MM-DD"); + state.province = payload.province || ""; + state.provinceId = payload.provinceId || ""; + state.city = payload.city || ""; + state.cityId = payload.cityId || ""; + state.area = payload.area || ""; + state.areaId = payload.areaId || ""; + state.token = payload.token || ""; + state.credit = payload.credit || 0; + state.expireCredit = payload.expireCredit || 0; + state.integralText = payload.integralText || ""; + + Taro.setStorageSync("mobile", state.mobile); + Taro.setStorageSync("token", state.token); + }, }, }); diff --git a/src/utils/Interface.js b/src/utils/Interface.js index 767b8f7..6f9e658 100644 --- a/src/utils/Interface.js +++ b/src/utils/Interface.js @@ -180,7 +180,7 @@ export const GetCloseOfficialAccount = (data) => { }; export const GetSitePopupList = (data) => { - // 站点管理-弹窗列表 + // 站点管理-弹窗列表 1-首页 2-发现模块 3-活动模块 return Ajax({ url: "/hzwx/siteInfo/popup/" + data, data, @@ -196,7 +196,7 @@ export const GetSiteCarousel = (data) => { }); }; export const GetSiteAddTag = (data) => { - // 站点管理-轮播图-添加标签 + // 站点管理-轮播图-添加标签 传值是id return Ajax({ url: "/hzwx/addTag/" + data, data, diff --git a/src/utils/request.js b/src/utils/request.js index a8763b6..b91632f 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -39,7 +39,7 @@ export const Ajax = (params) => { data: params.data, success(res) { if (res.statusCode !== 200) { - if (res.statusCode == 403) { + if (res.statusCode == 401) { Taro.showModal({ title: "提示", content: "登录已过期,请重新登录", @@ -80,7 +80,7 @@ export const Ajax = (params) => { showCancel: false, }).then(() => { reject(res); - if (res.data.code == 403 || res.data.msg === "登录状态已过期") { + if (res.data.code == 401 || res.data.msg === "登录状态已过期") { Taro.setStorageSync("token", null); Taro.reLaunch({ // url: "/pages/login/login", @@ -194,7 +194,7 @@ export const AjaxFormData = (params) => { data: params.data.buffer, success(res) { if (res.statusCode !== 200) { - if (res.statusCode == 403) { + if (res.statusCode == 401) { Taro.showModal({ title: "提示", content: "登录已过期,请重新登录", @@ -229,7 +229,7 @@ export const AjaxFormData = (params) => { showCancel: false, }).then(() => { reject(res); - if (res.data.code == 403 || res.data.msg === "登录状态已过期") { + if (res.data.code == 401 || res.data.msg === "登录状态已过期") { Taro.setStorageSync("token", null); Taro.reLaunch({ url: "/pages/login/login",