feat(新闻详情): 添加用户参数传递和微信小程序消息发送功能
- 在RankListMini组件中添加userParams参数传递 - 修改新闻详情页导航栏为注释状态 - 添加微信小程序环境判断及消息发送功能 - 优化搜索页面布局和样式
This commit is contained in:
parent
1d1bbae0c5
commit
b63bd3703a
|
|
@ -144,6 +144,11 @@ const props = defineProps({
|
||||||
required: true,
|
required: true,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
|
userParams: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
default: () => {},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const clickItem = ref({});
|
const clickItem = ref({});
|
||||||
|
|
@ -158,8 +163,10 @@ function goDetail(item) {
|
||||||
// url: "/pages/login/indexMini",
|
// url: "/pages/login/indexMini",
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
let phone = props.userParams.phone || "";
|
||||||
|
let userType = props.userParams.userType || "";
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/detail/indexNewsInfo?id=${item.news_id}`,
|
url: `/pages/detail/indexNewsInfo?id=${item.news_id}&phone=${phone}&userType=${userType}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 导航栏 start -->
|
<!-- 导航栏 start -->
|
||||||
<view
|
<!-- <view
|
||||||
class="custom-bav-bar"
|
class="custom-bav-bar"
|
||||||
:style="{
|
:style="{
|
||||||
position: 'sticky',
|
position: 'sticky',
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
<view class="center">
|
<view class="center">
|
||||||
<image src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/images/detail_logo.png" class="logo_icon" />
|
<image src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/images/detail_logo.png" class="logo_icon" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view> -->
|
||||||
|
|
||||||
<!-- 文章正文 start -->
|
<!-- 文章正文 start -->
|
||||||
<Article :data="data" :isDomestic="isDomestic" />
|
<Article :data="data" :isDomestic="isDomestic" />
|
||||||
|
|
@ -143,7 +143,6 @@ onLoad(async (option: any) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (option?.userType == 2) {
|
if (option?.userType == 2) {
|
||||||
console.log("🚀 ~ Date.now():", Date.now());
|
|
||||||
// 打开页面时链接中带有time字段,表示上次分享的时间
|
// 打开页面时链接中带有time字段,表示上次分享的时间
|
||||||
let shareTime = option?.time || 0;
|
let shareTime = option?.time || 0;
|
||||||
// 现在的时间对比上次的分享时间,如果超过24小时,则刷新推荐栏目
|
// 现在的时间对比上次的分享时间,如果超过24小时,则刷新推荐栏目
|
||||||
|
|
@ -153,6 +152,21 @@ onLoad(async (option: any) => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("准备发送消息到小程序");
|
||||||
|
if (typeof wx !== "undefined" && wx.miniProgram) {
|
||||||
|
wx.miniProgram.postMessage({
|
||||||
|
data: {
|
||||||
|
type: "share_info",
|
||||||
|
userType: option?.userType || null,
|
||||||
|
phone: option?.phone || null,
|
||||||
|
id: option?.id || null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log("消息已发送");
|
||||||
|
} else {
|
||||||
|
console.log("非微信小程序环境,无法发送消息");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const newList = async (columnId: number) => {
|
const newList = async (columnId: number) => {
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view style="margin-top: 30rpx" v-if="tabIndex == 0">
|
<view style="margin-top: 30rpx" v-if="tabIndex == 0">
|
||||||
<RankListMini :newsList="newsList"></RankListMini>
|
<RankListMini :newsList="newsList" :userParams="userParams"></RankListMini>
|
||||||
</view>
|
</view>
|
||||||
<!-- 列表区域 -->
|
<!-- 列表区域 -->
|
||||||
<view style="margin-top: 50rpx" v-if="tabIndex == 2">
|
<view style="margin-top: 50rpx" v-if="tabIndex == 2">
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 导航栏 start -->
|
<!-- 导航栏 start -->
|
||||||
<view
|
<!-- <view
|
||||||
class="custom-bav-bar"
|
class="custom-bav-bar"
|
||||||
:style="{
|
:style="{
|
||||||
position: 'sticky',
|
position: 'sticky',
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
class="logo_icon"
|
class="logo_icon"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view> -->
|
||||||
|
|
||||||
<!-- 搜索 start -->
|
<!-- 搜索 start -->
|
||||||
<view class="sreach">
|
<view class="sreach">
|
||||||
|
|
@ -52,15 +52,11 @@
|
||||||
:border="false"
|
:border="false"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<text class="serach_btn" @click="getData()">搜索</text>
|
<text class="serach_btn" style="width: 15vw" @click="getData()">搜索</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- 搜索 end -->
|
<!-- 搜索 end -->
|
||||||
|
|
||||||
<List
|
<List :data="screenList" @onClick="handleSwiperJump" v-if="screenList.length !== 0" />
|
||||||
:data="screenList"
|
|
||||||
@onClick="handleSwiperJump"
|
|
||||||
v-if="screenList.length !== 0"
|
|
||||||
/>
|
|
||||||
<!-- 列表 end -->
|
<!-- 列表 end -->
|
||||||
<!-- 加载更多的按钮 -->
|
<!-- 加载更多的按钮 -->
|
||||||
<!-- <view class="onLoad-btn" @click="onload" v-if="finish === false && inputValue">加载更多</view> -->
|
<!-- <view class="onLoad-btn" @click="onload" v-if="finish === false && inputValue">加载更多</view> -->
|
||||||
|
|
@ -70,7 +66,6 @@
|
||||||
v-if="screenList.length === 0"
|
v-if="screenList.length === 0"
|
||||||
text="无搜索结果"
|
text="无搜索结果"
|
||||||
width="157"
|
width="157"
|
||||||
height="50"
|
|
||||||
icon="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/nosearch_icon%E5%A4%87%E4%BB%BD%402x.png"
|
icon="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/nosearch_icon%E5%A4%87%E4%BB%BD%402x.png"
|
||||||
></u-empty>
|
></u-empty>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -242,10 +237,7 @@ const getData = async () => {
|
||||||
`<text style="color: #E7303F">$&</text>`
|
`<text style="color: #E7303F">$&</text>`
|
||||||
);
|
);
|
||||||
|
|
||||||
item.title = item.title.replace(
|
item.title = item.title.replace(keyWord.value, '<span style="color: red;">' + keyWord.value + "</span>");
|
||||||
keyWord.value,
|
|
||||||
'<span style="color: red;">' + keyWord.value + "</span>"
|
|
||||||
);
|
|
||||||
console.log("🚀 ~ getData ~ item.title :", item.title);
|
console.log("🚀 ~ getData ~ item.title :", item.title);
|
||||||
|
|
||||||
item.MarkInRedContent =
|
item.MarkInRedContent =
|
||||||
|
|
@ -285,7 +277,6 @@ onShow(() => {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
// height: 60rpx;
|
// height: 60rpx;
|
||||||
gap: 20rpx;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 12rpx 0;
|
padding: 12rpx 0;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue