import {Order} from "../../model/order.js";
```
import {Http} from "../utils/http";
import {Paging} from "../utils/paging";
import {config} from "../config/config";
class Order{
static async getContent(group=''){
if(group==''){
var paging= new Paging({url:'v1/order/getContentData'});
}else{
var paging= new Paging({url:`v1/order/getContentData?group_id=${group}`});
}
console.log(group)
return paging;
}
static makeImages(data){
data.forEach((item)=>{
//是否开启图片压缩
if(config.compress){
if(item.avatar)item.avatar+=config.headerCompressRule;
if(item.images){
var imgArray=item.images.split(',');
var okimg=[];
imgArray.forEach((i)=>{
okimg.push(i+=config.comunityCompressRule);
})
item.images=okimg;
}
}else{
if(item.images) item.images=item.images.split(',');
}
})
return data;
}
//发送动态
static async sendContent(data){
return await Http.tSend({
url:`v1/order/sendContent`,
data:data,
method:"POST"
})
}
//上传文件
static async uploadFile(file){
return await Http.upload({
url:`v1/file/uploadFile`,
file:file
})
}
//获取动态详细信息
static async getCommunityInfo(id){
var res = await Http.send({
url:`v1/order/getCommunityInfo?Id=${id}`
})
var info =Community.makeImages([res.data]);
res.data=info[0];
return res;
}
//删除动态
static async removeCommunity(id){
return await Http.tSend({
url:`v1/order/removeCommunity?Id=${id}`
})
}
//获取用户的动态
static async getUserCommunity(Id=''){
if(Id==''){
uni.showToast({
title:"用户参数错误",
icon:'none'
})
return ;
}
var paging= new Paging({url:`v1/order/getUserCommunity?Id=${Id}`});
return paging;
}
//
static async getUserCommunityIndex(Id=''){
if(Id==''){
uni.showToast({
title:"用户参数错误",
icon:'none'
})
return ;
}
return await Http.request({
url:`v1/order/getUserCommunityIndex?Id=${Id}`
})
}
static async searchAll(e){
var paging= new Paging({url:'v1/order/searchAll?searchValue='+e});
return paging;
}
}
export {
Order
}
```
send/order.vue
```
<template>
<view>
<header-title
title="发布你的内容吧"
:isPoint="true"
pointColor="#5466ff"
:isBtn="true"
:btnStyle="customStyle"
@clickBtn="clickBtn"
></header-title>
<view class="content Limit">
<view style="margin: 15rpx;">
<u-input v-model="form.content" :auto-height="false" type="textarea" maxlength="1000" height="300" placeholder="想说你就多说点" :border="false" /></u-form-item>
<view style="color: #C0C4CC;">
<text>{{form.content.length}}/1000</text>
</view>
</view>
<u-upload
:action="action"
:header="header"
:upload-text="type=='video'?'选择视频':'选择图片'"
:max-count="type=='video'?1:9"
:limitType="limitType"
@on-success="uploadSuccess"
:before-upload="beforeUpload"
v-if="type=='image'"
@on-error="onImageError"
:show-tips="false"
></u-upload>
<upload v-if="type=='video'" @uploadData="uploadData"></upload>
<u-cell-group>
<u-cell-item title="添加地点" @click="addAddress" :arrow="false">
<text class="iconfont icondingwei" slot="icon" style="margin-right: 10rpx;"></text>
<text slot="right-icon">{{address}}</text>
</u-cell-item>
<u-cell-item title="发布类别" @click="changeGroup" :arrow="false">
<text class="iconfont" slot="icon" style="margin-right: 10rpx;">

</text>
<text slot="right-icon">{{group.length>0?group[okGroup].name:''}}</text>
<u-picker v-model="show" mode="selector" :range="group" range-key="name" @confirm="confirm"></u-picker>
</u-cell-item>
<!-- <u-cell-item title="置顶" :arrow="false">
<text class="iconfont" slot="icon" style="margin-right: 10rpx;">

</text>
<view slot="right-icon">
<u-switch v-model="form.checked"></u-switch>
</view>
</u-cell-item> -->
</u-cell-group>
</view>
</view>
</template>
<script>
import {config} from "../../config/config";
import {Order} from "../../model/order";
import headerTitle from "../../components/header-title/header-title.vue"
import upload from "../../components/upload/upload.vue"
export default {
data() {
return {
customStyle: {
backgroundColor: '#5466ff',
marginRight: '30rpx'
},
type:'image',
header:{
token:uni.getStorageSync('token')
},
uploadVideo:'',
form: {
content: '',
checked: false
},
show: false,
address:"",
location:"",
okGroup:0,
limitType:['png', 'jpg', 'jpeg', 'webp', 'gif'],
action:config.apiBaseUrl+'v1/file/uploadFile',
fileList: [
],
group:[]
};
},
components:{
headerTitle
},
async onLoad(e) {
this.type=e.type;
if(this.type=='video'){
this.limitType=['mp4','avi','mov','flv'];
}
var res = await Order.getCommunityGroup();
if(res.code==200){
this.group=res.data;
}
},
methods:{
onImageError(e){
uni.showToast({
title:e.msg,
icon:"none"
})
},
beforeUpload(){
uni.showLoading({
title:"上传中",
icon:"none",
mask:true
})
},
//视频上传成功
uploadData(e){
this.uploadVideo=e;
console.log(e);
},
confirm(e){
this.okGroup=e;
},
changeGroup(){
this.show=!this.show;
},
addAddress(e){
var that = this;
uni.chooseLocation({
success: function (res) {
that.address=res.name;
that.location=res.longitude+','+res.latitude;
}
});
},
uploadSuccess(e){
this.fileList.push(e.data.src);
uni.hideLoading();
},
cunstomback(){
uni.reLaunch({
url:"../home/order"
})
},
async clickBtn(e){
if(this.form.content.length<1){
uni.showToast({
title:"说点什么在发吧",
icon:'none'
})
return;
}
if(this.type=='image'){
const images=this.fileList.join(',');
var data= {
communityContent:this.form.content,
images:images,
video:null,
group_id:this.group[this.okGroup].Id,
address:this.address,
location:this.location
}
var res = await Order.sendContent(data);
if(res.code==200){
uni.showToast({
title:res.msg
})
setTimeout(()=>{
uni.reLaunch({
url:'../home/order'
})
},1000)
}
}else{
var data= {
communityContent:this.form.content,
images:null,
video:this.uploadVideo!=''?this.uploadVideo.video:null,
group_id:this.group[this.okGroup].Id,
address:this.address,
location:this.location
}
var res = await Order.sendContent(data);
if(res.code==200){
uni.showToast({
title:res.msg
})
setTimeout(()=>{
uni.reLaunch({
url:'../home/order'
})
},1000)
}
}
}
}
};
</script>
<style lang="scss">
</style>
```
home/order.vue
```
<template>
<view>
<view class="u-page" style="height: 93vh;">
<view style="width: 95%;margin: 0 auto;">
<u-search placeholder="点我搜索" :disabled="true" :show-action="false" @click="tapSearch"></u-search>
</view>
<u-tabs :list="list" active-color="#5466ff" :is-scroll="true" :current="swiperCurrent" @change="change"></u-tabs>
<block v-for="(i,j) in communityList" :key="j">
<community-card
@tapComment="tapComment"
:info="i" :isIndex="j"
@clickGood="clickGood"
@clickCollection="clickCollection"
@clickFollow="clickFollow"
@clickH5comment="clickH5comment"
@changeMoreSelect="changeMoreSelect"
></community-card>
</block>
<community-comment
:show="showComment"
:info="commentList"
@close="closeComment"
@sendComment="sendComment"
@tapGood="tapGood"
@tapGoodTwo="tapGoodTwo"
></community-comment>
<view style="width: 100%;height: 10vh;margin-top: 20rpx;">
<u-loadmore :status="status"/>
</view>
<view style="width: 100%;height: 10vh">
</view>
</view>
<!-- <u-tabbar active-color="#5466ff" v-model="current" :list="tabbar" :mid-button="true" height="7vh"></u-tabbar> -->
<tabbar :current='current' :show="show" @changeShow="changeShow"></tabbar>
</view>
</template>
<script>
import communityCard from '../../components/community-card/index.vue';
import communityComment from '../../components/community-comment/index.vue';
import tabbar from "../../components/tabbar/tabbar"
//import tabbar from "../../common/tabbar.js"
import {Order} from "../../model/order";
import {getTime} from "../../utils/public.js";
export default {
data() {
return {
current:0,
tabsCurrent:1,
swiperCurrent:0,
// tabbar:tabbar,
communityList:[],
commentList:[],
status:"loading",
list: [
{
name: '关注',
},
{
name: '最新'
},
{
name: '最热'
}
],
show:false,
showComment: false,
commentCode:{
},
communityObject:""
};
},
components: {
communityCard,
communityComment,
tabbar
},
mounted() {
},
async onLoad(){
await this.initGroup();
this.initList();
},
async onReachBottom(){
if(this.communityObject=="")return ;
var paging =await this.communityObject;
console.log(paging.moreData==true)
if(paging.moreData){
var data = await paging.getMoreData();
const resData=Order.makeImages(data.items);
this.communityList=this.communityList.concat(resData);
if(!data.moreData){
this.status="nomore";
}
}else{
this.status="nomore";
}
console.log(this.status)
},
async onPullDownRefresh(){
await this.initList();
uni.showToast({
title:"刷新完成",
icon:'none'
})
uni.stopPullDownRefresh();
},
methods: {
tapSearch(e){
console.log(123)
uni.navigateTo({
url:"../search/search"
})
},
changeShow(e){
console.log(e)
this.show=true;
},
//选择了更多
async changeMoreSelect(e){
//举报
if(e.value==1){
var ress = await Order.sendReport(e.Id);
//删除
}else if(e.value==2){
var that = this;
await new Promise((res,rs)=>{
uni.showModal({
title: '提示',
content: '确定要删除吗',
success: async function (res) {
if (res.confirm) {
var ress = await Order.removeOrder(e.Id);
that.communityList.splice(e.index, 1);
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
})
}
if(ress.code==200){
uni.showToast({
title:ress.msg
})
}else{
uni.showToast({
title:ress.msg,
icon:'none'
})
}
},
//H5点击回复
clickH5comment(e){
uni.navigateTo({
url:"../community/index?Id="+e
})
},
//初始化数据
async initList(group='',index=1){
this.swiperCurrent=index;
//初始化最新首页数据
if(group==''){
var paging = await Order.getContent();
}else{
var paging = await Order.getContent(group);
}
var data = await paging.getMoreData();
if(!data.moreData){
this.status="nomore";
};
const resData=Order.makeImages(data.items);
this.communityList=resData;
this.communityObject=paging;
},
//初始化圈子类别
async initGroup(){
var quanzi = await Order.getCommunityGroup();
quanzi.data.shift();
this.list=this.list.concat(quanzi.data)
},
//二级评论点赞
async tapGoodTwo(e){
var res = await Order.sendCommentTwoGood(e.Id);
if(res){
this.commentList[e.index].twoComment[e.indexTwo].isGood=!e.isGood;
this.commentList[e.index].twoComment[e.indexTwo].isGood==1?this.commentList[e.index].twoComment[e.indexTwo].good+=1:this.commentList[e.index].twoComment[e.indexTwo].good-=1;
}
},
//评论点赞
async tapGood(e){
var res = await Order.sendCommentGood(e.Id);
if(res){
this.commentList[e.index].isGood=!e.isGood;
this.commentList[e.index].isGood==1?this.commentList[e.index].good+=1:this.commentList[e.index].good-=1;
}
},
//评论
async sendComment(e){
const res = await Order.senComment({'community_id':this.commentCode.Id,'comment_user_id':e.Id,'content':e.content});
if(res){
uni.showToast({
title:"评论成功"
})
uni.$emit('commentOk',{
code:true
});
const userInfo=uni.getStorageSync('userInfo');
let comment={
Id: res.data.Id,
avatar: userInfo.avatar,
content: e.content,
create_time:getTime(),
good: 0,
isGood: 0,
nickname: userInfo.nickname,
sign: userInfo.sign,
twoComment: [],
user_id: userInfo.Id,
username: userInfo.username
}
if(e.Id){
this.commentList[e.index]['twoComment'].unshift(comment);
}else{
this.commentList.unshift(comment);
}
}
},
//关注
async clickFollow(e){
uni.showLoading({
title:"请求中"
})
const res= await Order.sendFollow(e.Id);
uni.hideLoading();
var that = this;
this.communityList.forEach((item,index)=>{
if(item.user_id==e.Id){
that.communityList[index].isFollow=!e.isFollow;
}
})
},
//点赞
async clickGood(e){
this.communityList[e.isIndex].isGood=!e.isGood;
e.isGood==0?this.communityList[e.isIndex].good+=1:this.communityList[e.isIndex].good-=1;
const res= await Order.sendGood(e.Id);
if(res){
//#ifdef MP-WEIXIN
uni.vibrateShort({
success: function () {
console.log('抖动');
}
});
//#endif
}else{
this.communityList[e.isIndex].isGood=!this.communityList[e.isIndex].isGood;
e.isGood==0?this.communityList[e.isIndex].good-=1:this.communityList[e.isIndex].good+=1;
}
},
//收藏
async clickCollection(e){
this.communityList[e.isIndex].isCollection=!e.isCollection;
e.isCollection==0?this.communityList[e.isIndex].collection+=1:this.communityList[e.isIndex].collection-=1;
const res= await Order.sendCollection(e.Id);
if(res){
//#ifdef APP-PLUS||MP-WEIXIN
uni.vibrateShort({
success: function () {
console.log('抖动');
}
});
//#endif
}else{
e.isCollection==0?this.communityList[e.isIndex].collection-=1:this.communityList[e.isIndex].collection+=1;
}
},
async tapComment(e) {
this.commentCode=e;
this.showComment = true;
const res= await Order.getComment(e.Id);
this.commentList=res.accoumulator;
},
closeComment(e) {
this.showComment = false;
},
//获取我的关注
async getMyFollow(){
if(uni.getStorageSync('userInfo')==undefined || uni.getStorageSync('userInfo')==''){
uni.showToast({
title:"请先登录",
icon:"none"
})
return ;
}
this.swiperCurrent = 0;
var paging = await Order.getMyFollow();
const moreData = await paging.getMoreData();
const data=Order.makeImages(moreData.items);
if(!data.moreData){
this.status="nomore";
};
this.communityList=data;
this.communityObject=paging;
},
//获取最热
async getOrderFire(){
this.swiperCurrent = 2;
var paging = await Order.getOrderFire();
const moreData = await paging.getMoreData();
const data=Order.makeImages(moreData.items);
this.communityList=data;
this.communityObject=paging;
console.log(data);
},
// tab栏切换
change(index) {
if(index==0){
this.getMyFollow();
}else if(index==1){
this.initList()
}else if(index==2){
this.getOrderFire();
}else{
this.initList(this.list[index].Id,index);
this.swiperCurrent=index;
}
},
changeTab(index){
this.current=index;
uni.reLaunch({
url:this.tabbar[index].path
})
},
}
};
</script>
<style lang="scss">
// .swiper-box {
// flex: 1;
// height: calc(100vh - 50rpx - 80rpx - 100rpx - var(--window-top));
// }
.swiper-item {
height: 100%;
}
</style>
```
route.php
```
Route::get('order/getContentData','api/:version.order/getContentData');
Route::get('order/getCommunityInfo','api/:version.order/getCommunityInfo');
Route::get('order/getCommunityFire','api/:version.order/getCommunityFire');
Route::get('order/getComment','api/:version.order/getComment');
Route::get('order/getCommentTwo','api/:version.order/getCommentTwo');
Route::get('order/getCommunityType','api/:version.order/getCommunityType');
Route::get('order/getUserCommunity','api/:version.order/getUserCommunity');
Route::get('order/getUserCommunityIndex','api/:version.order/getUserCommunityIndex');
Route::get('order/addVisitorNumber','api/:version.order/addVisitorNumber');
Route::get('order/getCommunityTop','api/:version.order/getCommunityTop');
Route::get('order/searchAll','api/:version.order/searchAll');
Route::get('order/getHotSearch','api/:version.order/getHotSearch');
```
- 空白目录
- thinkcmf的权限管理
- thinkcmf+unicmf添加页面
- Thinkphp5做后台 Uni-app做前台解决跨域问题
- 组件
- h5跨域-uniapp
- thinkphp5 auth 教程
- thinkphp5Auth类
- uniapp添加与编辑的差别
- 常见的请求方式
- uni 单选回显数据_uniapp 页面跳转传值和接收
- uni-app 单选/多选/滑动 demo
- 关于uniapp checkbox多选框如何传值传数据
- uniApp 多选框checkbox ,判断是否选中
- uniapp添加复选框和获取复选框的值
- uni-app中全选多选单选
- uniapp多选框CheckBox 数据接收
- uniapp下拉列表单选框复选框实战demo(编辑或详情页)
- uni-data-CheckBox-OK
- js 字符串数组转换成数字数组
- js把字符串转为数组对象
- js中数组对象字符串的相互转换
- JS怎么把字符串数组转换成整型数组
- 小程序开发
- tp5.1跨域请求
- uniapp-h5跨域
- 新增
- order
- uni-app中调取接口的三种方式与封装uni.request()
- uView-checkbox
- 给u-view的u-select赋值
- uView-下拉框、复选框、单选框 数据发送及接收
- CURD操作
- thinkphp5.1增删改查
- TP5.1添加数据成功之后返回自增主键id
- Thinkphp实战之Request默认值except only 以及过滤参
- uni-app跨域解决方案
- thinkphp5.1+uni-app接口开发中跨域问题解决方案
- tp6 + uniapp 前后端跨域解决方案
- uniapp-token相关
- uniapp request请求封装包含token兼容多端,简单易用
- CORS.php
- ThinkPHP6 API开发前后端分离用户信息保存在后端的方法
- thinkphp的jwt(JSON Web Token)身份验证
- thinkphp6增删改查
- PHP模拟GET,POST请求
- php模拟get、post发送请求的6种方法
- thinkphp6
- uniapp封装网络请求
- thinkphp6搭建后端api接口jwt-auth
- uniapp实现APP微信登录流程
- [uni-app] 中保持用户登录状态
- 详解vue中localStorage的使用方法
- vue 实现通过vuex 存储值 在不同界面使用
- dispatch:异步操作,数据提交至 actions ,可用于向后台提交数据
- ThinkPHP6.0 + Vue + ElementUI + axios 的环境安装到实现 CURD 操作
- tp6错误集
- TP6 模型插入/添加数据,自动插入时间(自动时间戳)
- 手机不开机维修思路
- thinkphp6解决vue跨域问题
- 从0基础获取短视频去水印解析接口制作
- thinkphp5 删除缓存
- thinkPHP,怎么把json文件里面的数据导入数据库
- 数字转字符php
- php – 直接用curl下载远程文件
- thinkphp – 直接用curl下载远程文件
- apiAdmin安装
- echart
- thinkphp开发小程序推广分享带参数二维码生成
- php同比增加函数
- PHP获取同比上周、上一个月,上一个季度,去年时间区间
- “前3秒”金句100例,赶紧收藏起来!
- PHP配合微信公众号生成推广二维码
- thinkphp5+php微信公众号二维码扫码关注推广二维码事件实现
- 获取当前时间上一周的开始时间和结束时间
- TP6 查找指定工作日
- PHP 获取当天、近一周、本周、上月、本月、本季度、上季度时间方法大全
- php获取今日、昨日、本周、本月 日期方法
- Tp5+mysql按年季度月周日小时查询时无数据的时间段补0方法
- mysql按天统计的时候,该天没有数据也要统计为0
- 列出一星期的日期 无数据补0
- thinkphp6本周 上周 周一 周末日期
- 补全日期 无数据补0
- php+pv统计代码实现,Laravel 10 行代码实现简单的网站 pv uv 统计
- 通过API获取ip地址以及城市和运营商
- 获取访客信息
- 13行代码实现微信小程序设置概率触发激励视频阅读文章
- uniapp 微信小程序 获取场景值和场景值个性化参数
- 微信小程序分享小程序码的生成(带参数)以及参数的获取
- 小程序推广分享带参数二维码生成
- uniapp微信小程序生成对应页面二维码
- uniapp获取当前页面url
- uniapp微信小程序--微信登录
- 微信小程序,生成小程序码中scene参数的存放和获取问题
- uni-app 微信小程序生成二维码带参数
- uni-app 微信小程序如何把图片保存到本地相册?
- thinkPHP5使用assign()传递富文本,前端解析成HTML标签
- tp6解析编辑器里面的html标签原样输出
- PHP判断url链接是否被百度收录
- 微擎安装模块时提示 Failed to connect to we7.rewlkj.com port 80: Timed out
- 小程序码生成
- thinkphp开发小程序推广分享带参数二维码生成0
- tp3.2伪静态
- apiadmin安装教程-2022.8更新
- autojs事件代码
- uuuu
- thinkphp6: API 多版本控制