新增提交民意接口、查询我的民意接口、图片上传、视频上传、录音上传、类型查询

master
吃肉的饺子 2022-07-31 16:28:59 +08:00
parent 14cae43bb6
commit 2a23c59139
6 changed files with 244 additions and 82 deletions

View File

@ -1,4 +1,7 @@
import request from './requst.js';
export function uploadImg(data) {
return request.upload("/universal/api.upload/upload", data);
return request.upload("file/upload/image", data);
}
export function uploadFile(data) {
return request.upload("file/upload/file", data,'file');
}

View File

@ -35,42 +35,42 @@ const checkError = (e) => {
// console.error("----接口错误----", e)
if (e.data) {
if (e.data.code) {
switch (Number(e.data.code)) {
case 500:
// 接口错误
console.log('500接口错误');
case 4003:
// 参数错误
console.log('4003参数错误');
break;
case 4004:
// 记录不存在
console.log('4004记录不存在');
break;
case 5001:
// xxx错误
console.log('5001xxx错误');
break;
case 5050:
// 服务器错误,请稍后重试
console.log('5050服务器错误请稍后重试');
// 调用到登录页
goLogin();
break;
case 5051:
// 未知错误
console.log('5051未知错误');
break;
case 6001:
// token验证失败或已失效
console.log('6001token验证失败或已失效');
if(flag) {
flag = false;
if(flag) {
flag = false;
switch (Number(e.data.code)) {
case 500:
// 接口错误
console.log('500接口错误');
case 4003:
// 参数错误
console.log('4003参数错误');
break;
case 4004:
// 记录不存在
console.log('4004记录不存在');
break;
case 5001:
// xxx错误
console.log('5001xxx错误');
break;
case 5050:
// 服务器错误,请稍后重试
console.log('5050服务器错误请稍后重试');
// 调用到登录页
goLogin();
break;
case 5051:
// 未知错误
console.log('5051未知错误');
break;
case 6001:
// token验证失败或已失效
console.log('6001token验证失败或已失效');
// 调用刷新token事件并跳转到当前页面
refreshTokenPage();
break;
}
break;
}
}
}
}
}
@ -116,6 +116,10 @@ const request = (method, url, options) => {
resolve(res.data);
} else {
// 接口返回错误信息
uni.showToast({
title:res.data.msg,
icon:'none'
})
checkError(res);
}
} else {
@ -135,14 +139,15 @@ const request = (method, url, options) => {
})
}
// 上传文件 封装请求
const uploadFile = (url, options) => {
const uploadFile = (url, options, type) => {
let tempData = options || {}
console.log(type,7777);
return new Promise((resolve, reject) => {
uni.uploadFile({
url: `${getApp().globalData.hostapi}${url}`,
filePath: tempData.path,
name: 'image',
fileType:'image',
name: type,
// fileType:type,//支付宝小程序必传
formData: tempData,
header: {
'Content-Type': 'multipart/form-data;charset=UTF-8',
@ -174,7 +179,7 @@ export default {
return request('postForm', url, options)
},
// 上传
upload: (url, options) => {
return uploadFile(url, options)
upload: (url, options, type='image') => {
return uploadFile(url, options, type)
}
}

View File

@ -11,6 +11,9 @@ Vue.prototype.$toolAll = tools;
import requst from '@/jsFile/requst.js';
Vue.prototype.$requst = requst;
// 图片域名
Vue.prototype.$imghost = 'https://minyitong.scdxtc.cn';
App.mpType = 'app';
const app = new Vue({

View File

@ -24,6 +24,7 @@
userInfo:'',
ifFlag:true
}
},
methods: {
//
@ -59,7 +60,7 @@
}
this.$requst.post('user/login',params).then(res => {
uni.hideToast();
if(res.data.token!=''){
if(res.data.nickname!=''){
this.$toolAll.tools.showToast('已授权');
let dataObj = res.data;
uni.setStorageSync('token',dataObj.token);

View File

@ -6,46 +6,73 @@
<view @tap="switchEv(0)" class="pad-sx20 disjcac radius20" :style="switchIndex==0?'background-color:#39d091;color:#FFFFFF;':''" style="width: 288rpx;">已发起</view>
<view @tap="switchEv(1)" class="pad-sx20 disjcac radius20" :style="switchIndex==1?'background-color:#39d091;color:#FFFFFF;':''" style="width: 288rpx;">已办理</view>
</view>
<view class="mar-s20 radius20 fon24 bacf posir" v-for="(item,index) in 50" :key="index">
<view class="mar-s20 radius20 fon24 bacf posir" v-for="(item,index) in dataList" :key="index">
<view class="pad-sx20 pad-zy50 status-box">{{['待处理','已办理'][switchIndex]}}</view>
<view class="pad20 bbot line-h46 pad-x40">
<view class="fon30">LH20220729130234</view>
<view class="">用户名匿名提交</view>
<view class="">金牛社区A村</view>
<view class="">反馈问题我就是想问下我们村的路多久能修好</view>
<view class="fon30">{{item.coding}}</view>
<view class="">用户名{{item.u_name || '匿名提交'}}</view>
<view class="">{{item.community.name}}{{item.village.name}}</view>
<view class="">反馈问题{{item.description}}</view>
</view>
<view class="dis fon30">
<view @tap="goDetail(0)" class="width50 pad-sx30 disjcac border-r">
<view @tap="goDetail(item.id)" class="width50 pad-sx30 disjcac border-r">
<image class="mar-y20" src="/static/icon/icon-check.png" mode="" style="width: 34rpx;height: 34rpx;"></image>查看
</view>
<view v-if="switchIndex==0" class="width50 pad-sx30 disjcac">
<view v-if="switchIndex==0" @tap="returnEv(item.id,index)" class="width50 pad-sx30 disjcac">
<image class="mar-y20" src="/static/icon/icon-revoke.png" mode="" style="width: 34rpx;height: 34rpx;"></image>
撤诉
</view>
<view @tap="goFeedback(0)" v-if="switchIndex==1" class="width50 pad-sx30 disjcac">
<view @tap="goFeedback(item.id)" v-if="switchIndex==1" class="width50 pad-sx30 disjcac">
<image class="mar-y20" src="/static/icon/icon-feedback.png" mode="" style="width: 34rpx;height: 34rpx;"></image>
反馈
</view>
</view>
</view>
<view class="" v-if="total==dataList.length && total">
<pitera textStr="到底啦o(╥﹏╥)o"></pitera>
</view>
<view class="posixzy disjcac bacf pad-sx20" style="box-shadow: 0rpx -4rpx 30rpx rgba(0, 0, 0, .2);">
<view class="disjcac enter-btn" style="margin: 0;" @tap="goOpinionSubmit"></view>
</view>
</view>
</statusContainer>
<view class="" v-if="!total">
<nothing-page content="暂无数据"></nothing-page>
</view>
</view>
</template>
<script>
import statusContainer from '@/components/containers/status-container.vue';
import nothingPage from '@/components/nothing/nothing-page.vue';
import pitera from '@/components/nothing/pitera.vue';
export default {
components:{
statusContainer
statusContainer,
nothingPage,
pitera
},
data() {
return {
switchIndex:0,
newtop:uni.getSystemInfoSync().statusBarHeight
newtop:uni.getSystemInfoSync().statusBarHeight,
dataList:[],
page:1,
size:4,
state:0,
total:0
}
},
onShow() {
this.getList();
},
onLoad() {
},
onReachBottom() {
if(this.total != this.dataList.length){
this.page++;
this.getList();
}
},
methods: {
@ -53,6 +80,39 @@
switchEv(index){
console.log(index);
this.switchIndex = index;
this.state = index;
this.page = 1;
this.dataList = [];
this.getList();
},
//
getList(){
let params = {
page:this.page,
size:this.size,
state:this.state
}
this.$toolAll.tools.showToast('加载中...');
this.$requst.get('user/my-table',params).then(res=>{
if(res.code==0){
if(this.page==1){
this.dataList = [];
}
this.total = res.data.total;
this.dataList = [...this.dataList,...res.data.list];
uni.hideToast();
}
})
},
//
returnEv(id,index){
this.$toolAll.tools.showToast('正在撤销...');
this.$requst.post('user/revoke-opinion',{id}).then(res=>{
if(res.code==0){
this.$toolAll.tools.showToast('撤销成功');
this.dataList.splice(index,1);
}
})
},
//
goOpinionSubmit(){

View File

@ -4,11 +4,11 @@
<view class="" v-if="!ifAnonymous">
<view class="disjbac bbot pad-sx20">
<view class="fon30 colb bold flexs">真实姓名</view>
<input class="fon30 col9 tright width100" v-model="form.name" type="text" maxlength="16" placeholder="请输入姓名">
<input class="fon30 col9 tright width100" v-model="form.u_name" type="text" maxlength="16" placeholder="请输入姓名">
</view>
<view class="disjbac bbot pad-sx20">
<view class="fon30 colb bold flexs">联系方式</view>
<input class="fon30 col9 tright width100" v-model="form.phone" type="number" maxlength="11" placeholder="请填写手机号码">
<input class="fon30 col9 tright width100" v-model="form.u_phone" type="number" maxlength="11" placeholder="请填写手机号码">
</view>
</view>
<picker mode="selector" :range="communityList" :value="communityIndex" @change="changeCommunity" :range-key="'name'">
@ -33,8 +33,8 @@
<view class="colb bold flexs">图片上传</view>
<view class="disac col9 width100 fe fw">
<view v-for="(item,index) in imgArr" :key="index" class="col9 radius30 disjcac fc posir mar-y20 item-box width155">
<image :src="item" mode="aspectFill" class="width155 radius30"></image>
<view @tap="imgArr.splice(index,1)" class="posia disjcac del-btn">
<image :src="item" mode="aspectFill" class="width155 radius30" @tap="preVedio(index,0)"></image>
<view @tap="imgArr.splice(index,1),tempImg.splice(index,1)" class="posia disjcac del-btn">
<i class="icon icon-del-white fon24 colf" style="transform: scale(.8);"></i>
</view>
</view>
@ -48,8 +48,11 @@
<view class="colb bold flexs">视频上传</view>
<view class="disac col9 width100 fe">
<view v-for="(item,index) in vedioArr" :key="index" class="col9 radius30 disjcac fc posir mar-y20 item-box width155">
<image :src="item" mode="aspectFill" class="width155 radius30"></image>
<view @tap="vedioArr.splice(index,1)" class="posia disjcac del-btn">
<!-- <image :src="item" mode="aspectFill" class="width155 radius30"></image> -->
<view class="width155 radius30" style="overflow: hidden;" @tap="preVedio(index,1)">
<video :src="item" :controls="false" class="width155 radius30"></video>
</view>
<view @tap="vedioArr.splice(index,1),tempVedio.splice(index,1)" class="posia disjcac del-btn">
<i class="icon icon-del-white fon24 colf" style="transform: scale(.8);"></i>
</view>
</view>
@ -61,8 +64,8 @@
</view>
<view class="disjb bbot pad-sx20">
<view class="fon30 colb bold flexs">描述文案</view>
<!-- <input class="fon30 col9 tright" style="max-width: 90%;" v-model="form.content" type="text" placeholder="请输入描述文案"> -->
<textarea auto-height v-model="form.content" class="fon30 col9 tright" style="max-width: 70%;" placeholder="请输入描述文案"></textarea>
<!-- <input class="fon30 col9 tright" style="max-width: 90%;" v-model="form.description" type="text" placeholder="请输入描述文案"> -->
<textarea auto-height v-model="form.description" class="fon30 col9 tright" style="max-width: 70%;" placeholder="请输入描述文案"></textarea>
</view>
<view class="dis fon30 bbot pad-sx30">
<view class="colb bold flexs">语音上传</view>
@ -97,6 +100,7 @@
<script>
import { mapState } from 'vuex';
import { uploadImg,uploadFile } from "@/jsFile/public-api.js"
const recorderManager = uni.getRecorderManager();
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
@ -104,13 +108,16 @@
data() {
return {
form:{
name:'',//
phone:'',//
content:''//
u_name:'',//
u_phone:'',//
description:''//
},
imgArr:[],//
tempImg:[],
vedioArr:[],//
tempVedio:[],
audioText:'',//
tempAudio:'',
communityList:[],//
communityIndex:0,//
communityId:'',//id
@ -122,16 +129,18 @@
typeList:[],//
typeIndex:0,//
typeText:'请选择类别',
typeId:''//id
typeId:'',//id
flag:true
}
},
onLoad() {
//
this.getCommunityList();
//
this.getTypeList();
this.$requst.get('administrator/reviewedList').then(res=>{
if(res.code==0){
}
})
},
@ -141,24 +150,80 @@
})
},
methods: {
//
preVedio(index,num){
let arr = [];
let tempArr = [this.imgArr,this.vedioArr][num];
if(tempArr.length){
tempArr.forEach(item=>{
let obj = {
url:item,
type:['image','video'][num]
}
arr.push(obj);
})
}
uni.previewMedia({
current:index,
sources:arr
})
},
//
submitEv(){
let params = {
...this.form,
a:this.communityId,//id
b:this.villageId,//ID
c:this.imgArr.join(','),//
d:this.vedioArr.join(','),//
e:this.audioText,//
f:this.typeId,//
if(this.flag && this.checkEmpty()){
this.$toolAll.tools.showToast('正在提交...','none',10000);
this.flag = false;
let params = {
...this.form,
community_id:this.communityId,//id
village_id:this.villageId,//ID
images:this.tempImg.join(','),//
videos:this.tempVedio.join(','),//
audios:this.tempAudio,//
opinion_type:this.typeId,//
is_anonymous:this.ifAnonymous?1:0
}
this.$requst.post('opinion/createOpinion',params).then(res=>{
if(res.code==0){
this.$toolAll.tools.showToast('提交成功');
setTimeout(()=>{
uni.reLaunch({
url:'/pagesA/my-opinion-list/my-opinion-list'
})
},500)
}
})
}
console.log(params,77777);
// this.$requst.post('',params).then(res=>{
// })
// uni.reLaunch({
// url:'/pagesA/my-opinion-list/my-opinion-list'
// })
},
//
checkEmpty(){
let ifempty = false;
if(!this.ifAnonymous){
if(!this.form.u_name){
this.$toolAll.tools.showToast('请填写真实姓名');
} else if(this.$toolAll.tools.isPhone(this.form.u_phone)){
this.$toolAll.tools.showToast('请正确输入手机号');
} else if(!this.communityId){
this.$toolAll.tools.showToast('请选择社区');
} else if(!this.villageId){
this.$toolAll.tools.showToast('请选择村');
} else if(!this.typeId){
this.$toolAll.tools.showToast('请选择类别');
} else {
ifempty = true;
}
} else {
if(!this.communityId){
this.$toolAll.tools.showToast('请选择社区');
} else if(!this.villageId){
this.$toolAll.tools.showToast('请选择村');
} else if(!this.typeId){
this.$toolAll.tools.showToast('请选择类别');
} else {
ifempty = true;
}
}
return ifempty;
},
//
changeCommunity(e){
@ -202,9 +267,9 @@
},
//
getTypeList(){
this.$requst.get('common/villageList').then(res=>{
this.$requst.get('common/opinionTypes').then(res=>{
if(res.code==0){
this.typeList = res.data.list;
this.typeList = res.data;
}
})
},
@ -213,7 +278,12 @@
uni.chooseImage({
count:1,
success: (tempFile) => {
this.imgArr = [...this.imgArr,...tempFile.tempFilePaths]
this.$toolAll.tools.showToast('正在上传图片...','none',100000);
uploadImg({path:tempFile.tempFilePaths[0]}).then(res=>{
this.imgArr.push(tempFile.tempFilePaths[0]);
this.tempImg.push(this.$imghost + res.data.src);
uni.hideToast();
})
}
})
},
@ -222,7 +292,12 @@
uni.chooseVideo({
sourceType:['album','camera'],
success: (tempFile) => {
this.vedioArr.push(tempFile.tempFilePath);
this.$toolAll.tools.showToast('正在上传视频...','none',100000);
uploadFile({path:tempFile.tempFilePath}).then(res=>{
this.vedioArr.push(tempFile.tempFilePath);
this.tempVedio.push(this.$imghost + res.data.src);
uni.hideToast();
})
}
})
},
@ -240,13 +315,27 @@
icon:'none',
duration:1000*120
})
// const options = {
// duration:600000,
// sampleRate:44100,
// numberOfChannels:1,
// encodeBitRate:192000,
// format:'mp3',
// frameSize:50
// }
// recorderManager.start(options);
recorderManager.start();
},
//
endRecord() {
recorderManager.stop();
recorderManager.onStop((res)=> {
this.$toolAll.tools.showToast('正在上传录音...','none',100000);
this.audioText = res.tempFilePath;
uploadFile({path:this.audioText}).then(res=>{
this.tempAudio = this.$imghost + res.data.src;
uni.hideToast();
})
});
uni.hideToast();
},
@ -260,6 +349,7 @@
//
clearAudio(){
this.audioText = '';
this.tempAudio = '';
recorderManager.stop();
}
}