From 27eef168b3f6ee97ef2a8e138b5121c1ddde1480 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Thu, 31 Oct 2024 14:57:10 +0800 Subject: [PATCH] fix --- src/app.ts | 5 +- src/components/getPhoneModal/index.tsx | 21 ++++-- src/pages/Home/index.tsx | 8 +-- src/pages/Listen/index.tsx | 15 ++++- src/pages/Share/index.tsx | 8 ++- src/pages/UserHome/UserMessage/index.less | 10 ++- src/pages/UserHome/UserMessage/index.tsx | 67 ++++++++++--------- .../UserHome/UserPersonalInfo/index.less | 8 ++- src/pages/UserHome/UserPersonalInfo/index.tsx | 18 +++++ src/pages/UserHome/index.tsx | 48 ++++--------- src/pages/Vip/index.less | 47 ++++++++++++- src/pages/Vip/index.tsx | 18 +++++ 12 files changed, 183 insertions(+), 90 deletions(-) diff --git a/src/app.ts b/src/app.ts index 52ab705..ca09f03 100644 --- a/src/app.ts +++ b/src/app.ts @@ -26,6 +26,7 @@ export default function App(props: any) { Taro.setStorageSync('UserAvatar', sres.data.data.user.Avatar) Taro.setStorageSync('UserNickName', sres.data.data.user.NickName) Taro.setStorageSync('UserPhoneNumber', sres.data.data.user.Mobile) + Taro.setStorageSync('UserInviteCode', sres.data.data.user.InviteCode) Taro.setStorageSync('UserToken', sres.data.token) }else{ //注册key @@ -33,7 +34,7 @@ export default function App(props: any) { } } }) - } + } }) }) @@ -62,6 +63,6 @@ export default function App(props: any) { return ( props.children - + ) } diff --git a/src/components/getPhoneModal/index.tsx b/src/components/getPhoneModal/index.tsx index 2a49caf..94b86f2 100644 --- a/src/components/getPhoneModal/index.tsx +++ b/src/components/getPhoneModal/index.tsx @@ -1,6 +1,6 @@ import { Button, View, Text } from '@tarojs/components' import { useState } from 'react' -import Taro from '@tarojs/taro' +import Taro, { useLoad } from '@tarojs/taro' import './index.less' export default function GetPhoneNumber({ onClose, scene = null, modalVisible, onModalClose}) { @@ -8,6 +8,13 @@ export default function GetPhoneNumber({ onClose, scene = null, modalVisible, on //管理关闭动画状态 const [isAnimationOpen, setisAnimationOpen] = useState(false) + const [inviteCode, setInviteCode] = useState() + + useLoad((query)=> { + console.log(query.inviteCode) + setInviteCode(query.inviteCode || '') + }) + if(!modalVisible){ return null } @@ -31,12 +38,14 @@ export default function GetPhoneNumber({ onClose, scene = null, modalVisible, on MCODE: e.detail.code, channel: 'wusehua_mini', open_id: Taro.getStorageSync('LoginKey'), + invite_code: inviteCode }, success: (res: any) => { console.log('用户注册信息=>',res) Taro.setStorageSync('UserAvatar', res.data.user.Avatar) Taro.setStorageSync('UserNickName', res.data.user.NickName) Taro.setStorageSync('UserPhoneNumber', res.data.user.Mobile) + Taro.setStorageSync('UserInviteCode', res.data.user.InviteCode) Taro.setStorageSync('UserToken', res.data.token) if(scene){ @@ -110,7 +119,7 @@ export default function GetPhoneNumber({ onClose, scene = null, modalVisible, on - + - 暂不登录 - + - + ) } diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx index 57d5543..d489546 100644 --- a/src/pages/Home/index.tsx +++ b/src/pages/Home/index.tsx @@ -251,7 +251,7 @@ export default function Home() { } } - const handleBannerClick = (item: any) => { + const handleBannerClick = (item: any, index: number) => { if(item.is_subscribed === 0){ //提醒用户登录 setisLoginOpen(true) @@ -269,8 +269,8 @@ export default function Home() { else{ //已订阅,跳转详情页 Taro.navigateTo({ - // url: '/pages/CollectionDetail/index?id=' + item.prdt_id - url: '/pages/Share/index' + url: index ? '/pages/CollectionDetail/index?id=' + item.prdt_id : '/pages/Share/index' + // url: '/pages/Share/index' }) } } @@ -295,7 +295,7 @@ export default function Home() { handleBannerClick(item)} + onClick={()=>handleBannerClick(item, index)} > diff --git a/src/pages/Listen/index.tsx b/src/pages/Listen/index.tsx index 5c414ff..6366fbe 100644 --- a/src/pages/Listen/index.tsx +++ b/src/pages/Listen/index.tsx @@ -204,6 +204,19 @@ export default function Listen() { }) } + const handleBannerClick = (item: any, index: number) => { + if (!index) { + if(!Taro.getStorageSync('UserToken')){ + //提醒用户登录 + setisLoginOpen(true) + }else{ + Taro.navigateTo({ + url: '/pages/Vip/index' + }) + } + } + } + return ( {}} + onClick={()=>handleBannerClick(item, index)} > diff --git a/src/pages/Share/index.tsx b/src/pages/Share/index.tsx index 0cd5f8f..cbd7425 100644 --- a/src/pages/Share/index.tsx +++ b/src/pages/Share/index.tsx @@ -1,24 +1,26 @@ import { View, Image } from '@tarojs/components' -import { useLoad, useShareAppMessage, useShareTimeline, updateShareMenu, showShareMenu } from '@tarojs/taro' +import Taro, { useLoad, useShareAppMessage, useShareTimeline, updateShareMenu, showShareMenu } from '@tarojs/taro' import React, { useState } from 'react' import './index.less' import sharePic from '../../assets/images/share.svg' export default function Share() { + const inviteCode = Taro.getStorageSync('UserInviteCode') // 邀请码 + useShareAppMessage((res) => { if (res.from === 'button') { console.log(res.target); } return { title: '五色花', - path: '/pages/Home/index' + path: `/pages/Home/index?inviteCode=${inviteCode}` } }) useShareTimeline(() => { return { title: '五色花', - path: '/pages/Home/index' + path: `/pages/Home/index?inviteCode=${inviteCode}` } }) diff --git a/src/pages/UserHome/UserMessage/index.less b/src/pages/UserHome/UserMessage/index.less index 959bb68..2d5ecbc 100644 --- a/src/pages/UserHome/UserMessage/index.less +++ b/src/pages/UserHome/UserMessage/index.less @@ -42,15 +42,21 @@ } - .item_header_des { + .item_des { font-size: .9rem; color: #333; } - .item_header_link { + .item_link { margin-left: .5rem; font-size: .9rem; color: #3BA366; } } } + .none { + padding-top: 3rem; + font-size: .8rem; + text-align: center; + color: #9a9391; + } } diff --git a/src/pages/UserHome/UserMessage/index.tsx b/src/pages/UserHome/UserMessage/index.tsx index c0cfcea..178192d 100644 --- a/src/pages/UserHome/UserMessage/index.tsx +++ b/src/pages/UserHome/UserMessage/index.tsx @@ -1,7 +1,6 @@ import { ScrollView, View, Text } from '@tarojs/components' import React, { useState } from 'react' import Taro, { useLoad, useShareAppMessage, useShareTimeline } from '@tarojs/taro' -import DefaultPage2 from '../../../components/defaultPage2' import './index.less' interface subscribeProps { @@ -37,13 +36,16 @@ export default function UserMessage() { useLoad(() => { Taro.request({ - url: 'https://interapi.jm-kid.com/api/user/subscribed', + url: 'https://interapi.jm-kid.com/api/message/list', method: 'POST', header: { authorization: `bearer ${Taro.getStorageSync('UserToken')}`, }, + data: { + timestamp: Date.now(), + }, success: (res: any) => { - console.log('用户订阅查询成功=>', res.data) + console.log('消息列表查询成功=>', res.data) setuserSubuscribed(res.data.data) } }) @@ -58,37 +60,36 @@ export default function UserMessage() { return ( - - { - userSubuscribed && userSubuscribed.length > 0 && userSubuscribed.map((item: any, index: number) => ( - handleToCollectionDetail(item.PrdtId)} - > - - {item.PrdtTitle} - 10-01 - - - - {item.PrdtTitle} - 立即查看> > - + { + userSubuscribed && userSubuscribed.length ? + + { + userSubuscribed.map((item: any, index: number) => ( + handleToCollectionDetail(item.PrdtId)} + > + + {item.title} + {item.created_at} + { item.read_at && } + + + {item.content} + 立即查看> > + + - - )) - } - - { - userSubuscribed && userSubuscribed.length === 0 && - - } - + )) + } + : + 暂无消息~ + } ) } diff --git a/src/pages/UserHome/UserPersonalInfo/index.less b/src/pages/UserHome/UserPersonalInfo/index.less index bf28e87..57f3dcb 100644 --- a/src/pages/UserHome/UserPersonalInfo/index.less +++ b/src/pages/UserHome/UserPersonalInfo/index.less @@ -69,10 +69,16 @@ .info_content_btn_text { text-align: center; - color: #ffffff; + color: #fff; font-size: 1rem; font-weight: 600; margin: auto; } } + .logout { + background: #fcca1e; + .info_content_btn_text { + color: #333; + } + } } diff --git a/src/pages/UserHome/UserPersonalInfo/index.tsx b/src/pages/UserHome/UserPersonalInfo/index.tsx index 87e9df8..0684dd5 100644 --- a/src/pages/UserHome/UserPersonalInfo/index.tsx +++ b/src/pages/UserHome/UserPersonalInfo/index.tsx @@ -110,6 +110,16 @@ export default function UserPersonalInfo() { } + // 退出登录 + const logout = () => { + try { + Taro.clearStorageSync() + Taro.switchTab({ + url: '/pages/Home/index', + }) + } catch (e) {} + } + return ( @@ -152,6 +162,14 @@ export default function UserPersonalInfo() { className='info_content_btn_text' >保存 + + 退出登录 + ) } diff --git a/src/pages/UserHome/index.tsx b/src/pages/UserHome/index.tsx index c8f7213..c9fa6be 100644 --- a/src/pages/UserHome/index.tsx +++ b/src/pages/UserHome/index.tsx @@ -11,46 +11,39 @@ import GetPhoneNumber from '../../components/getPhoneModal' const userOperateList = [ { - index: 1, name: '我的订阅', icon: 'https://oss.jm-kid.com/wx_5colorflower/operate2.svg', pushUrl: '/pages/UserHome/UserSubscribe/index', des: 10, }, { - index: 2, name: '熏听会员', icon: 'https://oss.jm-kid.com/wx_5colorflower/operate2.svg', pushUrl: '/pages/Vip/index', des: '未开通', }, { - index: 3, name: '兑换码', icon: 'https://oss.jm-kid.com/wx_5colorflower/operate1.svg', pushUrl: '', }, { - index: 4, name: '商城', icon: storeIcon, pushUrl: '', }, { - index: 5, name: '邀请好友', icon: storeIcon, pushUrl: '/pages/Share/index', des: '免费领绘本', }, { - index: 6, name: '联系客服', icon: serviceIcon, - pushUrl: '', + pushUrl: '/pages/Customer/index', }, { - index: 7, name: '消息', icon: storeIcon, pushUrl: '/pages/UserHome/UserMessage/index', @@ -186,38 +179,23 @@ export default function UserHome() { { userOperateList.map((item: any, index: number) => ( - index === 5 ? - : - handlePush(index ,item.pushUrl)} - > - - - {item.name} - - - {item.des && {item.des}} - - + )) } diff --git a/src/pages/Vip/index.less b/src/pages/Vip/index.less index a74c9f2..b5ca028 100644 --- a/src/pages/Vip/index.less +++ b/src/pages/Vip/index.less @@ -1,18 +1,59 @@ .vip { padding: 1rem; + .vip_none { + font-size: .8rem; + text-align: center; + color: #9a9391; + } + .vip_record { + .vip_title { + font-size: 1rem; + font-weight: 600; + color: #333; + } + .vip_list { + margin-top: .5rem; + } + .vip_list_item { + margin-bottom: 1rem; + } + .vip_list_info { + display: flex; + justify-content: space-between; + margin-bottom: .3rem; + font-size: .95rem; + color: #714135; + } + .vip_list_date { + display: flex; + justify-content: space-between; + font-size: .8rem; + color: #696969; + } + } } .vip_card { + position: relative; display: flex; align-items: center; padding: 1.5rem; + margin-bottom: 1rem; border: 2px solid #ffd0c6; border-radius: 1.5rem; background: linear-gradient(to right, #fcc1b5 20%, #f8c8bd 50%, #fce4df 100%); + &::before { + content: '会员卡'; + position: absolute; + top: .6rem; + right: 1rem; + font-size: .8rem; + color: #714135; + } .vip_avatar{ width: 3.75rem; height: 3.75rem; margin-right: 1rem; - border: .0625rem solid #ccc; + border: .0625rem solid #444; border-radius: 50%; } .vip_name { @@ -27,8 +68,8 @@ } .vip_open { position: absolute; - top: 4rem; - right: 3rem; + top: 3.5rem; + right: 2rem; padding: .3rem .8rem; font-size: .9rem; font-weight: 600; diff --git a/src/pages/Vip/index.tsx b/src/pages/Vip/index.tsx index 99948e1..a312c84 100644 --- a/src/pages/Vip/index.tsx +++ b/src/pages/Vip/index.tsx @@ -32,6 +32,24 @@ export default function Share() { 立即开通 + 暂无开通记录~ + + + 开通记录 + + + + + 熏听会员年卡 + 1年 + + + 开通时间:2024 + 到期时间:2024 + + + + ) }