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

383 lines
9.5 KiB

3 years ago
<template>
<view class="content">
<view class="head">
<view class="headLine">Favorites</view>
<tn-list-view :card="cardMode" class="settingList" unlined="all">
<tn-list-cell class="listItem" v-for="(item, index) in favoritesList" :key="index">
<view class="list-icon-text">
<!-- 左边图标文本显示部分 -->
<view class="list-left">
<view class="list-left-icon tn-icon-circle-fill tn-color-gray"></view>
<view class="list-left-text">
<view class="list-left-text-one">{{ item.label }}</view>
<view class="list-left-text-two">{{ item.text }}</view>
</view>
</view>
<!-- 右边操作按钮部分 -->
<!-- <view class="list-right">
<tn-switch v-model="beepChecked" :inactiveValue="0" :activeValue="1"
:inactiveColor="inactiveColor" :activeColor="activeColor"></tn-switch>
</view> -->
</view>
</tn-list-cell>
</tn-list-view>
</view>
<view class="body">
<view class="headLine">History</view>
<tn-list-view :card="cardMode" class="settingList" unlined="all">
<tn-list-cell class="listItem" v-for="(item, index) in historyList" :key="index">
<view class="list-icon-text">
<!-- 左边图标文本显示部分 -->
<view class="list-left">
<view class="list-left-icon tn-icon-circle-fill tn-color-gray"></view>
2 years ago
<view class="list-left-text" @click="getHistory(item.category,item.content)">
<view class="list-left-text-one">{{ item.category }}</view>
<view class="list-left-text-two">{{ item.content }}</view>
</view>
</view>
<!-- 右边操作按钮部分 -->
<!-- <view class="list-right">
<tn-switch v-model="beepChecked" :inactiveValue="0" :activeValue="1"
:inactiveColor="inactiveColor" :activeColor="activeColor"></tn-switch>
</view> -->
</view>
</tn-list-cell>
</tn-list-view>
3 years ago
</view>
</view>
</template>
<script>
import { openSqlite,closedb,getPageList,updateSql} from "@/utils/database";
3 years ago
export default {
data() {
return {
title: 'History',
2 years ago
tableName:"scan_code",
options:{
current:1, // 分页默认为第1页
size:10,
},
list:[],
pages:0,
total:0,
cardMode: true,
favoritesList:[
{
"icon":"grid-item-icon tn-icon-empty-network",
"text":"https://test1.com",
"sort":"0",
"label":"URL"
},
{
"icon":"grid-item-icon tn-icon-empty-network",
"text":"https://test2.com",
"sort":"1",
"label":"URL"
},
{
"icon":"grid-item-icon tn-icon-empty-network",
"text":"https://test3.com",
"sort":"2",
"label":"URL"
},
{
"icon":"grid-item-icon tn-icon-empty-network",
"text":"https://test4.com",
"sort":"3",
"label":"URL"
},
{
"icon":"grid-item-icon tn-icon-empty-network",
"text":"https://test5.com",
"sort":"4",
"label":"URL"
},
{
"icon":"grid-item-icon tn-icon-empty-network",
"text":"https://test6.com",
"sort":"5",
"label":"URL"
},
],
2 years ago
historyList: []
// historyList:[
// {
// "icon":"grid-item-icon tn-icon-empty-network",
// "text":"15936215478",
// "sort":"0",
// "label":"WIFI"
// },
// {
// "icon":"grid-item-icon tn-icon-empty-network",
// "text":"15936215478",
// "sort":"1",
// "label":"WIFI"
// },
// {
// "icon":"grid-item-icon tn-icon-empty-network",
// "text":"15936215478",
// "sort":"2",
// "label":"WIFI"
// },
// {
// "icon":"grid-item-icon tn-icon-empty-network",
// "text":"15936215478",
// "sort":"3",
// "label":"WIFI"
// },
// {
// "icon":"grid-item-icon tn-icon-empty-network",
// "text":"15936215478",
// "sort":"4",
// "label":"WIFI"
// }
// ]
3 years ago
}
},
2 years ago
async onShow() {
let that = this;
//打开db
await that.openSqlite();
//获取历史数据
await that.getData();
},
2 years ago
onHide() {
let that = this;
that.closedb();
3 years ago
},
methods: {
2 years ago
//查看指定记录历史信息
getHistory(category,data){
console.log("123")
let that = this;
if(category === 'Contacts'){
that.jumpToPage('/pages/scan/Contacts','history',data);
}else if(category === 'Email'){
that.jumpToPage('/pages/scan/Email','history',data);
}else if(category === 'Tel'){
that.jumpToPage('/pages/scan/Tel','history',data);
}else if(category === 'Product'){
that.jumpToPage('/pages/scan/Product','history',data);
}else if(category === 'Sms'){
that.jumpToPage('/pages/scan/Sms','history',data);
}else if(category === 'Text'){
that.jumpToPage('/pages/scan/Text','history',data);
}else if(category === 'Url'){
that.jumpToPage('/pages/scan/Url','history',data);
}else if(category === 'Wifi'){
that.jumpToPage('/pages/scan/Wifi','history',data);
}else if(category === 'Location'){
that.jumpToPage('/pages/scan/Location','history',data);
}else if(category === 'Calendar'){
that.jumpToPage('/pages/scan/Calendar','history',data);
}else if(category === 'Book'){
that.jumpToPage('/pages/scan/Book','history',data);
}
},
//根据数据库页面类型结果判断跳转到哪个指定页面
jumpToPage(url,category,data){
uni.navigateTo({
url: url + '?data='+ data + '&category=' + category
});
},
// 打开数据库
async openSqlite(){
try{
let b = await openSqlite()
2 years ago
// uni.showToast({
// title:"open db success",
// icon:"none"
// })
console.log('db打开了');
}catch(e){
console.error("open db error",e)
}
},
// 关闭数据库
closedb(){
try{
closedb()
2 years ago
console.log('db关闭了');
}catch(e){
console.error("close db error",e)
}
},
// 获取数据
async getData(){
try{
let where = {}
2 years ago
let res = await getPageList(this.tableName,this.options,where,"id desc")
console.log("加载数据",res)
2 years ago
this.historyList = res.data.data.records
this.pages = res.data.data.pages
this.total = res.data.data.total
}catch(e){
2 years ago
// uni.showToast({
// title:"报错,请查看控制台",
// icon:"none"
// });
console.error("error",e)
}
},
// 修改数据
async changeData(){
// fid 是自增id
try{
let res = await getPageList(this.tableName,{current:1,size:1},{},"fid desc")
console.log("最后一页数据",res.data.data)
await updateSql(this.tableName,{title:"updated data"},{fid:res.data.data.records[0].fid})
uni.showToast({
title:"update ok",
icon:"none"
});
}catch(e){
uni.showToast({
title:"update error",
icon:"none"
});
console.error("修改报错",e)
}
},
3 years ago
}
}
</script>
<style lang="scss">
3 years ago
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #000000;
height:100%;
.headLine{
color: royalblue;
font-size: 36rpx;
//padding-top:30px;
//margin-right:200px;
margin-top:60rpx;
//border: 2px solid purple;
}
.settingList{
//border: 2px solid red;
2 years ago
width: 660rpx;
//height:300px;
height: auto;
//margin-top: 10px;
//background-color: #141b29;
.listItem{
//border: 2px solid yellow;
2 years ago
height: 100rpx;
//margin-top: 30px;
background-color: #141b29;
color: #fff;
text-align: start;
.list-icon-text {
display: flex;
align-items: center;
justify-content: space-between;
.list-left{
//border: 2px solid green;
display: flex;
align-items: center;
justify-content: flex-start;
.list-left-text{
2 years ago
width: 420rpx;
.list-left-text-one{
2 years ago
font-size: 30rpx;
//border: 2px solid blue;
}
.list-left-text-two{
color: grey;
2 years ago
font-size:26rpx;
//border: 2px solid lightsalmon;
}
}
.list-left-feedback-text{
2 years ago
width: 480rpx;
.list-left-feedback-text-one{
2 years ago
font-size: 30rpx;
//border: 2px solid blue;
}
.list-left-feedback-text-two{
color: grey;
2 years ago
font-size: 26rpx;
//border: 2px solid lightsalmon;
}
}
.list-left-icon{
//border: 2px solid blueviolet;
2 years ago
margin-right: 20rpx;
font-size: 50rpx;
}
.list-left-select-text{
2 years ago
width: 320rpx;
.list-left-select-text-one{
2 years ago
font-size: 30rpx;
//border: 2px solid blue;
}
}
}
.list-right{
//border: 2px solid pink;
color: royalblue;
2 years ago
font-size: 40rpx;
.list-right-icon{
//border: 2px solid gainsboro;
2 years ago
font-size: 50rpx;
margin-left: 30rpx;
}
.list-right-text{
//border: 2px solid green;
//margin-right: 30px;
//padding-right: 30px;
}
}
}
}
}
3 years ago
}
.head{
//border: 2px solid red;
font-size: 72rpx;
color: white;
margin-top:100rpx;
3 years ago
}
.body{
//border: 2px solid blue;
font-size: 72rpx;
color: white;
margin-top:50rpx;
3 years ago
}
3 years ago
</style>