Selaa lähdekoodia

[小程序公众号][新增]:用户已授权后的公众号链接支持

tags/湖南版5.1.4
Stormeye Wu 6 vuotta sitten
vanhempi
commit
a6d847f4b4
9 muutettua tiedostoa jossa 304 lisäystä ja 206 poistoa
  1. +4
    -0
      config/config.js
  2. +1
    -1
      pages/bargain/bargain.js
  3. +1
    -1
      pages/cardorder/detail/index.js
  4. +1
    -1
      pages/couponorder/detail/index.js
  5. +292
    -198
      pages/index/index.js
  6. +2
    -2
      pages/main/index.js
  7. +1
    -1
      pages/order/detail/index.js
  8. +1
    -1
      pages/orderquanma/index.js
  9. +1
    -1
      pages/spellGroup/spellGroup.js

+ 4
- 0
config/config.js Näytä tiedosto

@@ -167,6 +167,10 @@ var config = {
* 小程序获取游戏路径
*/
getGame:'/game/getOne',
/**
* 小程序某一个游戏信息
*/
getOneGame: '/game/getOneGame',
/**
* 用户更新信息
*/


+ 1
- 1
pages/bargain/bargain.js Näytä tiedosto

@@ -252,7 +252,7 @@ Page({
},
/**
*
* @param {砍价} 邀请好友砍价
* @param {砍价} 发起砍价
*/
invite: function (e) {
let couponChannelId = e.currentTarget.dataset.id;


+ 1
- 1
pages/cardorder/detail/index.js Näytä tiedosto

@@ -46,7 +46,7 @@ Page({
Http.get({
url: config.api.getGame,
data: {
triggleAction: 4
triggleAction: 4 // 核销触发
}
}).then(res => {
if (res.data.id) {


+ 1
- 1
pages/couponorder/detail/index.js Näytä tiedosto

@@ -49,7 +49,7 @@ Page({
Http.get({
url: config.api.getGame,
data: {
triggleAction: 4
triggleAction: 4 // 核销触发
}
}).then(res => {
if (res.data.id) {


+ 292
- 198
pages/index/index.js Näytä tiedosto

@@ -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();
})
},
})

+ 2
- 2
pages/main/index.js Näytä tiedosto

@@ -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 => {


+ 1
- 1
pages/order/detail/index.js Näytä tiedosto

@@ -121,7 +121,7 @@ Page({
Http.get({
url: config.api.getGame,
data: {
triggleAction: 3
triggleAction: 3 // 购买触发
}
}).then(res => {
if (res.data.id) {


+ 1
- 1
pages/orderquanma/index.js Näytä tiedosto

@@ -28,7 +28,7 @@ Page({
Http.get({
url: config.api.getGame,
data: {
triggleAction: 4
triggleAction: 4 // 核销触发
}
}).then(res => {
if (res.data.id) {


+ 1
- 1
pages/spellGroup/spellGroup.js Näytä tiedosto

@@ -382,7 +382,7 @@ Page({
},
/**
*
* @param {砍价} 邀请好友砍价
* @param goto拼团券详情
*/
invite: function (e) {
let couponChannelId = e.currentTarget.dataset.id;


Ladataan…
Peruuta
Tallenna