2023.11.1修改

This commit is contained in:
2023-11-01 00:33:57 +08:00
parent 11cecc737f
commit 22c039a8eb
18 changed files with 497 additions and 88 deletions

View File

@@ -7,16 +7,17 @@
import {ref,onMounted,nextTick} from "vue"
import {useStore} from '@/store/index.js'
import api from "@/api/index.js"
import util from "@/utils"
onLoad((e) => {
console.log(e)
a_info.value = JSON.parse(decodeURIComponent(e.info))
// console.log(e)
// a_info.value = JSON.parse(decodeURIComponent(e.info))
if(!e.id) {
uni.showToast({
icon:"error",
title:"错误",
duration:2000
})
a_info.value = null
// a_info.value = null
return
}
getDetail(e.id)
@@ -27,6 +28,19 @@
// 函数
async function getDetail(id) {
const res = await api.getArticleDetail({id})
if(res.code == 0) {
a_info.value = res.data
}
else{
uni.showToast({
title:'获取失败',
icon:"error",
duration:2000
})
}
}
async function starFunc(type) { // 点击收藏
a_info.value.isStar = type
}
</script>
<template>
@@ -34,11 +48,31 @@
<view class="title">
{{a_info?.title}}
</view>
<view class="more-info small-text">2023-10-5</view>
<view v-if="a_info" class="more-info small-text">{{util.timestampToDate(a_info?.CreatedAt)}}</view>
<view class="d-content" v-html="a_info?.content"></view>
<view class="action-box" v-if="a_info">
<view class="ab-item">
<uni-icons color="gray" type="eye" size="30"></uni-icons>
<view style="color: gray;">{{a_info?.reading_num}}</view>
</view>
<view class="ab-item">
<uni-icons color="#26758d" @tap="starFunc(0)" v-if="a_info?.isStar" type="star-filled" size="30"></uni-icons>
<uni-icons color="gray" @tap="starFunc(1)" v-else type="star" size="30"></uni-icons>
</view>
</view>
</view>
</template>
<style scoped lang="scss">
.action-box{
margin-top: 20px;
display: flex;
justify-content: flex-end;
.ab-item{
display: flex;
align-items: center;
margin: 0 20rpx;
}
}
.detailBox{
.more-info{
text-align: right;

View File

@@ -29,43 +29,36 @@
page:1,
pageSize:10
})
const list = ref([
{
id:1,
cover_img:'https://gwjxb.oss-cn-chengdu.aliyuncs.com/logo.png',
title:'金秋相逢 共叙合作',
reading_num:100,
content:`
新华社北京10月18日电 金秋时节,北京再迎盛会:第三届“一带一路”国际合作高峰论坛隆重举行。
春发其华,秋收其实。
共建“一带一路”走过了第一个蓬勃十年,正值风华正茂,务当昂扬奋进,奔向下一个金色十年!
`
},
{
id:2,
cover_img:'https://ms.bdimg.com/pacific/0/pic/1083217647_-478899572.png?x=0&y=0&h=340&w=510&vh=340.00&vw=510.00&oh=340.00&ow=510.00',
title:'金秋相逢 共叙合作',
reading_num:100,
content:`
新华社北京10月18日电 金秋时节,北京再迎盛会:第三届“一带一路”国际合作高峰论坛隆重举行。
春发其华,秋收其实。
共建“一带一路”走过了第一个蓬勃十年,正值风华正茂,务当昂扬奋进,奔向下一个金色十年!
`
}
])
const list = ref([])
// 方法
function init() {
queryParams.page = 1
queryParams.pageSize = 10
list.value = []
}
async function getList(){
const res = await api.getArticleList(queryParams.value)
if(res.code == 0) {
if( res.data.list.length>0) {
list.value.push(...res.data.list)
}
else{
queryParams.page-=1
}
}
else{
uni.showToast({
title:'获取失败',
icon:"error",
duration:2000
})
}
}
function toDetail(item) {
let info = encodeURIComponent(JSON.stringify(item))
// console.log(info)
uni.navigateTo({
url:"./detail?info="+info+"&id="+item.id
url:"./detail?id="+item.ID
})
}
</script>
@@ -81,7 +74,7 @@
</view>
<view class="lb-right">
<view class="lb-title">{{item.title}}</view>
<view class="lb-content text-ellipsis-1 small-text">{{item.content}}</view>
<view class="lb-content text-ellipsis-1 small-text" v-html="item.content"></view>
</view>
</view>
</view>