tmp: 部分代码与UnishopV5结合,但是代码有严重缺陷

This commit is contained in:
2025-12-20 15:30:39 +08:00
parent ed5181b382
commit e263a616f6
183 changed files with 31316 additions and 18590 deletions

View File

@@ -1,159 +1,165 @@
<template>
<page-meta :page-style="themeColor"></page-meta>
<view class="page">
<view class="help-title">{{ detail.article_title }}</view>
<view class="help-meta" v-if="detail.is_show_release_time == 1">
<text class="help-time">发表时间: {{ $util.timeStampTurnTime(detail.create_time) }}</text>
</view>
<view class="help-content"><rich-text :nodes="content"></rich-text></view>
<view class="bottom-area">
<view v-if="detail.is_show_read_num == 1">
阅读
<text class="price-font">{{ detail.read_num + detail.initial_read_num }}</text>
</view>
<view v-if="detail.is_show_dianzan_num == 1">
<text class="price-font">{{ detail.dianzan_num + detail.initial_dianzan_num }}</text>
人已赞
</view>
</view>
<loading-cover ref="loadingCover"></loading-cover>
<!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->
<privacy-popup ref="privacyPopup"></privacy-popup>
<!-- #endif -->
</view>
</template>
<script>
import htmlParser from '@/common/js/html-parser';
export default {
data() {
return {
articleId: 0,
detail: {},
content: ''
};
},
onLoad(options) {
this.articleId = options.article_id || 0;
// 小程序扫码进入
if (options.scene) {
var sceneParams = decodeURIComponent(options.scene);
this.articleId = sceneParams.split('-')[1];
}
if (this.articleId == 0) {
this.$util.redirectTo('/pages_tool/article/list', {}, 'redirectTo');
}
},
onShow() {
this.getData();
},
methods: {
getData() {
this.$api.sendRequest({
url: '/api/article/info',
data: {
article_id: this.articleId
},
success: res => {
if (res.code == 0 && res.data) {
this.detail = res.data;
this.$langConfig.title(this.detail.article_title);
this.content = htmlParser(this.detail.article_content);
this.setPublicShare();
} else {
this.$util.showToast({
title: res.message
});
setTimeout(() => {
this.$util.redirectTo('/pages_tool/article/list', {}, 'redirectTo');
}, 2000);
}
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
},
fail: res => {
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
},
// 设置公众号分享
setPublicShare() {
let shareUrl = this.$config.h5Domain + '/pages_tool/article/detail?article_id=' + this.articleId;
this.$util.setPublicShare({
title: this.detail.article_title,
desc: '',
link: shareUrl,
imgUrl: this.siteInfo ? this.$util.img(this.siteInfo.logo_square) : ''
});
}
},
onShareAppMessage(res) {
var title = this.detail.article_title;
var path = '/pages_tool/article/detail?article_id=' + this.articleId;
return {
title: title,
path: path,
success: res => {},
fail: res => {}
};
},
//分享到朋友圈
onShareTimeline() {
var title = this.detail.article_title;
var query = 'article_id=' + this.articleId;
return {
title: title,
query: query,
imageUrl: ''
};
}
};
</script>
<style lang="scss">
.page {
width: 100%;
height: 100%;
padding: 30rpx;
box-sizing: border-box;
background: #ffffff;
}
.help-title {
font-size: $font-size-toolbar;
text-align: left;
font-weight: bold;
}
.help-content {
margin-top: $margin-updown;
word-break: break-all;
}
.help-meta {
text-align: left;
margin-top: $margin-updown;
color: $color-tip;
.help-time {
font-size: $font-size-tag;
}
}
.bottom-area {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 40rpx;
.price-font {
font-weight: normal !important;
}
view {
color: #999;
font-size: 24rpx;
}
}
<template>
<page-meta :page-style="themeColor"></page-meta>
<view class="page">
<view class="help-title">{{ detail.article_title }}</view>
<view class="help-meta" v-if="detail.is_show_release_time == 1">
<text class="help-time">发表时间: {{ $util.timeStampTurnTime(detail.create_time) }}</text>
</view>
<view class="help-content">
<!-- <rich-text :nodes="content"></rich-text> -->
<ns-mp-html :content="content"></ns-mp-html>
</view>
<view class="bottom-area">
<view v-if="detail.is_show_read_num == 1">
阅读
<text class="price-font">{{ detail.read_num + detail.initial_read_num }}</text>
</view>
<view v-if="detail.is_show_dianzan_num == 1">
<text class="price-font">{{ detail.dianzan_num + detail.initial_dianzan_num }}</text>
人已赞
</view>
</view>
<!-- 悬浮按钮 -->
<hover-nav></hover-nav>
<loading-cover ref="loadingCover"></loading-cover>
<!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->
<privacy-popup ref="privacyPopup"></privacy-popup>
<!-- #endif -->
</view>
</template>
<script>
import htmlParser from '@/common/js/html-parser';
export default {
data() {
return {
articleId: 0,
detail: {},
content: ''
};
},
onLoad(options) {
this.articleId = options.article_id || 0;
// 小程序扫码进入
if (options.scene) {
var sceneParams = decodeURIComponent(options.scene);
this.articleId = sceneParams.split('-')[1];
}
if (this.articleId == 0) {
this.$util.redirectTo('/pages_tool/article/list', {}, 'redirectTo');
}
},
onShow() {
this.getData();
},
methods: {
getData() {
this.$api.sendRequest({
url: '/api/article/info',
data: {
article_id: this.articleId
},
success: res => {
if (res.code == 0 && res.data) {
this.detail = res.data;
this.$langConfig.title(this.detail.article_title);
// this.content = htmlParser(this.detail.article_content);
this.content = this.detail.article_content;
this.setPublicShare();
} else {
this.$util.showToast({
title: res.message
});
setTimeout(() => {
this.$util.redirectTo('/pages_tool/article/list', {}, 'redirectTo');
}, 2000);
}
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
},
fail: res => {
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
},
// 设置公众号分享
setPublicShare() {
let shareUrl = this.$config.h5Domain + '/pages_tool/article/detail?article_id=' + this.articleId;
this.$util.setPublicShare({
title: this.detail.article_title,
desc: '',
link: shareUrl,
imgUrl: this.siteInfo ? this.$util.img(this.siteInfo.logo_square) : ''
});
}
},
onShareAppMessage(res) {
var title = this.detail.article_title;
var path = '/pages_tool/article/detail?article_id=' + this.articleId;
return {
title: title,
path: path,
success: res => {},
fail: res => {}
};
},
//分享到朋友圈
onShareTimeline() {
var title = this.detail.article_title;
var query = 'article_id=' + this.articleId;
return {
title: title,
query: query,
imageUrl: ''
};
}
};
</script>
<style lang="scss">
.page {
width: 100%;
height: 100%;
padding: 30rpx;
box-sizing: border-box;
background: #ffffff;
}
.help-title {
font-size: $font-size-toolbar;
text-align: left;
font-weight: bold;
}
.help-content {
margin-top: $margin-updown;
word-break: break-all;
}
.help-meta {
text-align: left;
margin-top: $margin-updown;
color: $color-tip;
.help-time {
font-size: $font-size-tag;
}
}
.bottom-area {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 40rpx;
.price-font {
font-weight: normal !important;
}
view {
color: #999;
font-size: 24rpx;
}
}
</style>

View File

@@ -1,7 +1,21 @@
<template>
<page-meta :page-style="themeColor"></page-meta>
<view>
<mescroll-uni @getData="getData" ref="mescroll">
<scroll-view class="catrgory-nav" scroll-x="true" :scroll-left="scrollLeft" :show-scrollbar="false" scroll-with-animation="true">
<view class="navs">
<view v-for="(categoryItem, categoryIndex) in categoryList" :key="categoryIndex" class="uni-tab-item" :id="categoryItem.category_id" :data-current="categoryIndex" @click="ontabtap">
<text class="uni-tab-item-title" :class="categoryItem.category_id == categoryId ? 'uni-tab-item-title-active color-base-text' : ''">
{{ categoryItem.category_name }}
</text>
</view>
</view>
</scroll-view>
<!-- #ifdef MP -->
<mescroll-uni ref="mescroll" @getData="getData" top="60rpx" >
<!-- #endif -->
<!-- #ifndef MP -->
<mescroll-uni ref="mescroll" @getData="getData" top="86rpx" >
<!-- #endif -->
<block slot="list">
<view class="article-wrap" v-if="list.length">
<ns-adv keyword="NS_ARTICLE" class-name="adv-wrap"></ns-adv>
@@ -16,7 +30,7 @@
<text class="category-icon"></text>
<text>{{ item.category_name }}</text>
</block>
<text class="date">{{ $util.timeStampTurnTime(item.create_time, 'date') }}</text>
<text class="date">{{ $util.timeStampTurnTime(item.create_time, 'Y-m-d') }}</text>
</view>
</view>
</view>
@@ -25,6 +39,8 @@
<loading-cover ref="loadingCover"></loading-cover>
</block>
</mescroll-uni>
<!-- 悬浮按钮 -->
<hover-nav></hover-nav>
<!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->
@@ -38,22 +54,71 @@
export default {
data() {
return {
list: []
list: [],
categoryList: [],
categoryId: '',
scrollLeft: 0,
contentScrollW: 0, // 导航区宽度
};
},
components: {
nsAdv
},
onShow() {
this.getArticleCategory()
this.setPublicShare();
},
methods: {
getScrollW() {
const query = uni.createSelectorQuery().in(this);
query.select('.catrgory-nav').boundingClientRect(data => {
// 拿到 scroll-view 组件宽度
this.contentScrollW = data.width
}).exec();
query.selectAll('.uni-tab-item').boundingClientRect(data => {
let dataLen = data.length;
for (let i = 0; i < dataLen; i++) {
// scroll-view 子元素组件距离左边栏的距离
this.categoryList[i].left = data[i].left;
// scroll-view 子元素组件宽度
this.categoryList[i].width = data[i].width
}
}).exec()
},
ontabtap(e) {
let index = e.target.dataset.current || e.currentTarget.dataset.current;
this.categoryId = this.categoryList[index].category_id;
this.scrollLeft = this.categoryList[index].left - this.contentScrollW / 2 + this.categoryList[index].width / 2;
this.$refs.loadingCover.show();
this.$refs.mescroll.refresh();
},
/**
* 获取文章分类
*/
getArticleCategory() {
this.$api.sendRequest({
url: '/api/article/category',
success: res => {
if (res.code >= 0) {
this.categoryList = [{ category_id: '',category_name: '全部' }]
this.categoryList.push(...res.data);
this.$nextTick(()=>{
this.getScrollW()
})
}
},
});
},
getData(mescroll) {
this.$api.sendRequest({
url: '/api/article/page',
data: {
page_size: mescroll.size,
page: mescroll.num
page: mescroll.num,
category_id: this.categoryId
},
success: res => {
let newArr = [];
@@ -128,7 +193,60 @@
.empty-wrap {
padding-top: 200rpx;
}
.catrgory-nav {
height: 80rpx;
background: #fff;
position: fixed;
left: 0;
z-index: 998;
border-radius: 0px 0px 24rpx 24rpx;
.navs {
flex-direction: row;
/* #ifndef APP-PLUS */
white-space: nowrap;
/* #endif */
display: flex;
justify-content: space-around;
}
.uni-tab-item {
padding: 0 30rpx;
text-align: center;
}
.uni-tab-item-title {
display: inline-block;
height: 80rpx;
line-height: 80rpx;
border-bottom: 1px solid #fff;
flex-wrap: nowrap;
/* #ifndef APP-PLUS */
white-space: nowrap;
/* #endif */
text-align: center;
font-size: 30rpx;
position: relative;
}
.uni-tab-item-title-active::after {
content: ' ';
display: block;
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 6rpx;
background: linear-gradient(270deg, var(--base-color-light-9) 0%, var(--base-color) 100%);
}
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
}
.article-wrap {
background: #f8f8f8;