Browse Source

1.0版本上线

master 1.0.0
chengkun 2 years ago
parent
commit
ac416d8b00
  1. 3
      App.vue
  2. 20
      js_sdk/wa-permission/permission.js
  3. 4
      main.js
  4. 49
      pages.json
  5. 31
      pages/rights/RightsOpen.vue
  6. 30
      pages/rights/RightsSetting.vue
  7. 2
      pages/scan/Barcode.vue
  8. 280
      pages/scan/Book.vue
  9. 2
      pages/scan/Calendar.vue
  10. 2
      pages/scan/Contacts.vue
  11. 2
      pages/scan/Email.vue
  12. 2
      pages/scan/Location.vue
  13. 2
      pages/scan/Product.vue
  14. 73
      pages/scan/Scan.nvue
  15. 2
      pages/scan/Sms.vue
  16. 2
      pages/scan/Tel.vue
  17. 2
      pages/scan/Text.vue
  18. 2
      pages/scan/Url.vue
  19. 2
      pages/scan/Wifi.vue
  20. BIN
      unpackage/res/icons/1024x1024.png
  21. BIN
      unpackage/res/icons/144x144.png
  22. BIN
      unpackage/res/icons/192x192.png
  23. BIN
      unpackage/res/icons/72x72.png
  24. BIN
      unpackage/res/icons/96x96.png

3
App.vue

@ -1,7 +1,8 @@
<script> <script>
export default { export default {
onLaunch: function() { onLaunch() {
//console.log('App Launch') //console.log('App Launch')
}, },
onShow: function() { onShow: function() {
//console.log('App Show') //console.log('App Show')

20
js_sdk/wa-permission/permission.js

@ -159,9 +159,21 @@ function judgeIosPermissionMemo() {
function requestAndroidPermission(permissionID) { function requestAndroidPermission(permissionID) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
plus.android.requestPermissions( plus.android.requestPermissions(
[permissionID], // 理论上支持多个权限同时查询,但实际上本函数封装只处理了一个权限的情况。有需要的可自行扩展封装 [permissionID],
function(resultObj) { function(resultObj) {
var result = 0; //console.log('resultObj1',resultObj)
//resultObj.deniedAlways = [];
//console.log('resultObj2',resultObj)
// var result = undefined;
// if(resultObj.granted.length>0){ //权限被允许
// result = 1;
// }
// if(resultObj.deniedAlways.length>0){ //权限被永久拒绝
// result = -1;
// }
// if(resultObj.deniedPresent.length>0){ //权限被临时拒绝
// result = 0;
// }
for (var i = 0; i < resultObj.granted.length; i++) { for (var i = 0; i < resultObj.granted.length; i++) {
var grantedPermission = resultObj.granted[i]; var grantedPermission = resultObj.granted[i];
console.log('已获取的权限:' + grantedPermission); console.log('已获取的权限:' + grantedPermission);
@ -178,10 +190,6 @@ function requestAndroidPermission(permissionID) {
result = -1 result = -1
} }
resolve(result); resolve(result);
// 若所需权限被拒绝,则打开APP设置界面,可以在APP设置界面打开相应权限
// if (result != 1) {
// gotoAppPermissionSetting()
// }
}, },
function(error) { function(error) {
console.log('申请权限错误:' + error.code + " = " + error.message); console.log('申请权限错误:' + error.code + " = " + error.message);

4
main.js

@ -5,6 +5,10 @@ import Vue from 'vue'
// 引入全局TuniaoUI // 引入全局TuniaoUI
import TuniaoUI from 'tuniao-ui' import TuniaoUI from 'tuniao-ui'
Vue.use(TuniaoUI) Vue.use(TuniaoUI)
Vue.prototype.$onLaunched = new Promise(resolve => {
Vue.prototype.$isResolve = resolve
})
Vue.prototype.ifAppOnlaunched = false
import './uni.promisify.adaptor' import './uni.promisify.adaptor'
// 引入store // 引入store
import store from './store' import store from './store'

49
pages.json

@ -3,6 +3,13 @@
"^tn-(.*)": "@/tuniao-ui/components/tn-$1/tn-$1.vue" "^tn-(.*)": "@/tuniao-ui/components/tn-$1/tn-$1.vue"
}, },
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages "pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages
{
"path": "pages/rights/RightsOpen",
"style": {
"navigationBarTitleText": "RightsOpen",
"enablePullDownRefresh": false
}
},
{ {
"path": "pages/scan/Scan", "path": "pages/scan/Scan",
"style": { "style": {
@ -31,13 +38,6 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{
"path": "pages/rights/RightsOpen",
"style": {
"navigationBarTitleText": "RightsOpen",
"enablePullDownRefresh": false
}
},
// { // {
// "path": "pages/create/Create", // "path": "pages/create/Create",
// "style": { // "style": {
@ -66,13 +66,6 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
// {
// "path": "pages/scan/Book",
// "style": {
// "navigationBarTitleText": "Book",
// "enablePullDownRefresh": false
// }
// },
{ {
"path": "pages/scan/Calendar", "path": "pages/scan/Calendar",
"style": { "style": {
@ -180,21 +173,21 @@
"iconPath": "static/setting-default.png", "iconPath": "static/setting-default.png",
"selectedIconPath": "static/setting-select.png", "selectedIconPath": "static/setting-select.png",
"text": "Setting" "text": "Setting"
},
{
"pagePath": "pages/rights/RightsOpen",
"iconPath": "static/setting-default.png",
"selectedIconPath": "static/setting-select.png",
"text": "RightsOpen",
"visible": false
},
{
"pagePath": "pages/rights/RightsSetting",
"iconPath": "static/setting-default.png",
"selectedIconPath": "static/setting-select.png",
"text": "RightsSetting",
"visible": false
} }
// {
// "pagePath": "pages/rights/RightsOpen",
// "iconPath": "static/setting-default.png",
// "selectedIconPath": "static/setting-select.png",
// "text": "RightsOpen",
// "visible": false
// },
// {
// "pagePath": "pages/rights/RightsSetting",
// "iconPath": "static/setting-default.png",
// "selectedIconPath": "static/setting-select.png",
// "text": "RightsSetting",
// "visible": false
// }
] ]
} }
} }

31
pages/rights/RightsOpen.vue

@ -26,8 +26,8 @@
btnFontColor: '#fff' btnFontColor: '#fff'
} }
}, },
onLoad() { async onLoad() {
this.openPermission();
}, },
onHide() { onHide() {
@ -37,24 +37,29 @@
// //
async openPermission(){ async openPermission(){
let that = this; let that = this;
console.log('打开授权')
var result = await permision.requestAndroidPermission('android.permission.CAMERA') var result = await permision.requestAndroidPermission('android.permission.CAMERA')
if (result == 1) { console.log('打开授权结果为:',result)
if (result == '1') {
//, //,
that.jumpToRights('/pages/scan/Scan'); that.jumpToRights('/pages/scan/Scan',1);
}else if(result == -1) { }else if(result == '-1') {
// //
that.jumpToRights('/pages/rights/RightsSetting'); that.jumpToRights('/pages/rights/RightsSetting',0);
} }
}, },
// //
jumpToRights(url){ jumpToRights(url,type){
uni.switchTab({ if(type == 1){
url: url uni.switchTab({
}) url: url
} })
}else{
uni.reLaunch({
url: url
});
}
},
} }
} }
</script> </script>

30
pages/rights/RightsSetting.vue

@ -33,28 +33,22 @@
btnFontSize: 36, btnFontSize: 36,
btnBackgroundColor: '#0186ff', btnBackgroundColor: '#0186ff',
btnFontColor: '#fff', btnFontColor: '#fff',
hasRequestedPermission: false,
permissionStatus: false
} }
}, },
async onLaunch() {
let that = this;
that.ifAppOnlaunched = true;
that.$isResolve()
},
async onShow(){ async onShow(){
let that = this; let that = this;
if (!that.hasRequestedPermission) { if(!that.ifAppOnlaunched){
console.log('进入了判断setting权限',that.hasRequestedPermission) await that.$onLaunched;
const res = await that.requestAndroidPermission('android.permission.CAMERA'); console.log('setonShow')
console.log('res',res); await that.requestAndroidPermission('android.permission.CAMERA');
// if (result == 1) {
// //,
// that.jumpToRights('/pages/scan/Scan');
// }
}
else{
console.log('setting权限状态已变更为true,进入扫码页',that.hasRequestedPermission)
that.jumpToRights('/pages/scan/Scan');
} }
}, },
onHide() { onHide() {
this.hasRequestedPermission = false;
console.log('onHide') console.log('onHide')
}, },
onUnload(){ onUnload(){
@ -72,8 +66,10 @@
let that = this; let that = this;
var result = await permision.requestAndroidPermission(permisionID) var result = await permision.requestAndroidPermission(permisionID)
console.log('setting判断权限结果',result) console.log('setting判断权限结果',result)
that.hasRequestedPermission = true; if (result == '1') {
return result; //,
that.jumpToRights('/pages/scan/Scan');
}
}, },
// //

2
pages/scan/Barcode.vue

@ -58,7 +58,7 @@
tableName: 'scan_code', tableName: 'scan_code',
textImgUrl: '', textImgUrl: '',
starRateValue: 5, // starRateValue: 0, //
showStarTip: false, // showStarTip: false, //
startTipColor: '#706F6F', // startTipColor: '#706F6F', //
startTipFontColor: '#fff' // startTipFontColor: '#fff' //

280
pages/scan/Book.vue

@ -1,280 +0,0 @@
<!-- <template>
<view class="content">
<tn-avatar class="icon tn-icon-book" size="xl"></tn-avatar>
<tn-list-view :card="true" unlined="all" class="listView">
<tn-list-cell class="listItem-1">
<view>{{ bookInfo.display }}</view>
</tn-list-cell>
<tn-list-cell class="listItem">
<tn-grid align="center" :col="col">
<block v-for="(item, index) in fastToolList" :key="index">
<tn-grid-item class="toolItem">
<view :class="item.icon"></view>
<view class="cutline"></view>
<view class="toolText">{{ item.text }}</view>
</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">
<image src="/static/logo.png" class="buttomImg"/>
</tn-list-cell>
</tn-list-view>
<text class="bottomText">Feedback & Suggestion</text>
</view>
</template>
<script>
import { openSqlite,executeSql,closedb,isTable,addSql} from "@/utils/database";
export default {
data() {
return {
col: 4,
bookInfo:{},
tableName: 'scan_code',
fastToolList:[
{
"index": 0,
"text":"Web Search",
"icon": "tn-icon-search"
},
{
"index": 1,
"text":"View in store",
"icon": "tn-icon-shop"
},
{
"index": 2,
"text":"Price history",
"icon": "tn-icon-statistics"
},
{
"index": 3,
"text":"Copy",
"icon": "tn-icon-copy-fill"
}
]
}
},
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);
}
},
onHide() {
let that = this;
that.closedb();
},
methods: {
//
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)
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);
that.bookInfo = data;
//console.log('initwifiInfo',that.wifiInfo)
//console.log('password',that.wifiInfo.password)
//console.log('ssid',that.wifiInfo.ssid)
//db
await that.writeToDb("Book",that.bookInfo);
},
//
async getHistoryData(params){
//console.log('historyparams',params)
let that = this;
const data = JSON.parse(params);
//console.log('historydata',data)
that.bookInfo = data;
//console.log('HistotyWifiInfo',that.wifiInfo)
//console.log('password',wifiInfo.password)
//console.log('ssid',wifiInfo.ssid)
}
}
}
</script>
<style lang="scss">
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #000000;
height:100vh;
.listView{
z-index: 0;
position: relative;
width: 660rpx;
height: 1300rpx;
margin-top: 100rpx;
background-color: #141b29;
.listItem-1{
margin-top: 120rpx;
background-color: #141b29;
color: #fff;
//border: 2px solid yellow;
height: 160rpx;
text-align: center;
}
.listItem{
//border: 2px solid yellow;
height: 160rpx;
//margin-top: 30px;
//padding-top: 30px;
background-color: #141b29;
color: #fff;
.toolItem{
//border: 2px solid red;
background-color: #141b29;
font-size: 60rpx;
color: #8f8f94;
height: 120rpx;
text-align: center;
.toolText{
font-size: 24rpx;
color: #8f8f94;
}
}
}
.listItem-ad{
background-color: #141b29;
text-align: center;
color: #fff;
//border: 2px solid red;
height: 160rpx;
}
.listItemBottom{
height: 400rpx;
margin-top: 20rpx;
background-color: #141b29;
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.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;
}
.bottomText{
color: #fff;
text-align: center;
font-size: 24rpx;
margin-top: 40rpx;
margin-bottom: 40rpx;
}
.cutline{
border: 1px solid #8f8f94;
}
}
</style> -->

2
pages/scan/Calendar.vue

@ -68,7 +68,7 @@
tableName: 'scan_code', tableName: 'scan_code',
textImgUrl: '', textImgUrl: '',
starRateValue: 5, // starRateValue: 0, //
showStarTip: false, // showStarTip: false, //
startTipColor: '#706F6F', // startTipColor: '#706F6F', //
startTipFontColor: '#fff' // startTipFontColor: '#fff' //

