123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- // pages/FirstBangDing/FirstBangDing.js
- const app = getApp()
- const utils = require('../../utils/util.js')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- maxBindCount: 5,
- notices: [
- '部分小区水费由物业代收,请联系小区物业进行咨询缴费操作。',
- '户号绑定: 在绑定页面手动查询,输入地址关键词信息。',
- '每个微信用户最多绑定5个户号。'
- ],
- images: {
- logo: '',
- background: '',
- card: '',
- tzd: "",
- phone: "",
- yl: "",
- jcsfcjtzd: ""
- }
- },
- onLoad(options) {
- // 页面加载时获取图片路径
- this.setData({
- images: {
- logo: app.globalData.images.logo,
- background: app.globalData.images.background,
- card: app.globalData.images.card,
- tzd: app.globalData.images.tzd,
- phone: app.globalData.images.phone,
- yl: app.globalData.images.yl,
- jcsfcjtzd: app.globalData.images.jcsfcjtzd
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- const _this = this;
- // 重新获取用户信息
- wx.login({
- success: res => {
- if(res.code){
- wx.request({
- method: 'POST',
- url: app.globalData.interfaceUrls.loginUrl,
- data: {
- wxCode: res.code,
- dsKey: app.globalData.launchPara
- },
- success(res) {
- if (res.data.code == "200" && res.data.data) {
- const resData = res.data.data;
- // 更新全局用户信息
- app.globalData.userWxInfo = {
- openid: resData.openid,
- session_key: resData.session_key,
- token: resData.token,
- bindAccountInfo: resData.swUserManagementVos,
- currentDsKey: ""
- }
-
- // 检查是否有绑定的户号
- if(resData.swUserManagementVos && resData.swUserManagementVos.length > 0){
- app.globalData.currentAccountInfo = resData.swUserManagementVos[0];
- app.globalData.userWxInfo.currentDsKey = resData.swUserManagementVos[0].dsKey;
- // 保存到本地存储
- wx.setStorageSync('currentHuHao', resData.swUserManagementVos[0]);
- // 设置刷新标记
- app.globalData.refresh = 1;
-
- // 跳转到首页
- wx.switchTab({
- url: '/pages/homepage/homepage',
- success: function() {
- // 确保首页重新加载数据
- const pages = getCurrentPages();
- const homepage = pages[pages.length - 1];
- if (homepage && homepage.onLoad) {
- homepage.onLoad();
- }
- }
- });
- }
- }
- }
- });
- }
- }
- });
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- },
- bindAccount() {
- wx.navigateTo({
- url: '/pages/bind/bind'
- })
- },
- switchTab(e) {
- const page = e.currentTarget.dataset.page
- if (page === 'profile') {
- wx.switchTab({
- url: '/pages/profile/profile'
- })
- }
- },
- goToBindHuhao() {
- // 设置标记表示将要进行户号绑定
- wx.setStorageSync('goingToBindNewAccount', true);
- // 预先设置refresh标记,这样homepage在加载时就会刷新数据
- app.globalData.refresh = 1;
-
- // 提前将justBoundNewAccount标记设为true
- // 这样即使从huhaobangding直接跳转到homepage也能正确加载数据
- wx.setStorageSync('justBoundNewAccount', true);
-
- // 跳转到户号绑定页面
- wx.navigateTo({
- url: '/pages/huhaobangding/huhaobangding',
- fail: function(err) {
- console.error('跳转失败:', err);
- // 如果跳转失败,清除标记
- wx.removeStorageSync('goingToBindNewAccount');
- wx.removeStorageSync('justBoundNewAccount');
-
- utils.simleInfo('跳转失败,请稍后再试');
- }
- });
- }
- })
|