| @@ -603,5 +603,75 @@ Page({ | |||||
| // 返回shareObj | // 返回shareObj | ||||
| return shareObj; | return shareObj; | ||||
| }, | }, | ||||
| /** | |||||
| * 用户登录 | |||||
| */ | |||||
| userLogin: function (couponChannelId, couponId, orderId) { | |||||
| 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 | |||||
| }; | |||||
| } | |||||
| Http.post({ | |||||
| url: config.api.login, | |||||
| data: usrdata | |||||
| }) | |||||
| .then(res => { | |||||
| that.setData({ | |||||
| showPages: true | |||||
| }) | |||||
| app.globalData.token = res.data.token; | |||||
| Http.setToken(res.data.token); | |||||
| if (couponChannelId && couponId || orderId) { | |||||
| that.checkuerstatus(couponChannelId, couponId, orderId); | |||||
| } else { | |||||
| that.checkuerstatus(); | |||||
| } | |||||
| }) | |||||
| .catch(err => { | |||||
| wx.showModal({ | |||||
| title: '提示', | |||||
| showCancel: false, | |||||
| content: '登录失败,请重新尝试', | |||||
| success: function (res) { | |||||
| if (res.cancel) { | |||||
| //点击取消,默认隐藏弹框 | |||||
| } else { | |||||
| //点击确定 | |||||
| wx.reLaunch({ | |||||
| url: '/pages/index/index', | |||||
| }) | |||||
| } | |||||
| } | |||||
| }) | |||||
| }); | |||||
| } | |||||
| }); | |||||
| }, | |||||
| }); | }); | ||||
| @@ -17,9 +17,17 @@ Page({ | |||||
| content: "", | content: "", | ||||
| mystatus: '', | mystatus: '', | ||||
| showPage: false, | showPage: false, | ||||
| paramData:null | |||||
| }, | }, | ||||
| onLoad() { | |||||
| onLoad(options) { | |||||
| this.getList(0, 1); | this.getList(0, 1); | ||||
| if(options.fromId){ | |||||
| this.setData({ | |||||
| paramData:options | |||||
| },function(){ | |||||
| this.userLogin() | |||||
| }) | |||||
| } | |||||
| }, | }, | ||||
| onShow: function () { | onShow: function () { | ||||
| let that = this; | let that = this; | ||||
| @@ -148,6 +156,106 @@ Page({ | |||||
| page: that.data.page | page: that.data.page | ||||
| }); | }); | ||||
| that.getList(that.data.current_scroll, that.data.page); | that.getList(that.data.current_scroll, that.data.page); | ||||
| }, | |||||
| /** | |||||
| * 用户登录 | |||||
| */ | |||||
| userLogin: function () { | |||||
| 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 | |||||
| }; | |||||
| } | |||||
| Http.post({ | |||||
| url: config.api.login, | |||||
| data: usrdata | |||||
| }) | |||||
| .then(res => { | |||||
| that.setData({ | |||||
| showPages: true | |||||
| }) | |||||
| app.globalData.token = res.data.token; | |||||
| Http.setToken(res.data.token); | |||||
| that.checkuerstatus(); | |||||
| }) | |||||
| .catch(err => { | |||||
| wx.showModal({ | |||||
| title: '提示', | |||||
| showCancel: false, | |||||
| content: '登录失败,请重新尝试', | |||||
| success: function (res) { | |||||
| if (res.cancel) { | |||||
| //点击取消,默认隐藏弹框 | |||||
| } else { | |||||
| //点击确定 | |||||
| wx.reLaunch({ | |||||
| url: '/pages/index/index', | |||||
| }) | |||||
| } | |||||
| } | |||||
| }) | |||||
| }); | |||||
| } | |||||
| }); | |||||
| }, | |||||
| checkuerstatus(){ | |||||
| Http.post({ | |||||
| url: config.api.checkPhoneStatus, | |||||
| data: {} | |||||
| }) | |||||
| .then(res => { | |||||
| }) | |||||
| .catch(err => { | |||||
| if (err.code == 11005) { | |||||
| // 用户手机未授权 | |||||
| /** | |||||
| * 将值传到用户手机号授权的页面 | |||||
| * | |||||
| */ | |||||
| wx.redirectTo({ | |||||
| url: "/pages/getphoneInfo/index?path=index&fromId=" + that.data.paramData.fromId | |||||
| }); | |||||
| } else if (err.code == 11006) { | |||||
| // 用户手机已加密 | |||||
| wx.redirectTo({ | |||||
| url: "/pages/phoneinput/phoneinput?path=index&fromId=" + that.data.paramData.fromId | |||||
| }); | |||||
| } else { | |||||
| wx.showToast({ | |||||
| title: err.message, | |||||
| icon: 'none', | |||||
| duration: 2000, | |||||
| mask: false | |||||
| }); | |||||
| } | |||||
| }) | |||||
| } | } | ||||
| }) | }) | ||||
| function compare(pro) { | function compare(pro) { | ||||
| @@ -61,10 +61,17 @@ Page({ | |||||
| }).then( | }).then( | ||||
| function (res) { | function (res) { | ||||
| app.globalData.phone = res.data.phone; | app.globalData.phone = res.data.phone; | ||||
| if (that.path == 'index') { | |||||
| /** | |||||
| * fromId若存在来自卡转赠 | |||||
| */ | |||||
| if (that.path == 'index' && !that.data.paramData.fromId) { | |||||
| wx.redirectTo({ | wx.redirectTo({ | ||||
| url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId, | url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId, | ||||
| }) | }) | ||||
| } else if (that.path == 'index' && that.data.paramData.fromId){ | |||||
| wx.redirectTo({ | |||||
| url: "pages/discountCardList/discountCardList?fromId=" + that.data.paramData.fromId | |||||
| }) | |||||
| } else { | } else { | ||||
| wx.showToast({ | wx.showToast({ | ||||
| title: res.data.msg, | title: res.data.msg, | ||||
| @@ -50,9 +50,18 @@ Page({ | |||||
| url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId, | url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId, | ||||
| }) | }) | ||||
| }else{ | }else{ | ||||
| wx.redirectTo({ | |||||
| url: '/pages/coupon/detail/index?couponChannelId=' + that.data.couponChannelId + '&couponId=' + that.data.couponId + "&flag=pay", | |||||
| }) | |||||
| /** | |||||
| * fromId若存在来自卡转赠 | |||||
| */ | |||||
| if (this.data.paramData.fromId){ | |||||
| wx.redirectTo({ | |||||
| url: "pages/discountCardList/discountCardList?fromId=" + that.data.paramData.fromId | |||||
| }) | |||||
| }else{ | |||||
| wx.redirectTo({ | |||||
| url: '/pages/coupon/detail/index?couponChannelId=' + that.data.couponChannelId + '&couponId=' + that.data.couponId + "&flag=pay", | |||||
| }) | |||||
| } | |||||
| } | } | ||||
| }) | }) | ||||
| .catch(err => { | .catch(err => { | ||||