diff --git a/babel.config.js b/babel.config.js index 562f72a..ecd766a 100644 --- a/babel.config.js +++ b/babel.config.js @@ -10,4 +10,15 @@ module.exports = { }, ], ], + plugins: [ + [ + "import", + { + libraryName: "@antmjs/vantui", + libraryDirectory: "es", + style: (name) => `${name}/style/less`, + }, + "@antmjs/vantui", + ], + ], }; diff --git a/package-lock.json b/package-lock.json index 8bf03cc..436058d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,6 +45,7 @@ "@types/webpack-env": "^1.13.6", "@typescript-eslint/eslint-plugin": "^5.20.0", "@typescript-eslint/parser": "^5.20.0", + "babel-plugin-import": "^1.13.8", "babel-preset-taro": "3.6.19", "cache-loader": "^4.1.0", "eslint": "^8.12.0", @@ -10694,6 +10695,15 @@ "object.assign": "^4.1.0" } }, + "node_modules/babel-plugin-import": { + "version": "1.13.8", + "resolved": "https://registry.npmmirror.com/babel-plugin-import/-/babel-plugin-import-1.13.8.tgz", + "integrity": "sha512-36babpjra5m3gca44V6tSTomeBlPA7cHUynrE2WiQIm3rEGD9xy28MKsx5IdO45EbnpJY7Jrgd00C6Dwt/l/2Q==", + "dev": true, + "dependencies": { + "@babel/helper-module-imports": "^7.0.0" + } + }, "node_modules/babel-plugin-minify-dead-code-elimination": { "version": "0.5.2", "resolved": "https://registry.npmmirror.com/babel-plugin-minify-dead-code-elimination/-/babel-plugin-minify-dead-code-elimination-0.5.2.tgz", @@ -43787,6 +43797,15 @@ "object.assign": "^4.1.0" } }, + "babel-plugin-import": { + "version": "1.13.8", + "resolved": "https://registry.npmmirror.com/babel-plugin-import/-/babel-plugin-import-1.13.8.tgz", + "integrity": "sha512-36babpjra5m3gca44V6tSTomeBlPA7cHUynrE2WiQIm3rEGD9xy28MKsx5IdO45EbnpJY7Jrgd00C6Dwt/l/2Q==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.0.0" + } + }, "babel-plugin-minify-dead-code-elimination": { "version": "0.5.2", "resolved": "https://registry.npmmirror.com/babel-plugin-minify-dead-code-elimination/-/babel-plugin-minify-dead-code-elimination-0.5.2.tgz", diff --git a/package.json b/package.json index 70d4d59..2bb1a15 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "@types/webpack-env": "^1.13.6", "@typescript-eslint/eslint-plugin": "^5.20.0", "@typescript-eslint/parser": "^5.20.0", + "babel-plugin-import": "^1.13.8", "babel-preset-taro": "3.6.19", "cache-loader": "^4.1.0", "eslint": "^8.12.0", diff --git a/src/app.tsx b/src/app.tsx index 36b8aa8..0123b89 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -10,13 +10,6 @@ import store from "./store"; import "taro-ui/rn/style/components/icon.scss"; -import "@antmjs/vantui/es/datetime-picker/index.less"; -import "@antmjs/vantui/es/transition/index.less"; -import "@antmjs/vantui/es/toast/index.less"; -import "@antmjs/vantui/es/picker/index.less"; -import "@antmjs/vantui/es/picker-column/index.less"; -import "@antmjs/vantui/es/style/base.less"; - class App extends Component { // 可以使用所有的 React 生命周期方法 componentDidMount() {} diff --git a/src/components/popup/popup-alert.less b/src/components/popup/popup-alert.less index ec91ea6..46925df 100644 --- a/src/components/popup/popup-alert.less +++ b/src/components/popup/popup-alert.less @@ -1,63 +1,20 @@ -.alert-box { - width: 650rpx; - // height: 800rpx; - padding: 40rpx; - padding-bottom: 80rpx; - box-sizing: border-box; - .alert-popup-title { - font-size: 36rpx; - font-weight: 700; - text-align: center; - color: #000; - } -} - -.alert-popup-content-box { - margin-top: 60rpx; -} - -.alert-popup-content { - font-size: 28rpx; - margin-bottom: 20rpx; - max-height: 600rpx; - overflow-y: auto; -} - -.alert-popup-content.is-alert { - color: #41a9fc; - text-decoration: underline; -} - -.alert-popup-content.is-last { - margin-bottom: 0; +.text-left { + text-align: left; } -.alert-popup-btns { +.type3btn { display: flex; - margin-top: 76rpx; justify-content: center; -} - -.alert-popup-btn { - width: 480rpx; - height: 80rpx; - line-height: 80rpx; - font-size: 30rpx; + align-items: center; text-align: center; - border: 1rpx solid #000; - border-radius: 40rpx; - color: #fff; - background-color: #000; -} - -.pupup-close { - position: absolute; - right: 30rpx; - top: 30rpx; - color: #000; - font-size: 36rpx; -} - -.text-left { - text-align: left; + padding: 10rpx; + margin-top: -20rpx; + .checked { + width: 40rpx; + height: 40rpx; + margin-right: 30rpx; + } + .text { + color: #666; + } } diff --git a/src/components/popup/popup-alert.tsx b/src/components/popup/popup-alert.tsx index 2716305..7b2c4c8 100644 --- a/src/components/popup/popup-alert.tsx +++ b/src/components/popup/popup-alert.tsx @@ -1,11 +1,12 @@ import classnames from "classnames"; import { Component } from "react"; -import { Block, View, Button, PageMeta } from "@tarojs/components"; +import { Block, View, Image, Text, Button, PageMeta } from "@tarojs/components"; import { Popup } from "@antmjs/vantui"; import "./popup.less"; +import "./popup-alert.less"; import { go } from "../../utils/traoAPI"; @@ -47,9 +48,14 @@ export default class PopupAlert extends Component { let { type } = this.props; switch (type) { - case "1": + case "1": // 未注册 go("/pages/register/register"); break; + case "2": // 登录过期 + go("/pages/login/login"); + break; + case "3": // 前端提示-关注公众号 + break; } this.props.confirm(); }; @@ -67,6 +73,7 @@ export default class PopupAlert extends Component { isShow, isClose, isLarge, + type, } = this.props; return ( @@ -101,11 +108,24 @@ export default class PopupAlert extends Component { {content} - - - + + {type === "3" && ( + + + 今年不再提示 + + )} + + {type !== "3" && ( + + + + )} diff --git a/src/components/popup/popup.less b/src/components/popup/popup.less index 50d8279..a95c868 100644 --- a/src/components/popup/popup.less +++ b/src/components/popup/popup.less @@ -25,7 +25,7 @@ .common-popup-content { font-size: 28rpx; margin-bottom: 20rpx; - max-height: 600rpx; + max-height: 700rpx; overflow-y: auto; } diff --git a/src/pages/about/about.tsx b/src/pages/about/about.tsx index c08232d..72e9004 100644 --- a/src/pages/about/about.tsx +++ b/src/pages/about/about.tsx @@ -29,9 +29,16 @@ export default class About extends Component { componentDidHide() {} async initData() { - let res = await GetAboutUs(); - if (res.data.code === 200) { - this.setState({ version: res.data.data.value }); + // let res = await GetAboutUs(); + // if (res.data.code === 200) { + // 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 || "暂无", + }); } } diff --git a/src/pages/integral_list/integral_list.tsx b/src/pages/integral_list/integral_list.tsx index 3ff9777..31cdcf4 100644 --- a/src/pages/integral_list/integral_list.tsx +++ b/src/pages/integral_list/integral_list.tsx @@ -1,5 +1,6 @@ -import { Component, PropsWithChildren, useEffect, useState } from "react"; import Taro from "@tarojs/taro"; +import dayjs from "dayjs"; +import { Component, PropsWithChildren, useEffect, useState } from "react"; import { Block, View, Text, Image, RichText } from "@tarojs/components"; import "./integral_list.less"; @@ -15,7 +16,12 @@ import Navbar from "../../components/navbar/navbar"; import PopupAlert from "../../components/popup/popup-alert"; -import { GetIntegralRule, GetObtainUserIntegral } from "../../utils/Interface"; +import { + GetIntegralRule, + GetObtainUserIntegral, + GetOfficialAccount, + GetIsAttentionOfficialAccount, +} from "../../utils/Interface"; class IntegralList extends Component { constructor(props) { @@ -25,7 +31,8 @@ class IntegralList extends Component { userinfo: this.props.userInfo, page: 1, list: [], - isIntegral: false, + isIntegral: false, // 积分规则 + isOfficialAccount: false, // 是否关注公众号-一年展示一次 nodes: "", pageNum: 1, @@ -47,8 +54,40 @@ class IntegralList extends Component { async initData() { this.GetObtainUserIntegral(); + this.checkOfficialAccount(); + // this.GetOfficialAccount(); + // this.GetIsAttentionOfficialAccount(); + } + + // 检查是否关注公众号:只在每年的09-30号前提醒,如果没有关注则弹窗提醒 + checkOfficialAccount() { + let currentTime = dayjs().valueOf(); + let targetTime = dayjs().month(9).day(30).valueOf(); + // 仅9月30日前触发:提醒过期弹窗 + if (currentTime <= targetTime) { + let isOfficialAccount = Taro.getStorageSync("isOfficialAccount"); + if (isOfficialAccount) { + let oldYear = isOfficialAccount; + let currentYear = dayjs().format("YYYY"); + if (currentYear < oldYear) { + // 检查:今年未提醒,则弹窗 + this.setState({ isOfficialAccount: true }); + } + } else { + this.setState({ isOfficialAccount: true }); + } + } } + GetOfficialAccount = async () => { + let res = await GetOfficialAccount(); + console.log("GetOfficialAccount", res); + }; + GetIsAttentionOfficialAccount = async () => { + let res = await GetIsAttentionOfficialAccount(); + console.log("GetIsAttentionOfficialAccount", res); + }; + GetObtainUserIntegral = async () => { let { list, pageNum, pageSize } = this.state; let res = await GetObtainUserIntegral({ @@ -82,8 +121,18 @@ class IntegralList extends Component { this.setState({ isIntegral: false }); }; + /** 关注公众号弹窗 */ + officialPopupConfirm = () => { + let currentYear = dayjs().format("YYYY"); + Taro.setStorageSync("isOfficialAccount", currentYear); // 标记:本年度已提醒 + this.officialPopupClose(); + }; + officialPopupClose = () => { + this.setState({ isOfficialAccount: false }); + }; + render() { - let { list, userinfo, isIntegral, nodes } = this.state; + let { list, userinfo, isIntegral, isOfficialAccount, nodes } = this.state; return ( { close={this.integralPopupClose} confirm={this.integralPopupClose} > + + + + 长按图片关注公众号,可以接收积分过期提醒 + + + } + confirmButtonText="我知道了" + textAlgin="center" + close={this.officialPopupClose} + confirm={this.officialPopupConfirm} + > diff --git a/src/pages/login/login.tsx b/src/pages/login/login.tsx index 8b1d16e..a5c15ee 100644 --- a/src/pages/login/login.tsx +++ b/src/pages/login/login.tsx @@ -9,8 +9,6 @@ import { connect } from "react-redux"; import { setMobile } from "../../store/features/userInfo"; /*** redux end ***/ -import { go } from "../../utils/traoAPI"; - import "taro-ui/dist/style/components/button.scss"; // 按需引入 import "./login.less"; @@ -39,7 +37,9 @@ class Login extends Component { if (data.code === 200) { Taro.setStorageSync("token", data.data.token); this.props.setMobile(data.data.mobile); - go("/pages/index/index"); + Taro.switchTab({ + url: "/pages/index/index", + }); } }; diff --git a/src/pages/message/message.tsx b/src/pages/message/message.tsx index 0caba63..3a83004 100644 --- a/src/pages/message/message.tsx +++ b/src/pages/message/message.tsx @@ -30,9 +30,8 @@ export default class Message extends Component { list: [], pageNum: 1, pageSize: 10, + total: 0, scrollTop: 0, - // downText: "下拉刷新", - pullText: "上拉加载更多", isBottom: false, // 是否触底 start_p: {}, scrollY: true, @@ -67,9 +66,10 @@ export default class Message extends Component { }); if (res.data.code === 200) { if (res.data.rows.length) { - list = [].concat(list, res.data.rows); - console.log("list", list); - this.setState({ list: list }); + let newList = [].concat(list, res.data.rows); + setTimeout(() => { + this.setState({ list: newList, dargState: 0, total: res.data.total }); + }, 500); } } }; @@ -82,34 +82,13 @@ export default class Message extends Component { } }; - // onRefresh: IPullToRefreshProps["onRefresh"] = () => { - // return new Promise((resolve) => { - // setTimeout(() => { - // resolve(undefined); - // }, 1000); - // }); - // }; - - // _onscroll = (e) => this.setTop(e.detail.scrollTop); - - // setTop = (value) => { - // console.log("setTop", value); - // }; - /*** 上拉加载 ***/ reduction = () => { //还原初始设置 - const time = 0.5; + // const time = 0.5; this.setState({ - // dargState: 0, scrollY: true, }); - setTimeout(() => { - this.setState({ - pullText: "上拉加载更多", - // downText: "下拉刷新", - }); - }, time * 1000); }; touchStart = (e) => { this.setState({ @@ -135,7 +114,7 @@ export default class Message extends Component { if (move_y - start_y > 0) { //下拉操做 if (pY >= deviationY) { - this.setState({ dargState: 1, downText: "释放刷新" }); + // this.setState({ dargState: 1, downText: "释放刷新" }); } else { // this.setState({ dargState: 0, downText: "下拉刷新" }); } @@ -150,9 +129,7 @@ export default class Message extends Component { //上拉操做 // console.log("上拉操做"); if (pY >= deviationY) { - this.setState({ dargState: -1, pullText: "释放加载更多" }); - } else { - // this.setState({ dargState: 0, pullText: "上拉加载更多" }); + this.setState({ dargState: -1 }); } } } @@ -160,8 +137,15 @@ export default class Message extends Component { pull = () => { //上拉 console.log("上拉"); - - // this.props.onPull() + let { list, total, pageNum, dargState } = this.state; + if (dargState === -1) { + if (list.length < total) { + this.setState({ pageNum: pageNum + 1 }); + setTimeout(() => { + this.GetMessageList(); + }, 100); + } + } }; down = () => { //下拉 @@ -184,7 +168,7 @@ export default class Message extends Component { } else if (this.state.dargState === -1) { this.pull(); } - this.reduction(); + // this.reduction(); }; /*** 上拉加载 ***/ @@ -193,7 +177,7 @@ export default class Message extends Component { // }; render() { - let { list, scrollTop, dargState, pullText } = this.state; + let { total, list, dargState } = this.state; return ( @@ -281,13 +265,19 @@ export default class Message extends Component { - - {dargState === 0 ? ( - "上拉加载更多" - ) : ( - 加载中... - )} - + {list.length > 0 && list.length < total && ( + + {dargState === 0 ? ( + 上拉加载更多 + ) : ( + 加载中... + )} + + )} + + {list.length > 0 && list.length === total && ( + 已到底部 + )} {/* diff --git a/src/pages/recording/recording.config.js b/src/pages/recording/recording.config.js new file mode 100644 index 0000000..6e4c783 --- /dev/null +++ b/src/pages/recording/recording.config.js @@ -0,0 +1,3 @@ +export default definePageConfig({ + navigationBarTitleText: "护理历程", +}); diff --git a/src/pages/recording/recording.less b/src/pages/recording/recording.less new file mode 100644 index 0000000..e69de29 diff --git a/src/pages/recording/recording.tsx b/src/pages/recording/recording.tsx new file mode 100644 index 0000000..46e812f --- /dev/null +++ b/src/pages/recording/recording.tsx @@ -0,0 +1,32 @@ +import { Component, PropsWithChildren, useEffect, useState } from "react"; +import Taro from "@tarojs/taro"; +import { Block, View, Text, Image, Input, Button } from "@tarojs/components"; + +import { Tab, Tabs } from "@antmjs/vantui"; + +import "./recording.less"; + +export default class Recording extends Component { + constructor(props) { + super(props); + this.state = { + name: "护理历程", + }; + } + + async onLoad() {} + componentDidMount() {} + + componentWillUnmount() {} + + componentDidShow() {} + + componentDidHide() {} + + async initData() {} + + render() { + let { name } = this.state; + return {name}; + } +} diff --git a/src/utils/Interface.js b/src/utils/Interface.js index 36b4d75..395b76a 100644 --- a/src/utils/Interface.js +++ b/src/utils/Interface.js @@ -86,14 +86,6 @@ export const GetUserMobile = (data = { code: "" }) => { }); }; -export const getIntegralRule = (data) => { - //积分规则 - return Ajax({ - url: "/hzwx/setting/getIntegralRule", - data, - }); -}; - export const getAboutUs = (data) => { //关于我们 return Ajax({ @@ -156,6 +148,7 @@ export const GetMessageList = (data) => { }); }; +// 积分页面 export const GetObtainUserIntegral = (data) => { // 分页获取用户积分列表 return Ajax({ @@ -164,7 +157,6 @@ export const GetObtainUserIntegral = (data) => { method: "get", }); }; - export const GetIntegralRule = (data) => { // 获取积分规则 return Ajax({ @@ -173,7 +165,6 @@ export const GetIntegralRule = (data) => { method: "get", }); }; - export const GetIsAttentionOfficialAccount = (data) => { // 查询用户是否关注公众号 return Ajax({ @@ -182,7 +173,6 @@ export const GetIsAttentionOfficialAccount = (data) => { method: "get", }); }; - export const GetOfficialAccount = (data) => { // 查询用户是否关闭提醒关注公众号 return Ajax({ diff --git a/src/utils/request.js b/src/utils/request.js index 8296538..7c03d9e 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -46,11 +46,11 @@ export const Ajax = (params) => { content: "登录已过期,请重新登录", showCancel: false, }).then((res) => { - sessionStorage.setItem("token", null); + Taro.setStorageSync("token", null); Taro.clearStorage(); // 清空所有缓存 Taro.reLaunch({ // url: "/pages/login/login", - url: "/pages/initiate/initiate", + url: "/pages/login/login", }); }); return; @@ -82,10 +82,10 @@ export const Ajax = (params) => { }).then(() => { reject(res); if (res.data.code == 403 || res.data.msg === "登录状态已过期") { - sessionStorage.setItem("token", null); + Taro.setStorageSync("token", null); Taro.reLaunch({ // url: "/pages/login/login", - url: "/pages/initiate/initiate", + url: "/pages/login/login", }); } }); @@ -201,10 +201,10 @@ export const AjaxFormData = (params) => { content: "登录已过期,请重新登录", showCancel: false, }).then((res) => { - sessionStorage.setItem("token", null); + Taro.setStorageSync("token", null); Taro.clearStorage(); // 清空所有缓存 Taro.reLaunch({ - url: "/pages/initiate/initiate", + url: "/pages/login/login", }); }); return; @@ -231,9 +231,9 @@ export const AjaxFormData = (params) => { }).then(() => { reject(res); if (res.data.code == 403 || res.data.msg === "登录状态已过期") { - sessionStorage.setItem("token", null); + Taro.setStorageSync("token", null); Taro.reLaunch({ - url: "/pages/initiate/initiate", + url: "/pages/login/login", }); } }); diff --git a/yarn.lock b/yarn.lock index 30676b7..28f5abd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -206,7 +206,7 @@ dependencies: "@babel/types" "^7.23.0" -"@babel/helper-module-imports@^7.22.15": +"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.22.15": "integrity" "sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w==" "resolved" "https://registry.npmmirror.com/@babel/helper-module-imports/-/helper-module-imports-7.22.15.tgz" "version" "7.22.15" @@ -4168,6 +4168,13 @@ dependencies: "object.assign" "^4.1.0" +"babel-plugin-import@^1.13.8": + "integrity" "sha512-36babpjra5m3gca44V6tSTomeBlPA7cHUynrE2WiQIm3rEGD9xy28MKsx5IdO45EbnpJY7Jrgd00C6Dwt/l/2Q==" + "resolved" "https://registry.npmmirror.com/babel-plugin-import/-/babel-plugin-import-1.13.8.tgz" + "version" "1.13.8" + dependencies: + "@babel/helper-module-imports" "^7.0.0" + "babel-plugin-minify-dead-code-elimination@^0.5.2": "integrity" "sha512-krq9Lwi0QIzyAlcNBXTL4usqUvevB4BzktdEsb8srcXC1AaYqRJiAQw6vdKdJSaXbz6snBvziGr6ch/aoRCfpA==" "resolved" "https://registry.npmmirror.com/babel-plugin-minify-dead-code-elimination/-/babel-plugin-minify-dead-code-elimination-0.5.2.tgz"