Commit d6ba1ab0 authored by liwei's avatar liwei

对接了发表动态接口

parent ffdf5c8e
......@@ -10,8 +10,16 @@ export function articleList(query) {
})
}
// 发表动态
export function publishArticle(data) {
return request({
url: '/opmarticle/add',
data: data,
method: 'POST',
})
}
// 动态列表
// oss查询图片路径
export function getOssUrl(id) {
return request({
url: '/common/getOssUrl?businessId=' + id,
......
<template>
<view class="tuijian_over" :style="{'height': height,'backgroundColor':color}" @touchmove.stop.prevent="() => {}">
<view class="imgbg">
<image src="@/static/images/empty.png" mode="aspectFill"></image>
<image src="" mode="aspectFill"></image>
<view class="over-content">
<view class="isover">{{str}}</view>
</view>
......
......@@ -4,31 +4,33 @@
<view class="l" v-if="info.headPortrait == ''">
<view class="box">
<view class="day">
{{info.createTime.substring(8,10)*1}}
{{info.createDate.substring(8,10)*1}}
</view>
<view class="str">
/
</view>
<view class="month">
{{info.createTime.substring(5,7)*1}}
{{info.createDate.substring(5,7)*1}}
</view>
</view>
<view class="line">
</view>
</view>
<image v-else @click="gotoUserInfo(info)" :src="info.headPortrait" mode="aspectFill"></image>
<image v-else @click="gotoUserInfo(info)" :src="info.memAvatar" mode="aspectFill"></image>
</view>
<view class="center">
<template>
<view class="name">
<text @click="gotoUserInfo(info)">{{info.nickName}}</text>
<image v-if="info.gender != 'MALE'" class="gender" :src="baseUrl+'/user/famale.png'" mode="">
<text @click="gotoUserInfo(info)">{{info.memNickName}}</text>
<image v-if="info.memSex != '男'" class="gender" :src="baseUrl+'/user/famale.png'" mode="">
</image>
<image v-else class="gender" :src="baseUrl+'/user/male.png'" mode=""></image>
</view>
<view class="info">
<text decode="true" style="color: #434343;">{{info.information}}</text>
<text decode="true" style="color: #434343;">
{{info.memAge}}·{{info.city}}·{{info.memMaxEducation}}·{{info.memCareer}}
</text>
</view>
</template>
<!-- <view v-else style="height: 100rpx;">-->
......@@ -36,7 +38,7 @@
<!-- </view>-->
<view class="content">
<template v-if="info.content">
<u-read-more ref="uReadMore" :shadowStyle="shadowStyle" :toggle="true" color="#415C9E"
<u-read-more ref="uReadMore" :toggle="true" color="#415C9E"
:textIndent="0" showHeight="126rpx">
<view @click="gotoDetail(info)" style="font-size: 28rpx;color: #333333;">
<view class="" style="line-height: 1.5;">
......@@ -54,7 +56,7 @@
@close="close"></q-previewImage>
</view>
<view class="time">
{{info.time}}
{{info.createDate}}
</view>
<view class="btns">
<view class="btn">
......@@ -121,9 +123,8 @@
watch: {
info: {
handler(newValue) {
console.log('newValue:',newValue)
if (newValue?.img?.length) {
this.imgs = newValue.img
if (newValue?.pictureUrls?.length) {
this.imgs = newValue.pictureUrls
}
},
deep: true,
......@@ -157,10 +158,6 @@
// name: "举报"
// }
],
shadowStyle: {
backgroundImage: 'linear-gradient(-180deg, rgba(255, 255, 255, 0) 50%, #fff 100%)',
justifyContent: 'flex-end'
},
isConfirm: false
}
},
......
......@@ -14,7 +14,7 @@
'height': '375rpx'
}" v-model="dataList" @query="queryList" :fixed="false">
<view v-if="currentIndex == '2'">
<u-tabs ref="tabs" :list="topicList" font-size="30" :current="current"
<u-tabs ref="tabs" :list="topicList" font-size="30" :current="current" @click="tabClick"
:activeStyle="{
color: 'rgb(41, 121, 255)',
transform: 'scale(1)'
......@@ -38,6 +38,8 @@
import empty from '@/components/empty.vue'
import {topicList} from "../../../api/topic";
import {articleList} from "../../../api/article";
import {getCity, getValue} from "../../../common/options";
import {calculateAge, parseDate} from "../../../common";
export default {
name:'ArticleList',
components: {
......@@ -46,6 +48,8 @@
},
data() {
return {
//话题id
topicId: 0,
//当前的tab
current: 0,
//话题列表
......@@ -74,7 +78,7 @@
default: function() {
return 0
}
}
},
},
watch: {
currentIndex: {
......@@ -100,12 +104,18 @@
},
},
methods: {
//tab标签点击
tabClick({id}) {
this.topicId = id
this.reload()
},
//查询话题列表
getTopicList(){
topicList().then(res =>{
//获取res.data.data里的topicName赋值给this.topicList,并且
this.topicList = res.data.data.map(item => {
return {
id:item.businessId,
name: item.topicName
};
});
......@@ -123,44 +133,35 @@
const params = {
page:pageNo,
rows:pageSize,
topicId: this.topicId
}
articleList(params).then(res=>{
articleList(params).then( res =>{
const list = res.data.data
list.forEach(item => {
//处理头像
if (item.memAvatar != null){
item.memAvatar = item.memAvatar.replace(/\\/g, '/')
}
//处理动态照片
if (item.pictureUrls != null){
item.pictureUrls = item.pictureUrls.replace(/\\/g, '/').split(',')
}
//处理性别
item.memSex = getValue('sex',item.memSex)
//通过生日计算年龄
const dataItem = parseDate(item.memBirthday)
item.memAge = calculateAge(dataItem.year,dataItem.month,dataItem.day)
//处理地址
item.city = getCity(item.memResidenceProvince,item.memResidenceCity)
//处理教育经历
item.memMaxEducation = getValue('education',item.memMaxEducation)
})
this.$refs.paging.complete(list);
})
console.log('1111')
// 组件加载时会自动触发此方法,因此默认页面加载时会自动触发,无需手动调用
// 这里的pageNo和pageSize会自动计算好,直接传给服务器即可
// 模拟请求服务器获取分页数据,请替换成自己的网络请求
const arr = [
{
createTime:'2024-12-28 15:02:01',
headPortrait:'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg',//头像
nickName:'不爱吃辣的小王',//nickName
gender:'MALE',//性别
information:'02·重庆市·硕士·互联网',//个人信息
content:'昨天的快乐留在今天发,那就是100%',//动态内容
time:'2024-11-11 15:02:01',//发布动态的时间
commentCount:'10',//评论数
likeCount:'11',//点赞数
isLike:true,
img:[
'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg',
'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg'
]
},
{
createTime:'2024-12-28 15:02:01',
headPortrait:'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg',//头像
nickName:'不爱吃辣的小王',//nickName
gender:'MALE',//性别
information:'02·重庆市·硕士·互联网',//个人信息
content:'昨天的快乐留在今天发,那就是100%',//动态内容
time:'2024-11-11 15:02:01',//发布动态的时间
commentCount:'10',//评论数
likeCount:'11',//点赞数
},
]
this.$refs.paging.complete(arr);
// const params = {
// pageIndex: pageNo,
// pageSize: pageSize,
......
<template>
<view :class="['bigBox']">
<view class="box">
<textarea style="width: 100%;height: 260rpx;" v-model="form.content" :maxlength="-1" :auto-height="false"
<textarea style="width: 100%;height: 260rpx;" v-model="content" :maxlength="-1" :auto-height="false"
:showConfirmBar="false" :adjust-position="false" @focus="focusFn" :focus="focus" @blur="blurFn"
border="none" placeholder="分享生活、表达思考、提出困惑..."></textarea>
<image :src="img"></image>
<view class="upload">
<u-upload :fileList="fileList" accept="image" uploadIcon="plus" :capture="['album', 'camera']"
@afterRead="afterRead" @delete="deletePic" width="200rpx" height="200rpx" multiple :maxCount="9"
......@@ -27,18 +26,18 @@
<script>
import ELM from '@/components/elm-toast/index.vue';
import {getOssUrl, uploadPublic} from '../api/article/index'
import {getOssUrl, publishArticle, uploadPublic} from '../api/article/index'
export default {
components: {
ELM
},
data() {
return {
uploadImgJSON:{
id:[]
},
img:'',
form: {
content: '',
img: []
},
content: '',
fileList: [],
tipMsg: '',
isConfirm: false,
......@@ -55,21 +54,50 @@
methods: {
//发布
submit() {
getOssUrl(109).then(res=>{
this.img = res.data.data.replace(/\\/g, '/')
console.log(this.img)
if (!this.content && !this.fileList.length) {
this.tipMsg = '请输入内容或上传图片后再点击发布'
this.$refs.elm.showDialog();
return;
}
const params = {
content:this.content,
pictureId: JSON.stringify(this.uploadImgJSON),
}
//将params转成json
publishArticle(params).then( res => {
if (res.data.code == 200){
uni.showToast({
title: '发表成功',
icon: 'success'
})
setTimeout(() => {
uni.switchTab({
url: '/pages/tab/article',
});
},1000)
} else {
uni.showToast({
title: '发表失败,请稍后再试',
icon: 'error'
})
setTimeout(() => {
uni.switchTab({
url: '/pages/tab/article'
});
},1000)
}
})
// this.form.img = this.fileList.map(item => item.url )
// if (!this.form.content && !this.fileList.length) {
// this.tipMsg = '请输入内容或上传图片后再点击发布'
// this.$refs.elm.showDialog();
// return;
// }
},
// 删除图片
deletePic(event) {
this[`fileList${event.name}`].splice(event.index, 1)
},
//获取oss图片url
getOssUrl() {
// getOssUrl(id).then(res => {
// this.img = res.data.data.url
// })
},
// 新增图片
afterRead(event) {
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
......@@ -83,12 +111,13 @@
})
})
for (let i = 0; i < lists.length; i++) {
const result = this.uploadFilePromise(lists[i])
this.uploadFilePromise(lists[i]).then( res => {
this.uploadImgJSON.id.push(res.data.businessId)
})
let item = this.fileList[fileListLen]
this.fileList.splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
message: ''
}))
fileListLen++
}
......@@ -110,7 +139,7 @@
name: 'file',
success: (uploadFileRes) => {
let data = JSON.parse(uploadFileRes.data)
resolve(data.data.url)
resolve(data)
},
});
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment