diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index ea135ea..d374a61 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -7,6 +7,7 @@ import { Block, View, Text, Image, PageMeta, Button } from "@tarojs/components"; /*** redux ***/ import { connect } from "react-redux"; import { userRefresh } from "../../store/features/userInfo"; +import { otherSettingRefresh } from "../../store/features/otherSetting"; /*** redux end ***/ /** 自定义组件 **/ @@ -19,7 +20,11 @@ import Navbar from "../../components/navbar/navbar"; import { Toast } from "@antmjs/vantui"; -import { RefreshWxUserInfo, GetNoReadMessageNum } from "../../utils/Interface"; +import { + RefreshWxUserInfo, + GetNoReadMessageNum, + GetOtherSetting, +} from "../../utils/Interface"; // css引入 import "taro-ui/rn/style/components/calendar.scss"; @@ -87,6 +92,7 @@ class Index extends Component { const isFirst = Taro.getStorageSync("isWelcome"); if (isFirst) { this.checkShowPrivacyPopup(); + this.GetOtherSetting(); // 获取小程序设置:商城地址和版本 this.GetNoReadMessageNum(); // 查询是否有消息 this.RefreshWxUserInfo(); } @@ -125,6 +131,7 @@ class Index extends Component { } }; + // 获取消息数量 GetNoReadMessageNum = async () => { let res = await GetNoReadMessageNum(); if (res.data.code === 200) { @@ -133,6 +140,14 @@ class Index extends Component { } }; + // 获取小程序设置 + GetOtherSetting = async () => { + let res = await GetOtherSetting(); + if (res.data.code === 200) { + this.props.otherSettingRefresh(res.data.data); + } + }; + goRegister() { go("/pages/register/register"); } @@ -310,5 +325,8 @@ const mapDispatchToProps = (dispatch) => ({ userRefresh(data) { dispatch(userRefresh(data)); }, + otherSettingRefresh(data) { + dispatch(otherSettingRefresh(data)); + }, }); export default connect(mapStateToProps, mapDispatchToProps)(Index); diff --git a/src/store/features/otherSetting.js b/src/store/features/otherSetting.js new file mode 100644 index 0000000..a233625 --- /dev/null +++ b/src/store/features/otherSetting.js @@ -0,0 +1,26 @@ +import Taro from "@tarojs/taro"; +import dayjs from "dayjs"; +import { createSlice } from "@reduxjs/toolkit"; + +const otherSettingReducer = createSlice({ + name: "otherSetting", // store的名字 + initialState: { + id: "", + skipAppid: "", // 跳转商城id + skipPath: "", // 跳转商城地址 + sysVersion: "", // 小程序系统版本 + status: "", // 状态 + }, + reducers: { + otherSettingRefresh(state, { payload }) { + state.id = payload.id || ""; + state.skipAppid = payload.skipAppid || ""; + state.skipPath = payload.skipPath || ""; + state.sysVersion = payload.sysVersion || 0; + state.status = payload.status || ""; + }, + }, +}); + +export const { otherSettingRefresh } = otherSettingReducer.actions; +export default otherSettingReducer.reducer; diff --git a/src/utils/Interface.js b/src/utils/Interface.js index 5d9d22a..fa4428e 100644 --- a/src/utils/Interface.js +++ b/src/utils/Interface.js @@ -6,6 +6,7 @@ const paramsToUrlQueryString = (data) => { return "?" + new URLSearchParams(Object.entries(data)).toString(); }; +// 用户相关 export const WCUserLogin = (data) => { //登录 return Ajax({ @@ -15,7 +16,6 @@ export const WCUserLogin = (data) => { method: "POST", }); }; - export const GetAboutUs = (data) => { //获取用户信息接口 return Ajax({ @@ -24,7 +24,6 @@ export const GetAboutUs = (data) => { method: "get", }); }; - export const UpdateUser = (data) => { // 更新用户信息 return AjaxFormData({ @@ -33,7 +32,6 @@ export const UpdateUser = (data) => { method: "post", }); }; - export const RefreshWxUserInfo = (data) => { // 刷新用户信息 return Ajax({ @@ -42,7 +40,6 @@ export const RefreshWxUserInfo = (data) => { method: "get", }); }; - export const GetProvince = (data) => { // 获取全部省份 return Ajax({ @@ -51,7 +48,6 @@ export const GetProvince = (data) => { method: "get", }); }; - export const GetAreaListByPid = (data) => { // 获取全部省份 ?pid=xxx return Ajax({ @@ -60,20 +56,6 @@ export const GetAreaListByPid = (data) => { method: "get", }); }; - -/** - * 用户注册手机号 - * @param data - * @constructor - */ -export const UserInfoRegister = (data) => { - return Ajax({ - url: "/Api/UserInfoRegister", - data, - method: "POST", - }); -}; - export const GetUserMobile = (data = { code: "" }) => { if (!data.code) { data.code = Taro.getStorageSync("token") || ""; @@ -86,6 +68,7 @@ export const GetUserMobile = (data = { code: "" }) => { }); }; +// 获取平台设置 export const getAboutUs = (data) => { //关于我们 return Ajax({ @@ -93,7 +76,6 @@ export const getAboutUs = (data) => { data, }); }; - export const getPrivacyAgreement = (data) => { //用户隐私协议获取 return Ajax({ @@ -102,7 +84,14 @@ export const getPrivacyAgreement = (data) => { method: "get", }); }; - +export const GetOtherSetting = (data) => { + // 获取其他设置 + return Ajax({ + url: "/hzwx/setting/getOtherSetting", + data, + method: "get", + }); +}; export const getContactWorker = (data) => { // 联系客服 return Ajax({ @@ -111,9 +100,8 @@ export const getContactWorker = (data) => { method: "get", }); }; - export const SaveMessage = (data) => { - // 联系客服 + // 联系客服-保存信息 return Ajax({ url: "/hzwx/api/leaveMessage/saveMessage", data, @@ -121,6 +109,7 @@ export const SaveMessage = (data) => { }); }; +// 消息页 export const GetNoReadMessageNum = (data) => { // 查询是否有消息未读 return Ajax({