大理市民卡小程序1.0提交
diff --git a/pages/index/index.js b/pages/index/index.js
new file mode 100644
index 0000000..aec3f72
--- /dev/null
+++ b/pages/index/index.js
@@ -0,0 +1,194 @@
+//index.js
+//获取应用实例
+const app = getApp()
+
+Page({
+ data: {
+ bind: '',
+ bindcolor: '',
+ sign: '',
+ signcolor: '',
+ userInfo: {},
+ hasUserInfo: false,
+ canIUse: wx.canIUse('button.open-type.getUserInfo'),
+
+ },
+ tabChange(e) {
+ console.log('tab change', e)
+ },
+
+ //事件处理函数
+ bindViewTap: function() {
+ wx.navigateTo({
+ url: '../logs/logs'
+ })
+ },
+ testButton: function() {
+
+ console.log(app.globalData.userInfo)
+ wx.showModal({
+ title: '提示',
+ content: '该功能暂未完成,完整版请使用大理市民卡app',
+
+ duration: 2000
+ })
+ },
+ onLoad: function() {
+
+ var brightness=wx.getStorageSync("brightness");
+
+ if(!wx.$isEmpty(brightness)){
+ wx.setScreenBrightness({
+ value: brightness,
+ })
+ }
+
+ var userid = wx.getStorageSync("userid");
+ var signed = wx.getStorageSync("signed");
+ if (wx.$isEmpty(userid)) {
+ this.setData({
+ bind: '未绑定',
+ bindcolor: 'red'
+ })
+
+ } else {
+ this.setData({
+ bind: '已绑定',
+ bindcolor: 'green'
+ })
+ }
+ if (wx.$isEmpty(signed) || signed != 'yes') {
+ this.setData({
+ sign: '未签约',
+ signcolor: 'red'
+ })
+ } else {
+ this.setData({
+ sign: '已签约',
+ signcolor: 'green'
+ })
+ }
+
+ // if (app.globalData.userInfo) {
+ // this.setData({
+ // userInfo: app.globalData.userInfo,
+ // hasUserInfo: true
+ // })
+ // } else if (this.data.canIUse) {
+ // // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
+ // // 所以此处加入 callback 以防止这种情况
+ // app.userInfoReadyCallback = res => {
+ // this.setData({
+ // userInfo: res.userInfo,
+ // hasUserInfo: true
+ // })
+ // }
+ // } else {
+ // // 在没有 open-type=getUserInfo 版本的兼容处理
+ // wx.getUserInfo({
+ // success: res => {
+ // app.globalData.userInfo = res.userInfo
+ // this.setData({
+ // userInfo: res.userInfo,
+ // hasUserInfo: true
+ // })
+ // }
+ // })
+ // }
+ },
+ getUserInfo: function(e) {
+ console.log(e)
+ app.globalData.userInfo = e.detail.userInfo
+ this.setData({
+ userInfo: e.detail.userInfo,
+ hasUserInfo: true
+ })
+ },
+ pageredirect: function(e) {
+ wx.navigateTo({
+ url: '../wxlogin/wxlogin'
+ })
+ },
+ doBind: function() {
+ wx.navigateTo({
+ url: '../bindcard/bindcard'
+ })
+ },
+ doSign: function() {
+ var check = wx.$checkBankcard();
+ if (!check) {
+ return;
+ }
+ wx.navigateTo({
+ url: '../signxy/signxy'
+ })
+ },
+ doCardLost: function() {
+ wx.navigateTo({
+ url: '../cardlost/cardlost'
+ })
+ },
+ doScan: function() {
+ var check = wx.$checkBankcard();
+ if (!check) {
+
+ return;
+ }
+
+ wx.scanCode({
+ success(ret) {
+ console.log(ret);
+
+ var url = ret.result;
+
+
+ if (url.indexOf("yy.dlsmk.cn") >= 0) {
+ if (url.indexOf("?") > 0) {
+ url = url + '&userid=' + userid;
+ } else {
+ url = url + '?userid=' + userid;
+ }
+ wx.setStorageSync('trueurl', url);
+ wx.navigateTo({
+ url: '../scan2/scan2'
+ })
+ }
+ wx.setStorageSync('scanurl', url);
+ console.log(url);
+ wx.navigateTo({
+ url: '../scan/scan'
+ })
+ //}
+ }
+ })
+
+ },
+ doGetBill: function() {
+ var check = wx.$checkBankcard();
+ if (!check) {
+ return;
+ }
+ wx.navigateTo({
+ url: '../bill/bill',
+ })
+ },
+ doQrcode: function() {
+ var check = wx.$checkBankcard();
+ if (!check) {
+ return;
+ }
+ wx.navigateTo({
+ url: '../qrcode/qrcode',
+ })
+ },
+ doSafety: function() {
+ // var check = checkBankcard();
+ // if (!check) {
+ // return;
+ // }
+ wx.navigateTo({
+ url: '../safety/safety',
+ })
+ }
+
+})
\ No newline at end of file