This commit is contained in:
2025-06-16 10:09:19 +08:00
commit 7a066b3026
428 changed files with 50385 additions and 0 deletions

64
pages/tutorial/detail.vue Normal file
View File

@ -0,0 +1,64 @@
<template>
<view class="flex flex-column" style="width:100vw;height: 100vh;">
<i-loading v-if="loading" />
<view class="mt-2 font40 line15">{{newsInfo.title}}</view>
<scroll-view>
<view class="mt-2">
<u-parse :content="newsInfo.content" @preview="preview" @navigate="navigate"></u-parse>
</view>
</scroll-view>
</view>
</template>
<script>
import { friendlyDate } from '../../common/util';
import {
TaAjax
} from '@/common/ajax'
export default {
data() {
return {
id: 0,
newsInfo: {
title: "",
content: "",
material: "",
method: "",
view_count: 0,
},
loading: true
}
},
onLoad(params) {
this.id = params.id
this.loading = true;
TaAjax.get('/cms/api.tutorial/info', {
id: this.id
}).then((response) => {
if (response.code == 0) {
uni.showToast({
title: response.info
})
return uni.navigateBack()
}
const data = response.data;
uni.setNavigationBarTitle({
title: data.title
});
data.create_at = friendlyDate((new Date(data.create_at.replace(/\-/g, '/')).getTime()))
this.newsInfo = data;
}).catch((e) => {
console.warn(e)
}).finally(() => {
this.loading = false;
})
},
methods: {
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,91 @@
<template>
<view class="flex flex-column" style="width:100vw;height: 100vh;">
<i-loading v-if="loading" />
<view class="flex flex-column flex-1">
<scroll-view class="flex-1" :scroll-y="true" :refresher-enabled="true"
:refresher-triggered="refresh" @refresherrefresh="refreshData" @scrolltolower="loadData">
<view class="px-2">
<i-tutorial-list :resdata="newsList" />
</view>
<uni-load-more :status="more_status" @clickLoadMore="loadData"></uni-load-more>
</scroll-view>
</view>
</view>
</template>
<script>
import {
TaAjax
} from '@/common/ajax';
import {
friendlyDate
} from '@/common/util';
export default {
computed: {
more_status() {
if (this.finish) {
return 'no-more';
} else if (this.loading) {
return 'loading';
} else {
return 'more';
}
},
},
data() {
return {
newsList: [],
curPage: 1,
loading: true,
refresh: true,
finish: false
}
},
methods: {
loadData() {
if (this.refresh) {
this.newsList.length = 0;
this.finish = false;
}
if (this.finish) {
return;
}
TaAjax.get('/cms/api.tutorial/index', {
page: this.curPage
}).then((result) => {
const data = result.data;
const data_list = data.data.map((news) => {
news.publish_at = friendlyDate(new Date(news.create_at.replace(/\-/g, '/'))
.getTime())
news.imgs = [];
return news;
});
if (this.refresh) {
this.newsList.length = 0;
}
this.newsList = this.newsList.concat(data_list);
this.finish = data.total <= this.newsList.length;
this.curPage++;
}).catch((e) => {
console.warn(e)
if (this.newsList.length == 0) {
this.finish = true;
}
}).finally(() => {
this.refresh = false;
this.loading = false;
});
},
refreshData() {
this.finish = false;
this.refresh = true;
this.curPage = 1;
this.loadData();
},
}
}
</script>
<style>
</style>