2023-10-19 23:23:22 +08:00
|
|
|
<script setup>
|
|
|
|
// 引入依赖
|
|
|
|
// import uniDatetimePicker from '@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue'
|
|
|
|
// import uniEasyinput from '@/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue'
|
|
|
|
import { onLoad } from "@dcloudio/uni-app"
|
|
|
|
// import mySwiper from "@/components/mySwiper.vue"
|
|
|
|
import {ref,onMounted,nextTick} from "vue"
|
|
|
|
import {useStore} from '@/store/index.js'
|
2023-11-07 00:12:02 +08:00
|
|
|
import emptyCard from "@/components/emptyCard.vue"
|
2023-10-19 23:23:22 +08:00
|
|
|
import api from "@/api/index.js"
|
2023-11-01 00:33:57 +08:00
|
|
|
import util from "@/utils"
|
2023-12-29 00:12:16 +08:00
|
|
|
const store = useStore()
|
2023-10-19 23:23:22 +08:00
|
|
|
onLoad((e) => {
|
2023-12-29 00:12:16 +08:00
|
|
|
if(uni.getStorageSync('userInfo')) {
|
|
|
|
userInfo.value = JSON.parse( uni.getStorageSync('userInfo'))
|
|
|
|
}
|
2023-11-01 00:33:57 +08:00
|
|
|
// console.log(e)
|
|
|
|
// a_info.value = JSON.parse(decodeURIComponent(e.info))
|
2023-10-19 23:23:22 +08:00
|
|
|
if(!e.id) {
|
|
|
|
uni.showToast({
|
|
|
|
icon:"error",
|
|
|
|
title:"错误",
|
|
|
|
duration:2000
|
|
|
|
})
|
2023-11-01 00:33:57 +08:00
|
|
|
// a_info.value = null
|
2023-10-19 23:23:22 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
getDetail(e.id)
|
|
|
|
})
|
|
|
|
// 变量
|
2024-02-28 01:26:27 +08:00
|
|
|
let strings = `<div style="text-align: center; "><p> 测试内容222sdadd </p><figure class="image"><img src="https://jmyl-app.oss-cn-chengdu.aliyuncs.com/miniapp/uploads/2024-02-24/undone.png"/></figure></div>`
|
|
|
|
// `<p> 测试内容222sdadd </p><figure class="image"><img src="https://jmyl-app.oss-cn-chengdu.aliyuncs.com/miniapp/uploads/2024-02-24/undone.png"></figure>`
|
|
|
|
// strings = strings.replaceAll("figure", "div");
|
|
|
|
// strings = strings.replaceAll("<img", "<img style='width:100%'");
|
|
|
|
console.log(strings)
|
2023-12-29 00:12:16 +08:00
|
|
|
const userInfo = ref(null)
|
2023-10-19 23:23:22 +08:00
|
|
|
// const content = ref(null)
|
|
|
|
const a_info = ref(null)
|
|
|
|
// 函数
|
|
|
|
async function getDetail(id) {
|
|
|
|
const res = await api.getArticleDetail({id})
|
2023-11-01 00:33:57 +08:00
|
|
|
if(res.code == 0) {
|
|
|
|
a_info.value = res.data
|
2024-02-28 01:26:27 +08:00
|
|
|
if(a_info.value.content) {
|
|
|
|
a_info.value.content = a_info.value.content.replaceAll("figure", "div");
|
|
|
|
a_info.value.content = a_info.value.content.replaceAll("<img", "<img style='width:100%'");
|
|
|
|
}
|
2023-11-01 00:33:57 +08:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
uni.showToast({
|
|
|
|
title:'获取失败',
|
|
|
|
icon:"error",
|
|
|
|
duration:2000
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
async function starFunc(type) { // 点击收藏
|
2023-12-29 00:12:16 +08:00
|
|
|
if(!userInfo.value) {
|
|
|
|
store.afterFailLogin(2000)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
console.log(a_info.value)
|
|
|
|
if(type) { // 添加收藏
|
|
|
|
const res = await api.getArticleFavorite({
|
|
|
|
wz_id:a_info.value.ID,
|
|
|
|
userId:userInfo.value.userId,
|
|
|
|
cover:a_info.value.cover_img,
|
|
|
|
title:a_info.value.title,
|
|
|
|
introductions:''
|
|
|
|
},userInfo.value.userId)
|
|
|
|
}
|
|
|
|
else{ // 取消收藏
|
|
|
|
const res = await api.delArticleFavorite({
|
|
|
|
id:a_info.value.ID,
|
|
|
|
},userInfo.value.userId)
|
|
|
|
}
|
2023-12-29 02:23:35 +08:00
|
|
|
a_info.value.is_favorite = type
|
2023-12-29 00:12:16 +08:00
|
|
|
|
2024-02-28 01:26:27 +08:00
|
|
|
}
|
|
|
|
</script>
|
2023-10-19 23:23:22 +08:00
|
|
|
<template>
|
|
|
|
<view class="detailBox">
|
|
|
|
<view class="title">
|
|
|
|
{{a_info?.title}}
|
|
|
|
</view>
|
2023-11-01 00:33:57 +08:00
|
|
|
<view v-if="a_info" class="more-info small-text">{{util.timestampToDate(a_info?.CreatedAt)}}</view>
|
2024-02-28 01:26:27 +08:00
|
|
|
<!-- <view class="d-content">
|
|
|
|
<rich-text :nodes="a_info?.content"></rich-text>
|
|
|
|
</view> -->
|
|
|
|
<view v-if="a_info" class="d-content" v-html="a_info.content">
|
|
|
|
</view>
|
2023-11-01 00:33:57 +08:00
|
|
|
<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">
|
2023-12-29 00:12:16 +08:00
|
|
|
<uni-icons color="#26758d" @tap="starFunc(0)" v-if="a_info?.is_favorite" type="star-filled" size="30"></uni-icons>
|
2023-11-01 00:33:57 +08:00
|
|
|
<uni-icons color="gray" @tap="starFunc(1)" v-else type="star" size="30"></uni-icons>
|
|
|
|
</view>
|
|
|
|
</view>
|
2023-11-07 00:12:02 +08:00
|
|
|
<emptyCard title="暂无内容" v-if="!a_info"></emptyCard>
|
2024-02-28 01:26:27 +08:00
|
|
|
</view>
|
|
|
|
</template>
|
2023-10-19 23:23:22 +08:00
|
|
|
<style scoped lang="scss">
|
2023-11-01 00:33:57 +08:00
|
|
|
.action-box{
|
|
|
|
margin-top: 20px;
|
|
|
|
display: flex;
|
|
|
|
justify-content: flex-end;
|
|
|
|
.ab-item{
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
margin: 0 20rpx;
|
|
|
|
}
|
|
|
|
}
|
2023-10-19 23:23:22 +08:00
|
|
|
.detailBox{
|
|
|
|
.more-info{
|
|
|
|
text-align: right;
|
|
|
|
margin-bottom: 10rpx;
|
|
|
|
}
|
|
|
|
.title{
|
|
|
|
font-size: 32rpx;
|
|
|
|
font-weight: 900;
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
padding: 40rpx;
|
|
|
|
.d-content{
|
|
|
|
line-height: 50rpx;
|
|
|
|
}
|
2024-02-28 01:26:27 +08:00
|
|
|
}
|
2023-10-19 23:23:22 +08:00
|
|
|
</style>
|