blob: a6dd36f822548a71a0308240d6d5a7db286284d8 [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
38 var brightness=wx.getStorageSync("brightness");
39
40 if(!wx.$isEmpty(brightness)){
41 wx.setScreenBrightness({
42 value: brightness,
43 })
44 }
45
46 var userid = wx.getStorageSync("userid");
47 var signed = wx.getStorageSync("signed");
binquan.qiuf9647a22020-05-08 15:43:24 +080048 if (wx.$isEmpty(signed) || signed != 'yes') {
binquan.qiu7f2665f2020-03-27 17:19:57 +080049 this.setData({
binquan.qiuf9647a22020-05-08 15:43:24 +080050 bind: '未签约',
binquan.qiu7f2665f2020-03-27 17:19:57 +080051 bindcolor: 'red'
52 })
53
54 } else {
55 this.setData({
binquan.qiuf9647a22020-05-08 15:43:24 +080056 bind: '已签约',
binquan.qiu7f2665f2020-03-27 17:19:57 +080057 bindcolor: 'green'
58 })
59 }
binquan.qiuf9647a22020-05-08 15:43:24 +080060 // if (wx.$isEmpty(signed) || signed != 'yes') {
61 // this.setData({
62 // sign: '未签约',
63 // signcolor: 'red'
64 // })
65 // } else {
66 // this.setData({
67 // sign: '已签约',
68 // signcolor: 'green'
69 // })
70 // }
binquan.qiu7f2665f2020-03-27 17:19:57 +080071
72 // if (app.globalData.userInfo) {
73 // this.setData({
74 // userInfo: app.globalData.userInfo,
75 // hasUserInfo: true
76 // })
77 // } else if (this.data.canIUse) {
78 // // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
79 // // 所以此处加入 callback 以防止这种情况
80 // app.userInfoReadyCallback = res => {
81 // this.setData({
82 // userInfo: res.userInfo,
83 // hasUserInfo: true
84 // })
85 // }
86 // } else {
87 // // 在没有 open-type=getUserInfo 版本的兼容处理
88 // wx.getUserInfo({
89 // success: res => {
90 // app.globalData.userInfo = res.userInfo
91 // this.setData({
92 // userInfo: res.userInfo,
93 // hasUserInfo: true
94 // })
95 // }
96 // })
97 // }
98 },
99 getUserInfo: function(e) {
100 console.log(e)
101 app.globalData.userInfo = e.detail.userInfo
102 this.setData({
103 userInfo: e.detail.userInfo,
104 hasUserInfo: true
105 })
106 },
107 pageredirect: function(e) {
108 wx.navigateTo({
109 url: '../wxlogin/wxlogin'
110 })
111 },
112 doBind: function() {
binquan.qiuf9647a22020-05-08 15:43:24 +0800113 var signed = wx.getStorageSync("signed");
114 if (wx.$isEmpty(signed) || signed != 'yes') {
115 wx.navigateTo({
116 url: '../bindcard/bindcard'
117 })
118
119 }else{
120 wx.navigateTo({
121 url: '../unbind/unbind'
122 })
123
124 }
125
binquan.qiu7f2665f2020-03-27 17:19:57 +0800126 },
127 doSign: function() {
128 var check = wx.$checkBankcard();
129 if (!check) {
130 return;
131 }
132 wx.navigateTo({
133 url: '../signxy/signxy'
134 })
135 },
136 doCardLost: function() {
137 wx.navigateTo({
138 url: '../cardlost/cardlost'
139 })
140 },
141 doScan: function() {
binquan.qiu0da31352020-04-13 11:25:55 +0800142 // var check = wx.$checkBankcard();
143 // if (!check) {
binquan.qiu7f2665f2020-03-27 17:19:57 +0800144
binquan.qiu0da31352020-04-13 11:25:55 +0800145 // return;
146 // }
binquan.qiu7f2665f2020-03-27 17:19:57 +0800147
148 wx.scanCode({
149 success(ret) {
150 console.log(ret);
binquan.qiu7f2665f2020-03-27 17:19:57 +0800151 var url = ret.result;
binquan.qiu7f2665f2020-03-27 17:19:57 +0800152 wx.setStorageSync('scanurl', url);
153 console.log(url);
154 wx.navigateTo({
155 url: '../scan/scan'
156 })
157 //}
158 }
159 })
160
161 },
162 doGetBill: function() {
163 var check = wx.$checkBankcard();
164 if (!check) {
165 return;
166 }
167 wx.navigateTo({
168 url: '../bill/bill',
169 })
170 },
171 doQrcode: function() {
172 var check = wx.$checkBankcard();
173 if (!check) {
174 return;
175 }
176 wx.navigateTo({
177 url: '../qrcode/qrcode',
178 })
179 },
180 doSafety: function() {
181 // var check = checkBankcard();
182 // if (!check) {
183 // return;
184 // }
185 wx.navigateTo({
186 url: '../safety/safety',
187 })
188 }
189
190})