Commit d6ba1ab0 authored by liwei's avatar liwei

对接了发表动态接口

parent ffdf5c8e
...@@ -10,8 +10,16 @@ export function articleList(query) { ...@@ -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) { export function getOssUrl(id) {
return request({ return request({
url: '/common/getOssUrl?businessId=' + id, url: '/common/getOssUrl?businessId=' + id,
......
<template> <template>
<view class="tuijian_over" :style="{'height': height,'backgroundColor':color}" @touchmove.stop.prevent="() => {}"> <view class="tuijian_over" :style="{'height': height,'backgroundColor':color}" @touchmove.stop.prevent="() => {}">
<view class="imgbg"> <view class="imgbg">
<image src="@/static/images/empty.png" mode="aspectFill"></image> <image src="" mode="aspectFill"></image>
<view class="over-content"> <view class="over-content">
<view class="isover">{{str}}</view> <view class="isover">{{str}}</view>
</view> </view>
......
...@@ -4,31 +4,33 @@ ...@@ -4,31 +4,33 @@
<view class="l" v-if="info.headPortrait == ''"> <view class="l" v-if="info.headPortrait == ''">
<view class="box"> <view class="box">
<view class="day"> <view class="day">
{{info.createTime.substring(8,10)*1}} {{info.createDate.substring(8,10)*1}}
</view> </view>
<view class="str"> <view class="str">
/ /
</view> </view>
<view class="month"> <view class="month">
{{info.createTime.substring(5,7)*1}} {{info.createDate.substring(5,7)*1}}
</view> </view>
</view> </view>
<view class="line"> <view class="line">
</view> </view>
</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>
<view class="center"> <view class="center">
<template> <template>
<view class="name"> <view class="name">
<text @click="gotoUserInfo(info)">{{info.nickName}}</text> <text @click="gotoUserInfo(info)">{{info.memNickName}}</text>
<image v-if="info.gender != 'MALE'" class="gender" :src="baseUrl+'/user/famale.png'" mode=""> <image v-if="info.memSex != '男'" class="gender" :src="baseUrl+'/user/famale.png'" mode="">
</image> </image>
<image v-else class="gender" :src="baseUrl+'/user/male.png'" mode=""></image> <image v-else class="gender" :src="baseUrl+'/user/male.png'" mode=""></image>
</view> </view>
<view class="info"> <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> </view>
</template> </template>
<!-- <view v-else style="height: 100rpx;">--> <!-- <view v-else style="height: 100rpx;">-->
...@@ -36,7 +38,7 @@ ...@@ -36,7 +38,7 @@
<!-- </view>--> <!-- </view>-->
<view class="content"> <view class="content">
<template v-if="info.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"> :textIndent="0" showHeight="126rpx">
<view @click="gotoDetail(info)" style="font-size: 28rpx;color: #333333;"> <view @click="gotoDetail(info)" style="font-size: 28rpx;color: #333333;">
<view class="" style="line-height: 1.5;"> <view class="" style="line-height: 1.5;">
...@@ -54,7 +56,7 @@ ...@@ -54,7 +56,7 @@
@close="close"></q-previewImage> @close="close"></q-previewImage>
</view> </view>
<view class="time"> <view class="time">
{{info.time}} {{info.createDate}}
</view> </view>
<view class="btns"> <view class="btns">
<view class="btn"> <view class="btn">
...@@ -121,9 +123,8 @@ ...@@ -121,9 +123,8 @@
watch: { watch: {
info: { info: {
handler(newValue) { handler(newValue) {
console.log('newValue:',newValue) if (newValue?.pictureUrls?.length) {
if (newValue?.img?.length) { this.imgs = newValue.pictureUrls
this.imgs = newValue.img
} }
}, },
deep: true, deep: true,
...@@ -157,10 +158,6 @@ ...@@ -157,10 +158,6 @@
// name: "举报" // name: "举报"
// } // }
], ],
shadowStyle: {
backgroundImage: 'linear-gradient(-180deg, rgba(255, 255, 255, 0) 50%, #fff 100%)',
justifyContent: 'flex-end'
},
isConfirm: false isConfirm: false
} }
}, },
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
'height': '375rpx' 'height': '375rpx'
}" v-model="dataList" @query="queryList" :fixed="false"> }" v-model="dataList" @query="queryList" :fixed="false">
<view v-if="currentIndex == '2'"> <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="{ :activeStyle="{
color: 'rgb(41, 121, 255)', color: 'rgb(41, 121, 255)',
transform: 'scale(1)' transform: 'scale(1)'
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
import empty from '@/components/empty.vue' import empty from '@/components/empty.vue'
import {topicList} from "../../../api/topic"; import {topicList} from "../../../api/topic";
import {articleList} from "../../../api/article"; import {articleList} from "../../../api/article";
import {getCity, getValue} from "../../../common/options";
import {calculateAge, parseDate} from "../../../common";
export default { export default {
name:'ArticleList', name:'ArticleList',
components: { components: {
...@@ -46,6 +48,8 @@ ...@@ -46,6 +48,8 @@
}, },
data() { data() {
return { return {
//话题id
topicId: 0,
//当前的tab //当前的tab
current: 0, current: 0,
//话题列表 //话题列表
...@@ -74,7 +78,7 @@ ...@@ -74,7 +78,7 @@
default: function() { default: function() {
return 0 return 0
} }
} },
}, },
watch: { watch: {
currentIndex: { currentIndex: {
...@@ -100,12 +104,18 @@ ...@@ -100,12 +104,18 @@
}, },
}, },
methods: { methods: {
//tab标签点击
tabClick({id}) {
this.topicId = id
this.reload()
},
//查询话题列表 //查询话题列表
getTopicList(){ getTopicList(){
topicList().then(res =>{ topicList().then(res =>{
//获取res.data.data里的topicName赋值给this.topicList,并且 //获取res.data.data里的topicName赋值给this.topicList,并且
this.topicList = res.data.data.map(item => { this.topicList = res.data.data.map(item => {
return { return {
id:item.businessId,
name: item.topicName name: item.topicName
}; };
}); });
...@@ -123,44 +133,35 @@ ...@@ -123,44 +133,35 @@
const params = { const params = {
page:pageNo, page:pageNo,
rows:pageSize, 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会自动计算好,直接传给服务器即可 // 这里的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 = { // const params = {
// pageIndex: pageNo, // pageIndex: pageNo,
// pageSize: pageSize, // pageSize: pageSize,
......
<template> <template>
<view :class="['bigBox']"> <view :class="['bigBox']">
<view class="box"> <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" :showConfirmBar="false" :adjust-position="false" @focus="focusFn" :focus="focus" @blur="blurFn"
border="none" placeholder="分享生活、表达思考、提出困惑..."></textarea> border="none" placeholder="分享生活、表达思考、提出困惑..."></textarea>
<image :src="img"></image>
<view class="upload"> <view class="upload">
<u-upload :fileList="fileList" accept="image" uploadIcon="plus" :capture="['album', 'camera']" <u-upload :fileList="fileList" accept="image" uploadIcon="plus" :capture="['album', 'camera']"
@afterRead="afterRead" @delete="deletePic" width="200rpx" height="200rpx" multiple :maxCount="9" @afterRead="afterRead" @delete="deletePic" width="200rpx" height="200rpx" multiple :maxCount="9"
...@@ -27,18 +26,18 @@ ...@@ -27,18 +26,18 @@
<script> <script>
import ELM from '@/components/elm-toast/index.vue'; 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 { export default {
components: { components: {
ELM ELM
}, },
data() { data() {
return { return {
uploadImgJSON:{
id:[]
},
img:'', img:'',
form: { content: '',
content: '',
img: []
},
fileList: [], fileList: [],
tipMsg: '', tipMsg: '',
isConfirm: false, isConfirm: false,
...@@ -55,21 +54,50 @@ ...@@ -55,21 +54,50 @@
methods: { methods: {
//发布 //发布
submit() { submit() {
getOssUrl(109).then(res=>{ if (!this.content && !this.fileList.length) {
this.img = res.data.data.replace(/\\/g, '/') this.tipMsg = '请输入内容或上传图片后再点击发布'
console.log(this.img) 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) { deletePic(event) {
this[`fileList${event.name}`].splice(event.index, 1) this[`fileList${event.name}`].splice(event.index, 1)
}, },
//获取oss图片url
getOssUrl() {
// getOssUrl(id).then(res => {
// this.img = res.data.data.url
// })
},
// 新增图片 // 新增图片
afterRead(event) { afterRead(event) {
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式 // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
...@@ -83,12 +111,13 @@ ...@@ -83,12 +111,13 @@
}) })
}) })
for (let i = 0; i < lists.length; i++) { 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] let item = this.fileList[fileListLen]
this.fileList.splice(fileListLen, 1, Object.assign(item, { this.fileList.splice(fileListLen, 1, Object.assign(item, {
status: 'success', status: 'success',
message: '', message: ''
url: result
})) }))
fileListLen++ fileListLen++
} }
...@@ -110,7 +139,7 @@ ...@@ -110,7 +139,7 @@
name: 'file', name: 'file',
success: (uploadFileRes) => { success: (uploadFileRes) => {
let data = JSON.parse(uploadFileRes.data) 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