| 
				
				
					
				
				
				 | 
			
			 | 
			@@ -6,7 +6,27 @@ App({ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    var that = this; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    that.globalData.sceneAddress = options.scene; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    that.getLocation() | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    that.getUserInfo() | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    that.userLogin() | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  }, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  /** | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			   * 获取地址位置信息 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			   */ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  getLocation: function() { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    wx.getLocation({ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      type: 'wgs84', | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      success: function(res) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        console.log("getLocation", res); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      }, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      fail: error => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        console.log(error); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    }) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  }, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  /** | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			   * 用户登录 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			   */ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  userLogin: function() { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    var that = this; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    // 登录 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    wx.login({ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      success: ({ | 
		
		
	
	
		
			
				| 
				
				
				
					
				
				 | 
			
			 | 
			@@ -20,9 +40,11 @@ App({ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            sceneAddress: that.globalData.sceneAddress, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        }).then(res => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          console.log("req",res); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          console.log("req", res); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          that.globalData.token = res.data.token; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          Http.setToken(res.data.token) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          that.checkUserCarStatus() | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          that.getUserInfo() | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          if (that.couponChannelListCallback) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            that.couponChannelListCallback(that.globalData.token); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          } | 
		
		
	
	
		
			
				| 
				
				
				
					
				
				 | 
			
			 | 
			@@ -33,8 +55,7 @@ App({ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            url: config.api.checkUserStatus, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            data: {} | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          }) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        }).then(res => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        }).catch(err => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        }).then(res => {}).catch(err => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          console.log(err) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          if (err.code == 11004) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            // 用户昵称未授权 | 
		
		
	
	
		
			
				| 
				
				
				
					
				
				 | 
			
			 | 
			@@ -46,20 +67,6 @@ App({ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    }) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  }, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  /** | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			   * 获取地址位置信息 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			   */ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  getLocation: function() { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    wx.getLocation({ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      type: 'wgs84', | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      success: function(res) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        console.log("getLocation", res); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      }, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      fail: error => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        console.log(error); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    }) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  }, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  /** | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			   * 获取用户信息 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			   */ | 
		
		
	
	
		
			
				| 
				
				
				
					
				
				 | 
			
			 | 
			@@ -67,24 +74,53 @@ App({ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    // 获取用户信息 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    wx.getSetting({ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      success: res => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        console.log('getSetting', res) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        if (res.authSetting['scope.userInfo']) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          wx.getUserInfo({ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            success: res => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			              // 可以将 res 发送给后台解码出 unionId | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			              this.globalData.userInfo = res.userInfo | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			              // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			              // 所以此处加入 callback 以防止这种情况 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			              if (this.userInfoReadyCallback) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			                this.userInfoReadyCallback(res) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			              } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			              console.log('getUserInfo', res) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			          }) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    }) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  }, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  /** | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			   * 检查用户是否有车 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			   */ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  checkUserCarStatus: function() { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    var that = this | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    Http.get({ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      url: config.api.userCarCount, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      data: {} | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    }).then(res => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      if (res.data > 0) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        // 用户名下有车 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        that.globalData.phone = res.data.phone | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        that.globalData.supportCar = true | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        // 共同登录 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    }) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  }, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  /** | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			   * car共同登录 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			   */ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  userCarLogin: function() { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    var that = this | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    // 共同登录 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    Http.post({ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      url: config.api.carInit, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      data: { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        phone: this.globalData.phone | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    }).then(res => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      if (res.data.token != "undefined") { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        that.globalData.etcpToken = res.data.token | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    }) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  }, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  globalData: { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    // token | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    token: null, | 
		
		
	
	
		
			
				| 
				
				
				
					
				
				 | 
			
			 | 
			@@ -92,6 +128,11 @@ App({ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    sceneAddress: null, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    // 二维码参数 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    scene: null, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    // 支持智慧停车, 用户名下有车 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    phone: null, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    supportCar: false, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    // ETCP token | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    etcpToken: null, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    // 当前商场信息 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    market: { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      name: "陕西大悦城" | 
		
		
	
	
		
			
				| 
				
					
				
				
				
				 | 
			
			 | 
			
  |