diff --git a/src/pages/Customer/index.tsx b/src/pages/Customer/index.tsx index e51049d..f4680c4 100644 --- a/src/pages/Customer/index.tsx +++ b/src/pages/Customer/index.tsx @@ -8,6 +8,7 @@ export default function Customer() { src='https://oss.jm-kid.com/wx_5colorflower/icons/customer.svg' className='pic' mode='aspectFill' + show-menu-by-longpress > ) } diff --git a/src/pages/UserHome/UserMessage/index.less b/src/pages/UserHome/UserMessage/index.less index 2d5ecbc..f1a8ce3 100644 --- a/src/pages/UserHome/UserMessage/index.less +++ b/src/pages/UserHome/UserMessage/index.less @@ -3,56 +3,51 @@ background: #f1f1f1; padding: 1rem; - .subscribe_scrollview { - height: 100vh; - display: flex; - flex-direction: column; + .subscribe_item { + position: relative; + padding: 1rem 1.5rem; + background: #fff; + border-radius: .6rem; + gap: 1rem; + margin-bottom: 1rem; - .subscribe_item { - position: relative; - padding: 1rem 1.5rem; - background: #fff; - border-radius: .6rem; - gap: 1rem; - margin-bottom: 1rem; + .item_header { + display: flex; + justify-content: space-between; + margin-bottom: .3rem; - .item_header { - display: flex; - justify-content: space-between; - margin-bottom: .3rem; - - .item_header_title { - font-size: .9rem; - font-weight: 600; - color: #333; - } - .item_header_date { - font-size: .8rem; - color: #ccc; - } - .item_header_dot { - position: absolute; - top: .8rem; - right: .8rem; - width: .5rem; - height: .5rem; - background-color: #f00; - border-radius: 50%; - } - - } - - .item_des { - font-size: .9rem; + .item_header_title { + font-size: 1rem; + font-weight: 600; color: #333; } - .item_link { - margin-left: .5rem; - font-size: .9rem; - color: #3BA366; + .item_header_date { + font-size: .8rem; + color: #808080; + } + .item_header_dot { + position: absolute; + top: .5rem; + right: .7rem; + width: .5rem; + height: .5rem; + background-color: #f00; + border-radius: 50%; } + + } + + .item_des { + font-size: .9rem; + color: #333; + } + .item_link { + margin-left: .5rem; + font-size: .9rem; + color: #3BA366; } } + .none { padding-top: 3rem; font-size: .8rem; diff --git a/src/pages/UserHome/UserMessage/index.tsx b/src/pages/UserHome/UserMessage/index.tsx index 178192d..6ad24a0 100644 --- a/src/pages/UserHome/UserMessage/index.tsx +++ b/src/pages/UserHome/UserMessage/index.tsx @@ -1,6 +1,6 @@ import { ScrollView, View, Text } from '@tarojs/components' import React, { useState } from 'react' -import Taro, { useLoad, useShareAppMessage, useShareTimeline } from '@tarojs/taro' +import Taro, { useDidShow, useShareAppMessage, useShareTimeline } from '@tarojs/taro' import './index.less' interface subscribeProps { @@ -34,7 +34,7 @@ export default function UserMessage() { const [userSubuscribed, setuserSubuscribed] = useState() - useLoad(() => { + useDidShow(() => { Taro.request({ url: 'https://interapi.jm-kid.com/api/message/list', method: 'POST', @@ -52,42 +52,68 @@ export default function UserMessage() { }) //跳转详情页 - const handleToCollectionDetail = (id: string) => { - Taro.navigateTo({ - url: '/pages/CollectionDetail/index?id=' + id - }) + const handleDetailClick = (item: any) => { + if (item.read_at) { + toDetail(item) + } else { + // 标记已读 + Taro.request({ + url: 'https://interapi.jm-kid.com/api/message/mark', + method: 'POST', + header: { + authorization: `bearer ${Taro.getStorageSync('UserToken')}`, + }, + data: { + timestamp: Date.now(), + operate: 'read', + msg_id: item.msg_id + }, + success: () => { + toDetail(item) + } + }) + } + } + + //跳转详情页 + const toDetail = (item: any) => { + if (item.link) { + Taro.navigateTo({ + url: `/pages/CollectionDetail/index?id=${item.link.prdt_id}` + }) + } else { + Taro.switchTab({ + url: '/pages/Home/index', + }) + } } return ( { userSubuscribed && userSubuscribed.length ? - + { userSubuscribed.map((item: any, index: number) => ( handleToCollectionDetail(item.PrdtId)} + onClick={()=>handleDetailClick(item)} > {item.title} {item.created_at} - { item.read_at && } + { !item.read_at && } {item.content} - 立即查看> > + {item.link && 立即查看> >} )) } - : + : 暂无消息~ } diff --git a/src/pages/UserHome/index.less b/src/pages/UserHome/index.less index 429cc1c..bc63e5b 100644 --- a/src/pages/UserHome/index.less +++ b/src/pages/UserHome/index.less @@ -91,6 +91,8 @@ &:nth-child(7) { .user_home_content_item_des { display: flex; + justify-content: center; + min-width: 1rem; padding: .2rem .3rem; color: #fff; background-color: #ea2b2b;