Browse Source

[登录][修改]:[登录修改]

tags/江西版6.1.0
meo 5 years ago
parent
commit
e1ec5dc420
6 changed files with 291 additions and 291 deletions
  1. +64
    -4
      app.js
  2. +8
    -2
      pages/coupon/detail/index.js
  3. +66
    -66
      pages/discountCardList/discountCardList.js
  4. +105
    -175
      pages/index/index.js
  5. +32
    -28
      pages/main/index.js
  6. +16
    -16
      pages/passCar/passCar.js

+ 64
- 4
app.js View File

@@ -1,16 +1,22 @@
let config = require("./config/config.js"); let config = require("./config/config.js");
const Http = require("./utils/HttpBasics"); const Http = require("./utils/HttpBasics");
const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
App({ App({
data: {}, data: {},
onLaunch: function (options) { onLaunch: function (options) {
console.log("onUnload ")
var that = this; var that = this;
console.log("onLuanch")
that.globalData.sceneAddress = options.scene; that.globalData.sceneAddress = options.scene;

/**
* 用户登录
*/
that.userLogin(options.scene);
/**
* 小程序版本更新
*/
if (wx.canIUse('getUpdateManager')) { if (wx.canIUse('getUpdateManager')) {
const updateManager = wx.getUpdateManager() const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) { updateManager.onCheckForUpdate(function (res) {
console.log('onCheckForUpdate====', res)
// 请求完新版本信息的回调 // 请求完新版本信息的回调
if (res.hasUpdate) { if (res.hasUpdate) {
console.log('res.hasUpdate====') console.log('res.hasUpdate====')
@@ -39,11 +45,65 @@ App({
}) })
} }
}, },
/**
* 用户登录
*/
userLogin: function (sceneAddress) {
let that = this;
// 登录
wx.login({
success: ({
code
}) => {
let usrdata = {
appId: config.weapp.AppId,
code: code,
sceneAddress: sceneAddress
}
Http.post({
url: config.api.login,
data: usrdata
})
.then(res => {
if (res.data && res.data.score) {
if (res.data.score != 0) {
that.globalData.score = res.data.score;
}
}
Http.setToken(res.data.token);
that.globalData.token = res.data.token;
console.log(that.globalData.token)

if (that.tokenCallback) {
that.tokenCallback(res.data.token);
}
})
.catch(err => {
console.log(err)
wx.showModal({
title: '提示',
showCancel: false,
content: '登录失败,请重新尝试',
success: function (res) {
if (res.cancel) {
//点击取消,默认隐藏弹框
} else {
//点击确定
wx.reLaunch({
url: '/pages/index/index',
})
}
}
})
})
}
})
},
/** /**
* 获取地址位置信息 * 获取地址位置信息
*/ */
getLocation: function () { getLocation: function () {
var that = this
var that = this;
wx.getLocation({ wx.getLocation({
type: "wgs84", type: "wgs84",
success: function (res) { success: function (res) {


+ 8
- 2
pages/coupon/detail/index.js View File

@@ -266,6 +266,9 @@ Page({
}, },
gotopay: function(e) { gotopay: function(e) {
let that = this; let that = this;
wx.showLoading({
title: '',
})
if (e.currentTarget.dataset.type == 51 || e.currentTarget.dataset.type == 50){ if (e.currentTarget.dataset.type == 51 || e.currentTarget.dataset.type == 50){
wx.navigateTo({ wx.navigateTo({
url: '/pages/integralmall/payIntegcoupondetail/index?couponChannelId=' + that.data.couponChannelId + '&couponId=' + that.data.couponId, url: '/pages/integralmall/payIntegcoupondetail/index?couponChannelId=' + that.data.couponChannelId + '&couponId=' + that.data.couponId,
@@ -285,7 +288,7 @@ Page({
} }
}) })
.then(res => { .then(res => {
console.log(res);
wx.hideLoading();
if (res.data == undefined) { if (res.data == undefined) {
that.orderFunc(discount); that.orderFunc(discount);
that.setData({ that.setData({
@@ -307,6 +310,7 @@ Page({
} }
}) })
.catch(err => { .catch(err => {
wx.hideLoading();
wx.showToast({ wx.showToast({
title: err.message, title: err.message,
icon: 'none', icon: 'none',
@@ -651,7 +655,7 @@ Page({
}); });
}) })
.catch(err => { .catch(err => {
console.log(err);
wx.hideLoading()
that.setData({ that.setData({
showbutton: false, showbutton: false,
showbutton1: false showbutton1: false
@@ -806,6 +810,7 @@ Page({
} }
}, },
fail: res => { fail: res => {
wx.hideLoading();
/** /**
* 支付失败,需要更新订单的状态 * 支付失败,需要更新订单的状态
*/ */
@@ -820,6 +825,7 @@ Page({
/// End payment -------- /// End payment --------
}) })
.catch(err => { .catch(err => {
wx.hideLoading();
wx.showToast({ wx.showToast({
title: err.message, title: err.message,
icon: 'none', icon: 'none',


+ 66
- 66
pages/discountCardList/discountCardList.js View File

@@ -46,11 +46,11 @@ Page({
this.setData({ this.setData({
paramData:options paramData:options
},function(){ },function(){
this.userLogin()
// this.userLogin()
}) })
} }
}, },
//点击跳转到详情页面
//点击跳转到详情页面
gotouse: function (e) { gotouse: function (e) {
console.log(e.currentTarget.dataset.couponid) console.log(e.currentTarget.dataset.couponid)
wx.navigateTo({ wx.navigateTo({
@@ -156,70 +156,70 @@ 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',
})
}
}
})
});
}
});
},
// 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(){ checkuerstatus(){
Http.get({ Http.get({
url: config.api.checkPhoneStatus, url: config.api.checkPhoneStatus,


+ 105
- 175
pages/index/index.js View File

@@ -11,8 +11,13 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) {
onLoad: function(options) {
let that = this; let that = this;
wx.showToast({
title: '加载中',
icon: "loading",
duration: 2000
})
/** /**
* 根据接收到的参数的值,判断跳转到哪个页面 * 根据接收到的参数的值,判断跳转到哪个页面
*/ */
@@ -22,7 +27,7 @@ Page({
if (decodeURIComponent(options.scene) == "undefined") { if (decodeURIComponent(options.scene) == "undefined") {
that.setData({ that.setData({
scene: 0 scene: 0
});
})
} else { } else {
that.setData({ that.setData({
scene: decodeURIComponent(options.scene) scene: decodeURIComponent(options.scene)
@@ -30,7 +35,6 @@ Page({
that.setData({ that.setData({
newArr: this.data.scene.split(':') newArr: this.data.scene.split(':')
}) })
console.log(this.data.newArr)
//// 大屏-二维码-start //// 大屏-二维码-start
if (this.data.newArr[0] == 'JC') { if (this.data.newArr[0] == 'JC') {
// 跳转券详情 // 跳转券详情
@@ -39,12 +43,11 @@ Page({
// 跳转拼团详情 // 跳转拼团详情
options.couponChannelId = this.data.newArr[1]; options.couponChannelId = this.data.newArr[1];
options.path = 'daping' options.path = 'daping'
}
else if (this.data.newArr[0] == 't') {
} else if (this.data.newArr[0] == 't') {
// 普通二维码 // 普通二维码
options.type = this.data.newArr[1]; options.type = this.data.newArr[1];
app.globalData.type = options.type; app.globalData.type = options.type;
if(options.type == 'cd') {
if (options.type == 'cd') {
options.couponChannelId = this.data.newArr[2]; options.couponChannelId = this.data.newArr[2];
} else if (options.type == 'bd') { } else if (options.type == 'bd') {
options.bt = this.data.newArr[2]; options.bt = this.data.newArr[2];
@@ -59,28 +62,49 @@ Page({
} }
} }
} }
wx.showToast({
title: '加载中',
icon: "loading",
duration: 2000
})
wx.setStorageSync('options', JSON.stringify(options)) wx.setStorageSync('options', JSON.stringify(options))
wx.setStorageSync('imgurl', imgurl) wx.setStorageSync('imgurl', imgurl)
app.getLocation();
if (options.couponChannelId || options.orderId || options.id) {
that.userLogin(options);

// app.getLocation();
if (app.globalData.token) {
if (options.couponChannelId || options.orderId || options.id) {
that.userStatus(options);
} else {
that.userStatus();
}
} else {
// 由于 token 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.tokenCallback = token => {
if (options.couponChannelId || options.orderId || options.id) {
that.userStatus(options);
} else {
that.userStatus();
}
}
} }
}, },
onShow(){
let that = this;
that.userLogin();
console.log("onshow-----------------------------------login")

/**
* 检查用户的状态
*/
userStatus: function(options) {
var that = this;
if (options && (options.couponChannelId || options.orderId || options.id)) {
that.checkuserstatus(options);
} else {
that.checkuserstatus();
}
}, },

checkuserstatus(options) { checkuserstatus(options) {
let that = this;
Http.get({
let that = this;
Http.get({
url: config.api.checkUserStatus, url: config.api.checkUserStatus,
data: {}
data: {
token:app.globalData.token
}
}) })
.then(res => { .then(res => {
//参与拼团 //参与拼团
@@ -88,7 +112,6 @@ Page({
wx.redirectTo({ wx.redirectTo({
url: `/pages/joinFrDpell/index?couponId=${options.couponId}&orderGroupId=${options.orderGroupId}&couponChannelId=${options.couponChannelId}&orderId=${options.orderId}&avatarUrl=${options.avatarUrl}&nickName=${options.nickName}` url: `/pages/joinFrDpell/index?couponId=${options.couponId}&orderGroupId=${options.orderGroupId}&couponChannelId=${options.couponChannelId}&orderId=${options.orderId}&avatarUrl=${options.avatarUrl}&nickName=${options.nickName}`
}) })
return;
} }
//来自大屏的跳转拼团券详情 //来自大屏的跳转拼团券详情
else if (options && options.couponChannelId && options.path == 'daping') { else if (options && options.couponChannelId && options.path == 'daping') {
@@ -105,33 +128,30 @@ Page({
wx.redirectTo({ wx.redirectTo({
url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${options.couponChannelId}&couponId=${data.couponId}` url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${options.couponChannelId}&couponId=${data.couponId}`
}) })
});
return;
}
else if (options && options.couponChannelId && !options.spellGroup) {
// 转赠判断
if (options.cuserId){
})
} else if (options && options.couponChannelId && !options.spellGroup) {
// 转赠判断
if (options.cuserId) {
wx.redirectTo({ 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}`, 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{
} else {
// 跳转普通券/消费卡/限时秒杀/砍价详情 // 跳转普通券/消费卡/限时秒杀/砍价详情
wx.redirectTo({ wx.redirectTo({
url: `/pages/coupon/detail/index?couponChannelId=${options.couponChannelId}`, url: `/pages/coupon/detail/index?couponChannelId=${options.couponChannelId}`,
}) })
} }
}
}
// 拼团详情页(只有通过扫码进入才可能进入拼团详情页面,只有这一个入口) // 拼团详情页(只有通过扫码进入才可能进入拼团详情页面,只有这一个入口)
else if (options && options.couponChannelId && app.globalData.type == 'sd' || options && options.couponChannelId && options.spellGroup) { else if (options && options.couponChannelId && app.globalData.type == 'sd' || options && options.couponChannelId && options.spellGroup) {
wx.redirectTo({ wx.redirectTo({
url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${options.couponChannelId}`, url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${options.couponChannelId}`,
}) })
}
}
// 游戏页面 // 游戏页面
else if (options && options.id && app.globalData.type == 'gm') { else if (options && options.id && app.globalData.type == 'gm') {
that.getGameOne(app.globalData.token, options.id) that.getGameOne(app.globalData.token, options.id)
}
}
// 宣传页详情 // 宣传页详情
else if (options && options.bt && options.id && app.globalData.type == 'bd') { else if (options && options.bt && options.id && app.globalData.type == 'bd') {
if (options.bt == '2') { if (options.bt == '2') {
@@ -145,13 +165,13 @@ Page({
url: `/pages/bannerdetail/index?id=${options.id}`, url: `/pages/bannerdetail/index?id=${options.id}`,
}) })
} }
}
}
// 专题 // 专题
else if (options && options.id && app.globalData.type == 'td'){
else if (options && options.id && app.globalData.type == 'td') {
wx.redirectTo({ wx.redirectTo({
url: `/pages/topicDetail/index?id=${options.id}` url: `/pages/topicDetail/index?id=${options.id}`
}); });
}
}
// 参与砍价 // 参与砍价
else if (options && options.orderId) { else if (options && options.orderId) {
wx.redirectTo({ wx.redirectTo({
@@ -163,117 +183,117 @@ Page({
wx.switchTab({ wx.switchTab({
url: '/pages/user/index' url: '/pages/user/index'
}); });
}
}
// 积分 // 积分
else if (app.globalData.type == 'jf') { else if (app.globalData.type == 'jf') {
wx.redirectTo({ wx.redirectTo({
url: '/pages/integralmall/index' url: '/pages/integralmall/index'
}); });
}
}
// 首页 // 首页
else if (app.globalData.type == 'in') { else if (app.globalData.type == 'in') {
wx.switchTab({ wx.switchTab({
url: '/pages/main/index' url: '/pages/main/index'
}); });
}
}
// 停车 // 停车
else if (app.globalData.type == 'pc') { else if (app.globalData.type == 'pc') {
// 停车 // 停车
wx.switchTab({ wx.switchTab({
url: '/pages/passCar/passCar' url: '/pages/passCar/passCar'
}); });
}
}
// 我的券包 // 我的券包
else if (app.globalData.type == 'mc') { else if (app.globalData.type == 'mc') {
// 我的券包 // 我的券包
wx.redirectTo({ wx.redirectTo({
url: '/pages/couponorder/index/index' url: '/pages/couponorder/index/index'
}); });
}
}
// 我的订单 // 我的订单
else if (app.globalData.type == 'mo') { else if (app.globalData.type == 'mo') {
// 我的订单 // 我的订单
wx.redirectTo({ wx.redirectTo({
url: '/pages/order/index/index?id=all' url: '/pages/order/index/index?id=all'
}); });
}
}
// 我的卡包 // 我的卡包
else if (app.globalData.type == 'ca') { else if (app.globalData.type == 'ca') {
// 我的卡包 // 我的卡包
wx.redirectTo({ wx.redirectTo({
url: '/pages/cardorder/index/index' url: '/pages/cardorder/index/index'
}); });
}
}
// 特享礼遇 // 特享礼遇
else if (app.globalData.type == 'sc') { else if (app.globalData.type == 'sc') {
// 特享礼遇 // 特享礼遇
wx.redirectTo({ wx.redirectTo({
url: '/pages/specialcourtesy/specialcourtesy' url: '/pages/specialcourtesy/specialcourtesy'
}); });
}
}
// 限时秒杀 // 限时秒杀
else if (app.globalData.type == 'rb') { else if (app.globalData.type == 'rb') {
// 限时秒杀 // 限时秒杀
wx.redirectTo({ wx.redirectTo({
url: '/pages/rushToBuy/index' url: '/pages/rushToBuy/index'
});
}
})
}
// 砍价专场 // 砍价专场
else if (app.globalData.type == 'bl') { else if (app.globalData.type == 'bl') {
// 砍价专场 // 砍价专场
wx.redirectTo({ wx.redirectTo({
url: '/pages/bargain/bargain' url: '/pages/bargain/bargain'
});
}
})
}
// 我的砍价 // 我的砍价
else if (app.globalData.type == 'mb') { else if (app.globalData.type == 'mb') {
// 我的砍价 // 我的砍价
wx.redirectTo({ wx.redirectTo({
url: '/pages/bargain/bargain?from=myhtml' url: '/pages/bargain/bargain?from=myhtml'
});
}
})
}
// 拼团专场 // 拼团专场
else if (app.globalData.type == 'sl') { else if (app.globalData.type == 'sl') {
// 拼团专场 // 拼团专场
wx.redirectTo({ wx.redirectTo({
url: '/pages/spellGroup/spellGroup' url: '/pages/spellGroup/spellGroup'
});
}
})
}
// 我的拼团 // 我的拼团
else if (app.globalData.type == 'ms') { else if (app.globalData.type == 'ms') {
// 我的拼团 // 我的拼团
wx.redirectTo({ wx.redirectTo({
url: '/pages/spellGroup/spellGroup?from=myhtml' url: '/pages/spellGroup/spellGroup?from=myhtml'
});
}
})
}
// 消费卡 // 消费卡
else if (app.globalData.type == 'dc') { else if (app.globalData.type == 'dc') {
// 消费卡 // 消费卡
wx.redirectTo({ wx.redirectTo({
url: '/pages/discountCardList/discountCardList' url: '/pages/discountCardList/discountCardList'
});
}
})
}
// 门店 // 门店
else if (app.globalData.type == 'ml') { else if (app.globalData.type == 'ml') {
// 门店 // 门店
wx.switchTab({ wx.switchTab({
url: '/pages/index/searchbar/index' url: '/pages/index/searchbar/index'
});
})
} else { } else {
// 主页 // 主页
wx.switchTab({ wx.switchTab({
url: '/pages/main/index' url: '/pages/main/index'
});
})
} }
}) })
.catch(err => { .catch(err => {
console.log(err)
if (err.code == 11004) { if (err.code == 11004) {
// 用户昵称未授权 // 用户昵称未授权
if (options && options.orderGroupId) { if (options && options.orderGroupId) {
wx.redirectTo({ wx.redirectTo({
url: `/pages/getuserinfo/index?couponId=${options.couponId}&orderGroupId=${options.orderGroupId}&couponChannelId=${options.couponChannelId}&orderId=${options.orderId}&avatarUrl=${options.avatarUrl}&nickName=${options.nickName}` url: `/pages/getuserinfo/index?couponId=${options.couponId}&orderGroupId=${options.orderGroupId}&couponChannelId=${options.couponChannelId}&orderId=${options.orderId}&avatarUrl=${options.avatarUrl}&nickName=${options.nickName}`
}) })
return;
} }
/** /**
* spellGroup * spellGroup
@@ -283,22 +303,22 @@ Page({
if (options && options.couponChannelId && !options.cuserId && !options.spellGroup) { if (options && options.couponChannelId && !options.cuserId && !options.spellGroup) {
wx.redirectTo({ wx.redirectTo({
url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}` url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}`
});
})
} else if (options && options.couponChannelId && !options.cuserId && options.spellGroup) { } else if (options && options.couponChannelId && !options.cuserId && options.spellGroup) {
wx.redirectTo({ wx.redirectTo({
url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}&spellGroup=${options.spellGroup}` url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}&spellGroup=${options.spellGroup}`
});
})
} else if (options && options.couponChannelId && options.cuserId) { } else if (options && options.couponChannelId && options.cuserId) {
/** /**
* 转赠判断 * 转赠判断
*/ */
wx.redirectTo({ 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}` 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) { } else if (options && options.orderId) {
wx.redirectTo({ wx.redirectTo({
url: `/pages/getuserinfo/index?orderId=${options.orderId}&from='${"discount"}` url: `/pages/getuserinfo/index?orderId=${options.orderId}&from='${"discount"}`
});
})
} else { } else {
wx.redirectTo({ wx.redirectTo({
url: `/pages/getuserinfo/index` url: `/pages/getuserinfo/index`
@@ -307,124 +327,34 @@ Page({
} }
}); });
}, },
/**
* 用户登录
*/
userLogin: function (options) {
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
};
getGameOne: function(token, id) {
let _this = this;
Http.get({
url: config.api.getOneGame,
data: {
token: token,
id: id
} }
Http.post({
url: config.api.login,
data: usrdata
}).then(res => {
wx.redirectTo({
url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
}) })
.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
})
.catch(err => {
wx.showModal({
title: '提示',
content: err.message,
showCancel: false,
success: function(res) {
// 如果游戏下架或者找不到,重启首页
if (res.confirm) {
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 || options.id)) {
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,
this.alphaClick();
}) })
})
.catch(err => {
wx.showModal({
title: '提示',
content: err.message,
showCancel: false,
success:function(res){
// 如果游戏下架或者找不到,重启首页
if (res.confirm){
wx.reLaunch({
url: '/pages/index/index',
})
}
}
})
this.alphaClick();
})
}, },
}) })

+ 32
- 28
pages/main/index.js View File

@@ -216,9 +216,9 @@ Page({
that.setData({ that.setData({
optionsData: optionss optionsData: optionss
}) })
that.userLogin(optionss.couponChannelId, optionss.orderId);
that.getWeapNote(optionss.couponChannelId, optionss.orderId);
} else { } else {
that.userLogin()
that.getWeapNote()
} }
//获取条形码 //获取条形码
// util.barcode("barcode", optionss.quancode, 510, 100); // util.barcode("barcode", optionss.quancode, 510, 100);
@@ -255,10 +255,9 @@ Page({
that.alphaClick(); that.alphaClick();
}, 8000) }, 8000)
}, },
// 会员码获取
getmemberId: function(token) { getmemberId: function(token) {
let that = this;
Http.get({
let that = this;
Http.get({
url: config.api.getScore, url: config.api.getScore,
data: { data: {
token: token token: token
@@ -271,6 +270,13 @@ Page({
credit: res.data.credit ? res.data.credit : 0, credit: res.data.credit ? res.data.credit : 0,
score: res.data.score score: res.data.score
}) })
if (res.data && res.data.score) {
if (res.data.score != 0) {
app.globalData.score = res.data.score;
}
}
if (res.data.nickName) { if (res.data.nickName) {
that.setData({ that.setData({
ismember: true, ismember: true,
@@ -310,13 +316,10 @@ Page({
onBargain: function(e) { onBargain: function(e) {
console.log(e) console.log(e)
}, },
/**
* 用户登录
*/
userLogin: function(couponChannelId, couponId, orderId) {
getWeapNote: function(couponChannelId, couponId, orderId) {
var that = this; var that = this;
// 登录
that.getmemberId(app.globalData.token); that.getmemberId(app.globalData.token);
that.getUserInfo();
that.getBannerlist(); that.getBannerlist();
that.topicShow(); that.topicShow();
that.getMallInfo(app.globalData.token); that.getMallInfo(app.globalData.token);
@@ -529,21 +532,21 @@ Page({
/** /**
* 获取用户信息 * 获取用户信息
*/ */
getUserInfo: function() {
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting["scope.userInfo"]) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
}
});
}
}
});
},
// getUserInfo: function() {
// // 获取用户信息
// wx.getSetting({
// success: res => {
// if (res.authSetting["scope.userInfo"]) {
// // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
// wx.getUserInfo({
// success: res => {
// // 可以将 res 发送给后台解码出 unionId
// }
// });
// }
// }
// });
// },
gotoBargain: function() { gotoBargain: function() {
wx.navigateTo({ wx.navigateTo({
url: '/pages/bargain/bargain' url: '/pages/bargain/bargain'
@@ -554,14 +557,14 @@ Page({
*/ */
onPullDownRefresh: function(e) { onPullDownRefresh: function(e) {
let that = this; let that = this;
that.userLogin();
that.getWeapNote();
that.setData({ that.setData({
page: 1 page: 1
}) })
if (this.data.optionsData != null && (this.data.optionsData.couponChannelId || this.data.optionsData.orderId)) { if (this.data.optionsData != null && (this.data.optionsData.couponChannelId || this.data.optionsData.orderId)) {
this.userLogin(this.data.optionsData.couponChannelId, this.data.optionsData.orderId);
this.getWeapNote(this.data.optionsData.couponChannelId, this.data.optionsData.orderId);
} else { } else {
this.userLogin()
this.getWeapNote()
} }
if (that.data.code == 0 || that.data.code == undefined) { if (that.data.code == 0 || that.data.code == undefined) {
that.selectComponent("#lists").getList(0, 1, "refresh"); that.selectComponent("#lists").getList(0, 1, "refresh");
@@ -598,6 +601,7 @@ Page({
return { return {
title: this.data.weappShareTitle, title: this.data.weappShareTitle,
imageUrl: this.data.weappShareCoverImg, imageUrl: this.data.weappShareCoverImg,
// desc: this.data.desc,
success: function(res) { success: function(res) {
wx.showToast({ wx.showToast({
title: "分享成功", title: "分享成功",


+ 16
- 16
pages/passCar/passCar.js View File

@@ -208,7 +208,7 @@ Page({
app.globalData.token = res.data.token; app.globalData.token = res.data.token;
Http.setToken(res.data.token); Http.setToken(res.data.token);
that.checkUserCarStatus(); that.checkUserCarStatus();
that.getUserInfo();
// that.getUserInfo();
that.getList(); that.getList();
that.init(); that.init();
that.initUsrCarList(); that.initUsrCarList();
@@ -259,21 +259,21 @@ Page({
/** /**
* 获取用户信息 * 获取用户信息
*/ */
getUserInfo: function () {
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting["scope.userInfo"]) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
}
});
}
}
})
},
// getUserInfo: function () {
// // 获取用户信息
// wx.getSetting({
// success: res => {
// if (res.authSetting["scope.userInfo"]) {
// // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
// wx.getUserInfo({
// success: res => {
// // 可以将 res 发送给后台解码出 unionId
// }
// });
// }
// }
// })
// },
jumpToAdd: function () { jumpToAdd: function () {
wx.navigateTo({ wx.navigateTo({
url: `/pages/addPark/addPark?flags=managepalte` url: `/pages/addPark/addPark?flags=managepalte`


Loading…
Cancel
Save