|  |  | @@ -11,8 +11,13 @@ Page({ | 
		
	
		
			
			|  |  |  | /** | 
		
	
		
			
			|  |  |  | * 生命周期函数--监听页面加载 | 
		
	
		
			
			|  |  |  | */ | 
		
	
		
			
			|  |  |  | onLoad: function (options) { | 
		
	
		
			
			|  |  |  | onLoad: function(options) { | 
		
	
		
			
			|  |  |  | let that = this; | 
		
	
		
			
			|  |  |  | wx.showToast({ | 
		
	
		
			
			|  |  |  | title: '加载中', | 
		
	
		
			
			|  |  |  | icon: "loading", | 
		
	
		
			
			|  |  |  | duration: 2000 | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | /** | 
		
	
		
			
			|  |  |  | * 根据接收到的参数的值,判断跳转到哪个页面 | 
		
	
		
			
			|  |  |  | */ | 
		
	
	
		
			
				|  |  | @@ -22,7 +27,7 @@ Page({ | 
		
	
		
			
			|  |  |  | if (decodeURIComponent(options.scene) == "undefined") { | 
		
	
		
			
			|  |  |  | that.setData({ | 
		
	
		
			
			|  |  |  | scene: 0 | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } else { | 
		
	
		
			
			|  |  |  | that.setData({ | 
		
	
		
			
			|  |  |  | scene: decodeURIComponent(options.scene) | 
		
	
	
		
			
				|  |  | @@ -30,7 +35,6 @@ Page({ | 
		
	
		
			
			|  |  |  | that.setData({ | 
		
	
		
			
			|  |  |  | newArr: this.data.scene.split(':') | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | console.log(this.data.newArr) | 
		
	
		
			
			|  |  |  | //// 大屏-二维码-start | 
		
	
		
			
			|  |  |  | if (this.data.newArr[0] == 'JC') { | 
		
	
		
			
			|  |  |  | // 跳转券详情 | 
		
	
	
		
			
				|  |  | @@ -39,12 +43,11 @@ Page({ | 
		
	
		
			
			|  |  |  | // 跳转拼团详情 | 
		
	
		
			
			|  |  |  | options.couponChannelId = this.data.newArr[1]; | 
		
	
		
			
			|  |  |  | options.path = 'daping' | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | else if (this.data.newArr[0] == 't') { | 
		
	
		
			
			|  |  |  | } else if (this.data.newArr[0] == 't') { | 
		
	
		
			
			|  |  |  | // 普通二维码 | 
		
	
		
			
			|  |  |  | options.type = this.data.newArr[1]; | 
		
	
		
			
			|  |  |  | app.globalData.type = options.type; | 
		
	
		
			
			|  |  |  | if(options.type == 'cd') { | 
		
	
		
			
			|  |  |  | if (options.type == 'cd') { | 
		
	
		
			
			|  |  |  | options.couponChannelId = this.data.newArr[2]; | 
		
	
		
			
			|  |  |  | } else if (options.type == 'bd') { | 
		
	
		
			
			|  |  |  | options.bt = this.data.newArr[2]; | 
		
	
	
		
			
				|  |  | @@ -59,28 +62,49 @@ Page({ | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | wx.showToast({ | 
		
	
		
			
			|  |  |  | title: '加载中', | 
		
	
		
			
			|  |  |  | icon: "loading", | 
		
	
		
			
			|  |  |  | duration: 2000 | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | wx.setStorageSync('options', JSON.stringify(options)) | 
		
	
		
			
			|  |  |  | wx.setStorageSync('imgurl', imgurl) | 
		
	
		
			
			|  |  |  | app.getLocation(); | 
		
	
		
			
			|  |  |  | if (options.couponChannelId || options.orderId || options.id) { | 
		
	
		
			
			|  |  |  | that.userLogin(options); | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // app.getLocation(); | 
		
	
		
			
			|  |  |  | if (app.globalData.token) { | 
		
	
		
			
			|  |  |  | if (options.couponChannelId || options.orderId || options.id) { | 
		
	
		
			
			|  |  |  | that.userStatus(options); | 
		
	
		
			
			|  |  |  | } else { | 
		
	
		
			
			|  |  |  | that.userStatus(); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } else { | 
		
	
		
			
			|  |  |  | // 由于 token 是网络请求,可能会在 Page.onLoad 之后才返回 | 
		
	
		
			
			|  |  |  | // 所以此处加入 callback 以防止这种情况 | 
		
	
		
			
			|  |  |  | app.tokenCallback = token => { | 
		
	
		
			
			|  |  |  | if (options.couponChannelId || options.orderId || options.id) { | 
		
	
		
			
			|  |  |  | that.userStatus(options); | 
		
	
		
			
			|  |  |  | } else { | 
		
	
		
			
			|  |  |  | that.userStatus(); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | onShow(){ | 
		
	
		
			
			|  |  |  | let that = this; | 
		
	
		
			
			|  |  |  | that.userLogin(); | 
		
	
		
			
			|  |  |  | console.log("onshow-----------------------------------login") | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | /** | 
		
	
		
			
			|  |  |  | * 检查用户的状态 | 
		
	
		
			
			|  |  |  | */ | 
		
	
		
			
			|  |  |  | userStatus: function(options) { | 
		
	
		
			
			|  |  |  | var that = this; | 
		
	
		
			
			|  |  |  | if (options && (options.couponChannelId || options.orderId || options.id)) { | 
		
	
		
			
			|  |  |  | that.checkuserstatus(options); | 
		
	
		
			
			|  |  |  | } else { | 
		
	
		
			
			|  |  |  | that.checkuserstatus(); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | checkuserstatus(options) { | 
		
	
		
			
			|  |  |  | let that = this; | 
		
	
		
			
			|  |  |  | Http.get({ | 
		
	
		
			
			|  |  |  | let that = this; | 
		
	
		
			
			|  |  |  | Http.get({ | 
		
	
		
			
			|  |  |  | url: config.api.checkUserStatus, | 
		
	
		
			
			|  |  |  | data: {} | 
		
	
		
			
			|  |  |  | data: { | 
		
	
		
			
			|  |  |  | token:app.globalData.token | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | .then(res => { | 
		
	
		
			
			|  |  |  | //参与拼团 | 
		
	
	
		
			
				|  |  | @@ -88,7 +112,6 @@ Page({ | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: `/pages/joinFrDpell/index?couponId=${options.couponId}&orderGroupId=${options.orderGroupId}&couponChannelId=${options.couponChannelId}&orderId=${options.orderId}&avatarUrl=${options.avatarUrl}&nickName=${options.nickName}` | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | return; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | //来自大屏的跳转拼团券详情 | 
		
	
		
			
			|  |  |  | else if (options && options.couponChannelId && options.path == 'daping') { | 
		
	
	
		
			
				|  |  | @@ -105,33 +128,30 @@ Page({ | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${options.couponChannelId}&couponId=${data.couponId}` | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | return; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | else if (options && options.couponChannelId && !options.spellGroup) { | 
		
	
		
			
			|  |  |  | // 转赠判断 | 
		
	
		
			
			|  |  |  | if (options.cuserId){ | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } else if (options && options.couponChannelId && !options.spellGroup) { | 
		
	
		
			
			|  |  |  | // 转赠判断 | 
		
	
		
			
			|  |  |  | if (options.cuserId) { | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: `/pages/coupon/detail/index?couponChannelId=${options.couponChannelId}&cuserId=${options.cuserId}&coverImg=${options.coverImg}&userName=${options.userName}&avatarUrl=${options.avatarUrl}&couponOrderId=${options.couponOrderId}&updateDate=${options.updateDate}`, | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | }else{ | 
		
	
		
			
			|  |  |  | } else { | 
		
	
		
			
			|  |  |  | // 跳转普通券/消费卡/限时秒杀/砍价详情 | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: `/pages/coupon/detail/index?couponChannelId=${options.couponChannelId}`, | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 拼团详情页(只有通过扫码进入才可能进入拼团详情页面,只有这一个入口) | 
		
	
		
			
			|  |  |  | else if (options && options.couponChannelId && app.globalData.type == 'sd' || options && options.couponChannelId && options.spellGroup) { | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${options.couponChannelId}`, | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 游戏页面 | 
		
	
		
			
			|  |  |  | else if (options && options.id && app.globalData.type == 'gm') { | 
		
	
		
			
			|  |  |  | that.getGameOne(app.globalData.token, options.id) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 宣传页详情 | 
		
	
		
			
			|  |  |  | else if (options && options.bt && options.id && app.globalData.type == 'bd') { | 
		
	
		
			
			|  |  |  | if (options.bt == '2') { | 
		
	
	
		
			
				|  |  | @@ -145,13 +165,13 @@ Page({ | 
		
	
		
			
			|  |  |  | url: `/pages/bannerdetail/index?id=${options.id}`, | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 专题 | 
		
	
		
			
			|  |  |  | else if (options && options.id && app.globalData.type == 'td'){ | 
		
	
		
			
			|  |  |  | else if (options && options.id && app.globalData.type == 'td') { | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: `/pages/topicDetail/index?id=${options.id}` | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 参与砍价 | 
		
	
		
			
			|  |  |  | else if (options && options.orderId) { | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
	
		
			
				|  |  | @@ -163,117 +183,117 @@ Page({ | 
		
	
		
			
			|  |  |  | wx.switchTab({ | 
		
	
		
			
			|  |  |  | url: '/pages/user/index' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 积分 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'jf') { | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: '/pages/integralmall/index' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 首页 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'in') { | 
		
	
		
			
			|  |  |  | wx.switchTab({ | 
		
	
		
			
			|  |  |  | url: '/pages/main/index' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 停车 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'pc') { | 
		
	
		
			
			|  |  |  | // 停车 | 
		
	
		
			
			|  |  |  | wx.switchTab({ | 
		
	
		
			
			|  |  |  | url: '/pages/passCar/passCar' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 我的券包 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'mc') { | 
		
	
		
			
			|  |  |  | // 我的券包 | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: '/pages/couponorder/index/index' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 我的订单 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'mo') { | 
		
	
		
			
			|  |  |  | // 我的订单 | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: '/pages/order/index/index?id=all' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 我的卡包 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'ca') { | 
		
	
		
			
			|  |  |  | // 我的卡包 | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: '/pages/cardorder/index/index' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 特享礼遇 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'sc') { | 
		
	
		
			
			|  |  |  | // 特享礼遇 | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: '/pages/specialcourtesy/specialcourtesy' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 限时秒杀 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'rb') { | 
		
	
		
			
			|  |  |  | // 限时秒杀 | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: '/pages/rushToBuy/index' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 砍价专场 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'bl') { | 
		
	
		
			
			|  |  |  | // 砍价专场 | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: '/pages/bargain/bargain' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 我的砍价 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'mb') { | 
		
	
		
			
			|  |  |  | // 我的砍价 | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: '/pages/bargain/bargain?from=myhtml' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 拼团专场 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'sl') { | 
		
	
		
			
			|  |  |  | // 拼团专场 | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: '/pages/spellGroup/spellGroup' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 我的拼团 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'ms') { | 
		
	
		
			
			|  |  |  | // 我的拼团 | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: '/pages/spellGroup/spellGroup?from=myhtml' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 消费卡 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'dc') { | 
		
	
		
			
			|  |  |  | // 消费卡 | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: '/pages/discountCardList/discountCardList' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // 门店 | 
		
	
		
			
			|  |  |  | else if (app.globalData.type == 'ml') { | 
		
	
		
			
			|  |  |  | // 门店 | 
		
	
		
			
			|  |  |  | wx.switchTab({ | 
		
	
		
			
			|  |  |  | url: '/pages/index/searchbar/index' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } else { | 
		
	
		
			
			|  |  |  | // 主页 | 
		
	
		
			
			|  |  |  | wx.switchTab({ | 
		
	
		
			
			|  |  |  | url: '/pages/main/index' | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | .catch(err => { | 
		
	
		
			
			|  |  |  | console.log(err) | 
		
	
		
			
			|  |  |  | if (err.code == 11004) { | 
		
	
		
			
			|  |  |  | // 用户昵称未授权 | 
		
	
		
			
			|  |  |  | if (options && options.orderGroupId) { | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: `/pages/getuserinfo/index?couponId=${options.couponId}&orderGroupId=${options.orderGroupId}&couponChannelId=${options.couponChannelId}&orderId=${options.orderId}&avatarUrl=${options.avatarUrl}&nickName=${options.nickName}` | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | return; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | /** | 
		
	
		
			
			|  |  |  | * spellGroup | 
		
	
	
		
			
				|  |  | @@ -283,22 +303,22 @@ Page({ | 
		
	
		
			
			|  |  |  | if (options && options.couponChannelId && !options.cuserId && !options.spellGroup) { | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}` | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } else if (options && options.couponChannelId && !options.cuserId && options.spellGroup) { | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}&spellGroup=${options.spellGroup}` | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } else if (options && options.couponChannelId && options.cuserId) { | 
		
	
		
			
			|  |  |  | /** | 
		
	
		
			
			|  |  |  | * 转赠判断 | 
		
	
		
			
			|  |  |  | */ | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}&cuserId=${options.cuserId}&coverImg=${options.coverImg}&userName=${options.userName}&avatarUrl=${options.avatarUrl}&couponOrderId=${options.couponOrderId}&updateDate=${options.updateDate}` | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } else if (options && options.orderId) { | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: `/pages/getuserinfo/index?orderId=${options.orderId}&from='${"discount"}` | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } else { | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: `/pages/getuserinfo/index` | 
		
	
	
		
			
				|  |  | @@ -307,124 +327,34 @@ Page({ | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | /** | 
		
	
		
			
			|  |  |  | * 用户登录 | 
		
	
		
			
			|  |  |  | */ | 
		
	
		
			
			|  |  |  | userLogin: function (options) { | 
		
	
		
			
			|  |  |  | var that = this; | 
		
	
		
			
			|  |  |  | // 登录 | 
		
	
		
			
			|  |  |  | wx.login({ | 
		
	
		
			
			|  |  |  | success: ({ | 
		
	
		
			
			|  |  |  | code | 
		
	
		
			
			|  |  |  | }) => { | 
		
	
		
			
			|  |  |  | wx.getSystemInfo({ | 
		
	
		
			
			|  |  |  | success: function (res) { | 
		
	
		
			
			|  |  |  | that.setData({ | 
		
	
		
			
			|  |  |  | systemInfo: JSON.stringify(res) | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | var usrdata = { | 
		
	
		
			
			|  |  |  | appId: config.weapp.AppId, | 
		
	
		
			
			|  |  |  | code: code, | 
		
	
		
			
			|  |  |  | sceneAddress: app.globalData.sceneAddress, | 
		
	
		
			
			|  |  |  | scene: that.data.scene, | 
		
	
		
			
			|  |  |  | systemInfo: that.data.systemInfo | 
		
	
		
			
			|  |  |  | }; | 
		
	
		
			
			|  |  |  | if (app.globalData.locationInfo) { | 
		
	
		
			
			|  |  |  | usrdata = { | 
		
	
		
			
			|  |  |  | appId: config.weapp.AppId, | 
		
	
		
			
			|  |  |  | code: code, | 
		
	
		
			
			|  |  |  | sceneAddress: app.globalData.sceneAddress, | 
		
	
		
			
			|  |  |  | latitude: "" + app.globalData.locationInfo.latitude, | 
		
	
		
			
			|  |  |  | longitude: "" + app.globalData.locationInfo.longitude, | 
		
	
		
			
			|  |  |  | scene: that.data.scene, | 
		
	
		
			
			|  |  |  | systemInfo: that.data.systemInfo | 
		
	
		
			
			|  |  |  | }; | 
		
	
		
			
			|  |  |  | getGameOne: function(token, id) { | 
		
	
		
			
			|  |  |  | let _this = this; | 
		
	
		
			
			|  |  |  | Http.get({ | 
		
	
		
			
			|  |  |  | url: config.api.getOneGame, | 
		
	
		
			
			|  |  |  | data: { | 
		
	
		
			
			|  |  |  | token: token, | 
		
	
		
			
			|  |  |  | id: id | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | Http.post({ | 
		
	
		
			
			|  |  |  | url: config.api.login, | 
		
	
		
			
			|  |  |  | data: usrdata | 
		
	
		
			
			|  |  |  | }).then(res => { | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId, | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | .then(res => { | 
		
	
		
			
			|  |  |  | that.setData({ | 
		
	
		
			
			|  |  |  | showPages: true | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | app.globalData.token = res.data.token; | 
		
	
		
			
			|  |  |  | app.globalData.openId = res.data.openId; | 
		
	
		
			
			|  |  |  | // 初始化websocket | 
		
	
		
			
			|  |  |  | if (extConfig.attr.ifHaveWebSocket == 1) { | 
		
	
		
			
			|  |  |  | app.initSocket(); | 
		
	
		
			
			|  |  |  | // 回调发送给自己的消息 | 
		
	
		
			
			|  |  |  | app.globalData.socketReceiver = function (e) { | 
		
	
		
			
			|  |  |  | let msgList = that.data.msgList | 
		
	
		
			
			|  |  |  | msgList.push(e) | 
		
	
		
			
			|  |  |  | that.setData({ | 
		
	
		
			
			|  |  |  | msgList: msgList | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | .catch(err => { | 
		
	
		
			
			|  |  |  | wx.showModal({ | 
		
	
		
			
			|  |  |  | title: '提示', | 
		
	
		
			
			|  |  |  | content: err.message, | 
		
	
		
			
			|  |  |  | showCancel: false, | 
		
	
		
			
			|  |  |  | success: function(res) { | 
		
	
		
			
			|  |  |  | // 如果游戏下架或者找不到,重启首页 | 
		
	
		
			
			|  |  |  | if (res.confirm) { | 
		
	
		
			
			|  |  |  | wx.reLaunch({ | 
		
	
		
			
			|  |  |  | url: '/pages/index/index', | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | if (res.data && res.data.score) { | 
		
	
		
			
			|  |  |  | if (res.data.score != 0) { | 
		
	
		
			
			|  |  |  | app.globalData.score = res.data.score; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | Http.setToken(res.data.token); | 
		
	
		
			
			|  |  |  | if (options && (options.couponChannelId || options.orderId || options.id)) { | 
		
	
		
			
			|  |  |  | that.checkuserstatus(options); | 
		
	
		
			
			|  |  |  | } else { | 
		
	
		
			
			|  |  |  | that.checkuserstatus(); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | .catch(err => { | 
		
	
		
			
			|  |  |  | wx.showModal({ | 
		
	
		
			
			|  |  |  | title: '提示', | 
		
	
		
			
			|  |  |  | showCancel: false, | 
		
	
		
			
			|  |  |  | content: '登录失败,请重新尝试', | 
		
	
		
			
			|  |  |  | success: function (res) { | 
		
	
		
			
			|  |  |  | if (res.cancel) { | 
		
	
		
			
			|  |  |  | //点击取消,默认隐藏弹框 | 
		
	
		
			
			|  |  |  | } else { | 
		
	
		
			
			|  |  |  | //点击确定 | 
		
	
		
			
			|  |  |  | wx.reLaunch({ | 
		
	
		
			
			|  |  |  | url: '/pages/index/index', | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }); | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | getGameOne: function (token, id) { | 
		
	
		
			
			|  |  |  | let _this = this; | 
		
	
		
			
			|  |  |  | Http.get({ | 
		
	
		
			
			|  |  |  | url: config.api.getOneGame, | 
		
	
		
			
			|  |  |  | data: { | 
		
	
		
			
			|  |  |  | token: token, | 
		
	
		
			
			|  |  |  | id: id | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }).then(res => { | 
		
	
		
			
			|  |  |  | wx.redirectTo({ | 
		
	
		
			
			|  |  |  | url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId, | 
		
	
		
			
			|  |  |  | this.alphaClick(); | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | .catch(err => { | 
		
	
		
			
			|  |  |  | wx.showModal({ | 
		
	
		
			
			|  |  |  | title: '提示', | 
		
	
		
			
			|  |  |  | content: err.message, | 
		
	
		
			
			|  |  |  | showCancel: false, | 
		
	
		
			
			|  |  |  | success:function(res){ | 
		
	
		
			
			|  |  |  | // 如果游戏下架或者找不到,重启首页 | 
		
	
		
			
			|  |  |  | if (res.confirm){ | 
		
	
		
			
			|  |  |  | wx.reLaunch({ | 
		
	
		
			
			|  |  |  | url: '/pages/index/index', | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | this.alphaClick(); | 
		
	
		
			
			|  |  |  | }) | 
		
	
		
			
			|  |  |  | }, | 
		
	
		
			
			|  |  |  | }) |