2
pages/scan/Contacts.vue

@ -67,7 +67,7 @@
tableName: 'scan_code', tableName: 'scan_code',
textImgUrl: '', textImgUrl: '',
starRateValue: 5, // starRateValue: 0, //
showStarTip: false, // showStarTip: false, //
startTipColor: '#706F6F', // startTipColor: '#706F6F', //
startTipFontColor: '#fff' // startTipFontColor: '#fff' //

2
pages/scan/Email.vue

@ -64,7 +64,7 @@
tableName: 'scan_code', tableName: 'scan_code',
textImgUrl: '', textImgUrl: '',
starRateValue: 5, // starRateValue: 0, //
showStarTip: false, // showStarTip: false, //
startTipColor: '#706F6F', // startTipColor: '#706F6F', //
startTipFontColor: '#fff' // startTipFontColor: '#fff' //

2
pages/scan/Location.vue

@ -63,7 +63,7 @@
tableName: 'scan_code', tableName: 'scan_code',
textImgUrl: '', textImgUrl: '',
starRateValue: 5, // starRateValue: 0, //
showStarTip: false, // showStarTip: false, //
startTipColor: '#706F6F', // startTipColor: '#706F6F', //
startTipFontColor: '#fff' // startTipFontColor: '#fff' //

2
pages/scan/Product.vue

@ -62,7 +62,7 @@
tableName: 'scan_code', tableName: 'scan_code',
textImgUrl: '', textImgUrl: '',
starRateValue: 5, // starRateValue: 0, //
showStarTip: false, // showStarTip: false, //
startTipColor: '#706F6F', // startTipColor: '#706F6F', //
startTipFontColor: '#fff' // startTipFontColor: '#fff' //

73
pages/scan/Scan.nvue

@ -60,34 +60,27 @@
code: "", code: "",
path:'',//扫描图片 path:'',//扫描图片
flashLightFlag: true, flashLightFlag: true,
hasPermission: false
} }
}, },
async onShow(){ onShow(){
let that = this; let that = this;
//await that.$onLaunched;
if(that.$refs.scanComponent){ if(that.$refs.scanComponent){
setTimeout(function(){ setTimeout(function(){
that.$refs.scanComponent.remoteResume(); that.$refs.scanComponent.remoteResume();
},300); },300);
} }
if (!that.hasPermission) { //await that.requestAndroidPermission('android.permission.CAMERA');
console.log('进入了判断scan权限',that.hasPermission)
//判断是否有权限
await that.requestAndroidPermission('android.permission.CAMERA')
}
//TODO 有权限就是扫码页面,没权限跳转到权限提示
// else{
// console.log('scan权限状态已变更为true,进入扫码页',that.hasPermission)
// //that.jumpToRights('/pages/scan/Scan');
// }
}, },
onLoad(){ async onLoad(){
let that = this; let that = this;
//打开db //打开db
that.openSqlite(); that.openSqlite();
//初始化,创建表 //初始化,创建表
that.createTable(); that.createTable();
//await that.requestAndroidPermission('android.permission.CAMERA')
}, },
onHide() { onHide() {
let that = this; let that = this;
@ -95,7 +88,6 @@
that.$refs.scanComponent.remotePause(); that.$refs.scanComponent.remotePause();
} }
//that.hasPermission = false;
}, },
onUnload() { onUnload() {
let that = this; let that = this;
@ -104,24 +96,43 @@
}, },
methods: { methods: {
//判断是否有相机权限 // //判断是否有相机权限
async requestAndroidPermission(permisionID) { async requestAndroidPermission(permisionID) {
let that = this; let that = this;
var result = await permision.requestAndroidPermission(permisionID) var result = await permision.requestAndroidPermission(permisionID)
console.log('scan判断权限结果',result) console.log('scan判断权限结果',result)
that.hasPermission = true; if (result == '0') {
if (result == 0) {
//无权限,跳转到引导打开权限 //无权限,跳转到引导打开权限
that.jumpToRights('/pages/rights/RightsOpen'); that.jumpToRights('/pages/rights/RightsOpen');
}else if(result == -1) { }else if(result == '1'){
//禁止权限,跳转到权限设置页面
that.jumpToRights('/pages/rights/RightsSetting');
}else{
//有权限,跳转到扫码界面 //有权限,跳转到扫码界面
that.jumpToRights('/pages/scan/Scan'); that.jumpToRights('/pages/scan/Scan');
}else{
//返回空,跳转rightsOpen授权页面
that.jumpToRights('/pages/rights/RightsOpen');
} }
}, },
//判断是否有相机权限
// requestAndroidPermission(permisionID) {
// let that = this;
// var result = permision.queryRightsSettingPermission(permisionID)
// console.log('scan判断权限结果',result)
// that.hasPermission = true;
// if (result == 0) {
// //无权限,跳转到引导打开权限
// that.jumpToRights('/pages/rights/RightsOpen');
// }else if(result == -1) {
// //禁止权限,跳转到权限设置页面
// that.jumpToRights('/pages/rights/RightsSetting');
// }else{
// //有权限,跳转到扫码界面
// that.jumpToRights('/pages/scan/Scan');
// }
// },
// 识别完成回调 ------ res.detail.data是组装好的数据 // 识别完成回调 ------ res.detail.data是组装好的数据
scanResult(res) { scanResult(res) {
console.log(res.detail.data) console.log(res.detail.data)
@ -154,9 +165,6 @@
}else if(type === 'email'){ }else if(type === 'email'){
that.jumpToPage('/pages/scan/Email','scan',JSON.stringify(result)) that.jumpToPage('/pages/scan/Email','scan',JSON.stringify(result))
} }
// else if(type === 3){
// that.jumpToPage('/pages/scan/Book','scan',JSON.stringify(result))
// }
else if(type === 'tel_phone'){ else if(type === 'tel_phone'){
that.jumpToPage('/pages/scan/Tel','scan',JSON.stringify(result)) that.jumpToPage('/pages/scan/Tel','scan',JSON.stringify(result))
}else if(type === 'article'){ }else if(type === 'article'){
@ -303,23 +311,6 @@
url: url url: url
}) })
}, },
//mlkit扫码
// scanCode(){
// let that = this;
// var mlscan = uni.requireNativePlugin("JY-MLScanSDK");
// //console.log(mlscan)
// mlscan.startScan(res=> {
// that.analyserCode(res);
// // uni.showToast({
// // icon:'none',
// // title:JSON.stringify(res)
// // })
// })
// },
} }
} }
</script> </script>

