diff --git a/src/components/calendar/controller/index.tsx b/src/components/calendar/controller/index.tsx index b2015b1..82b9a47 100644 --- a/src/components/calendar/controller/index.tsx +++ b/src/components/calendar/controller/index.tsx @@ -1,8 +1,10 @@ import classnames from "classnames"; +import Taro from "@tarojs/taro"; import dayjs, { Dayjs } from "dayjs"; import React from "react"; import { Text, View, Block } from "@tarojs/components"; import { DatetimePicker, Popup } from "@antmjs/vantui"; +import _ from "lodash"; import { AtCalendarControllerProps, @@ -11,13 +13,16 @@ import { import "./index.less"; +let _currentDate = 0; + export default class AtCalendarController extends React.Component { public constructor(props: any) { super(props); this.state = { showDatePicker: false, selectDate: 0, - curDate: 0, + curDate: dayjs(this.props.currentDate).valueOf(), + tempDate: 0, }; } @@ -26,7 +31,7 @@ export default class AtCalendarController extends React.Component { }; onInput = (e) => { - this.setState({ curDate: e.detail }); + _currentDate = e.detail; }; onClickStop = (e) => { @@ -34,8 +39,7 @@ export default class AtCalendarController extends React.Component { }; onSelectDate = () => { - let { curDate } = this.state; - this.props.onSelectDate(curDate); + this.props.onSelectDate(_currentDate); this.onPopupClose(); }; @@ -43,6 +47,10 @@ export default class AtCalendarController extends React.Component { this.setState({ showDatePicker: false }); }; + onConfirm(e) { + console.log("confirm", e); + } + public render(): JSX.Element { const { generateDate, @@ -70,7 +78,9 @@ export default class AtCalendarController extends React.Component { ? dayjsMaxDate.format("YYYY-MM") : ""; - let { showDatePicker, selectDate, curDate } = this.state; + let { showDatePicker, curDate } = this.state; + + _currentDate = curDate; return ( @@ -127,9 +137,9 @@ export default class AtCalendarController extends React.Component { 确定 diff --git a/src/components/popup/popup-privacy.tsx b/src/components/popup/popup-privacy.tsx index 7a9c94b..0795904 100644 --- a/src/components/popup/popup-privacy.tsx +++ b/src/components/popup/popup-privacy.tsx @@ -60,7 +60,7 @@ export default class PopupPrivacy extends Component { }); }; handleAgreePrivacyAuthorization = (event) => { - Taro.setStorageSync("isPrivacyPopup", "true"); + // Taro.setStorageSync("isPrivacyPopup", "true"); this.props.closePrivacy(); // 通知父组件关闭 }; diff --git a/src/components/popup/popup.less b/src/components/popup/popup.less index a61dccb..21b3e92 100644 --- a/src/components/popup/popup.less +++ b/src/components/popup/popup.less @@ -70,7 +70,7 @@ } .common-popup-btn2:first-child { - margin-left: 22rpx; + margin-right: 22rpx; background-color: transparent; } diff --git a/src/pages/about/about.tsx b/src/pages/about/about.tsx index 72e9004..0cf886d 100644 --- a/src/pages/about/about.tsx +++ b/src/pages/about/about.tsx @@ -34,12 +34,10 @@ export default class About extends Component { // this.setState({ version: res.data.data.value }); // } const accountInfo = Taro.getAccountInfoSync(); - console.log("accountInfo", accountInfo); - if (accountInfo?.miniProgram?.version) { - this.setState({ - version: accountInfo?.miniProgram?.version || "暂无", - }); - } + this.setState({ + version: accountInfo?.miniProgram?.version || "开发版", + // accountInfo?.miniProgram?.envVersion, + }); } render() { diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index e0215a8..741f641 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -31,7 +31,6 @@ import Navbar from "../../components/navbar/navbar"; import { RefreshWxUserInfo, GetNoReadMessageNum, - GetOtherSetting, GetSitePopupList, GetSiteCarousel, GetSiteAddTag, @@ -106,48 +105,51 @@ class Index extends Component { showInit() { const isFirst = Taro.getStorageSync("isWelcome"); - const mobile = Taro.getStorageSync("mobile"); if (isFirst) { this.checkShowPrivacyPopup(); - this.GetSitePopupList(); - this.GetSiteCarousel(); - // this.GetOtherSetting(); // 获取小程序设置:商城地址和版本 - - if (mobile) { - this.GetNoReadMessageNum(); // 查询是否有消息 - // this.RefreshWxUserInfo(); - - // if (!this.state.isShowIndexFlag) { - // // 仅初次进入首页运行 - // this.GetSitePopupList(); - // this.props.setIndexFlag(true); - // } - } } } // 检测是否弹出隐私协议 checkShowPrivacyPopup() { - const isPrivacy = Taro.getStorageSync("isPrivacy"); - if (isPrivacy !== "true") { - Taro.getPrivacySetting({ - success: (res) => { - // console.log("检测是否弹出隐私协议", res); // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' } - if (res.needAuthorization) { - // 需要弹出隐私协议 - const isPrivacyPopup = Taro.getStorageSync("isPrivacyPopup"); - if (!isPrivacyPopup) { - // 隐私确认弹窗 - this.setState({ isShowPrivacyPopup: true }); - Taro.setStorageSync("isPrivacy", "true"); - } - } else { - // 用户已经同意过隐私协议,所以不需要再弹出隐私协议,也能调用隐私接口 - } - }, - fail: () => {}, - complete: () => {}, - }); + Taro.getPrivacySetting({ + success: (res) => { + // console.log("检测是否弹出隐私协议", res); // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' } + if (res.needAuthorization) { + this.setState({ isShowPrivacyPopup: true }); + // Taro.setStorageSync("isPrivacy", "true"); + // 需要弹出隐私协议 + // const isPrivacyPopup = Taro.getStorageSync("isPrivacyPopup"); + // if (!isPrivacyPopup) { + // // 隐私确认弹窗 + // this.setState({ isShowPrivacyPopup: true }); + // Taro.setStorageSync("isPrivacy", "true"); + // } + } else { + // 用户已经同意过隐私协议,所以不需要再弹出隐私协议,也能调用隐私接口 + this.initData(); + } + }, + fail: () => {}, + complete: () => { + // 授权完成运行页面初始化 + }, + }); + } + // 页面初始化 + initData() { + const mobile = Taro.getStorageSync("mobile"); + this.GetSitePopupList(); + this.GetSiteCarousel(); + + if (mobile) { + this.GetNoReadMessageNum(); // 查询是否有消息 + + // if (!this.state.isShowIndexFlag) { + // // 仅初次进入首页运行 + // this.GetSitePopupList(); + // this.props.setIndexFlag(true); + // } } } @@ -168,14 +170,6 @@ class Index extends Component { } }; - // 获取小程序设置 - GetOtherSetting = async () => { - let res = await GetOtherSetting(); - if (res.data.code === 200) { - this.props.otherSettingRefresh(res.data.data); - } - }; - // 获取站点管理-弹窗列表 1-首页 2-发现模块 3-活动模块 GetSitePopupList = async () => { let res = await GetSitePopupList(1); @@ -242,6 +236,7 @@ class Index extends Component { closePrivacy = () => { this.setState({ isShowPrivacyPopup: false }); + this.initData(); }; closeAlert = () => { @@ -562,9 +557,6 @@ const mapDispatchToProps = (dispatch) => ({ userRefresh(data) { dispatch(userRefresh(data)); }, - otherSettingRefresh(data) { - dispatch(otherSettingRefresh(data)); - }, setIndexFlag(data) { dispatch(setIndexFlag(data)); }, diff --git a/src/pages/initiate/initiate.tsx b/src/pages/initiate/initiate.tsx index 51b7620..3446912 100644 --- a/src/pages/initiate/initiate.tsx +++ b/src/pages/initiate/initiate.tsx @@ -12,9 +12,6 @@ import { SwiperItem, } from "@tarojs/components"; -// import { Toast } from "@antmjs/vantui"; -// const Toast_ = Toast.createOnlyToast(); - /*** redux ***/ import { connect } from "react-redux"; import { userRefresh } from "../../store/features/userInfo"; @@ -57,7 +54,6 @@ class Initiate extends Component { Taro.setStorageSync("isWelcome", true); await this.initData(); } else { - // this.setBg(); go("/pages/entry/entry"); } } @@ -79,12 +75,15 @@ class Initiate extends Component { let url = ""; if (data.rows.length) { Taro.setStorageSync("MpSplashDetail_type1", JSON.stringify(data.rows)); - } - - let bgObj = data.rows.find((item: any) => item.fileSuffix === "video"); - if (bgObj) { - url = bgObj.filePath; - this.setState({ url }); + let bgObj = data.rows.find((item: any) => item.fileSuffix === "video"); + if (bgObj) { + url = bgObj.filePath; + this.setState({ url }); + } + } else { + Taro.reLaunch({ + url: "/pages/index/index", + }); } } else { msg("获取首页视频失败!"); diff --git a/src/pages/instrument/instrument.tsx b/src/pages/instrument/instrument.tsx index 73d1d5d..5fa72b6 100644 --- a/src/pages/instrument/instrument.tsx +++ b/src/pages/instrument/instrument.tsx @@ -44,7 +44,10 @@ export default class Instrument extends Component { loading: true, channelList: [], channelInfo: { + id: "", image: "", + serial: "", + bind_intro_Video: "", }, equipmentList: [ { @@ -77,14 +80,20 @@ export default class Instrument extends Component { onSerial = (event) => { const { value } = event.detail; - this.setState({ "channelInfo.serial": value }); + let { channelInfo } = this.state; + channelInfo.serial = value; + + this.setState({ channelInfo }); }; onScanCode() { Taro.scanCode({ scanType: ["qrCode"], success: (res) => { - this.setState({ "channelInfo.serial": res.result }); + let { channelInfo } = this.state; + channelInfo.serial = res.result; + + this.setState({ channelInfo }); }, }); } @@ -219,7 +228,7 @@ export default class Instrument extends Component { }); }; - async onChangeImg() { + onChangeImg = async () => { Taro.chooseMedia({ count: 1, mediaType: ["image"], @@ -230,12 +239,13 @@ export default class Instrument extends Component { // 压缩后文件地址 let compressTempFilePath = compressImage.tempFilePath; + console.log(" this.state", this.state); let { channelInfo } = this.state; channelInfo.image = compressTempFilePath; this.setState({ channelInfo }); }, }); - } + }; onSubmit = () => { const that = this; @@ -338,6 +348,7 @@ export default class Instrument extends Component { className="instrument_img" src={utilHtml.getHttpsUrl(item.banner)} mode="aspectFill" + // mode="aspectFit" > {item.titile} @@ -407,7 +418,10 @@ export default class Instrument extends Component { {channelInfo.image && ( - + )} {!channelInfo.image && ( { userinfo: { ...this.props.userInfo, }, + otherSetting: { + // skipAppid: "", + // skipPath: "", + // envVersion: "", + ...this.props.otherSetting, + }, page: 1, list: [], isIntegral: false, // 积分规则 @@ -74,8 +81,6 @@ class IntegralList extends Component { GetOtherSetting = async () => { let res = await GetOtherSetting(); if (res.data.code === 200) { - this.props.otherSettingRefresh(res.data.data); - let { otherSetting } = this.state; otherSetting.skipAppid = res.data.data.skipAppid; otherSetting.skipPath = res.data.data.skipPath; @@ -92,14 +97,14 @@ class IntegralList extends Component { envVersion: otherSetting.envVersion, success(res) { // 打开成功 - Taro.reLaunch({ - url: "/pages/index/index", - }); + // Taro.reLaunch({ + // url: "/pages/index/index", + // }); }, fail(res) { - Taro.reLaunch({ - url: "/pages/index/index", - }); + // Taro.reLaunch({ + // url: "/pages/index/index", + // }); }, }); }; @@ -227,9 +232,10 @@ class IntegralList extends Component { style={{ width: "100%", height: "600rpx", - backgroundColor: "#666", + // backgroundColor: "#666", }} - src="" + src={require("../../img/qrcode.jpg")} + mode="aspectFit" > 长按图片关注公众号,可以接收积分过期提醒 @@ -308,10 +314,14 @@ class IntegralList extends Component { // export default IntegralList const mapStateToProps = (state) => ({ userInfo: state.userInfo, + otherSetting: state.otherSetting, }); const mapDispatchToProps = (dispatch) => ({ userRefresh(data) { dispatch(userRefresh(data)); }, + otherSettingRefresh(data) { + dispatch(otherSettingRefresh(data)); + }, }); export default connect(mapStateToProps, mapDispatchToProps)(IntegralList); diff --git a/src/pages/message/message.tsx b/src/pages/message/message.tsx index 4672f1d..a51422c 100644 --- a/src/pages/message/message.tsx +++ b/src/pages/message/message.tsx @@ -225,6 +225,7 @@ export default class Message extends Component { ); })} + @@ -239,7 +240,9 @@ export default class Message extends Component { )} {list.length > 0 && list.length === total && ( - 已到底部 + + 已到底部 + )} diff --git a/src/pages/register/register.tsx b/src/pages/register/register.tsx index 0ae1cb5..2bfcbcc 100644 --- a/src/pages/register/register.tsx +++ b/src/pages/register/register.tsx @@ -28,7 +28,7 @@ class Register extends Component { "width:calc(100% - 100rpx);background:#fff;border-radius: 20rpx;box-shadow: -2rpx 0 12rpx .5rpx rgba(129, 129, 129, 0.1); height: 800rpx; padding: 30rpx;", titleHeight: "", menu: {}, - isChecked: true, + isChecked: false, isRegister: false, isShow: false, isButtonDisabled: false, diff --git a/src/pages/user/user.tsx b/src/pages/user/user.tsx index 74a7d92..b7ba2a7 100644 --- a/src/pages/user/user.tsx +++ b/src/pages/user/user.tsx @@ -72,6 +72,7 @@ class User extends Component { let res = await RefreshWxUserInfo(); if (res.data.code === 200) { this.props.userRefresh(res.data.data); + this.setState({ userInfo: res.data.data }); } }; @@ -118,12 +119,12 @@ class User extends Component { gominiapp() { Taro.navigateToMiniProgram({ - appId: this.state.otherSetting.skipAppid, - path: this.state.otherSetting.skipPath, - envVersion: this.state.otherSetting.sysVersion, + appId: "wx438760012de48d74", + path: "/pages/home/home", + envVersion: "release", success(res) { // 打开成功 - console.log("res", res); + // console.log("res", res); }, }); } diff --git a/src/pages/userInfo/userInfo.tsx b/src/pages/userInfo/userInfo.tsx index d5ffe09..ebf6d6c 100644 --- a/src/pages/userInfo/userInfo.tsx +++ b/src/pages/userInfo/userInfo.tsx @@ -182,10 +182,11 @@ class UserInfo extends Component { userInfo.areaId = res.data.data.areaId; userInfo.nickname = res.data.data.nickname; userInfo.headimg = res.data.data.headimg; + userInfo.integralText = res.data.data.integralText; this.props.userRefresh(userInfo); this.setState({ userInfo: userInfo }); - if (userInfo.integralText) { + if (res.data.data.integralText) { this.setState({ isShowIntegralText: true }); } else { this.goUser(); diff --git a/src/pages/userInfoDetail/userInfoDetail.tsx b/src/pages/userInfoDetail/userInfoDetail.tsx index 06fb420..bf4c264 100644 --- a/src/pages/userInfoDetail/userInfoDetail.tsx +++ b/src/pages/userInfoDetail/userInfoDetail.tsx @@ -209,10 +209,11 @@ class UserInfoDetail extends Component { userInfo.areaId = res.data.data.areaId; userInfo.nickname = res.data.data.nickname; userInfo.headimg = res.data.data.headimg; + userInfo.integralText = res.data.data.integralText; this.props.userRefresh(userInfo); this.setState({ userInfo: userInfo }); - if (userInfo.integralText) { + if (res.data.data.integralText) { this.setState({ isShowIntegralText: true }); } else { this.goUser(); diff --git a/src/store/features/globalStore.js b/src/store/features/globalStore.js index 4ef1535..7b8fab6 100644 --- a/src/store/features/globalStore.js +++ b/src/store/features/globalStore.js @@ -5,7 +5,7 @@ import { createSlice } from "@reduxjs/toolkit"; const globalStoreReducer = createSlice({ name: "globalStore", // store的名字 initialState: { - domain: "http://flossom.yq-h5.cn:8080", // 请求地址 + domain: "https://flossom.yq-h5.cn/prod-api/", // 请求地址 // domain: "http://192.168.10.147:8080", // 请求地址 // 是否首次进入首页 isShowIndexFlag: false,