Commit b2ff7ce5 authored by jyx's avatar jyx

添加扫描及分享页

parent 29c87335
......@@ -14,6 +14,10 @@
{
"launchtype" : "local"
},
"quickapp-union" :
{
"launchtype" : "local"
},
"type" : "uniCloud"
}
]
......
......@@ -10,7 +10,13 @@
"pages": [
// #ifndef APP-PLUS
{
"path": "pages/loading",
// "path": "pages/loading",
// "style": {
// "navigationStyle": "custom",
// "navigationBarBackgroundColor": "#2196f3",
// "navigationBarTextStyle": "black" //用于配置状态栏的字体颜色
// }
"path": "pagesC/scan/result",
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
......@@ -70,7 +76,14 @@
}, {
"root": "pagesC",
"pages": [{
"path": "video/videoDetail",
"path": "scan/scan",
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
}, {
"path": "scan/result",
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
......
......@@ -105,7 +105,8 @@
navigateTo(`/pagesD/watchRecord/watchRecord`)
},
handlePayRecord() {
navigateTo(`/pagesD/payRecord/payRecord`)
// navigateTo(`/pagesD/payRecord/payRecord`)
navigateTo(`/pagesC/scan/scan`)
},
handleVipPay() {
navigateTo(`/pagesA/vipPay/vipPay`)
......
<template>
<view class="body" :style='{width:windowWidth+"px",height:windowHeight+"px"}'>
<status-title :showBack="true" iconColor="black">识别结果</status-title>
<view style="display: flex;flex-direction: column;height: 100%;">
<view style="height: 40%;">
<image mode="heightFix" style="height: 100%;" src="../../static/bg_vip_0.png" />
</view>
<view style="background: white;height: 50%;display: flex;flex-direction: column;padding-top: 30rpx;">
<view style="font-weight: bold;padding-left: 10rpx;">识别结果</view>
<scroll-view :scroll-y="true">
<view>
<block v-for="(item, index) in dataList" :key="index">
<view>
<view style="margin: 10rpx;">{{item}}</view>
<view style="height: 1rpx;width: 100%;background: darkgray;"></view>
</view>
</block>
</view>
</scroll-view>
</view>
<view style="height: 10%;display: flex;flex-direction: row;background: white;">
<view @click="copy"
style="display: flex;flex-direction: column;flex: 1;align-items: center;padding-top: 20rpx;">
<image style="width: 30rpx;height: 30rpx;" src="../../static/ic_selected.png">
</image>
<view>复制</view>
</view>
<view @click="myShare"
style="display: flex;flex-direction: column;flex: 1;align-items: center;padding-top: 20rpx;">
<image style="width: 30rpx;height: 30rpx;" src="../../static/ic_selected.png">
</image>
<view>导出</view>
</view>
</view>
</view>
</view>
</template>
<script>
import common from '@/mixins/common';
const app = getApp();
export default {
name: 'result',
mixins: [common],
data() {
return {
windowWidth: '',
windowHeight: '',
dataList: [
"AAAAAAAA",
"AAAAAAAA",
"AAAAAAAA",
"AAAAAAAA",
"AAAAAAAA",
"AAAAAAAA",
"AAAAAAAA",
"AAAAAAAA",
"AAAAAAAA",
"AAAAAAAA",
"AAAAAAAA",
"AAAAAAAA",
]
};
},
onLoad() {
let {
windowWidth,
windowHeight
} = uni.getSystemInfoSync()
this.windowWidth = windowWidth
this.windowHeight = windowHeight
},
methods: {
copy() {
var text = ''
uni.setClipboardData({
data: text,
complete() {
uni.showToast({
title: "已复制到剪贴板"
})
}
})
},
myShare() {
// var msg = {
// content: '分享内容',
// type: 'text'
// };
// plus.share.sendWithSystem(msg, function() {
// console.log('分享成功');
// }, function(e) {
// console.log('分享失败:' + JSON.stringify(e));
// });
// uni.share({
// provider: "weixin",
// scene: "WXSceneSession",
// type: 1,
// summary: "-",
// success: function (res) {
// console.log("success:" + JSON.stringify(res));
// },
// fail: function (err) {
// console.log("fail:" + JSON.stringify(err));
// }
// });
uni.shareWithSystem({
summary: 'AAAA',
success() {
// 分享完成,请注意此时不一定是成功分享
},
fail() {
// 分享失败
}
})
// share.share({
// type: 'text/html',
// data: '<b>bold</b>',
// success: function(data) {
// console.log('handling success')
// },
// fail: function(data, code) {
// console.log(`handling fail, code = ${code}`)
// }
// })
}
},
}
</script>
<style lang="scss">
</style>
\ No newline at end of file
<template>
<view class="body" :style='{width:windowWidth+"px",height:windowHeight+"px"}'>
<camera resolution="high" device-position="back" flash="off" @error="error" @initdone="initdone"
style="position:relative;" :style='{width:windowWidth+"px",height:(windowHeight/1.3)+"px"}' />
<view style="display: flex;flex-direction: column;"
:style='{width:windowWidth+"px",height:(windowHeight/1.7)+"px"}'>
<view style="display: flex;height: 10%;">
<block v-for="(item, index) in tabs" :key="index">
<view class="flex" style="width: 25%;" @click="clickItem(index)">
<view class="font">{{item.name}}</view>
<view v-if="current==index"
style="width: 10rpx;height: 10rpx;background: red;border-radius: 10rpx;margin: 0 auto;">
</view>
</view>
</block>
</view>
<view style=" display: flex;height: 20%;">
<view class="icon_flex" @click="openAlbum">
<image class="img" mode="aspectFit" src="../../static/ic_photo.png" />
<view class="font"> 相册 </view>
</view>
<view class="icon_flex" @click="takePhoto">
<image class="img" mode="aspectFit" src="../../static/ic_take_photo.png" />
<view class="font"> 拍照 </view>
</view>
<view class="icon_flex" @click="openAlbum">
<image class="img" mode="aspectFit" src="../../static/ic_scan_ocr.png" />
<view class="font"> 识别 </view>
</view>
</view>
</view>
<image class="img" style="position: absolute;top: 60rpx;left: 60rpx;z-index: 999;"
src="../../static/ic_close.png" @click="close" />
</view>
</template>
<script>
import common from '@/mixins/common';
import {
imageCompress
} from "@/utils/utils.js"
import {
navigateBack,
reLaunch
} from '@/utils/fun';
const app = getApp();
export default {
name: 'scan',
mixins: [common],
data() {
return {
windowWidth: '',
windowHeight: '',
current: 0,
tabs: [{
name: '通用文字识别'
}, {
name: '表格识别'
}, {
name: '中文识别'
}, {
name: '英文识别'
}]
}
},
onLoad() {
let {
windowWidth,
windowHeight
} = uni.getSystemInfoSync()
this.windowWidth = windowWidth
this.windowHeight = windowHeight
},
methods: {
takePhoto() {
const ctx = uni.createCameraContext();
ctx.takePhoto({
quality: 'high',
success: (res) => {
this.src = res.tempImagePath
}
});
},
openAlbum() {
const that = this
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ["album"],
success: (res) => {
console.log(res.tempFilePaths[0], '-------------175')
}
});
},
error(e) {
console.log(e.detail);
},
initdone({
detail: {
maxZoom
}
}) {
// 最大放大倍速
this.maxZoom = maxZoom / 2
},
close() {
// #ifdef APP-PLUS
let iconClone = getCurrentPages().length === 1 ? 'back' : 'back';
// #endif
if (this.iconClone === 'back') {
navigateBack();
} else {
reLaunch('pages/home');
}
},
clickItem(index) {
this.current = index
},
async uploadFile(file, index) {
const currentIndex = this.mediaList.findIndex(v => v.path === file.path);
let compressFile = await imageCompress(file)
let that = this
that.mediaList[currentIndex].status = 'upload'
return new Promise((resolve, reject) => {
uni.uploadFile({
url: app.globalData.baseUrl + '/app/uploadImgNotCensor',
filePath: compressFile.tempFilePath ? compressFile.tempFilePath : compressFile
.path,
fileType: "image",
name: 'file',
formData: {
session: app.globalData.token
},
success: (uploadFileRes) => {
let res = JSON.parse(uploadFileRes.data)
if (res.data != null && res.code == '200') {
that.mediaList[currentIndex].url = file.path
that.mediaList[currentIndex].fileID = res.data.imgUrl
// if (currentIndex == 0) {
// that.form.media = res.data.imgUrl
// } else {
// that.form.media += (',' + res.data.imgUrl)
// }
resolve()
} else {
that.$refs.fileImage.clearFiles(currentIndex)
that.mediaList.splice(currentIndex, 1);
reject()
loading.hide();
alert({
content: res.errorMsg || res.msg
})
}
},
fail: e => {
that.mediaList.splice(currentIndex, 1);
that.$refs.fileImage.clearFiles(currentIndex)
reject()
alert(e)
loading.hide();
}
});
})
},
}
}
</script>
<style lang="scss">
.body {
background: black;
}
.img {
width: 60rpx;
height: 60rpx;
}
.font {
text-align: center;
font-size: 26rpx;
color: white;
margin-top: 30rpx;
}
.icon_flex {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
margin-top: 50rpx;
}
</style>
\ No newline at end of file
This diff is collapsed.
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