|
<template>
<div class="mainmenu">
<text class="title">text>
<div class="tp">
<image src="{{photoUri}} " class = "phu" alt="无法显示图片">image>
div>
<div class="lujing">
<text class="information">
{{photoSaveUri}}
text>
div>
<input type="button" class="btn" onclick="takePhoto" value="拍照"/>
<input type="button" class="btn" onclick="openPhoto" value="相册"/>
div>
template>
<style>
.mainmenu {
flex-direction: column;
justify-content: center;
align-items: center;
}
.tp{
color: red;
}
.btn{
color: #00bfff;
}
.phu{
margin: 50px 0px;
width: 800px;
height: 300px;
}
style>
<script>
// import settings from '@android.settings';
import media from '@system.media';
import image from '@system.image';
import request from '@system.request';
// import prompt from '@system.prompt';
module.exports = {
data: {
title: 'menu',
photoUri:'',//图片路径
photoSaveUri:' '
},
onInit() {
this.$page.setTitleBar({
text: 'menu',
textColor: '#ffffff',
backgroundColor: '#007DFF',
backgroundOpacity: 0.5,
menu:true
})
},
takePhoto(){
var that = this;
media.takePhoto({
success: function (data) {
console.log('handling success: ' + data.uri);
that.photoUri = data.uri;
that.photoSaveUri = data.uri;
media.saveToPhotosAlbum({
uri:that.photoSaveUri,
success: function () {
console.log('save success');
that.photoUri = data.uri;
that.photoSaveUri = data.uri;
},
fail: function (data, code) {
console.log('handling fail, code = ' + code);
}
})
request.upload({
"url": 'http://139.9.7.2:80/',
"files": [
{
"uri":that.photoSaveUri,
}
],
// method:"PUT",
success: function (data) {
console.log("handling success");
},
fail: function (data, code) {
console.log("handling fail, code = " + code);
}
})
}
})
},
editImage(){
var that = this;
image.editImage({
uri: that.photoSaveUri,
success: function (data) {
console.log(data.uri);
that.photoUri = data.uri;
that.photoSaveUri = data.uri;
},
fail: function (data, code) {
console.log('handling fail, code = ' + code);
}
})
},
openPhoto(){
var that = this;
media.pickFile({
success: function (data) {
console.log('handling success: ' + data.uri);
that.photoSaveUri=data.uri;
that.photoUri = data.uri;
},
fail: function (data) {
console.log('handling fail: code' + data.code);
}
})
},
}
script>
|
|