|
|
@@ -1,3 +1,4 @@ |
|
|
|
const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {} |
|
|
|
const Http = require("../../utils/HttpBasics"); |
|
|
|
const imgurl = require("../../utils/imgurl"); |
|
|
|
const config = require("../../config/config"); |
|
|
@@ -25,27 +26,27 @@ Page({ |
|
|
|
// 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]; |
|
|
|
/** |
|
|
|
* 来自大屏跳转券详情 |
|
|
|
*/ |
|
|
|
options.couponChannelId = this.data.newArr[1]; |
|
|
|
}else if (this.data.newArr[0] == 'JG'){ |
|
|
|
/** |
|
|
|
* 来自大屏跳转拼团详情 |
|
|
|
*/ |
|
|
|
options.couponChannelId = this.data.newArr[1]; |
|
|
|
options.path='daping' |
|
|
|
/** |
|
|
|
* 来自大屏跳转拼团详情 |
|
|
|
*/ |
|
|
|
options.couponChannelId = this.data.newArr[1]; |
|
|
|
options.path='daping' |
|
|
|
} |
|
|
|
} |
|
|
|
wx.showToast({ |
|
|
@@ -70,107 +71,107 @@ Page({ |
|
|
|
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 &&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' |
|
|
|
}); |
|
|
|
} |
|
|
|
}) |
|
|
|
.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` |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
/** |
|
|
@@ -182,71 +183,85 @@ Page({ |
|
|
|
// 登录 |
|
|
|
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 |
|
|
|
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 |
|
|
|
}) |
|
|
|
.then(res => { |
|
|
|
that.setData({ |
|
|
|
showPages: true |
|
|
|
}) |
|
|
|
app.globalData.token = res.data.token; |
|
|
|
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', |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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', |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |