-
+
- code: {{ productInfo.display }}
+ code: {{ productInfo.message }}
-
-
-
+
+
+
- {{ item.text }}
+ View in store
+
+
+
+
+ Web Search
+
+
+
+
+ Copy
+
+
+
+
+ Share
@@ -19,7 +34,7 @@
我是谷歌ad部分
-
+
Feedback or Suggestion
@@ -31,37 +46,177 @@
export default {
data() {
return {
- col: 3,
+ col: 4,
productInfo:{},
- fastToolList:[
- {
- "index": 0,
- "text":"Web Search",
- "icon": "tn-icon-search"
- },
- {
- "index": 1,
- "text":"View in store",
- "icon": "tn-icon-shop"
- },
- {
- "index": 2,
- "text":"Copy",
- "icon": "tn-icon-copy-fill"
- }
- ]
+ tableName: 'scan_code',
+ textImgUrl: '',
}
},
- onLoad(option) {
+ async onLoad(option) {
+ console.log('onLoadOption',option)
let that = this;
- that.initData(option);
+ //打开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();
},
methods: {
- initData(option){
+
+ //跳转亚马逊
+ openShoping(){
let that = this;
- let data = JSON.parse(option.data);
+ console.log('that.textInfo.message',that.productInfo.message)
+ uni.navigateTo({
+ url: '/pages/webview/webview?url=https://www.amazon.com/s?k=' + that.productInfo.message
+ //url: '/pages/webview/webview?url=http://www.google.com?wd=' + that.textInfo.message
+ });
+ },
+
+ //分享
+ share(){
+ uni.shareWithSystem({
+ summary: '',
+ href: 'https://uniapp.dcloud.io',
+ success(){
+ // 分享完成,请注意此时不一定是成功分享
+ uni.showToast({
+ title: 'share success!'
+ });
+ },
+ fail(){
+ // 分享失败
+ uni.showToast({
+ title: 'share fail!'
+ });
+ }
+ })
+ },
+
+ //打开内部浏览器
+ openWeb(){
+ let that = this;
+ console.log('that.textInfo.message',that.productInfo.message)
+ uni.navigateTo({
+ url: '/pages/webview/webview?url=https://www.baidu.com/s?wd=' + that.productInfo.message
+ //url: '/pages/webview/webview?url=http://www.google.com?wd=' + that.textInfo.message
+ });
+ },
+
+ //copy结果值
+ copyValue(){
+ let that = this;
+ //console.log('点击复制关键词事件')
+ uni.setClipboardData({
+ data: that.productInfo.message,
+ success() {
+ uni.showToast({
+ title: 'copy success!'
+ });
+ }
+ })
+ },
+
+ // 打开数据库
+ 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 = {
+ message : data.message,
+ imgUrl: data.imgUrl
+ }
+ that.productInfo = insertData;
+ that.textImgUrl = 'file://'+that.productInfo.imgUrl;
+ //写入db
+ await that.writeToDb("Product",that.productInfo);
+ },
+
+ //获取历史信息
+ async getHistoryData(params){
+ //console.log('historyparams',params)
+ let that = this;
+ const data = JSON.parse(params);
that.productInfo = data;
- console.log('productInfo',that.productInfo)
+ that.textImgUrl = 'file://'+that.productInfo.imgUrl;
}
}
}
@@ -74,13 +229,14 @@
align-items: center;
justify-content: center;
background-color: #000000;
- height:100%;
+ height:100vh;
.listView{
+ //border: 2px solid yellow;
z-index: 0;
position: relative;
width: 660rpx;
- height: 1000rpx;
+ height: 1300rpx;
margin-top: 100rpx;
background-color: #141b29;
@@ -96,26 +252,30 @@
.listItem{
//border: 2px solid yellow;
height: 160rpx;
+ width: 660rpx;
//margin-top: 30px;
//padding-top: 30px;
background-color: #141b29;
color: #fff;
+ }
+
- .toolItem{
- //border: 2px solid red;
- background-color: #141b29;
- font-size: 60rpx;
- height: 120rpx;
- text-align: center;
+ .toolItem{
+ //border: 2px solid red;
+ background-color: #141b29;
+ font-size: 60rpx;
+ color: #8f8f94;
+ height: 120rpx;
+ text-align: center;
- .toolText{
- font-size: 24rpx;
- color: #fff;
- }
+ .toolText{
+ font-size: 24rpx;
+ color: #8f8f94;
}
-
}
+
+
.listItem-ad{
background-color: #141b29;
text-align: center;
@@ -144,8 +304,11 @@
.icon{
z-index: 1;
position: absolute;
- margin-top: -960rpx;
-
+ margin-top: -620rpx;
+ background-color: #3e444d;
+ font-size: 120rpx;
+ color: #fff;
+ text-align: center;
}
@@ -162,3 +325,4 @@
}
+
diff --git a/pages/scan/Scan.nvue b/pages/scan/Scan.nvue
index 4517c50..5927eb3 100644
--- a/pages/scan/Scan.nvue
+++ b/pages/scan/Scan.nvue
@@ -1,52 +1,175 @@
-
+
+
+
+
+
+ Scan the QR code in the box
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
跳转Barcode页面
- 跳转Book页面
- 跳转Calendar页面
- 跳转Contacts页面
- 跳转Email页面
- 跳转Location页面
- 跳转Paypal页面
- 跳转Product页面
- 跳转Sms页面
- 跳转Tel页面
- 跳转Text页面
- 跳转Url页面
- 跳转Wifi页面
-
+ 跳转Book页面
+ 跳转Calendar页面
+ 跳转Contacts页面
+ 跳转Email页面
+ 跳转Location页面
+ 跳转Paypal页面
+ 跳转Product页面
+ 跳转Sms页面
+ 跳转Tel页面
+ 跳转Text页面
+ 跳转Url页面
+ 跳转Wifi页面
+
+
-
-
-
-
+