blob: 8320ac10238b04cab063def9b206ff8271eae0a2 [file] [log] [blame]
binquan.qiu7f2665f2020-03-27 17:19:57 +08001//index.js
2//获取应用实例
3const app = getApp()
4
5Page({
6 data: {
7 bind: '',
8 bindcolor: '',
9 sign: '',
10 signcolor: '',
11 userInfo: {},
12 hasUserInfo: false,
13 canIUse: wx.canIUse('button.open-type.getUserInfo'),
14
15 },
16 tabChange(e) {
17 console.log('tab change', e)
18 },
19
20 //事件处理函数
21 bindViewTap: function() {
22 wx.navigateTo({
23 url: '../logs/logs'
24 })
25 },
26 testButton: function() {
27
28 console.log(app.globalData.userInfo)
29 wx.showModal({
30 title: '提示',
31 content: '该功能暂未完成,完整版请使用大理市民卡app',
32
33 duration: 2000
34 })
35 },
36 onLoad: function() {
37
binquan.qiu1dddb772020-07-28 18:10:03 +080038 wx.hideHomeButton();
39
binquan.qiu7f2665f2020-03-27 17:19:57 +080040 var brightness=wx.getStorageSync("brightness");
41
42 if(!wx.$isEmpty(brightness)){
43 wx.setScreenBrightness({
44 value: brightness,
45 })
46 }
47
48 var userid = wx.getStorageSync("userid");
49 var signed = wx.getStorageSync("signed");
binquan.qiuf9647a22020-05-08 15:43:24 +080050 if (wx.$isEmpty(signed) || signed != 'yes') {
binquan.qiu7f2665f2020-03-27 17:19:57 +080051 this.setData({
binquan.qiuf9647a22020-05-08 15:43:24 +080052 bind: '未签约',
binquan.qiu7f2665f2020-03-27 17:19:57 +080053 bindcolor: 'red'
54 })
55
56 } else {
57 this.setData({
binquan.qiuf9647a22020-05-08 15:43:24 +080058 bind: '已签约',
binquan.qiu7f2665f2020-03-27 17:19:57 +080059 bindcolor: 'green'
60 })
61 }
binquan.qiuf9647a22020-05-08 15:43:24 +080062 // if (wx.$isEmpty(signed) || signed != 'yes') {
63 // this.setData({
64 // sign: '未签约',
65 // signcolor: 'red'
66 // })
67 // } else {
68 // this.setData({
69 // sign: '已签约',
70 // signcolor: 'green'
71 // })
72 // }
binquan.qiu7f2665f2020-03-27 17:19:57 +080073
74 // if (app.globalData.userInfo) {
75 // this.setData({
76 // userInfo: app.globalData.userInfo,
77 // hasUserInfo: true
78 // })
79 // } else if (this.data.canIUse) {
80 // // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
81 // // 所以此处加入 callback 以防止这种情况
82 // app.userInfoReadyCallback = res => {
83 // this.setData({
84 // userInfo: res.userInfo,
85 // hasUserInfo: true
86 // })
87 // }
88 // } else {
89 // // 在没有 open-type=getUserInfo 版本的兼容处理
90 // wx.getUserInfo({
91 // success: res => {
92 // app.globalData.userInfo = res.userInfo
93 // this.setData({
94 // userInfo: res.userInfo,
95 // hasUserInfo: true
96 // })
97 // }
98 // })
99 // }
100 },
101 getUserInfo: function(e) {
102 console.log(e)
103 app.globalData.userInfo = e.detail.userInfo
104 this.setData({
105 userInfo: e.detail.userInfo,
106 hasUserInfo: true
107 })
108 },
109 pageredirect: function(e) {
110 wx.navigateTo({
111 url: '../wxlogin/wxlogin'
112 })
113 },
114 doBind: function() {
binquan.qiuf9647a22020-05-08 15:43:24 +0800115 var signed = wx.getStorageSync("signed");
116 if (wx.$isEmpty(signed) || signed != 'yes') {
117 wx.navigateTo({
118 url: '../bindcard/bindcard'
119 })
120
121 }else{
122 wx.navigateTo({
123 url: '../unbind/unbind'
124 })
125
126 }
127
binquan.qiu7f2665f2020-03-27 17:19:57 +0800128 },
129 doSign: function() {
130 var check = wx.$checkBankcard();
131 if (!check) {
132 return;
133 }
134 wx.navigateTo({
135 url: '../signxy/signxy'
136 })
137 },
138 doCardLost: function() {
139 wx.navigateTo({
140 url: '../cardlost/cardlost'
141 })
142 },
143 doScan: function() {
binquan.qiu1dddb772020-07-28 18:10:03 +0800144
binquan.qiu7f2665f2020-03-27 17:19:57 +0800145
146 wx.scanCode({
147 success(ret) {
148 console.log(ret);
binquan.qiu7f2665f2020-03-27 17:19:57 +0800149 var url = ret.result;
binquan.qiu7f2665f2020-03-27 17:19:57 +0800150 wx.setStorageSync('scanurl', url);
151 console.log(url);
152 wx.navigateTo({
153 url: '../scan/scan'
154 })
binquan.qiu1dddb772020-07-28 18:10:03 +0800155
binquan.qiu7f2665f2020-03-27 17:19:57 +0800156 }
157 })
158
159 },
160 doGetBill: function() {
161 var check = wx.$checkBankcard();
162 if (!check) {
163 return;
164 }
165 wx.navigateTo({
166 url: '../bill/bill',
167 })
168 },
169 doQrcode: function() {
170 var check = wx.$checkBankcard();
171 if (!check) {
172 return;
173 }
174 wx.navigateTo({
175 url: '../qrcode/qrcode',
176 })
177 },
178 doSafety: function() {
179 // var check = checkBankcard();
180 // if (!check) {
181 // return;
182 // }
183 wx.navigateTo({
184 url: '../safety/safety',
185 })
186 }
187
188})