安卓扫码器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
7.6 KiB

3 years ago
<template>
<view class="content">
2 years ago
<tn-avatar class="icon tn-icon-email" size="xl"></tn-avatar>
3 years ago
<tn-list-view :card="true" unlined="all" class="listView">
2 years ago
<tn-list-cell class="listItem-1">
2 years ago
<view>To: {{ emailInfo.addressInfo }}</view>
<view>Subject: {{ emailInfo.SubjectInfo }}</view>
<view>Content: {{ emailInfo.BodyInfo }}</view>
2 years ago
</tn-list-cell>
3 years ago
<tn-list-cell class="listItem">
<tn-grid align="center" :col="col">
2 years ago
<block>
<tn-grid-item class="toolItem" @click="sendEmail()">
<view class="tn-icon-email"></view>
3 years ago
<view class="cutline"></view>
2 years ago
<view class="toolText">Send email</view>
</tn-grid-item>
<tn-grid-item class="toolItem" @click="addContact()">
<view class="tn-icon-my-circle-fill"></view>
<view class="cutline"></view>
<view class="toolText">Add to contacts</view>
</tn-grid-item>
<tn-grid-item class="toolItem" @click="share()">
<view class="tn-icon-share-triangle"></view>
<view class="cutline"></view>
<view class="toolText">Share</view>
</tn-grid-item>
<tn-grid-item class="toolItem" @click="copyValue()">
<view class="tn-icon-copy-fill"></view>
<view class="cutline"></view>
<view class="toolText">Copy</view>
3 years ago
</tn-grid-item>
</block>
</tn-grid>
</tn-list-cell>
<view class="cutline"></view>
<tn-list-cell class="listItem-ad">我是谷歌ad部分</tn-list-cell>
<tn-list-cell class="listItemBottom">
2 years ago
<image :src="textImgUrl" class="buttomImg"/>
3 years ago
</tn-list-cell>
</tn-list-view>
<text class="bottomText">Feedback or Suggestion</text>
3 years ago
</view>
</template>
<script>
2 years ago
import { openSqlite,executeSql,closedb,isTable,addSql} from "@/utils/database";
3 years ago
export default {
data() {
return {
3 years ago
col: 4,
2 years ago
emailInfo:{},
2 years ago
tableName: 'scan_code',
textImgUrl: '',
3 years ago
}
},
2 years ago
async onLoad(option) {
console.log('onLoadOption',option)
2 years ago
let that = this;
2 years ago
//打开db
await that.openSqlite();
//判断是否存在表
await that.createTable();
//scan为写入,history为历史页面
if(option.category === 'scan'){
//获取初始化数据并写入db
await that.initData(option.data);
}else{
//查看历史页面
await that.getHistoryData(option.data);
}
},
onHide() {
let that = this;
that.closedb();
3 years ago
},
methods: {
2 years ago
//发送邮件
sendEmail(){
},
//添加联系人
addContact(){
},
//分享
share(){
uni.shareWithSystem({
summary: '',
href: 'https://uniapp.dcloud.io',
success(){
// 分享完成,请注意此时不一定是成功分享
uni.showToast({
title: 'share success!'
});
},
fail(){
// 分享失败
uni.showToast({
title: 'share fail!'
});
}
})
},
//copy结果值
copyValue(){
let that = this;
//console.log('点击复制关键词事件')
uni.setClipboardData({
data: that.emailInfo,
success() {
uni.showToast({
title: 'copy success!'
});
}
})
},
// 打开数据库
async openSqlite(){
try{
let b = await openSqlite()
// uni.showToast({
// title:"open db success",
// icon:"none"
// })
console.log('db打开了');
}catch(e){
console.error("open db error",e)
}
},
// 关闭数据库
closedb(){
try{
closedb()
console.log('db关闭了');
}catch(e){
console.error("close db error",e)
}
},
// 创建表
async createTable(){
let sql = this.createTableSql_outbound()
try{
let exist = await isTable(this.tableName)
console.log("表是否存在",exist)
if(!exist){
let res = await executeSql(sql)
// uni.showToast({
// title:"insert table ok",
// icon:"none"
// })
console.log("新增表scancode",res)
}else{
// uni.showToast({
// title:"table exist",
// icon:"none"
// })
console.log("表scancode已存在")
}
}catch(e){
uni.showToast({
title:"insert table error",
icon:"none"
})
console.error("新增表报错scancode",e)
}
},
//写入扫描记录
async writeToDb(type,params){
try{
let data = {
category: type,
content: params
}
let b = await addSql(this.tableName,data)
console.log("数据添加成功!")
}catch(e){
console.error("insert data error!",e)
}
},
//创建表语句
createTableSql_outbound(){
return "CREATE TABLE IF NOT EXISTS `scan_code` (" +
" `id` INTEGER PRIMARY KEY AUTOINCREMENT," +
" `category` varchar(50) DEFAULT NULL ," +
" `content` text DEFAULT NULL ," +
" `createTime` datetime DEFAULT CURRENT_TIMESTAMP ," +
" `updateTime` datetime DEFAULT NULL default(datetime('now','localtime'))" +
"); "
},
//加载数据
async initData(option){
//console.log('initoption',option)
let that = this;
let data = JSON.parse(option);
let insertData = {
addressInfo : data.addressInfo,
SubjectInfo: data.SubjectInfo,
BodyInfo: data.BodyInfo,
imgUrl: data.imgUrl
}
that.emailInfo = insertData;
that.textImgUrl = 'file://'+that.emailInfo.imgUrl;
//写入db
await that.writeToDb("Email",that.emailInfo);
},
//获取历史信息
async getHistoryData(params){
//console.log('historyparams',params)
2 years ago
let that = this;
2 years ago
const data = JSON.parse(params);
2 years ago
that.emailInfo = data;
2 years ago
that.textImgUrl = 'file://'+that.emailInfo.imgUrl;
2 years ago
}
3 years ago
}
}
</script>
3 years ago
<style lang="scss">
3 years ago
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
3 years ago
background-color: #000000;
2 years ago
height:100vh;
3 years ago
.listView{
z-index: 0;
position: relative;
2 years ago
width: 660rpx;
2 years ago
height: 1300rpx;
2 years ago
margin-top: 100rpx;
3 years ago
background-color: #141b29;
.listItem-1{
2 years ago
margin-top: 120rpx;
3 years ago
background-color: #141b29;
color: #fff;
//border: 2px solid yellow;
2 years ago
height: 160rpx;
2 years ago
text-align: start;
3 years ago
}
.listItem{
//border: 2px solid yellow;
2 years ago
height: 160rpx;
3 years ago
//margin-top: 30px;
//padding-top: 30px;
background-color: #141b29;
color: #fff;
.toolItem{
//border: 2px solid red;
background-color: #141b29;
2 years ago
font-size: 60rpx;
2 years ago
color: #8f8f94;
2 years ago
height: 120rpx;
3 years ago
text-align: center;
.toolText{
2 years ago
font-size: 24rpx;
2 years ago
color: #8f8f94;
3 years ago
}
}
}
.listItem-ad{
background-color: #141b29;
text-align: center;
color: #fff;
//border: 2px solid red;
2 years ago
height: 160rpx;
3 years ago
}
.listItemBottom{
2 years ago
height: 400rpx;
margin-top: 20rpx;
3 years ago
background-color: #141b29;
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.buttomImg{
2 years ago
width: 300rpx;
height: 300rpx;
3 years ago
}
}
}
.icon{
z-index: 1;
position: absolute;
2 years ago
margin-top: -620rpx;
background-color: #3e444d;
font-size: 120rpx;
color: #fff;
text-align: center;
3 years ago
}
.bottomText{
color: #fff;
text-align: center;
2 years ago
font-size: 24rpx;
margin-top: 40rpx;
margin-bottom: 40rpx;
3 years ago
}
.cutline{
border: 1px solid #8f8f94;
}
3 years ago
}
</style>