|
|
@@ -13,15 +13,7 @@ Page({ |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad: function(options) { |
|
|
|
console.log(options) |
|
|
|
let that = this; |
|
|
|
wx.showToast({ |
|
|
|
title: '加载中', |
|
|
|
icon: "loading", |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
wx.setStorageSync('options', JSON.stringify(options)) |
|
|
|
wx.setStorageSync('imgurl', imgurl) |
|
|
|
if (decodeURIComponent(options.scene) == "undefined") { |
|
|
|
that.setData({ |
|
|
|
scene: 0 |
|
|
@@ -30,38 +22,53 @@ Page({ |
|
|
|
that.setData({ |
|
|
|
scene: decodeURIComponent(options.scene) |
|
|
|
}); |
|
|
|
that.setData({ |
|
|
|
newArr: this.data.scene.split(':') |
|
|
|
}) |
|
|
|
console.log(this.data.newArr) |
|
|
|
if (this.data.newArr[0]=='JC'){ |
|
|
|
options.couponChannelId = this.data.newArr[1]; |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(options.couponChannelId) |
|
|
|
wx.showToast({ |
|
|
|
title: '加载中', |
|
|
|
icon: "loading", |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
wx.setStorageSync('options', JSON.stringify(options)) |
|
|
|
wx.setStorageSync('imgurl', imgurl) |
|
|
|
app.getLocation(); |
|
|
|
if (options.couponChannelId && options.couponId || options.orderId) { |
|
|
|
if (options.couponChannelId || options.orderId) { |
|
|
|
if (options.cuserId){ |
|
|
|
/** |
|
|
|
* 转赠判断 |
|
|
|
*/ |
|
|
|
that.userLogin(options.couponChannelId, options.couponId, null, options.cuserId, options.coverImg, options.userName, options.avatarUrl, options.couponOrderId, options.updateDate); |
|
|
|
that.userLogin(options.couponChannelId, null, options.cuserId, options.coverImg, options.userName, options.avatarUrl, options.couponOrderId, options.updateDate); |
|
|
|
}else{ |
|
|
|
that.userLogin(options.couponChannelId, options.couponId, options.orderId); |
|
|
|
that.userLogin(options.couponChannelId, options.orderId); |
|
|
|
} |
|
|
|
} else { |
|
|
|
that.userLogin() |
|
|
|
} |
|
|
|
}, |
|
|
|
checkuerstatus(couponChannelId, couponId, orderId, cuserId, coverImg, userName, avatarUrl, couponOrderId, updateDate) { |
|
|
|
checkuerstatus(couponChannelId, orderId, cuserId, coverImg, userName, avatarUrl, couponOrderId, updateDate) { |
|
|
|
let that = this; |
|
|
|
Http.post({ |
|
|
|
url: config.api.checkUserStatus, |
|
|
|
data: {} |
|
|
|
}) |
|
|
|
.then(res => { |
|
|
|
if (couponChannelId && couponId && !cuserId) { |
|
|
|
if (couponChannelId && !cuserId) { |
|
|
|
wx.redirectTo({ |
|
|
|
url: `/pages/coupon/detail/index?couponChannelId=${couponChannelId}&couponId=${couponId}`, |
|
|
|
url: `/pages/coupon/detail/index?couponChannelId=${couponChannelId}`, |
|
|
|
}) |
|
|
|
} else if (couponChannelId && couponId && cuserId){ |
|
|
|
} else if (couponChannelId && cuserId){ |
|
|
|
/** |
|
|
|
* 转赠判断 |
|
|
|
*/ |
|
|
|
wx.redirectTo({ |
|
|
|
url: `/pages/coupon/detail/index?couponChannelId=${couponChannelId}&couponId=${couponId}&cuserId=${cuserId}&coverImg=${coverImg}&userName=${userName}&avatarUrl=${avatarUrl}&couponOrderId=${couponOrderId}&updateDate=${updateDate}`, |
|
|
|
url: `/pages/coupon/detail/index?couponChannelId=${couponChannelId}&cuserId=${cuserId}&coverImg=${coverImg}&userName=${userName}&avatarUrl=${avatarUrl}&couponOrderId=${couponOrderId}&updateDate=${updateDate}`, |
|
|
|
}) |
|
|
|
} else if (orderId) { |
|
|
|
wx.redirectTo({ |
|
|
@@ -69,23 +76,23 @@ Page({ |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
wx.switchTab({ |
|
|
|
url: '/pages/login/index' |
|
|
|
url: '/pages/main/index' |
|
|
|
}); |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
if (err.code == 11004) { |
|
|
|
// 用户昵称未授权 |
|
|
|
if (couponChannelId && couponId && !cuserId) { |
|
|
|
if (couponChannelId && !cuserId) { |
|
|
|
wx.redirectTo({ |
|
|
|
url: `/pages/getuserinfo/index?couponChannelId=${couponChannelId}&couponId=${couponId}` |
|
|
|
url: `/pages/getuserinfo/index?couponChannelId=${couponChannelId}` |
|
|
|
}); |
|
|
|
} else if (couponChannelId && couponId && cuserId){ |
|
|
|
} else if (couponChannelId && cuserId){ |
|
|
|
/** |
|
|
|
* 转赠判断 |
|
|
|
*/ |
|
|
|
wx.redirectTo({ |
|
|
|
url: `/pages/getuserinfo/index?couponChannelId=${couponChannelId}&couponId=${couponId}&cuserId=${cuserId}&coverImg=${coverImg}&userName=${userName}&avatarUrl=${avatarUrl}&couponOrderId=${couponOrderId}&updateDate=${updateDate}` |
|
|
|
url: `/pages/getuserinfo/index?couponChannelId=${couponChannelId}&cuserId=${cuserId}&coverImg=${coverImg}&userName=${userName}&avatarUrl=${avatarUrl}&couponOrderId=${couponOrderId}&updateDate=${updateDate}` |
|
|
|
}); |
|
|
|
} else if (orderId) { |
|
|
|
wx.redirectTo({ |
|
|
@@ -102,7 +109,7 @@ Page({ |
|
|
|
/** |
|
|
|
* 用户登录 |
|
|
|
*/ |
|
|
|
userLogin: function (couponChannelId, couponId, orderId, cuserId, coverImg, userName, avatarUrl, couponOrderId, updateDate) { |
|
|
|
userLogin: function (couponChannelId, orderId, cuserId, coverImg, userName, avatarUrl, couponOrderId, updateDate) { |
|
|
|
var that = this; |
|
|
|
// 登录 |
|
|
|
wx.login({ |
|
|
@@ -144,8 +151,8 @@ Page({ |
|
|
|
}) |
|
|
|
app.globalData.token = res.data.token; |
|
|
|
Http.setToken(res.data.token); |
|
|
|
if (couponChannelId&&couponId || orderId){ |
|
|
|
that.checkuerstatus(couponChannelId, couponId, orderId, cuserId, coverImg, userName, avatarUrl, couponOrderId, updateDate); |
|
|
|
if (couponChannelId || orderId){ |
|
|
|
that.checkuerstatus(couponChannelId, orderId, cuserId, coverImg, userName, avatarUrl, couponOrderId, updateDate); |
|
|
|
}else{ |
|
|
|
that.checkuerstatus(); |
|
|
|
} |
|
|
|