const util = require('../../../utils/utils.js'); var app = getApp(); Page({ data: { list: [ { id: 0, imgUrl: 'http://resource.bike.hanyiyun.com/weapp/notice.png', name: '公告列表' }, { id: 1, imgUrl: '/img/shenqing.png', name: '申请还车点' }, { id: 2, imgUrl: 'http://resource.bike.hanyiyun.com/weapp/aid.png', name: '帮助中心' }, { id: 3, imgUrl: '/img/fnakui.png', name: '问题反馈' } ], open: true, user: '', balance: '', //我的钱包 phone: [], actionSheetHidden: true, state: '', arr: [], show: '', imgUrl: 'http://resource.bike.hanyiyun.com/xiaobanma/mineBg.png', time: wx.getStorageSync('home').customer_service_time, showOnlinePhone: wx.getStorageSync('home').setting, screenHeight: '', adHeight: '', img: app.globalData.imgUrl, title: app.globalData.title, setting:{}, navBarHeight: 0, // 导航栏高度 menuRight: 0, // 胶囊距右方间距(方保持左、右间距一致) menuTop: 0, // 胶囊距底部间距(保持底部间距一致) menuHeight: 0, }, //返回首页 skipIndex() { console.log(app.globalData.compatible) if (app.globalData.compatible) { wx.reLaunch({ url: '/pages/compatible/index/index', }) } else { wx.reLaunch({ url: '/pages/index/index', }) } }, showService: function (e) { this.setData({ open: !this.data.open }) }, realname: function () { wx.navigateTo({ url: '/pages/real_name/real_name?state2=2&index=1&hidden=true', }) }, getUserInfo: function (e) { console.log(e) wx.showLoading({ title: '登陆中请稍等...', mask: true }) var that = this; if (e.detail.rawData) { var data = e.detail.userInfo wx.setStorageSync('userInfo', data) if (wx.getStorageSync('home').id != undefined) { data.area_id = wx.getStorageSync('home').id } console.log(data) app.request("/auth/weapp-userinfo-sync", data, "POST").then(res => { if (res.statusCode == 200) { wx.showToast({ title: '授权成功', icon: 'none' }) wx.setStorageSync('userInfo', res.data) // wx.navigateBack() that.setData({ user: res.data }) } else { wx.showToast({ title: '登陆失败请重试', icon: 'none' }) } }) } else { wx.showToast({ title: '授权失败', icon: 'none' }) } }, tuichu() { wx.showModal({ title: '提示', content: '确定要退出当前账户吗?', success: function (res) { if (res.confirm) { wx.reLaunch({ url: '/pages/authentication/authentication', }) } } }) }, jumpPage: function (e) { let index = e.currentTarget.dataset.idx; switch (index) { case 0: wx.navigateTo({ url: '/pages/announcement_list/announcement_list', }) break; case 1: wx.navigateTo({ url: '/pages/apply/apply', }) break; case 2: wx.navigateTo({ url: '/pages/personal/help/help' }) break; case 3: wx.navigateTo({ url: '/pages/personal/helpDetail/helpDetail?show=14' }) break; default: if (app.globalData.compatible) { wx.reLaunch({ url: '/pages/compatible/index/index', }) } else { wx.reLaunch({ url: '/pages/index/index', }) } } }, userinfo: function (e) { var that = this; wx.showLoading({ title: '加载中...', mask: true }) app.request("/me", '', "GET").then(res => { 200 == res.statusCode && wx.setStorageSync("userInfo", res.data), that.setData({ user: res.data }), wx.hideLoading() }) }, onLoad: function (options) { wx.setNavigationBarTitle({ title: app.globalData.title }) const that = this; // 获取系统信息 const systemInfo = wx.getSystemInfoSync(); // 胶囊按钮位置信息 const menuButtonInfo = wx.getMenuButtonBoundingClientRect(); // 导航栏高度 = 状态栏高度 + 44 that.setData({ navBarHeight:systemInfo.statusBarHeight + 44, menuRight:systemInfo.screenWidth - menuButtonInfo.right, menuTop:menuButtonInfo.top, menuHeight:menuButtonInfo.height }) this.setData({ setting: wx.getStorageSync('setting') }) var phones = wx.getStorageSync('home').customer_service_phone this.setData({ phone: this.data.phone.concat(phones) }); //获取实名认证状态 }, buy: function () { wx.navigateTo({ url: '/pages/recharge/recharge', }) }, look() { wx.navigateTo({ url: '/pages/riding_card/riding_card', }) }, onReady: function () { }, phone1: util.throttle(function (e) { var phone = this.data.phone[0]; if(phone!==''&&phone!==undefined){ wx.makePhoneCall({ phoneNumber: phone, }) }else{ wx.makePhoneCall({ phoneNumber:"037163211915", }) } }, 1000), onShow: function () { var that = this; that.setData({ time: wx.getStorageSync('home').customer_service_time }); var area_id = '' if (wx.getStorageSync('home').id != undefined) { area_id = wx.getStorageSync('home').id } var data = { 'area_id': area_id } app.request("/card_riding/user_card", data, "GET").then(res => { console.log(res) that.setData({ arr: res.data.user_card, show: res.data.is_card_begin }) }) this.userinfo(); app.request("/user/status", '', "GET").then(res => { console.log(res) if (res.statusCode == 200) { if (res.data.is_card_certified == 1) { this.setData({ state: '已实名' }) } else { this.setData({ state: '未实名' }) } wx.setStorageSync('userState', res.data) } }) }, onHide: function () { }, onUnload: function () { }, onPullDownRefresh: function () { wx.showNavigationBarLoading(); var that = this; app.request("/me", '', "GET").then(res => { 200 == res.statusCode && wx.setStorageSync("userInfo", res.data), that.setData({ user: res.data }) wx.hideNavigationBarLoading() wx.stopPullDownRefresh(); }) }, onReachBottom: function () { }, onShareAppMessage: function () { } })