2
pages/scan/Sms.vue

@ -59,7 +59,7 @@
tableName: 'scan_code', tableName: 'scan_code',
textImgUrl: '', textImgUrl: '',
starRateValue: 5, // starRateValue: 0, //
showStarTip: false, // showStarTip: false, //
startTipColor: '#706F6F', // startTipColor: '#706F6F', //
startTipFontColor: '#fff' // startTipFontColor: '#fff' //

2
pages/scan/Tel.vue

@ -63,7 +63,7 @@
tableName: 'scan_code', tableName: 'scan_code',
textImgUrl: '', textImgUrl: '',
starRateValue: 5, // starRateValue: 0, //
showStarTip: false, // showStarTip: false, //
startTipColor: '#706F6F', // startTipColor: '#706F6F', //
startTipFontColor: '#fff' // startTipFontColor: '#fff' //

2
pages/scan/Text.vue

@ -67,7 +67,7 @@
// openFont: 'More', // openFont: 'More',
// closeFont: 'Close', // closeFont: 'Close',
starRateValue: 5, // starRateValue: 0, //
showStarTip: false, // showStarTip: false, //
startTipColor: '#706F6F', // startTipColor: '#706F6F', //
startTipFontColor: '#fff' // startTipFontColor: '#fff' //

2
pages/scan/Url.vue

@ -58,7 +58,7 @@
tableName: 'scan_code', tableName: 'scan_code',
textImgUrl: '', textImgUrl: '',
starRateValue: 5, // starRateValue: 0, //
showStarTip: false, // showStarTip: false, //
startTipColor: '#706F6F', // startTipColor: '#706F6F', //
startTipFontColor: '#fff' // startTipFontColor: '#fff' //

2
pages/scan/Wifi.vue

@ -59,7 +59,7 @@
tableName: 'scan_code', tableName: 'scan_code',
textImgUrl: '', textImgUrl: '',
starRateValue: 5, // starRateValue: 0, //
showStarTip: false, // showStarTip: false, //
startTipColor: '#706F6F', // startTipColor: '#706F6F', //
startTipFontColor: '#fff' // startTipFontColor: '#fff' //

BIN
unpackage/res/icons/1024x1024.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
unpackage/res/icons/144x144.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
unpackage/res/icons/192x192.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
unpackage/res/icons/72x72.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
unpackage/res/icons/96x96.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Loading…
Cancel
Save