From a6d847f4b4b9ea43d7358831ac7fe68255676f5e Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Fri, 12 Apr 2019 14:35:18 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=85=AC=E4=BC=97?= =?UTF-8?q?=E5=8F=B7][=E6=96=B0=E5=A2=9E]:=E7=94=A8=E6=88=B7=E5=B7=B2?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E5=90=8E=E7=9A=84=E5=85=AC=E4=BC=97=E5=8F=B7?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.js | 4 + pages/bargain/bargain.js | 2 +- pages/cardorder/detail/index.js | 2 +- pages/couponorder/detail/index.js | 2 +- pages/index/index.js | 490 ++++++++++++++++++------------ pages/main/index.js | 4 +- pages/order/detail/index.js | 2 +- pages/orderquanma/index.js | 2 +- pages/spellGroup/spellGroup.js | 2 +- 9 files changed, 304 insertions(+), 206 deletions(-) diff --git a/config/config.js b/config/config.js index 48c585c..ec1acdb 100755 --- a/config/config.js +++ b/config/config.js @@ -167,6 +167,10 @@ var config = { * 小程序获取游戏路径 */ getGame:'/game/getOne', + /** + * 小程序某一个游戏信息 + */ + getOneGame: '/game/getOneGame', /** * 用户更新信息 */ diff --git a/pages/bargain/bargain.js b/pages/bargain/bargain.js index 18aa910..d8449ff 100644 --- a/pages/bargain/bargain.js +++ b/pages/bargain/bargain.js @@ -252,7 +252,7 @@ Page({ }, /** * - * @param {砍价} 邀请好友砍价 + * @param {砍价} 发起砍价 */ invite: function (e) { let couponChannelId = e.currentTarget.dataset.id; diff --git a/pages/cardorder/detail/index.js b/pages/cardorder/detail/index.js index ebbd09a..bfa4bc6 100644 --- a/pages/cardorder/detail/index.js +++ b/pages/cardorder/detail/index.js @@ -46,7 +46,7 @@ Page({ Http.get({ url: config.api.getGame, data: { - triggleAction: 4 + triggleAction: 4 // 核销触发 } }).then(res => { if (res.data.id) { diff --git a/pages/couponorder/detail/index.js b/pages/couponorder/detail/index.js index f6e8314..768ba8a 100644 --- a/pages/couponorder/detail/index.js +++ b/pages/couponorder/detail/index.js @@ -49,7 +49,7 @@ Page({ Http.get({ url: config.api.getGame, data: { - triggleAction: 4 + triggleAction: 4 // 核销触发 } }).then(res => { if (res.data.id) { diff --git a/pages/index/index.js b/pages/index/index.js index 0a7f632..2957fe2 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -13,40 +13,40 @@ Page({ /** * 生命周期函数--监听页面加载 */ - onLoad: function(options) { + onLoad: function (options) { console.log(options); let that = this; /** - * 根据接收到的值,判断跳转到哪个页面 + * 根据接收到的参数的值,判断跳转到哪个页面 */ - if(options&&options.type){ + if (options && options.type) { app.globalData.type = options.type; console.log(app.globalData.type) } - // app.globalData.type = 'pc'; if (decodeURIComponent(options.scene) == "undefined") { that.setData({ - scene: 0 + scene: 0 }); } else { that.setData({ - scene: decodeURIComponent(options.scene) + scene: decodeURIComponent(options.scene) }); that.setData({ - newArr: this.data.scene.split(':') + newArr: this.data.scene.split(':') }) - console.log(this.data.newArr) - if (this.data.newArr[0]=='JC'){ - /** - * 来自大屏跳转券详情 - */ - options.couponChannelId = this.data.newArr[1]; - }else if (this.data.newArr[0] == 'JG'){ - /** - * 来自大屏跳转拼团详情 - */ - options.couponChannelId = this.data.newArr[1]; - options.path='daping' + console.log(this.data.newArr) + //// 大屏-二维码-start + if (this.data.newArr[0] == 'JC') { + // 跳转券详情 + options.couponChannelId = this.data.newArr[1]; + } else if (this.data.newArr[0] == 'JG') { + // 跳转拼团详情 + options.couponChannelId = this.data.newArr[1]; + options.path = 'daping' + } + //// 大屏-二维码-end + else if (this.data.newArr[0] == 't') { + // 普通二维码 } } wx.showToast({ @@ -58,211 +58,305 @@ Page({ wx.setStorageSync('imgurl', imgurl) app.getLocation(); if (options.couponChannelId || options.orderId) { - console.log(options,33333333333) + console.log(options, 33333333333) that.userLogin(options); } else { that.userLogin() } }, - checkuerstatus(options) { + checkuserstatus(options) { let that = this; Http.get({ url: config.api.checkUserStatus, data: {} }) .then(res => { - if (options && options.orderGroupId) { - 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; - } - /** - * 来自大屏的跳转拼团券详情 - */ - if (options && options.couponChannelId && options.path== 'daping'){ - /** - * 主要是为了拿couponId - */ - Http.get({ - url: config.api.couponDetail, - data: { - couponChannelId: options.couponChannelId - } - }).then(res => { - let data = res.data; - wx.redirectTo({ - url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${options.couponChannelId}&couponId=${data.couponId}` - }) - }); - return; - } - if (options && options.couponChannelId && !options.cuserId &&app.globalData.type == 'cd') { - wx.redirectTo({ - url: `/pages/coupon/detail/index?couponChannelId=${options.couponChannelId}`, - }) - } else if (options &&options.couponChannelId && 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 if (options&&options.orderId&&app.globalData.type=='bg') { - wx.redirectTo({ - url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${options.orderId}&from='${"discount"}`, - }) - } else if (app.globalData.type == 'uc'){ - wx.switchTab({ - url: '/pages/user/index' - }); - } else if (app.globalData.type == 'pc') { - wx.switchTab({ - url: '/pages/passCar/passCar' - }); - } else if (app.globalData.type == 'co') { - wx.redirectTo({ - url: '/pages/couponorder/index/index' - }); - } else if (app.globalData.type == 'or') { - wx.redirectTo({ - url: '/pages/couponorder/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{ - wx.switchTab({ - url: '/pages/main/index' - }); - } + /** + * 参与拼团 + */ + if (options && options.orderGroupId) { + 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; + } + /** + * 来自大屏的跳转拼团券详情 + */ + if (options && options.couponChannelId && options.path == 'daping') { + /** + * 主要是为了拿couponId + */ + Http.get({ + url: config.api.couponDetail, + data: { + couponChannelId: options.couponChannelId + } + }).then(res => { + let data = res.data; + wx.redirectTo({ + url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${options.couponChannelId}&couponId=${data.couponId}` + }) + }); + return; + } + + if (options && options.couponChannelId && 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 if (options && options.couponChannelId && app.globalData.type == 'cd') { + // 跳转普通券/消费卡/限时秒杀/砍价详情 + wx.redirectTo({ + url: `/pages/coupon/detail/index?couponChannelId=${options.couponChannelId}`, + }) + } else if (options && options.couponChannelId && options.id && app.globalData.type == 'bd') { + // 砍价详情页 + wx.redirectTo({ + url: `/pages/coupon/detail/index?couponChannelId=${options.couponChannelId}&couponId=${options.id}`, + }) + } else if (options && options.couponChannelId && options.id && app.globalData.type == 'sd') { + // 拼团详情页 + wx.redirectTo({ + url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${options.couponChannelId}&couponId=${options.id}`, + }) + } else if (options && options.id && app.globalData.type == 'gm') { + // 游戏页面 + that.getGameOne(token, ) + } else if (options && options.bt && options.id && app.globalData.type == 'bd') { + // 宣传页详情 + if (options.bt == '2') { + // 自由图文 + wx.redirectTo({ + url: `/pages/freeBannerDetail/index?id=${options.id}`, + }) + } else { + // 标准格式 + wx.redirectTo({ + url: `/pages/bannerdetail/index?id=${options.id}`, + }) + } + } else if (options && options.orderId && app.globalData.type == 'bg') { + // 参与砍价 + wx.redirectTo({ + url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${options.orderId}&from='${"discount"}`, + }) + } else if (app.globalData.type == 'uc') { + // 我的 + wx.switchTab({ + url: '/pages/user/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 == 'td') { + // 专题活动页 + wx.redirectTo({ + url: '/pages/topicDetail/index' + }); + } else if (app.globalData.type == 'ml') { + // 门店 + wx.redirectTo({ + url: '/pages/index/searchbar/index' + }); + } else { + // 主页 + wx.switchTab({ + url: '/pages/main/index' + }); + } }) .catch(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; - } - if (options && options.couponChannelId && !options.cuserId) { - wx.redirectTo({ - url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}` - }); - } 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` - }); - } - } + 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; + } + if (options && options.couponChannelId && !options.cuserId) { + wx.redirectTo({ + url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}` + }); + } 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` + }); + } + } }); }, /** * 用户登录 */ userLogin: function (options) { - console.log(1111,options,2222222222) + console.log(1111, options, 2222222222) var that = this; // 登录 wx.login({ success: ({ - code + 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; - 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 - }) + 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 + }; } - } - - 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)){ - that.checkuerstatus(options); - }else{ - that.checkuerstatus(); - } - }) - .catch(err => { - wx.showModal({ - title: '提示', - showCancel: false, - content: '登录失败,请重新尝试', - success:function(res){ - if (res.cancel) { - //点击取消,默认隐藏弹框 - } else { - //点击确定 - wx.reLaunch({ - url: '/pages/index/index', - }) - } - } - }) - }); + Http.post({ + url: config.api.login, + data: usrdata + }) + .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 + }) + } + } + + 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)) { + 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, + }) + }) + .catch(err => { + this.alphaClick(); + }) + }, }) \ No newline at end of file diff --git a/pages/main/index.js b/pages/main/index.js index b5cecce..547280b 100644 --- a/pages/main/index.js +++ b/pages/main/index.js @@ -397,7 +397,7 @@ Page({ Http.get({ url: config.api.getGame, data: { - triggleAction: 2, + triggleAction: 2, // 固定入口 token: token } }).then(res => { @@ -427,7 +427,7 @@ Page({ Http.get({ url: config.api.getGame, data: { - triggleAction: 1, + triggleAction: 1, // 登录触发 token: token } }).then(res => { diff --git a/pages/order/detail/index.js b/pages/order/detail/index.js index 0e367e1..91a11c9 100644 --- a/pages/order/detail/index.js +++ b/pages/order/detail/index.js @@ -121,7 +121,7 @@ Page({ Http.get({ url: config.api.getGame, data: { - triggleAction: 3 + triggleAction: 3 // 购买触发 } }).then(res => { if (res.data.id) { diff --git a/pages/orderquanma/index.js b/pages/orderquanma/index.js index d21f660..a442e18 100644 --- a/pages/orderquanma/index.js +++ b/pages/orderquanma/index.js @@ -28,7 +28,7 @@ Page({ Http.get({ url: config.api.getGame, data: { - triggleAction: 4 + triggleAction: 4 // 核销触发 } }).then(res => { if (res.data.id) { diff --git a/pages/spellGroup/spellGroup.js b/pages/spellGroup/spellGroup.js index 8bb1712..9ad32ea 100644 --- a/pages/spellGroup/spellGroup.js +++ b/pages/spellGroup/spellGroup.js @@ -382,7 +382,7 @@ Page({ }, /** * - * @param {砍价} 邀请好友砍价 + * @param goto拼团券详情 */ invite: function (e) { let couponChannelId = e.currentTarget.dataset.id;