index.js
4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// custom-tab-bar/index.js
const app = getApp()
const urlMap = {
'coupon': '/pages/activityDetail/activityDetail',
'y': '/scanGroup/index/index', // /pages/ywymReward/index /scanGroup/jyScan/index/index /middlePage/pages/privacyGps/privacyGps /scanGroup/index/index /scanGroup/dahaoda/index/index
'jys': '/scanGroup/index/index',
'costa': '/pages/costa/index/index',
'x': '/scanGroup/index/index',
'h': '/scanGroup/index/index', // 吉士丁扫码
'jyo':'/scanGroup/index/index',
'singleProduct': '/pages/index/index',
'delivery-sxh': '/delivery/index/index',
't': '/subPackages/tickets/index/index'
}
const urls = {
'HTTPS://M.HH66.CN/': '/pages/qptest/index',
'https://test-utc-paltform.bzh001.com': '/subPackages/scan/middle/middle'
}
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
// tabbar 的列表
tabbarLists:[
{
pagePath: "/custom-pages/custom-index/index",
text: "首页",
type:'page',
iconPath: "/images/icon_index.png",
selectedIconPath: "/images/icon_index_act.png"
},
{
pagePath: "/custom-pages/custom-scan/index",
text: "扫一扫",
type:'scan',
// iconPath: "/images/icon-pack.png",
selectedIconPath: "/images/tab_scan.png"
},
{
pagePath: "/custom-pages/custom-product/index",
text: "产品介绍",
// type:'page_pro',
type:'page',
iconPath: "/images/icon_pro.png",
selectedIconPath: "/images/icon_pro_act.png"
}
],
active:null, //设为数字,会产生tabbar闪烁
isShow:true //控制显示隐藏tabbar
},
/**
* 组件的方法列表
*/
methods: {
switchTab(e){
const { index,url,item } = e.currentTarget.dataset;
if(item.type!=='scan'){
// if(item.type=='page_pro'){
// wx.showModal({
// title: '提示',
// content: '暂未开放,敬请期待',
// showCancel:false,
// confirmText:'知道了',
// confirmColor:'#00478b',
// complete: (res) => {
// if (res.cancel) {
// }
// if (res.confirm) {
// }
// }
// })
// return
// }
wx.switchTab({url})
}else{
console.log('扫码');
this.showScan()
}
},
showScan() {
wx.scanCode({
success(res) {
console.log(res,"res");
// success
var url = res.result
url = "HTTPS://AAX6.CN/JYS/:QD3T8+4:F-ZS19GIG,8DDHPVIT"
url = url.trim()
url = url.replace(/[\r\n]/g, '')
let type = app.GetUrlParh(url)
console.log(type,"--------");
// url = "HTTP://JY.AAX6.CN/Y/NZU-NWL.2BDJ8F$:IA,0000003101"
if (urlMap.hasOwnProperty(type)) {
wx.navigateTo({
url: `${urlMap[type]}?q=${encodeURIComponent(url)}`
})
return
}
for (const i in urls) {
if (url.indexOf(i) > -1) {
wx.navigateTo({
url: `${urls[i]}?q=${encodeURIComponent(url)}`
})
return
}
}
wx.showToast({
icon: 'none',
title: '无法找到页面资源'
})
}
})
},
}
})