Commit bfd6cf86 authored by wangqinghua's avatar wangqinghua

图片 视频上传

parent ba03f72b
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
<plugin name="phonegap-plugin-mobile-accessibility" spec="~1.0.5-dev" /> <plugin name="phonegap-plugin-mobile-accessibility" spec="~1.0.5-dev" />
<plugin name="cordova-plugin-camera" spec="~4.0.3" /> <plugin name="cordova-plugin-camera" spec="~4.0.3" />
<engine name="ios" spec="4.5.5" /> <engine name="ios" spec="4.5.5" />
<engine name="browser" spec="5.0.4" />
<engine name="android" spec="7.0.0" /> <engine name="android" spec="7.0.0" />
<plugin name="cordova-plugin-file-transfer" spec="~1.7.1" /> <plugin name="cordova-plugin-file-transfer" spec="~1.7.1" />
<engine name="browser" spec="~5.0.4" />
</widget> </widget>
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"proxies": [ "proxies": [
{ {
"path": "/wisdomgroup", "path": "/wisdomgroup",
"proxyUrl": "http://47.103.35.216:8080/wisdomgroup" "proxyUrl": "http://192.168.2.235:8080/wisdomgroup"
} }
] ]
} }
\ No newline at end of file
...@@ -10450,6 +10450,11 @@ ...@@ -10450,6 +10450,11 @@
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
}, },
"vconsole": {
"version": "3.3.0",
"resolved": "http://r.cnpmjs.org/vconsole/download/vconsole-3.3.0.tgz",
"integrity": "sha1-QmKcB/s7anJzPSu8QX7j6Esrx24="
},
"verror": { "verror": {
"version": "1.10.0", "version": "1.10.0",
"resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
"moment": "^2.22.2", "moment": "^2.22.2",
"rxjs": "5.5.2", "rxjs": "5.5.2",
"sw-toolbox": "3.6.0", "sw-toolbox": "3.6.0",
"vconsole": "^3.3.0",
"zone.js": "0.8.18" "zone.js": "0.8.18"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -25,8 +25,14 @@ ...@@ -25,8 +25,14 @@
</ion-select> </ion-select>
</ion-item> </ion-item>
<ion-item> <ion-item>
<ion-input [(ngModel)]="obj.title" placeholder="请输入内容标题"></ion-input>
</ion-item>
<ion-item>
<textarea [(ngModel)]="obj.content" class="content-textarea" placeholder="请在此输入发布内容"></textarea>
</ion-item>
<ion-item *ngIf="type == 'image'">
<ion-row> <ion-row>
<ion-col class="imgList" col-4 *ngFor="let img of imgList"> <ion-col class="imgList" col-4 *ngFor="let img of fileList">
<img [src]="pictrue + img.filePath" alt="标题图片"> <img [src]="pictrue + img.filePath" alt="标题图片">
</ion-col> </ion-col>
<ion-col col-4> <ion-col col-4>
...@@ -37,8 +43,11 @@ ...@@ -37,8 +43,11 @@
</ion-col> </ion-col>
</ion-row> </ion-row>
</ion-item> </ion-item>
<ion-item> <ion-item *ngIf="type == 'video'">
<ion-row> <ion-row>
<ion-col class="imgList" col-4 *ngFor="let video of fileList">
<video [src]="pictrue + video.filePath"></video>
</ion-col>
<ion-col col-4> <ion-col col-4>
<div class="selectDiv" (click)="selectVideo()"> <div class="selectDiv" (click)="selectVideo()">
<div class="height"></div> <div class="height"></div>
...@@ -47,11 +56,4 @@ ...@@ -47,11 +56,4 @@
</ion-col> </ion-col>
</ion-row> </ion-row>
</ion-item> </ion-item>
<ion-item>
<ion-input [(ngModel)]="obj.title" placeholder="请输入内容标题"></ion-input>
</ion-item>
<ion-item>
<textarea [(ngModel)]="obj.content" class="content-textarea" placeholder="请在此输入发布内容"></textarea>
</ion-item>
<!-- <span (click)="selectPicture()">选择文件</span>-->
</ion-content> </ion-content>
...@@ -52,8 +52,11 @@ page-publish { ...@@ -52,8 +52,11 @@ page-publish {
border-radius: 2px; border-radius: 2px;
} }
} }
.imgList img{ .imgList{
width: 100%; video,img{
max-height: 100px; width: 100%;
max-height: 100px;
}
} }
} }
...@@ -35,21 +35,23 @@ export class PublishPage { ...@@ -35,21 +35,23 @@ export class PublishPage {
content: '', content: '',
publishRange: '', publishRange: '',
}; };
imgList = []; //图片数组 fileList = []; //文件数组
videoList = []; //视频数组
group; //用户组 group; //用户组
userid; //当前登录人的id userid; //当前登录人的id
file; // 文件 file; // 文件
pictrue = AppGlobal.domain; pictrue = AppGlobal.domain + '/wisdomgroup';
type; //视频文章or图片文章
constructor(public navCtrl: NavController, public navParams: NavParams, public storage: Storage, constructor(public navCtrl: NavController, public navParams: NavParams, public storage: Storage,
public camera: Camera, public actionSheetCtrl: ActionSheetController, public camera: Camera, public actionSheetCtrl: ActionSheetController,
public loadingCtrl: LoadingController,public transfer:FileTransfer, public loadingCtrl: LoadingController, public transfer: FileTransfer,
public commonSer: CommonService, public tabSer: TabsService) { public commonSer: CommonService, public tabSer: TabsService) {
} }
ionViewDidLoad() { ionViewDidLoad() {
this.type = this.navParams.get('type');
this.storage.get("userLoginInfo").then((value) => { this.storage.get("userLoginInfo").then((value) => {
this.userid = value.userid; this.userid = value.userid;
}) })
...@@ -96,17 +98,25 @@ export class PublishPage { ...@@ -96,17 +98,25 @@ export class PublishPage {
selectPicture(srcType) { selectPicture(srcType) {
const options: CameraOptions = { const options: CameraOptions = {
quality: 100, quality: 100,
destinationType: this.camera.DestinationType.DATA_URL, destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG, encodingType: this.camera.EncodingType.PNG,
mediaType: this.camera.MediaType.PICTURE, mediaType: this.camera.MediaType.PICTURE,
sourceType: srcType, sourceType: srcType,
saveToPhotoAlbum: false saveToPhotoAlbum: false
}; };
const option : FileUploadOptions = { const option: FileUploadOptions = {
httpMethod: 'POST',
} headers: {
'Accept': 'application/json', //不加入 发生错误!!
},
fileName:'image.png'
};
this.camera.getPicture(options).then((imagedata) => { this.camera.getPicture(options).then((imagedata) => {
this.upload(imagedata,option); if(imagedata.indexOf('?') !== -1){ //获取文件名
imagedata = imagedata.split('?')[0];
}
let arr = imagedata.split('/');
this.upload(arr[arr.length -1], option);
}) })
} }
...@@ -118,13 +128,21 @@ export class PublishPage { ...@@ -118,13 +128,21 @@ export class PublishPage {
mediaType: this.camera.MediaType.VIDEO, mediaType: this.camera.MediaType.VIDEO,
sourceType: 0, sourceType: 0,
}; };
const option :FileUploadOptions = { const option: FileUploadOptions = {
fileKey: "file", httpMethod: 'POST',
fileName: 'test', headers: {
mimeType:'vedio/mp4', 'Accept': 'application/json', //不加入 发生错误!!
},
fileName:'video.mp4',
mimeType:'mp4'
}; };
this.camera.getPicture(options).then((videoData) => { this.camera.getPicture(options).then((videoData) => {
this.upload(videoData,option); if(videoData.indexOf('?') !== -1){ //获取文件名
videoData = videoData.split('?')[0];
}
let arr = videoData.split('/');
this.upload(arr[arr.length -1], option);
this.upload(videoData, option);
}) })
} }
...@@ -144,22 +162,29 @@ export class PublishPage { ...@@ -144,22 +162,29 @@ export class PublishPage {
// } ], // } ],
// "error" : [ ] // "error" : [ ]
// } // }
upload(file,options){ upload(file, options) {
this.commonSer.log(file);
const uploadLoading = this.loadingCtrl.create({ const uploadLoading = this.loadingCtrl.create({
content: '上传中...' content: '上传中...',
dismissOnPageChange:true,
enableBackdropDismiss:true,
}); });
alert(file);
uploadLoading.present(); uploadLoading.present();
const fileTransfer: FileTransferObject = this.transfer.create(); const fileTransfer: FileTransferObject = this.transfer.create();
fileTransfer.upload(file, '/wisdomgroup/modules/common/file/upload1',options).then( fileTransfer.upload(file, AppGlobal.domain + '/wisdomgroup/modules/common/file/upload1', options).then(
(res) => { (res) => {
uploadLoading.dismiss(); uploadLoading.dismiss();
this.commonSer.toast('上传成功'); this.commonSer.toast('上传成功');
const data = JSON.parse(res.response); const data = JSON.parse(res.response);
this.imgList.push(data.data[0]); const obj = {
},err=>{ resourceType: 1,
path: data.data[0].filePath,
name: data.data[0].showName,
};
this.commonSer.log(data);
this.fileList.push(obj);
}, err => {
uploadLoading.dismiss(); uploadLoading.dismiss();
console.log(err)
this.commonSer.toast('上传错误'); this.commonSer.toast('上传错误');
}); });
} }
...@@ -175,9 +200,7 @@ export class PublishPage { ...@@ -175,9 +200,7 @@ export class PublishPage {
publishRange: this.obj.publishRange, publishRange: this.obj.publishRange,
submitter: this.userid, submitter: this.userid,
stuffType: 1, stuffType: 1,
attachments:[ attachments: this.fileList,
{resourceType:1,path:'',name:''}
]
}; };
this.commonSer.alert('确定提交审核当前内容?', () => { this.commonSer.alert('确定提交审核当前内容?', () => {
this.tabSer.stuffSave(data).subscribe( this.tabSer.stuffSave(data).subscribe(
...@@ -188,7 +211,6 @@ export class PublishPage { ...@@ -188,7 +211,6 @@ export class PublishPage {
}, 800) }, 800)
} }
) )
}) })
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</button> </button>
</ion-buttons> </ion-buttons>
<ion-buttons end> <ion-buttons end>
<button ion-button icon-only (click)="goToPublish()" class="toolbar-signUp"> <button ion-button icon-only (click)="isPublish = true" class="toolbar-signUp">
<ion-icon class="icon-fabu iconfont"></ion-icon> <ion-icon class="icon-fabu iconfont"></ion-icon>
<span class="signUp-span" >发布</span> <span class="signUp-span" >发布</span>
</button> </button>
...@@ -116,3 +116,10 @@ ...@@ -116,3 +116,10 @@
<p class="noData" *ngIf="!loadMore">你已经看到我的底线了</p> <p class="noData" *ngIf="!loadMore">你已经看到我的底线了</p>
</ion-content> </ion-content>
<div class="publishMisk" *ngIf="isPublish" (click)="close()">
<div class="content" (click)="stop($event)">
<div class="image" (click)="goToPublish('image')">发图文</div>
<div class="video" (click)="goToPublish('video')">发视频</div>
</div>
</div>
...@@ -183,4 +183,25 @@ page-discover { ...@@ -183,4 +183,25 @@ page-discover {
.swiper-container{ .swiper-container{
overflow: auto; overflow: auto;
} }
.publishMisk{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,.4);
z-index: 99999;
.content{
position: absolute;
top: 44px;
right: 10px;
background-color: #fff;
width: 25%;
border-radius: 4px;
padding: 8px;
div{
margin-top: 5px;
}
}
}
} }
...@@ -177,6 +177,7 @@ export class DiscoverPage { ...@@ -177,6 +177,7 @@ export class DiscoverPage {
totalNum; totalNum;
pageNum = 1; pageNum = 1;
isPublish = false;
constructor(public navCtrl: NavController, public navParams: NavParams, constructor(public navCtrl: NavController, public navParams: NavParams,
public commonSer: CommonService,public renderer:Renderer2, public commonSer: CommonService,public renderer:Renderer2,
...@@ -342,8 +343,9 @@ export class DiscoverPage { ...@@ -342,8 +343,9 @@ export class DiscoverPage {
} }
//前往发布页面 //前往发布页面
goToPublish() { goToPublish(type) {
this.navCtrl.push(PublishPage); this.navCtrl.push(PublishPage,{type:type});
this.isPublish = false;
} }
//消息提醒页面 //消息提醒页面
...@@ -357,4 +359,12 @@ export class DiscoverPage { ...@@ -357,4 +359,12 @@ export class DiscoverPage {
if (index == this.tabsList.length + 1) index = 1; if (index == this.tabsList.length + 1) index = 1;
this.changeParent(this.tabsList[index]) this.changeParent(this.tabsList[index])
} }
close(){
this.isPublish = false;
}
stop(e) {
e.stopPropagation();
}
} }
...@@ -3,6 +3,9 @@ import {AlertController, LoadingController, ToastController} from "ionic-angular ...@@ -3,6 +3,9 @@ import {AlertController, LoadingController, ToastController} from "ionic-angular
import {AppGlobal} from "../service/http.service"; import {AppGlobal} from "../service/http.service";
import {File} from "@ionic-native/file"; import {File} from "@ionic-native/file";
import {FileOpener} from "@ionic-native/file-opener"; import {FileOpener} from "@ionic-native/file-opener";
import VConsole from 'vconsole';
var vconsole = new VConsole();
@Injectable() @Injectable()
...@@ -218,14 +221,16 @@ export class CommonService{ ...@@ -218,14 +221,16 @@ export class CommonService{
return mimeType; return mimeType;
} }
/** /**
* vConsole 移动端调试工具
* 定义全局的log日志 开发模式 打印log 生产环境 关闭 * 定义全局的log日志 开发模式 打印log 生产环境 关闭
* @param message 日志信息 * @param message 信息
*/ */
log(message){ log(message){
if(AppGlobal.domain === ""){ //开发环境时 // if(AppGlobal.domain === ""){ //开发环境时
console.log(message); console.log(message);
} // }
} }
} }
\ No newline at end of file
...@@ -13,10 +13,10 @@ export class AppGlobal { ...@@ -13,10 +13,10 @@ export class AppGlobal {
}; };
//接口基地址 //接口基地址
// static domain = "http://101.89.112.92:80"; //正式环境 // static domain = "http://101.89.112.92:80"; //正式环境
// static domain = "http://180.168.156.212:2931"; //测试环境 // static domain = "http://192.168.2.235:8080"; //测试环境
static domain = "http://47.103.35.216:8080"; //阿里云地址 // static domain = "http://47.103.35.216:8080"; //阿里云地址
// static domain = ""; //本地环境 static domain = ""; //本地环境
//图片地址 //图片地址
// static picture = AppGlobal.domain + "/wisdomgroup/manager/getIcon/"; //正式地址 // static picture = AppGlobal.domain + "/wisdomgroup/manager/getIcon/"; //正式地址
......
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