first commit
This commit is contained in:
197
pages/article/detail/detail.vue
Normal file
197
pages/article/detail/detail.vue
Normal file
@ -0,0 +1,197 @@
|
||||
<template>
|
||||
<view :data-theme="theme()" :class="theme() || ''" class="article-detail" v-if="loadding">
|
||||
<view class="title fb">{{ article.article_title }}</view>
|
||||
<view class="info d-b-c f24">
|
||||
<view>
|
||||
<text class="red">{{ article.category.name }}</text>
|
||||
<text class="ml30">{{ article.create_time }}</text>
|
||||
</view>
|
||||
<button class="share-box" open-type="share" @click="shareFunc"><image class="share_img" src="/static/icon/fenxiang.png" mode=""></image></button>
|
||||
</view>
|
||||
<view class="article-content" v-html="article.article_content"></view>
|
||||
<tabBar></tabBar>
|
||||
<!--app分享-->
|
||||
<AppShare :isAppShare="isAppShare" :appParams="appParams" @close="closeAppShare"></AppShare>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import utils from '@/common/utils.js';
|
||||
import AppShare from '@/components/app-share.vue';
|
||||
export default {
|
||||
components: {
|
||||
AppShare
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
/*是否加载完成*/
|
||||
loadding: false,
|
||||
indicatorDots: true,
|
||||
autoplay: true,
|
||||
interval: 2000,
|
||||
duration: 500,
|
||||
/*文章id*/
|
||||
article_id: 0,
|
||||
/*文章详情*/
|
||||
article: {
|
||||
image: {}
|
||||
},
|
||||
urldata: '',
|
||||
/*app分享*/
|
||||
isAppShare: false,
|
||||
appParams: {
|
||||
title: '',
|
||||
summary: '',
|
||||
path: ''
|
||||
}
|
||||
};
|
||||
},
|
||||
onLoad(e) {
|
||||
/*分类id*/
|
||||
this.article_id = e.article_id;
|
||||
//#ifdef H5
|
||||
if (this.isWeixin()) {
|
||||
this.urldata = window.location.href;
|
||||
}
|
||||
//#endif
|
||||
},
|
||||
mounted() {
|
||||
/*获取产品详情*/
|
||||
this.getData();
|
||||
},
|
||||
/*分享*/
|
||||
onShareAppMessage() {
|
||||
let self = this;
|
||||
// 构建页面参数
|
||||
let params = self.getShareUrlParams({
|
||||
article_id: self.article_id
|
||||
});
|
||||
self.taskFunc();
|
||||
return {
|
||||
title: self.article.article_title,
|
||||
path: '/pages/article/detail/detail?' + params
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
taskFunc() {
|
||||
let self = this;
|
||||
self._post(
|
||||
'plus.task.Task/dayTask',
|
||||
{
|
||||
task_type: 'article'
|
||||
},
|
||||
res => {
|
||||
console.log('分享成功')
|
||||
}
|
||||
);
|
||||
},
|
||||
/*复制*/
|
||||
copyUrl() {
|
||||
var input = document.createElement('input');
|
||||
let message = window.location.href;
|
||||
input.value = message;
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
input.setSelectionRange(0, input.value.length), document.execCommand('Copy');
|
||||
document.body.removeChild(input);
|
||||
uni.showToast({
|
||||
title: '复制成功',
|
||||
icon: 'success',
|
||||
mask: true,
|
||||
duration: 2000
|
||||
});
|
||||
},
|
||||
shareFunc() {
|
||||
let self = this;
|
||||
this.taskFunc();
|
||||
//#ifdef H5
|
||||
self.copyUrl();
|
||||
//#endif
|
||||
//#ifdef APP-PLUS
|
||||
self.appParams.title = self.detail.product_name;
|
||||
self.appParams.summary = self.detail.product_name;
|
||||
// 构建页面参数
|
||||
let params = self.getShareUrlParams({
|
||||
article_id: self.article_id
|
||||
});
|
||||
self.appParams.path = '/pages/article/detail/detail?' + params;
|
||||
self.appParams.image = self.detail.image[0].file_path;
|
||||
self.isAppShare = true;
|
||||
//#endif
|
||||
},
|
||||
//关闭分享
|
||||
closeAppShare(data) {
|
||||
this.isAppShare = false;
|
||||
},
|
||||
/*获取文章详情*/
|
||||
getData() {
|
||||
let self = this;
|
||||
uni.showLoading({
|
||||
title: '加载中'
|
||||
});
|
||||
self.loading = true;
|
||||
let article_id = self.article_id;
|
||||
self._get(
|
||||
'plus.article.article/detail',
|
||||
{
|
||||
article_id: article_id,
|
||||
url: self.urldata
|
||||
},
|
||||
function(res) {
|
||||
/*详情内容格式化*/
|
||||
res.data.detail.article_content = utils.format_content(res.data.detail.article_content);
|
||||
console.log(res.data.detail.article_content);
|
||||
self.article = res.data.detail;
|
||||
// 配置微信分享参数
|
||||
//#ifdef H5
|
||||
if (self.url != '') {
|
||||
let params = {
|
||||
article_id: self.article_id
|
||||
};
|
||||
self.configWx(res.data.share.signPackage, res.data.share.shareParams, params);
|
||||
}
|
||||
//#endif
|
||||
self.loadding = true;
|
||||
uni.hideLoading();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.article-detail {
|
||||
padding: 30rpx;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.article-detail .title {
|
||||
font-size: 44rpx;
|
||||
}
|
||||
|
||||
.article-detail .info {
|
||||
padding: 40rpx 0;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.article-detail .article-content {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
line-height: 60rpx;
|
||||
font-size: 34 rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
.article-detail .article-content image,
|
||||
.article-detail .article-content img {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
}
|
||||
.share-box {
|
||||
background: none;
|
||||
}
|
||||
.share_img {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
</style>
|
||||
242
pages/article/list/list.vue
Normal file
242
pages/article/list/list.vue
Normal file
@ -0,0 +1,242 @@
|
||||
<template>
|
||||
<view class="article-list-wrap" :data-theme='theme()' :class="theme() || ''">
|
||||
<view class="top-tabbar">
|
||||
<scroll-view scroll-x="true" scroll-with-animation="true">
|
||||
<view class="type-list d-s-c">
|
||||
<view :class="type_active == 0 ? 'tab-item active' : 'tab-item '" @click="tabTypeFunc(0)">
|
||||
全部
|
||||
</view>
|
||||
<view :class="type_active == item.category_id ? 'tab-item active' : 'tab-item '" v-for="(item, index) in categorys" :key="index" @click="tabTypeFunc(item.category_id)">
|
||||
{{ item.name }}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<template>
|
||||
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50" @scrolltolower="scrolltolowerFunc">
|
||||
<view class="article-list">
|
||||
<view class="item" v-for="(item, index) in listData" :key="index" @click="gotoDetail(item.article_id)">
|
||||
<view class="info">
|
||||
<view class="title">{{ item.article_title }}</view>
|
||||
<view class="summary">{{ item.dec }}</view>
|
||||
<view class="datatime d-s-c">
|
||||
<text>{{ item.create_time }}</text>
|
||||
<text class="icon iconfont icon-chakan ml30"></text>
|
||||
<text class="ml10">{{ item.actual_views }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="pic" v-if="item.image != null"><image :src="item.image.file_path" mode="aspectFill"></image></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 没有记录 -->
|
||||
<view class="d-c-c p30" v-if="listData.length == 0 && !loading">
|
||||
<text class="iconfont icon-wushuju"></text>
|
||||
<text class="cont">亲,暂无相关记录哦</text>
|
||||
</view>
|
||||
<uni-load-more v-else :loadingType="loadingType"></uni-load-more>
|
||||
</scroll-view>
|
||||
</template>
|
||||
<tabBar></tabBar>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import uniLoadMore from '@/components/uni-load-more.vue';
|
||||
export default {
|
||||
components: {
|
||||
uniLoadMore
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
/*是否加载完成*/
|
||||
loading: true,
|
||||
/*手机高度*/
|
||||
phoneHeight: 0,
|
||||
/*可滚动视图区域高度*/
|
||||
scrollviewHigh: 0,
|
||||
/*数据列表*/
|
||||
listData: [],
|
||||
/*是否有更多*/
|
||||
no_more: null,
|
||||
/*一页多少条*/
|
||||
list_rows: 10,
|
||||
/*当前第几页*/
|
||||
page: 1,
|
||||
/*分类数据*/
|
||||
categorys: [],
|
||||
/*当前选中的类别*/
|
||||
type_active: 0
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
/*加载中状态*/
|
||||
loadingType() {
|
||||
if (this.loading) {
|
||||
return 1;
|
||||
} else {
|
||||
if (this.listData.length != 0 && this.no_more) {
|
||||
return 2;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
/*获取分类*/
|
||||
this.getCategory();
|
||||
/*获取新闻列表*/
|
||||
this.getData();
|
||||
},
|
||||
methods: {
|
||||
/*初始化*/
|
||||
init() {
|
||||
let _this = this;
|
||||
uni.getSystemInfo({
|
||||
success(res) {
|
||||
_this.phoneHeight = res.windowHeight;
|
||||
// 计算组件的高度
|
||||
let view = uni.createSelectorQuery().select('.top-tabbar');
|
||||
view.boundingClientRect(data => {
|
||||
let h = _this.phoneHeight - data.height;
|
||||
_this.scrollviewHigh = h;
|
||||
}).exec();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/*获取文章分类*/
|
||||
getCategory() {
|
||||
let self = this;
|
||||
self._get('plus.article.article/category', {}, function(res) {
|
||||
self.categorys = res.data.category;
|
||||
});
|
||||
},
|
||||
|
||||
/*tab切换*/
|
||||
tabTypeFunc(e) {
|
||||
if(e!=this.type_active){
|
||||
this.type_active=e;
|
||||
this.page=1;
|
||||
this.listData=[];
|
||||
this.getData();
|
||||
}
|
||||
},
|
||||
|
||||
/*获取数据*/
|
||||
getData() {
|
||||
let self = this;
|
||||
let page = self.page;
|
||||
let list_rows = self.list_rows;
|
||||
self.loading = true;
|
||||
uni.showLoading({
|
||||
title: '加载中'
|
||||
});
|
||||
self._get(
|
||||
'plus.article.article/index',
|
||||
{
|
||||
page: page || 1,
|
||||
list_rows: list_rows,
|
||||
category_id:self.type_active
|
||||
},
|
||||
function(res) {
|
||||
self.listData = self.listData.concat(res.data.list.data);
|
||||
self.last_page = res.data.list.last_page;
|
||||
if (res.data.list.last_page <= 1) {
|
||||
self.no_more = true;
|
||||
}
|
||||
self.loading = false;
|
||||
uni.hideLoading();
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/*可滚动视图区域到底触发*/
|
||||
scrolltolowerFunc() {
|
||||
let self = this;
|
||||
self.bottomRefresh = true;
|
||||
self.page++;
|
||||
self.loading = true;
|
||||
if (self.page > self.last_page) {
|
||||
self.loading = false;
|
||||
self.no_more = true;
|
||||
return;
|
||||
}
|
||||
self.getData();
|
||||
},
|
||||
|
||||
/*跳转文章详情*/
|
||||
gotoDetail(e) {
|
||||
this.gotoPage('/pages/article/detail/detail?article_id=' + e);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.article-list-wrap .type-list .tab-item {
|
||||
padding: 0 30rpx;
|
||||
font-size: 34rpx;
|
||||
height: 86rpx;
|
||||
line-height: 86rpx;
|
||||
white-space: nowrap;
|
||||
border-bottom: 4rpx solid #FFFFFF;
|
||||
}
|
||||
.article-list-wrap .type-list .tab-item.active{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.article-list {
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.article-list .item {
|
||||
padding: 30rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid #e3e3e3;
|
||||
}
|
||||
|
||||
.article-list .item .info {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.article-list .item .title {
|
||||
font-size: 36rpx;
|
||||
}
|
||||
|
||||
.article-list .item .summary {
|
||||
margin-top: 20rpx;
|
||||
font-size: 28rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.article-list .item .title,
|
||||
.article-list .item .summary {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
.article-list .item .pic {
|
||||
padding-left: 30rpx;
|
||||
}
|
||||
|
||||
.article-list .item .pic,
|
||||
.article-list .item .pic image {
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
}
|
||||
|
||||
.article-list .item .datatime {
|
||||
margin-top: 20rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user