安卓扫码器
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.

654 lines
17 KiB

3 years ago
<template>
<view class="content">
2 years ago
<!-- <tn-avatar class="icon tn-icon-calendar" size="xl"></tn-avatar> -->
<!-- <tn-list-view :card="true" unlined="all" class="listView">
2 years ago
<tn-list-cell class="listItem-1">
2 years ago
<view>Subject: {{ calendarInfo.Theme }}</view>
2 years ago
<view>Start: {{ calendarInfo.startTime }}</view>
2 years ago
<view>End: {{ calendarInfo.closeTime }}</view>
<view>Note: {{ calendarInfo.AbstractInfo }}</view>
2 years ago
<view>Address: {{ calendarInfo.PlaceInfo }}</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>
2 years ago
<tn-grid-item class="toolItem" @click="addActivity()">
2 years ago
<view class="tn-icon-calendar"></view>
<view class="toolText">Add to events</view>
</tn-grid-item>
<tn-grid-item class="toolItem" @click="share()">
<view class="tn-icon-share-triangle"></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="toolText">Copy</view>
3 years ago
</tn-grid-item>
</block>
</tn-grid>
</tn-list-cell> -->
2 years ago
<!-- <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" @click="jumpToFeedback()">Feedback & Suggestion</text> -->
2 years ago
<!-- <tn-modal v-model="showStarTip" :custom="true" :backgroundColor="startTipColor">
2 years ago
<view class="startTipContent">
<view slot="left" class="tn-icon tn-icon-about-fill">
<view class="starTipText">Do you like this app?</view>
</view>
<view slot="center" class="tn-icon tn-icon-about-fill">
2 years ago
<tn-rate v-model="starRateValue" :size="80" :allowHalf="false" activeColor="#0186FF"></tn-rate>
2 years ago
</view>
<view slot="right" class="tn-icon tn-icon-about-fill">
2 years ago
<tn-button :fontSize="50" margin="80rpx" height="100rpx" backgroundColor="#0186FF" fontColor="tn-color-white" @click="starTipSubmit()">submit</tn-button>
2 years ago
</view>
</view>
</tn-modal>
<tn-toast ref="toast"></tn-toast> -->
<uv-list class="listView">
<uv-list-item class="listItem-1">
<text class="listItemText">Subject: {{ calendarInfo.Theme }}</text>
<text class="listItemText">Start: {{ calendarInfo.startTime }}</text>
<text class="listItemText">End: {{ calendarInfo.closeTime }}</text>
<text class="listItemText">Note: {{ calendarInfo.AbstractInfo }}</text>
<text class="listItemText">Address: {{ calendarInfo.PlaceInfo }}</text>
</uv-list-item>
<uv-list-item class="listItem">
<uv-grid :col="col">
<uv-grid-item class="toolItem" :bgColor="bgColor" @click="addActivity()">
<!-- <view class="tn-icon-search"></view> -->
<uv-icon name="search" :size="36"></uv-icon>
<text class="toolText">Add to events</text>
</uv-grid-item>
<uv-grid-item class="toolItem" :bgColor="bgColor" @click="share()">
<!-- <view class="tn-icon-share-triangle"></view> -->
<uv-icon name="share" :size="36"></uv-icon>
<text class="toolText">Share</text>
</uv-grid-item>
<uv-grid-item class="toolItem" :bgColor="bgColor" @click="copyValue()">
<!-- <view class="tn-icon-copy-fill"></view> -->
<uv-icon name="photo" :size="36"></uv-icon>
<text class="toolText">Copy</text>
</uv-grid-item>
</uv-grid>
</uv-list-item>
<uv-list-item class="listItem-ad" :bgColor="bgColor">
<!-- #ifdef APP-PLUS -->
<google-native-view class="pangle-native-view"
@onAdLoaded="onAdLoaded"
@onAdClicked="onAdClicked"
@onAdFailedToLoad="onAdFailedToLoad"
:adId="nativeAdId"
:style="{ width: 320, height: 450,backgroundColor:'#1F222B' }">
</google-native-view>
<!-- #endif -->
</uv-list-item>
<uv-list-item class="listItemBottom">
<image :src="textImgUrl" class="buttomImg"/>
</uv-list-item>
</uv-list>
<text class="bottomText" @click="jumpToFeedback()">Feedback & Suggestion</text>
<view>
<uv-modal ref="showStarTip" :showConfirmButton="false">
<view class="startTipContent">
<view class="starTipView">
<text class="starTipText">Do you like this app?</text>
</view>
<view class="starTipView">
<uv-rate :count="5" v-model="starRateValue" :size="40" active-color="#0186FF" inactive-color="#b2b2b2" gutter="20"></uv-rate>
</view>
<view class="starTipView">
<uv-button text="submit" color="#0186FF" class="starTipButton" @click="starTipSubmit()"></uv-button>
</view>
<!-- <tn-button :fontSize="50" margin="80rpx" height="100rpx" backgroundColor="#0186FF" fontColor="tn-color-white" @click="starTipSubmit()">submit</tn-button> -->
</view>
</uv-modal>
</view>
<uv-toast ref="toast"></uv-toast>
3 years ago
</view>
</template>
<script>
2 years ago
// var calanderURL = "content://com.android.calendar/calendars";
// var calanderEventURL = "content://com.android.calendar/events";
// var calanderRemiderURL = "content://com.android.calendar/reminders";
// var calId; //日历账户id
2 years ago
import { openSqlite,executeSql,closedb,isTable,addSql} from "@/utils/database";
2 years ago
import permision from "@/js_sdk/wa-permission/permission.js"
import {addSchedule} from '@/uni_modules/vv-schedule'
3 years ago
export default {
data() {
return {
2 years ago
col: 3,
2 years ago
calendarInfo:{},
2 years ago
tableName: 'scan_code',
textImgUrl: '',
bgColor: '#1F222B',
nativeAdId:'ca-app-pub-3940256099942544/2247696110', //原生广告id
2 years ago
2 years ago
starRateValue: 0, //评分星星数量
2 years ago
}
},
async onLoad(option) {
console.log('onLoadOption',option)
let that = this;
//打开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);
3 years ago
}
},
2 years ago
onHide() {
2 years ago
let that = this;
2 years ago
that.closedb();
3 years ago
},
2 years ago
onShow() {
//uni.clearStorageSync();
},
onBackPress(e){
let that = this;
//判断评分弹窗条件是否达到要求
let starTipStatus = that.getStarTipStatus();
console.log('starTipStatus',JSON.stringify(starTipStatus))
2 years ago
if(starTipStatus === null || starTipStatus === ""){
//达到要求
//that.showStarTip = true;
that.starTipOpen();
2 years ago
that.setStarTipStatus(false);
2 years ago
return true;
}else{
return false;
}
},
3 years ago
methods: {
2 years ago
starTipOpen(){
let that = this;
that.$refs.showStarTip.open();
},
onAdLoaded() {
console.log('BarcodeNative广告加载成功');
},
onAdClicked() {
console.log('点击BarcodeNative广告');
},
onAdFailedToLoad(fail) {
console.log('native广告加载失败', fail.detail);
console.log('error code: ' + fail.detail.errorCode);
console.log('error message: ' + fail.detail.errorMessage);
this.showToast('ad load error!');
},
showToast(title = '', duration = 1500) {
uni.showToast({
title: title,
mask: true,
duration: duration,
icon: 'none'
});
},
2 years ago
//获取弹窗状态结果
getStarTipStatus(){
return uni.getStorageSync('starTipStatus');
},
//设置弹窗状态结果
setStarTipStatus(value){
uni.setStorageSync('starTipStatus', value);
},
//提交反馈
starTipSubmit(){
let that = this;
that.$refs.toast.show({
message: 'Thanks for feedback!',
2 years ago
duration: 3000
})
that.setStarTipStatus(true);
that.$refs.showStarTip.close();
2 years ago
},
//跳转到反馈页面
jumpToFeedback(){
uni.navigateTo({
url: '/pages/feedback/Feedback'
});
},
2 years ago
//添加活动
2 years ago
async addActivity(){
let that = this;
await addSchedule({
title: that.calendarInfo.Theme,
description: that.calendarInfo.AbstractInfo,
dtstart: new Date(that.calendarInfo.startTime).getTime(),
dtend: new Date(that.calendarInfo.closeTime).getTime(),
})
that.$refs.toast.show({
title: 'Success',
content: 'Add calander success!',
icon: 'success',
duration: 1500
})
2 years ago
},
//分享
share(){
uni.shareWithSystem({
2 years ago
summary: this.calendarInfo,
2 years ago
success(){
// 分享完成,请注意此时不一定是成功分享
},
fail(){
// 分享失败
uni.showToast({
title: 'share fail!'
});
}
})
},
//copy结果值
copyValue(){
let that = this;
2 years ago
//console.log('点击复制关键词事件',that.calendarInfo)
2 years ago
uni.setClipboardData({
2 years ago
data: JSON.stringify(that.calendarInfo),
2 years ago
success() {
uni.showToast({
2 years ago
title: 'copy success!',
2 years ago
});
}
})
},
// 打开数据库
async openSqlite(){
try{
let b = await openSqlite()
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)
console.log("新增表scancode",res)
}else{
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 = {
AbstractInfo : data.AbstractInfo,
PlaceInfo: data.PlaceInfo,
Sponsor: data.Sponsor,
Theme: data.Theme,
Condition: data.Condition,
2 years ago
closeTime: data.closeTime.Year +'-'+ data.closeTime.Month +'-'+ data.closeTime.Day
+' '+ data.closeTime.Hours +':'+ data.closeTime.Minutes +':'+ data.closeTime.Seconds,
startTime: data.startTime.Year +'-'+ data.startTime.Month +'-'+ data.startTime.Day
+' '+ data.startTime.Hours +':'+ data.startTime.Minutes +':'+ data.startTime.Seconds,
2 years ago
imgUrl: data.imgUrl
}
that.calendarInfo = insertData;
that.textImgUrl = 'file://'+that.calendarInfo.imgUrl;
//写入db
await that.writeToDb("Calendar",that.calendarInfo);
},
//获取历史信息
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.calendarInfo = data;
2 years ago
that.textImgUrl = 'file://'+that.calendarInfo.imgUrl;
2 years ago
},
// * 获取日历权限 *
getCalendarJurisdiction() {
return new Promise((resolve, reject) => {
plus.android.requestPermissions(['android.permission.READ_CALENDAR',
'android.permission.WRITE_CALENDAR'
],
function(e) {
if (e.deniedAlways.length > 0) { //权限被永久拒绝
// 弹出提示框解释为何需要定位权限,引导用户打开设置页面开启
console.log('Always Denied!!! ' + e.deniedAlways.toString());
reject({
data: -1,
message: "权限被永久拒绝了"
})
}
if (e.deniedPresent.length > 0) { //权限被临时拒绝
reject({
data: 0,
message: "权限被临时拒绝了"
})
// 弹出提示框解释为何需要定位权限,可再次调用plus.android.requestPermissions申请权限
console.log('Present Denied!!! ' + e.deniedPresent.toString());
}
if (e.granted.length > 0) { //权限被允许
//调用依赖获取定位权限的代码
resolve({
data: 1,
message: "ok"
})
}
})
})
},
3 years ago
}
}
</script>
3 years ago
<style lang="scss">
// .content {
// display: flex;
// flex-direction: column;
// align-items: center;
// justify-content: center;
// background-color: #1F222B;
// height:650vh;
3 years ago
// .listView{
// z-index: 0;
// position: relative;
// width: 660rpx;
// height: 1300rpx;
// margin-top: 100rpx;
// background-color: #1F222B;
// overflow: auto;
3 years ago
// .listItem-1{
// margin-top: 120rpx;
// background-color: #1F222B;
// color: #fff;
// //border: 2px solid green;
// height: auto;
// text-align: start;
// }
3 years ago
// .listItem{
// //border: 2px solid yellow;
// height: 160rpx;
// //margin-top: 30px;
// //padding-top: 30px;
// width: 660rpx;
// background-color: #1F222B;
// color: #fff;
3 years ago
// .toolItem{
// //border: 2px solid red;
// background-color: #1F222B;
// font-size: 60rpx;
// color: #8f8f94;
// height: 120rpx;
// text-align: center;
3 years ago
// .toolText{
// font-size: 24rpx;
// color: #8f8f94;
// }
// }
3 years ago
// }
3 years ago
// .listItem-ad{
// background-color: #1F222B;
// text-align: center;
// color: #fff;
// //border: 2px solid red;
// height: 160rpx;
// }
3 years ago
// .listItemBottom{
// height: 400rpx;
// margin-top: 20rpx;
// background-color: #1F222B;
// color: #fff;
// display: flex;
// flex-direction: column;
// align-items: center;
// justify-content: center;
3 years ago
// .buttomImg{
// width: 300rpx;
// height: 300rpx;
// }
// }
// }
// // .icon{
// // z-index: 1;
// // position: absolute;
// // margin-top: -620rpx;
// // background-color: #3e444d;
// // font-size: 120rpx;
// // color: #fff;
// // text-align: center;
// // }
3 years ago
// .bottomText{
// color: #fff;
// text-align: center;
// font-size: 24rpx;
// //margin-top: 40rpx;
// margin-bottom: 120rpx;
// }
// .cutline{
// border: 1px solid #8f8f94;
// }
2 years ago
// .starTipText{
// color: #fff;
// font-size: 48rpx;
// }
2 years ago
// .startTipContent{
// margin-bottom: 30rpx;
// }
// }
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #1F222B;
height:660vh;
}
.listView{
z-index: 0;
position: relative;
width: 700rpx;
//height: 500rpx;
margin-top: 100rpx;
background-color: #1F222B;
}
.listItem-1{
margin-top: 220rpx;
background-color: #1F222B;
//border: 2px solid yellow;
height: 400rpx;
text-align: center;
}
.listItem{
//border: 2px solid yellow;
/* #ifndef APP-PLUS-NVUE */
height: auto;
/* #endif */
margin-top: 300rpx;
//padding-top: 30px;
background-color: #1F222B;
color: #fff;
}
.toolItem{
//border: 2px solid pink;
background-color: #1F222B;
font-size: 60rpx;
color: #8f8f94;
//height: 120rpx;
text-align: center;
}
.toolText{
font-size: 24rpx;
color: #8f8f94;
}
.listItem-ad{
background-color: #1F222B;
text-align: center;
//margin-top: 150rpx;
color: #fff;
//border: 2px solid blue;
height: 160rpx;
}
.listItemBottom{
height: 400rpx;
margin-top: 20rpx;
width: 700rpx;
//border: 2px solid blue;
background-color: #1F222B;
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.buttomImg{
width: 300rpx;
height: 300rpx;
}
.bottomText{
color: #fff;
text-align: center;
font-size: 24rpx;
//margin-top: 40rpx;
margin-bottom: 240rpx;
}
.cutline{
border: 1px solid #8f8f94;
}
.starTipText{
color: #fff;
font-size: 48rpx;
text-align: center;
}
.startTipContent{
margin-bottom: 30rpx;
}
.starTipView{
margin-top: 50rpx;
}
.starTipButton{
width: 250rpx;
height: 80rpx;
text-align: center;
margin-left: 190rpx;
}
.listItemText{
font-size: 36rpx;
text-align: center;
background-color: #1F222B;
//border: 2px solid pink;
color: #fff;
3 years ago
}
</style>