Commit 5c5c61ca authored by 潘永坪's avatar 潘永坪

支付页面参数修改

parent 3ad0f954
<script> <script>
// 1、uni-app的页面生命周期仅在page页面有效,而单独封装的组件中【页面周期无效】, // 1、uni-app的页面生命周期仅在page页面有效,而单独封装的组件中【页面周期无效】,
//但是Vue的生命周期依然有效 【Vue的生命周期在任何地方都是有效的,即你仍然可以在uni-app项目中使用Vue生命周期,但是不建议这么做】 //但是Vue的生命周期依然有效 【Vue的生命周期在任何地方都是有效的,即你仍然可以在uni-app项目中使用Vue生命周期,但是不建议这么做】
// 2、推荐使用uni-app里面的onLoad 代替 vue 里面的 created // 2、推荐使用uni-app里面的onLoad 代替 vue 里面的 created
// 3、推荐使用uni-app里面的onReady 代替 vue 里面的 mounted // 3、推荐使用uni-app里面的onReady 代替 vue 里面的 mounted
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全 //4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
export default { export default {
onLaunch: function(options) { //初始化完成时触发(全局只触发一次 onLaunch: function(options) { //初始化完成时触发(全局只触发一次
let today = this.$commonjs.today() let today = this.$commonjs.today()
let oldDate = uni.getStorageSync('oldDate') let oldDate = uni.getStorageSync('oldDate')
//大于7天重新登录 //大于7天重新登录
if (oldDate) { if (oldDate) {
let number = this.$commonjs.dateDifference(today, oldDate) let number = this.$commonjs.dateDifference(today, oldDate)
if (number > 7) { if (number > 7) {
uni.clearStorageSync() uni.clearStorageSync()
} }
} else { } else {
//用于处理这个功能之前登录过的用户,未保存登录时间 //用于处理这个功能之前登录过的用户,未保存登录时间
uni.clearStorageSync() uni.clearStorageSync()
} }
let path = options.path let path = options.path
uni.setStorageSync('enterOptions', options) uni.setStorageSync('enterOptions', options)
let token = uni.getStorageSync('token') let token = uni.getStorageSync('token')
if (!token && path.indexOf('pages/payment/ourPayment/ourPayment') == -1) { //扫码支付页面不需要在此登录 if (!token && path.indexOf('pages/payment/ourPayment/ourPayment') == -1) { //扫码支付页面不需要在此登录
setTimeout(() => { //解决关联普通二维码扫码首次进入时一直显示登录中 setTimeout(() => { //解决关联普通二维码扫码首次进入时一直显示登录中
uni.navigateTo({ uni.navigateTo({
url: '/pages/login/login' url: '/pages/login/login'
}) })
}, 300) }, 300)
} }
//#ifdef MP-WEIXIN //#ifdef MP-WEIXIN
uni.setStorageSync('appid', 'wxe678d5240e98a7b8') uni.setStorageSync('appid', 'wxe678d5240e98a7b8')
//#endif //#endif
//#ifdef MP-ALIPAY //#ifdef MP-ALIPAY
if (options.query && options.query.qrCode) { uni.setStorageSync('appid', '2021001194629244')
uni.setStorageSync('alipayQrCode', options.query.qrCode) if (options.query && options.query.qrCode) {
} else { uni.setStorageSync('alipayQrCode', options.query.qrCode)
uni.removeStorageSync('alipayQrCode') } else {
} uni.removeStorageSync('alipayQrCode')
//#endif }
/* 版本自动更新代码 */ //#endif
const updateManager = uni.getUpdateManager() /* 版本自动更新代码 */
updateManager.onCheckForUpdate(function (res) { const updateManager = uni.getUpdateManager()
console.log('是否有更新:' + res.hasUpdate) // 请求完新版本信息的回调 true说明有更新 updateManager.onCheckForUpdate(function (res) {
}) console.log('是否有更新:' + res.hasUpdate) // 请求完新版本信息的回调 true说明有更新
updateManager.onUpdateReady(function () { })
uni.showModal({ updateManager.onUpdateReady(function () {
title: '更新检测', // 此处可自定义提示标题 uni.showModal({
content: '检测到新版本,是否重启小程序?', // 此处可自定义提示消息内容 title: '更新检测', // 此处可自定义提示标题
success: function (res) { content: '检测到新版本,是否重启小程序?', // 此处可自定义提示消息内容
if (res.confirm) { success: function (res) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 if (res.confirm) {
updateManager.applyUpdate() // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
} updateManager.applyUpdate()
} }
}) }
}) })
updateManager.onUpdateFailed(function () { })
// 新的版本下载失败 updateManager.onUpdateFailed(function () {
uni.showModal({ // 新的版本下载失败
title: '更新提示', uni.showModal({
content: '新版本下载失败', title: '更新提示',
showCancel: false content: '新版本下载失败',
}) showCancel: false
}) })
}, })
onShow: function() { },
onShow: function() {
}, },
onHide: function() { onHide: function() {
} }
} }
</script> </script>
<style lang="scss"> <style lang="scss">
......
...@@ -6,20 +6,20 @@ ...@@ -6,20 +6,20 @@
export default { export default {
data() { data() {
return { return {
timer:null, timer:null,
} }
}, },
onLoad() { onLoad() {
this.login() this.login()
}, },
// 一般页面用onUnload // 一般页面用onUnload
// tabbar页面用onHide // tabbar页面用onHide
onUnload() { onUnload() {
if(this.timer) { if(this.timer) {
clearTimeout(this.timer) clearTimeout(this.timer)
this.timer = null this.timer = null
} }
}, },
methods:{ methods:{
//---登录 //---登录
login(){ login(){
...@@ -40,8 +40,10 @@ export default { ...@@ -40,8 +40,10 @@ export default {
let data = { let data = {
code: res.code, code: res.code,
source, //微信小程序3,支付宝小程序4 source, //微信小程序3,支付宝小程序4
companyId:uni.getStorageSync('enterOptions').query.companyId||'', appid:uni.getStorageSync('appid')||''
appid:uni.getStorageSync('appid')||'' }
if(uni.getStorageSync('enterOptions').query){
data.companyId=uni.getStorageSync('enterOptions').query.companyId||''
} }
_this.$request('wechat/wx/getUserInfoByCode', data).then(res => { _this.$request('wechat/wx/getUserInfoByCode', data).then(res => {
if (res.code == '00') { if (res.code == '00') {
...@@ -68,9 +70,9 @@ export default { ...@@ -68,9 +70,9 @@ export default {
uni.redirectTo({ uni.redirectTo({
url: '/' + enterOptions.path + '?' + queryTotal url: '/' + enterOptions.path + '?' + queryTotal
}) })
//保存当前日期 //保存当前日期
let oldDate=_this.$commonjs.today() let oldDate=_this.$commonjs.today()
uni.setStorageSync('oldDate', oldDate) uni.setStorageSync('oldDate', oldDate)
// uni.navigateBack({ // uni.navigateBack({
// delta:1 // delta:1
// }) // })
......
...@@ -140,8 +140,10 @@ export default { ...@@ -140,8 +140,10 @@ export default {
let data = { let data = {
code: res.code, code: res.code,
source, //微信小程序3,支付宝小程序4 source, //微信小程序3,支付宝小程序4
companyId:uni.getStorageSync('enterOptions').query.companyId||'', appid:uni.getStorageSync('appid')||''
appid:uni.getStorageSync('appid')||'' }
if(uni.getStorageSync('enterOptions').query){
data.companyId=uni.getStorageSync('enterOptions').query.companyId||''
} }
_this.$request('wechat/wx/getUserInfoByCode', data) _this.$request('wechat/wx/getUserInfoByCode', data)
.then(res => { .then(res => {
...@@ -177,13 +179,13 @@ export default { ...@@ -177,13 +179,13 @@ export default {
} }
this.$request('orderc/order/findOrderInfo', data).then(res => { this.$request('orderc/order/findOrderInfo', data).then(res => {
if (res.code == '00') { if (res.code == '00') {
if(res.data.orderType=='10'){ if(res.data.orderType=='10'){
//组合票和联票跳订单列表 //组合票和联票跳订单列表
this.afterBuyUrl='/pages/my/order/orderList/orderList' this.afterBuyUrl='/pages/my/order/orderList/orderList'
}else{ }else{
//单票跳详情 //单票跳详情
this.afterBuyUrl='/pages/my/order/electronicTicket/electronicTicket' this.afterBuyUrl='/pages/my/order/electronicTicket/electronicTicket'
} }
this.bodyShow = true this.bodyShow = true
//支付参数开始 //支付参数开始
this.timeStamp = res.data.timestamp this.timeStamp = res.data.timestamp
...@@ -196,9 +198,9 @@ export default { ...@@ -196,9 +198,9 @@ export default {
//支付参数结束 //支付参数结束
this.pdOrderMoney = res.data.pdOrderMoney this.pdOrderMoney = res.data.pdOrderMoney
if (this.pdOrderMoney == 0 && res.data.subOrderType == -1) { if (this.pdOrderMoney == 0 && res.data.subOrderType == -1) {
this.afterBuyUrl='/pages/my/order/electronicTicket/electronicTicket' this.afterBuyUrl='/pages/my/order/electronicTicket/electronicTicket'
uni.navigateTo({ uni.navigateTo({
url: '/pages/payment/paySuccess/paySuccess?orderId=' + _this.orderId+'&afterBuyUrl=' + _this.afterBuyUrl + '&ifyukuaiCode=' + _this.ifyukuaiCode url: '/pages/payment/paySuccess/paySuccess?orderId=' + _this.orderId+'&afterBuyUrl=' + _this.afterBuyUrl + '&ifyukuaiCode=' + _this.ifyukuaiCode
}) })
} }
this.errorMessage = res.data.errorMessage this.errorMessage = res.data.errorMessage
......
This diff is collapsed.
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
} }
this.ticketStatus() this.ticketStatus()
intFun() intFun()
}, 1200) }, 2000)
} }
intFun() intFun()
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment