123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- <template>
- <view class="main">
- <view class="info">
- <scroll-view scroll-y="true" :scroll-top="scrollTop" class="scroll-view">
- <view class="list-scroll-view">
- <view class="one">
- <swiperImg :imgsList='info.file'></swiperImg>
- </view>
- <view class="two">
- <view class="two_1">{{info.title||'暂无标题'}}</view>
- <view class="two_2">#{{info.zhType||'暂无类型'}}</view>
- <view class="two_3">
- <rich-text :nodes="info.content"></rich-text>
- </view>
- <view class="two_4">发布时间:{{info.create_time}}</view>
- </view>
- <view class="thr">
- <view class="thr_1">评论 {{total}}</view>
- <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
- <view class="list-scroll-view">
- <view class="thr_2">
- <view class="list" v-for="(item,index) in list" :key="index">
- <image class="image"
- :src="item.user_file&&item.user_file.length>0?item.user_file[0].url:'../../static/my.png'"
- mode="aspectFill">
- </image>
- <view class="other">
- <view class="name textOver">{{item.user_name||'暂无'}}</view>
- <view class="content">{{item.content||'暂无'}}</view>
- </view>
- </view>
- </view>
- <view class="is_bottom" v-if="is_bottom">
- <text>{{config.bottom_title}}</text>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="foot">
- <view class="foot_1">
- <view class="left">
- <uni-easyinput confirmType="send" prefixIcon="chatbubble" v-model="content" placeholder="说点什么..."
- @confirm="toSend">
- </uni-easyinput>
- </view>
- <view class="right">
- <view class="right_1"><text class="iconfont icon-aixin"></text>{{like}}</view>
- <view class="right_1"><text class="iconfont icon-shoucang1"></text>{{collect}}</view>
- <view class="right_1" @click="pageScroll"><text class="iconfont icon-pinglun"></text>{{total}}
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import swiperImg from '../../components/swiper/index.vue';
- export default {
- components: {
- swiperImg
- },
- data() {
- return {
- id: '',
- config: {},
- user: {},
- info: {},
- // 评论数量
- list: [],
- total: 0,
- skip: 0,
- limit: 15,
- page: 0,
- // 数据是否触底
- is_bottom: false,
- scrollTop: 0,
- // 评论
- content: '',
- // 点赞
- like: 0,
- // 收藏
- collect: 0,
- // 字典表
- typeList: []
- }
- },
- onLoad: async function(e) {
- const that = this;
- that.$set(that, `id`, e && e.id || '');
- that.searchConfig();
- that.searchToken();
- await that.searchOther();
- await that.search();
- },
- methods: {
- searchConfig() {
- const that = this;
- try {
- const res = uni.getStorageSync('config');
- if (res) that.$set(that, `config`, res);
- } catch (e) {
- uni.showToast({
- title: err.errmsg,
- icon: 'error',
- duration: 2000
- });
- }
- },
- searchToken() {
- const that = this;
- try {
- const res = uni.getStorageSync('token');
- if (res) that.$set(that, `user`, res);
- } catch (e) {
- uni.showToast({
- title: err.errmsg,
- icon: 'error',
- duration: 2000
- });
- }
- },
- // 查询
- async search() {
- const that = this;
- if (that.id) {
- let res;
- res = await that.$api(`/article/${that.id}`, 'GET', {})
- if (res.errcode == '0') {
- res.data.content = res.data.content.replace(/\<img/gi, '<img class="rich-img"');
- res.data.zhType = that.searchDict(res.data.type, 'type')
- that.$set(that, `info`, res.data)
- uni.setNavigationBarTitle({
- title: res.data.contact_name
- });
- } else {
- uni.showToast({
- title: res.errmsg,
- });
- }
- // 查看评论
- that.searchComment();
- }
- },
- // 查看评论
- async searchComment() {
- const that = this;
- let res;
- let info = {
- skip: that.skip,
- limit: that.limit,
- is_use: '0',
- status: '1',
- }
- res = await that.$api(`/comment`, 'GET', {
- ...info,
- });
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data];
- that.$set(that, `list`, list);
- that.$set(that, `total`, res.total)
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- },
- // 查询字典表
- searchDict(e, model) {
- const that = this;
- let data
- if (model == 'type') {
- data = that.typeList.find((i) => i.value == e);
- if (data) return data.label
- else return '暂无'
- }
- },
- // 滑动到评论专区
- pageScroll() {
- this.$set(this, `scrollTop`, 0);
- this.$nextTick(() => {
- setTimeout(() => {
- uni.createSelectorQuery().in(this).select(`.thr`).boundingClientRect(res => {
- this.$set(this, `scrollTop`, res.top);
- }).exec();
- }, 100);
- });
- },
- // 发送
- async toSend(item) {
- if (that.user && that.user._id) {
- console.log(item);
- } else {
- uni.navigateTo({
- url: `/pagesIndex/login/index`
- })
- }
- },
- // 分页
- toPage(e) {
- const that = this;
- let list = that.list;
- let limit = that.limit;
- if (that.total > list.length) {
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- let page = that.page + 1;
- that.$set(that, `page`, page)
- let skip = page * limit;
- that.$set(that, `skip`, skip)
- that.searchComment();
- uni.hideLoading();
- } else that.$set(that, `is_bottom`, true)
- },
- // 触底
- toScroll(e) {
- const that = this;
- let up = that.scrollTop;
- that.$set(that, `scrollTop`, e.detail.scrollTop);
- let num = Math.sign(up - e.detail.scrollTop);
- if (num == 1) that.$set(that, `is_bottom`, false);
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 15)
- that.$set(that, `page`, 0)
- },
- // 查询其他信息
- async searchOther() {
- const that = this;
- let res;
- // 查询类型
- res = await that.$api(`/dictData`, 'GET', {
- type: 'home_tabs',
- is_use: '0',
- })
- if (res.errcode == '0') that.$set(that, `typeList`, res.data);
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .main {
- display: flex;
- flex-direction: column;
- box-sizing: border-box;
- width: 100vw;
- height: 100vh;
- .info {
- position: relative;
- flex-grow: 1;
- .two {
- padding: 0 2vw;
- .two_1 {
- font-weight: bold;
- font-size: var(--font16Size);
- }
- .two_2 {
- padding: 1vw;
- font-size: var(--font14Size);
- color: var(--f3CColor);
- }
- .two_3 {
- .rich-img {
- width: 100% !important;
- display: block;
- }
- }
- .two_4 {
- padding: 3vw 0;
- font-size: var(--font12Size);
- color: var(--f99Color);
- border-bottom: 1px solid var(--f9Color);
- }
- }
- .thr {
- .thr_1 {
- padding: 2vw 4vw;
- font-weight: 500;
- font-size: var(--font15Size);
- border-bottom: 1px solid var(--f9Color);
- }
- }
- }
- .foot {
- padding: 2vw;
- background-color: var(--mainColor);
- .foot_1 {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .left {
- .is-input-border {
- border-radius: 45px;
- }
- }
- .right {
- width: 45%;
- display: flex;
- justify-content: space-around;
- .right_1 {
- display: flex;
- align-items: center;
- font-size: var(--font17Szie);
- .iconfont {
- padding: 0 1vw;
- font-size: 21px;
- }
- }
- }
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- }
- }
- .is_bottom {
- width: 100%;
- text-align: center;
- text {
- padding: 2vw 0;
- display: inline-block;
- color: var(--f85Color);
- font-size: var(--font14Size);
- }
- }
- </style>
|