对接文章相关接口
parent
063b3d68e3
commit
b29e554e20
|
|
@ -627,7 +627,7 @@
|
||||||
"iconPath": "static/tabbar/healthy.png",
|
"iconPath": "static/tabbar/healthy.png",
|
||||||
"selectedIconPath": "static/tabbar/healthy_sel.png",
|
"selectedIconPath": "static/tabbar/healthy_sel.png",
|
||||||
"pagePath": "pages/healthy/index",
|
"pagePath": "pages/healthy/index",
|
||||||
"text": "健康"
|
"text": "文章"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"iconPath": "static/tabbar/my.png",
|
"iconPath": "static/tabbar/my.png",
|
||||||
|
|
|
||||||
|
|
@ -33,20 +33,11 @@
|
||||||
<view class="px-36rpx mt-15rpx text-md text-txBase">{{info.subtitle}}</view>
|
<view class="px-36rpx mt-15rpx text-md text-txBase">{{info.subtitle}}</view>
|
||||||
<view class="px-36rpx flex items-center justify-between text-md text-txGray">
|
<view class="px-36rpx flex items-center justify-between text-md text-txGray">
|
||||||
<view class="">{{info.created_at}}</view>
|
<view class="">{{info.created_at}}</view>
|
||||||
<view @tap="getThumbs" class="flex items-center">
|
|
||||||
<u-icon :color="info.like_status ? '#378264' : ''" size="48"
|
|
||||||
:name="info.like_status ? 'thumb-up-fill' : 'thumb-up'"></u-icon>
|
|
||||||
<view class="ml-base">{{info.likes}}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="mx-base mt-base h-2rpx bg-txBorder"></view>
|
<view class="mx-base mt-base h-2rpx bg-txBorder"></view>
|
||||||
<view class="px-36rpx mt-30rpx text-md text-txBase leading-60rpx">
|
<view class="px-36rpx mt-30rpx text-md text-txBase leading-60rpx">
|
||||||
<u-parse :tag-style="style" :html="info.content"></u-parse>
|
<u-parse :tag-style="style" :html="info.content"></u-parse>
|
||||||
</view>
|
</view>
|
||||||
<!-- 倒计时 -->
|
|
||||||
<view v-if="isShow"
|
|
||||||
class="w-100rpx text-center borders text-lg text-txBase fixed right-0 z-8 top-500rpx bg-primary bg-opacity-60 ">
|
|
||||||
{{Time}}</view>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -56,11 +47,7 @@
|
||||||
return {
|
return {
|
||||||
swiperList: [], //轮播图
|
swiperList: [], //轮播图
|
||||||
info: {},
|
info: {},
|
||||||
Time: 15,
|
|
||||||
val: '',
|
|
||||||
isShow: false,
|
|
||||||
style: {
|
style: {
|
||||||
// img:'width:100% !important',
|
|
||||||
table: 'width:100% !important',
|
table: 'width:100% !important',
|
||||||
p: 'text-indent:20px'
|
p: 'text-indent:20px'
|
||||||
},
|
},
|
||||||
|
|
@ -68,21 +55,12 @@
|
||||||
audioCtx:''
|
audioCtx:''
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {},
|
async onLoad({id}) {
|
||||||
async onLoad({
|
|
||||||
id
|
|
||||||
}) {
|
|
||||||
await this.getDate(id)
|
await this.getDate(id)
|
||||||
await this.getDown()
|
|
||||||
},
|
},
|
||||||
onReady() {
|
onReady() {
|
||||||
this.audioCtx = uni.createAudioContext('myAudio')
|
this.audioCtx = uni.createAudioContext('myAudio')
|
||||||
},
|
},
|
||||||
onUnload() {
|
|
||||||
clearInterval(this.val)
|
|
||||||
this.Time = 15,
|
|
||||||
this.isShow = false
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
audioClick(){
|
audioClick(){
|
||||||
this.isPlaying=!this.isPlaying
|
this.isPlaying=!this.isPlaying
|
||||||
|
|
@ -98,49 +76,13 @@
|
||||||
if (resDate.media_type == 1) {
|
if (resDate.media_type == 1) {
|
||||||
this.getSwiper(resDate.media_content)
|
this.getSwiper(resDate.media_content)
|
||||||
}
|
}
|
||||||
if (resDate.points > 0 && !resDate.has_read) {
|
|
||||||
this.isShow = true
|
|
||||||
}
|
|
||||||
this.info = resDate
|
this.info = resDate
|
||||||
},
|
},
|
||||||
getSwiper(val) {
|
getSwiper(val) {
|
||||||
let arr = val.split(',')
|
let arr = val.split(',')
|
||||||
this.swiperList = arr
|
this.swiperList = arr
|
||||||
},
|
},
|
||||||
//点赞
|
},
|
||||||
async getThumbs() {
|
|
||||||
await this.$api.post(`/v1/articles/${this.info.id}/like`, {}, {
|
|
||||||
custom: {
|
|
||||||
loading: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.info.like_status = true;
|
|
||||||
this.info.likes += 1
|
|
||||||
this.$u.toast('点赞成功');
|
|
||||||
uni.$emit('isUp', {
|
|
||||||
id: this.info.id
|
|
||||||
})
|
|
||||||
},
|
|
||||||
//倒计时
|
|
||||||
getDown() {
|
|
||||||
if (this.isShow && !this.info.has_read) {
|
|
||||||
this.val = setInterval(() => {
|
|
||||||
this.Time--
|
|
||||||
if (this.Time == 0) {
|
|
||||||
this.Time = 15
|
|
||||||
clearInterval(this.val)
|
|
||||||
this.isShow = false
|
|
||||||
this.$api.post(`/v1/articles/${this.info.id}/read`).then(({
|
|
||||||
points
|
|
||||||
}) => {
|
|
||||||
this.$store.dispatch('user/getUserInfo')
|
|
||||||
this.$u.toast(`阅读成功,+${points}积分`);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}, 1000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
<view>
|
<view>
|
||||||
<loading-view v-if="isFirstLoading"></loading-view>
|
<loading-view v-if="isFirstLoading"></loading-view>
|
||||||
<!-- 顶部tabbar -->
|
<!-- 顶部tabbar -->
|
||||||
<view class="bg-white sticky top-0 z-9999">
|
<view class="bg-white sticky w-full top-0 z-9999">
|
||||||
<u-tabs :list="list" active-color="#378264" inactive-color="#808080" :current="id" @change="change"></u-tabs>
|
<u-tabs :list="tabbarList" :is-scroll="isScroll" active-color="#378264" inactive-color="#808080" :current="current" @change="change"></u-tabs>
|
||||||
</view>
|
</view>
|
||||||
<mescroll-body :height="height" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
|
<mescroll-body :height="height" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
|
||||||
:down="downOption" :up="upOption">
|
:down="downOption" :up="upOption">
|
||||||
|
|
@ -17,18 +17,10 @@
|
||||||
<block v-if="item.cover">
|
<block v-if="item.cover">
|
||||||
<u-image border-radius="15rpx" width="250rpx" height="187rpx" :src="item.cover" :lazy-load="true"></u-image>
|
<u-image border-radius="15rpx" width="250rpx" height="187rpx" :src="item.cover" :lazy-load="true"></u-image>
|
||||||
</block>
|
</block>
|
||||||
<view class="ml-base flex-1">
|
<view class="ml-base flex-1 h-187rpx flex items-start justify-between flex-col">
|
||||||
<view class="text-txBase w-full h-80rpx leading-40rpx text-30rpx two-ellipsis font-bold">{{item.title}}
|
<view class="text-txBase w-full leading-40rpx text-30rpx three-ellipsis font-bold">{{item.title}}
|
||||||
</view>
|
|
||||||
<view class="text-txGray text-md mt-10rpx">{{item.created_at}}</view>
|
|
||||||
<view class="flex items-center justify-between mt-10rpx text-txGray text-md">
|
|
||||||
<view>积分: {{item.points}}</view>
|
|
||||||
<view class="flex items-center">
|
|
||||||
<u-icon :color="item.like_status ? '#378264' : ''" size="48"
|
|
||||||
:name="item.like_status ? 'thumb-up-fill' : 'thumb-up'"></u-icon>
|
|
||||||
<view class="ml-10rpx h-30rpx">{{item.likes}}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
<view class="text-txGray text-md text-right w-full">{{item.created_at}}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</mescroll-body>
|
</mescroll-body>
|
||||||
|
|
@ -42,28 +34,9 @@
|
||||||
mixins: [MescrollMixin, CartMixin],
|
mixins: [MescrollMixin, CartMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
list: [{
|
tabbarList: [],
|
||||||
name: '待收货'
|
|
||||||
}, {
|
|
||||||
name: '待付款'
|
|
||||||
}, {
|
|
||||||
name: '待评价',
|
|
||||||
}, {
|
|
||||||
name: '待收货'
|
|
||||||
}, {
|
|
||||||
name: '待付款'
|
|
||||||
}, {
|
|
||||||
name: '待评价',
|
|
||||||
}, {
|
|
||||||
name: '待收货'
|
|
||||||
}, {
|
|
||||||
name: '待付款'
|
|
||||||
}, {
|
|
||||||
name: '待评价',
|
|
||||||
}],
|
|
||||||
isFirstLoading: true,
|
isFirstLoading: true,
|
||||||
article_banner: [], //广告位图片
|
article_banner: [], //广告位图片
|
||||||
searchText: '',
|
|
||||||
downOption: {
|
downOption: {
|
||||||
auto: false,
|
auto: false,
|
||||||
},
|
},
|
||||||
|
|
@ -74,10 +47,13 @@
|
||||||
noMoreSize: 1
|
noMoreSize: 1
|
||||||
},
|
},
|
||||||
dataList: [], //获取到的数据
|
dataList: [], //获取到的数据
|
||||||
id: 0
|
current: 0
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
isScroll(){
|
||||||
|
return this.tabbarList.length>5?true:false
|
||||||
|
},
|
||||||
height() {
|
height() {
|
||||||
const {
|
const {
|
||||||
windowHeight,
|
windowHeight,
|
||||||
|
|
@ -87,30 +63,23 @@
|
||||||
},
|
},
|
||||||
cpaceImage() {
|
cpaceImage() {
|
||||||
return this.article_banner.length > 0 ? this.article_banner[0] : {}
|
return this.article_banner.length > 0 ? this.article_banner[0] : {}
|
||||||
|
},
|
||||||
|
chooseItem(){
|
||||||
|
return this.tabbarList[this.current]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad({
|
onLoad() {
|
||||||
id
|
|
||||||
}) {
|
|
||||||
this.id = id
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isFirstLoading = false
|
this.isFirstLoading = false
|
||||||
}, 300)
|
}, 300)
|
||||||
this.getCpace()
|
this.getCpace()
|
||||||
uni.$on('isUp', ({
|
this.getDate()
|
||||||
id
|
|
||||||
}) => {
|
|
||||||
this.dataList.forEach((item) => {
|
|
||||||
if (item.id == id) {
|
|
||||||
item.like_status = true;
|
|
||||||
item.likes += 1
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
change(e) {
|
change(e) {
|
||||||
this.id = e
|
if(e==this.current) return
|
||||||
|
this.current=e
|
||||||
|
this.downCallback()
|
||||||
},
|
},
|
||||||
//获取广告位
|
//获取广告位
|
||||||
async getCpace() {
|
async getCpace() {
|
||||||
|
|
@ -121,8 +90,14 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.article_banner = resDate.article_banner
|
this.article_banner = resDate.article_banner
|
||||||
} catch (err) {} finally {}
|
} catch (err) {}
|
||||||
},
|
},
|
||||||
|
//获取文章分类
|
||||||
|
async getDate(){
|
||||||
|
const resData=await this.$api.get('/v1/articles/category')
|
||||||
|
this.tabbarList=resData
|
||||||
|
this.downCallback()
|
||||||
|
},
|
||||||
downCallback() {
|
downCallback() {
|
||||||
this.mescroll.resetUpScroll();
|
this.mescroll.resetUpScroll();
|
||||||
this.dataList = []
|
this.dataList = []
|
||||||
|
|
@ -135,12 +110,12 @@
|
||||||
size
|
size
|
||||||
}) {
|
}) {
|
||||||
let obj = {
|
let obj = {
|
||||||
category: this.id,
|
cate: this.chooseItem?.id,
|
||||||
key: this.searchText,
|
key:'',
|
||||||
page: num,
|
page: num,
|
||||||
per_page: size
|
per_page: size
|
||||||
}
|
}
|
||||||
this.$api.get(`/v1/articles/by-category/${ this.id}`, {
|
this.$api.get(`/v1/articles`, {
|
||||||
params: obj
|
params: obj
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
this.mescroll.endSuccess(res.data.length)
|
this.mescroll.endSuccess(res.data.length)
|
||||||
|
|
@ -159,7 +134,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue