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

支付页面参数修改

parent 3ad0f954
<script>
// 1、uni-app的页面生命周期仅在page页面有效,而单独封装的组件中【页面周期无效】,
//但是Vue的生命周期依然有效 【Vue的生命周期在任何地方都是有效的,即你仍然可以在uni-app项目中使用Vue生命周期,但是不建议这么做】
// 2、推荐使用uni-app里面的onLoad 代替 vue 里面的 created
// 3、推荐使用uni-app里面的onReady 代替 vue 里面的 mounted
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
export default {
onLaunch: function(options) { //初始化完成时触发(全局只触发一次
let today = this.$commonjs.today()
let oldDate = uni.getStorageSync('oldDate')
//大于7天重新登录
if (oldDate) {
let number = this.$commonjs.dateDifference(today, oldDate)
if (number > 7) {
uni.clearStorageSync()
}
} else {
//用于处理这个功能之前登录过的用户,未保存登录时间
uni.clearStorageSync()
}
let path = options.path
uni.setStorageSync('enterOptions', options)
let token = uni.getStorageSync('token')
if (!token && path.indexOf('pages/payment/ourPayment/ourPayment') == -1) { //扫码支付页面不需要在此登录
setTimeout(() => { //解决关联普通二维码扫码首次进入时一直显示登录中
uni.navigateTo({
url: '/pages/login/login'
})
}, 300)
}
//#ifdef MP-WEIXIN
uni.setStorageSync('appid', 'wxe678d5240e98a7b8')
//#endif
// 1、uni-app的页面生命周期仅在page页面有效,而单独封装的组件中【页面周期无效】,
//但是Vue的生命周期依然有效 【Vue的生命周期在任何地方都是有效的,即你仍然可以在uni-app项目中使用Vue生命周期,但是不建议这么做】
// 2、推荐使用uni-app里面的onLoad 代替 vue 里面的 created
// 3、推荐使用uni-app里面的onReady 代替 vue 里面的 mounted
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
export default {
onLaunch: function(options) { //初始化完成时触发(全局只触发一次
let today = this.$commonjs.today()
let oldDate = uni.getStorageSync('oldDate')
//大于7天重新登录
if (oldDate) {
let number = this.$commonjs.dateDifference(today, oldDate)
if (number > 7) {
uni.clearStorageSync()
}
} else {
//用于处理这个功能之前登录过的用户,未保存登录时间
uni.clearStorageSync()
}
let path = options.path
uni.setStorageSync('enterOptions', options)
let token = uni.getStorageSync('token')
if (!token && path.indexOf('pages/payment/ourPayment/ourPayment') == -1) { //扫码支付页面不需要在此登录
setTimeout(() => { //解决关联普通二维码扫码首次进入时一直显示登录中
uni.navigateTo({
url: '/pages/login/login'
})
}, 300)
}
//#ifdef MP-WEIXIN
uni.setStorageSync('appid', 'wxe678d5240e98a7b8')
//#endif
//#ifdef MP-ALIPAY
if (options.query && options.query.qrCode) {
uni.setStorageSync('alipayQrCode', options.query.qrCode)
} else {
uni.removeStorageSync('alipayQrCode')
}
//#endif
/* 版本自动更新代码 */
const updateManager = uni.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
console.log('是否有更新:' + res.hasUpdate) // 请求完新版本信息的回调 true说明有更新
})
updateManager.onUpdateReady(function () {
uni.showModal({
title: '更新检测', // 此处可自定义提示标题
content: '检测到新版本,是否重启小程序?', // 此处可自定义提示消息内容
success: function (res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(function () {
// 新的版本下载失败
uni.showModal({
title: '更新提示',
content: '新版本下载失败',
showCancel: false
})
})
},
onShow: function() {
//#ifdef MP-ALIPAY
uni.setStorageSync('appid', '2021001194629244')
if (options.query && options.query.qrCode) {
uni.setStorageSync('alipayQrCode', options.query.qrCode)
} else {
uni.removeStorageSync('alipayQrCode')
}
//#endif
/* 版本自动更新代码 */
const updateManager = uni.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
console.log('是否有更新:' + res.hasUpdate) // 请求完新版本信息的回调 true说明有更新
})
updateManager.onUpdateReady(function () {
uni.showModal({
title: '更新检测', // 此处可自定义提示标题
content: '检测到新版本,是否重启小程序?', // 此处可自定义提示消息内容
success: function (res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(function () {
// 新的版本下载失败
uni.showModal({
title: '更新提示',
content: '新版本下载失败',
showCancel: false
})
})
},
onShow: function() {
},
onHide: function() {
},
onHide: function() {
}
}
}
}
</script>
<style lang="scss">
......
......@@ -6,20 +6,20 @@
export default {
data() {
return {
timer:null,
}
timer:null,
}
},
onLoad() {
this.login()
},
// 一般页面用onUnload
// tabbar页面用onHide
onUnload() {
if(this.timer) {
clearTimeout(this.timer)
this.timer = null
}
},
// 一般页面用onUnload
// tabbar页面用onHide
onUnload() {
if(this.timer) {
clearTimeout(this.timer)
this.timer = null
}
},
methods:{
//---登录
login(){
......@@ -40,8 +40,10 @@ export default {
let data = {
code: res.code,
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 => {
if (res.code == '00') {
......@@ -68,9 +70,9 @@ export default {
uni.redirectTo({
url: '/' + enterOptions.path + '?' + queryTotal
})
//保存当前日期
let oldDate=_this.$commonjs.today()
uni.setStorageSync('oldDate', oldDate)
//保存当前日期
let oldDate=_this.$commonjs.today()
uni.setStorageSync('oldDate', oldDate)
// uni.navigateBack({
// delta:1
// })
......
......@@ -140,8 +140,10 @@ export default {
let data = {
code: res.code,
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 => {
......@@ -177,13 +179,13 @@ export default {
}
this.$request('orderc/order/findOrderInfo', data).then(res => {
if (res.code == '00') {
if(res.data.orderType=='10'){
//组合票和联票跳订单列表
this.afterBuyUrl='/pages/my/order/orderList/orderList'
}else{
//单票跳详情
this.afterBuyUrl='/pages/my/order/electronicTicket/electronicTicket'
}
if(res.data.orderType=='10'){
//组合票和联票跳订单列表
this.afterBuyUrl='/pages/my/order/orderList/orderList'
}else{
//单票跳详情
this.afterBuyUrl='/pages/my/order/electronicTicket/electronicTicket'
}
this.bodyShow = true
//支付参数开始
this.timeStamp = res.data.timestamp
......@@ -196,9 +198,9 @@ export default {
//支付参数结束
this.pdOrderMoney = res.data.pdOrderMoney
if (this.pdOrderMoney == 0 && res.data.subOrderType == -1) {
this.afterBuyUrl='/pages/my/order/electronicTicket/electronicTicket'
this.afterBuyUrl='/pages/my/order/electronicTicket/electronicTicket'
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
......
......@@ -83,268 +83,273 @@
</template>
<script>
import orderCoupon from "@/components/orderCoupon.vue"
export default {
components:{
orderCoupon
},
data() {
return {
enterUrl:"",//进入页面路由
buyMoney:"", //输入金额
companyId: "", //公司Id
merchantId: "", //商户Id
name: "", //商家名称
payType:"",//支付类型,微信小程序42,支付宝小程序33
paySign: "", //签名
signType: "", //签名方式
timeStamp: "", //时间戳
nonceStr: "", //随机字符串
package: "", //订单详情扩展字符串
orderInfo:"",//支付宝订单号
flag: "", //setTimeout函数
couponData: "", //所有劵数据
chooseCouponObj: "", //默认选中最优价格优惠券
savedMoney:0,//优惠金额
ableConpon: "", //没有可用优惠券时,达到一定条件可用,显示达到的条件
orderSource:8,//1公众号平台、2公众号组合页面1、3公众号组合页面2、4胖丁伙伴app、5第三方自助机、6第三方票房窗口、7平台快捷买单、8扫码支付
background:"",//普通按钮背景颜色
spaceBackground:"",//回格按钮背景颜色
payBackground:"#1dce2e",//支付背景颜色
leftList:[//左侧按钮数据
{
child:[
{text:1,background:""},
{text:2,background:""},
{text:3,background:""}
]
},
{
child:[
{text:4,background:""},
{text:5,background:""},
{text:6,background:""},
]
},
{
child:[
{text:7,background:""},
{text:8,background:""},
{text:9,background:""},
]
},
{
child:[
{text:0,background:""},
{text:'.',background:""},
]
}
],
orderId:"",//订单Id
paydJumpUrl:"",//页面跳转路径
companyAttribute:"",//等于5时为出租车
timer:null,//定时器
}
},
onLoad(option) {
//#ifdef MP-WEIXIN
this.enterUrl=option.q
this.payType = 42
//#endif
import orderCoupon from '@/components/orderCoupon.vue'
export default {
components:{
orderCoupon
},
data() {
return {
enterUrl:'',//进入页面路由
buyMoney:'', //输入金额
companyId: '', //公司Id
merchantId: '', //商户Id
name: '', //商家名称
payType:'',//支付类型,微信小程序42,支付宝小程序33
paySign: '', //签名
signType: '', //签名方式
timeStamp: '', //时间戳
nonceStr: '', //随机字符串
package: '', //订单详情扩展字符串
orderInfo:'',//支付宝订单号
flag: '', //setTimeout函数
couponData: '', //所有劵数据
chooseCouponObj: '', //默认选中最优价格优惠券
savedMoney:0,//优惠金额
ableConpon: '', //没有可用优惠券时,达到一定条件可用,显示达到的条件
orderSource:8,//1公众号平台、2公众号组合页面1、3公众号组合页面2、4胖丁伙伴app、5第三方自助机、6第三方票房窗口、7平台快捷买单、8扫码支付
background:'',//普通按钮背景颜色
spaceBackground:'',//回格按钮背景颜色
payBackground:'#1dce2e',//支付背景颜色
leftList:[//左侧按钮数据
{
child:[
{text:1,background:''},
{text:2,background:''},
{text:3,background:''}
]
},
{
child:[
{text:4,background:''},
{text:5,background:''},
{text:6,background:''},
]
},
{
child:[
{text:7,background:''},
{text:8,background:''},
{text:9,background:''},
]
},
{
child:[
{text:0,background:''},
{text:'.',background:''},
]
}
],
orderId:'',//订单Id
paydJumpUrl:'',//页面跳转路径
companyAttribute:'',//等于5时为出租车
timer:null,//定时器
extendInfo:''//额外信息
}
},
onLoad(option) {
//#ifdef MP-WEIXIN
this.enterUrl=option.q
this.payType = 42
//#endif
//#ifdef MP-ALIPAY
this.enterUrl=uni.getStorageSync("alipayQrCode")
uni.removeStorageSync('alipayQrCode')//临时解决出租车扫码之后跳转到组合票时,参数会有问题,有时间再根本解决
this.payType = 33
//#endif
if(this.enterUrl){//扫普通二维码进入
this.merchantId=this.getUrlKey("merchantId")
this.companyId=this.getUrlKey("companyId")
}else{//扫小程序二维码进入
this.merchantId=option.merchantId
this.companyId=option.companyId
}
if(uni.getStorageSync("openid")){
this.openid=uni.getStorageSync("openid")
this.getUserBrowse()
if (this.merchantId) { //大商家的有merchantId
//#ifdef MP-ALIPAY
this.enterUrl=uni.getStorageSync('alipayQrCode')
uni.removeStorageSync('alipayQrCode')//临时解决出租车扫码之后跳转到组合票时,参数会有问题,有时间再根本解决
this.payType = 33
//#endif
if(this.enterUrl){//扫普通二维码进入
this.merchantId=this.getUrlKey('merchantId')
this.companyId=this.getUrlKey('companyId')
this.extendInfo=this.getUrlKey('extendInfo')
}else{//扫小程序二维码进入
this.merchantId=option.merchantId
this.companyId=option.companyId
this.extendInfo=option.extendInfo
}
if(uni.getStorageSync('openid')){
this.openid=uni.getStorageSync('openid')
this.getUserBrowse()
if (this.merchantId) { //大商家的有merchantId
this.init()
} else { //小商家没有merchantId
} else { //小商家没有merchantId
this.initTwo()
}
this.initCoupon()
}else{
this.login()
}
},
// 一般页面用onUnload
// tabbar页面用onHide
onUnload() {
if(this.timer) {
clearTimeout(this.timer)
this.timer = null
}
},
methods: {
getUserBrowse(){//---获取浏览记录
}
this.initCoupon()
}else{
this.login()
}
},
// 一般页面用onUnload
// tabbar页面用onHide
onUnload() {
if(this.timer) {
clearTimeout(this.timer)
this.timer = null
}
},
methods: {
getUserBrowse(){//---获取浏览记录
let queryUrl=this.$commonjs.getCurrentPageUrl()
let data={
openid:uni.getStorageSync("openid") ,//用户Id
userName:"",//用户昵称
openid:uni.getStorageSync('openid') ,//用户Id
userName:'',//用户昵称
pageType:4,//页面类型(0首页,1商户页,2产品页,3售票页,4付款页,5付款完成页,6行记页,7评论页,8咨询页,9劵中心页,11订单页,12订单详情页,13IC卡出行页,14电子门票页,15常用信息页,16其他页)
queryUrl,//页面全地址
merchantType:""//商户类型1景区,2酒店,3餐饮,4特产
merchantType:''//商户类型1景区,2酒店,3餐饮,4特产
}
this.$request("wechatUser/wxUser/saveUserBrowse",data).then((res)=>{
this.$request('wechatUser/wxUser/saveUserBrowse',data).then((res)=>{
})
},
login(){//---登录
let _this=this
uni.getProvider({
service: 'oauth',
success(proRes){
uni.login({
},
login(){//---登录
let _this=this
uni.getProvider({
service: 'oauth',
success(proRes){
uni.login({
provider:proRes.provider[0],
success: function (res) {
if(res.code){
let source=""
if(proRes.provider[0]=="weixin"){
source=3
}else if(proRes.provider[0]=="alipay"){
source=4
}
let data={
code:res.code,
source,//微信小程序3,支付宝小程序4
companyId:uni.getStorageSync('enterOptions').query.companyId||'',
appid:uni.getStorageSync('appid')||''
}
_this.$request('wechat/wx/getUserInfoByCode',data).then(res => {
if(res.code=='00'){
_this.openid=res.data.openid
uni.setStorageSync('openid',_this.openid)
_this.getUserBrowse()
if (_this.merchantId) { //大商家的有merchantId
if(res.code){
let source=''
if(proRes.provider[0]=='weixin'){
source=3
}else if(proRes.provider[0]=='alipay'){
source=4
}
let data={
code:res.code,
source,//微信小程序3,支付宝小程序4
appid:uni.getStorageSync('appid')||''
}
if(uni.getStorageSync('enterOptions').query){
data.companyId=uni.getStorageSync('enterOptions').query.companyId||''
}
_this.$request('wechat/wx/getUserInfoByCode',data).then(res => {
if(res.code=='00'){
_this.openid=res.data.openid
uni.setStorageSync('openid',_this.openid)
_this.getUserBrowse()
if (_this.merchantId) { //大商家的有merchantId
_this.init()
} else { //小商家没有merchantId
} else { //小商家没有merchantId
_this.initTwo()
}
_this.initCoupon()
//用于获取token等信息
let userId=res.data.userId||""
let openid=res.data.openid||""
let datas={openid,source,userId}
_this.$request("wechatUser/login/findWxUserAndLogin",datas).then((res)=>{
if(res.code=="00"){
let token=res.data.token||""
uni.setStorageSync('token',token)
let createUserId=res.data.personId||""
uni.setStorageSync('createUserId',createUserId)
let userId=res.data.userId||""
uni.setStorageSync('userId',userId)
}
_this.initCoupon()
//用于获取token等信息
let userId=res.data.userId||''
let openid=res.data.openid||''
let datas={openid,source,userId}
_this.$request('wechatUser/login/findWxUserAndLogin',datas).then((res)=>{
if(res.code=='00'){
let token=res.data.token||''
uni.setStorageSync('token',token)
let createUserId=res.data.personId||''
uni.setStorageSync('createUserId',createUserId)
let userId=res.data.userId||''
uni.setStorageSync('userId',userId)
}else{
uni.showToast({
title:res.message,
icon:"none"
icon:'none'
})
}
}).catch((err)=>{
}).catch((err)=>{
uni.showToast({
title:"登录失败",
icon:"none"
title:'登录失败',
icon:'none'
})
_this.timer = setTimeout(() => {
_this.timer = setTimeout(() => {
_this.login()
}, 2000)
})
}else{
uni.showToast({
title:res.message,
icon:"none"
})
}
}).catch((err)=>{
}, 2000)
})
}else{
uni.showToast({
title:res.message,
icon:'none'
})
}
}).catch((err)=>{
uni.showToast({
title:"登录失败",
icon:"none"
title:'登录失败',
icon:'none'
})
_this.timer = setTimeout(() => {
_this.timer = setTimeout(() => {
_this.login()
}, 2000)
})
}
}, 2000)
})
}
}
})
}
})
},
getUrlKey(name){//---获取url
return(new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(decodeURIComponent(this.enterUrl)) || [, ""])[1].replace(/\+/g, '%20') || "";
},
clickNum(i,index,a) {//---输入数字
})
}
})
},
getUrlKey(name){//---获取url
return(new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(decodeURIComponent(this.enterUrl)) || [, ''])[1].replace(/\+/g, '%20') || ''
},
clickNum(i,index,a) {//---输入数字
this.buyMoney += i
this.leftList[index].child[a].background="#dddddd"
this.leftList[index].child[a].background='#dddddd'
setTimeout(()=>{
this.leftList[index].child[a].background=""
this.leftList[index].child[a].background=''
},200)
clearTimeout(this.flag)
this.flag = setTimeout(()=>{
this.initCoupon()
}, 1500)
},
clickEnter(){//---退格
this.buyMoney = this.buyMoney.substr(0, this.buyMoney.length - 1)
this.spaceBackground="#dddddd"
setTimeout(()=>{
this.spaceBackground=""
},200)
clearTimeout(this.flag)
this.flag = setTimeout(()=>{
},
clickEnter(){//---退格
this.buyMoney = this.buyMoney.substr(0, this.buyMoney.length - 1)
this.spaceBackground='#dddddd'
setTimeout(()=>{
this.spaceBackground=''
},200)
clearTimeout(this.flag)
this.flag = setTimeout(()=>{
this.initCoupon()
}, 1500)
},
couponChoose(data) { //---子组件券选择之后触发的事件
if(data){
this.chooseCouponObj = data
this.savedMoney=this.chooseCouponObj.savedMoney||0
}else{
this.chooseCouponObj = ""
this.savedMoney=0
}
}, 1500)
},
couponChoose(data) { //---子组件券选择之后触发的事件
if(data){
this.chooseCouponObj = data
this.savedMoney=this.chooseCouponObj.savedMoney||0
}else{
this.chooseCouponObj = ''
this.savedMoney=0
}
},
showCoupon() { //---展示券列表
},
showCoupon() { //---展示券列表
this.$refs.orderCoupon.showCoupon()
},
init() { //---初始化获取商家名称,大商家
},
init() { //---初始化获取商家名称,大商家
let data = {
"merchantId": this.merchantId,
"companyId": this.companyId,
'merchantId': this.merchantId,
'companyId': this.companyId,
}
uni.showLoading({title: '加载中',mask:true})
this.$request("scenic/order/findCodePayInfo",data).then((res) => {
this.$request('scenic/order/findCodePayInfo',data).then((res) => {
uni.hideLoading()
if (res.code =="00") {
if (res.code =='00') {
this.name = res.data.name
} else {
uni.showToast({
title:res.message,
icon:"none"
icon:'none'
})
}
}).catch((err)=>{
uni.hideLoading()
})
},
initTwo() { //---初始化获取商家名称,没有merchantId的小商家
},
initTwo() { //---初始化获取商家名称,没有merchantId的小商家
let data = {
"id": this.companyId,
'id': this.companyId,
}
uni.showLoading({title: '加载中',mask:true})
this.$request("user/company/detail", data).then((res) => {
this.$request('user/company/detail', data).then((res) => {
uni.hideLoading()
if (res.code=="00"){
if (res.code=='00'){
this.companyAttribute=res.data.companyVo.companyAttribute
this.paydJumpUrl=res.data.paydJumpUrl
if(this.companyAttribute==5){//出租车显示联系人姓名,其他显示公司名称
......@@ -355,17 +360,17 @@
} else {
uni.showToast({
title:res.message,
icon:"none"
})
icon:'none'
})
}
}).catch((err)=>{
uni.hideLoading()
})
},
initCoupon() { //---加载优惠券
},
initCoupon() { //---加载优惠券
let savedMoneyList = []
this.chooseCouponObj = ""
this.ableConpon = ""
this.chooseCouponObj = ''
this.ableConpon = ''
let data = {
money:parseFloat(this.buyMoney)||0, //订单总价,不算券,和现金红包
merchantId:this.merchantId, //商户Id
......@@ -373,8 +378,8 @@
orderSource:this.orderSource,//订单来源 8扫码支付
openid:this.openid
}
this.$request("wechatUser/myPage/usableCouponList",data).then((res) =>{
if (res.code == "00") {
this.$request('wechatUser/myPage/usableCouponList',data).then((res) =>{
if (res.code == '00') {
this.couponData = res.data
let masterSlaveCouponList=res.data.masterSlaveCouponList
if (masterSlaveCouponList&&masterSlaveCouponList.length>0) {
......@@ -388,7 +393,7 @@
if(arr.length==1){
this.chooseCouponObj=arr[0]
}else{
//如果数组有多个时
//如果数组有多个时
let index=arr.findIndex((item)=>{//如果有多个,找到是否有平台券,平台劵优先
return item.createSource==1
})
......@@ -410,42 +415,42 @@
}
}
})
},
clickPay(){//---点击立即支付,获取支付需要的参数
if (!parseFloat(this.buyMoney)) {
uni.showToast({
title:"请输入正确金额",
icon:"none"
})
return
}
let couponList = []
if (this.chooseCouponObj != '') {
},
clickPay(){//---点击立即支付,获取支付需要的参数
if (!parseFloat(this.buyMoney)) {
uni.showToast({
title:'请输入正确金额',
icon:'none'
})
return
}
let couponList = []
if (this.chooseCouponObj != '') {
if(this.chooseCouponObj.slaveList.length>0){//有从卷取值从卷,没有从卷取值主劵
couponList=[//券列表
{
couponId:this.chooseCouponObj.slaveCouponId,//券id
isMerchant:this.chooseCouponObj.slaveCreateSource,//是否是商户的券
myCouponId:this.chooseCouponObj.slaveId,//领取人编号
couponType:this.chooseCouponObj.couponType,//券类型
couponPrice:this.chooseCouponObj.savedMoney,//券价格
couponCompanyId:this.chooseCouponObj.companyId,//公司Id
couponType:this.chooseCouponObj.couponType,//券类型
couponPrice:this.chooseCouponObj.savedMoney,//券价格
couponCompanyId:this.chooseCouponObj.companyId,//公司Id
}
]
}else{
couponList=[
{
couponId:this.chooseCouponObj.couponId,//券id
isMerchant:this.chooseCouponObj.createSource,//是否是商户的券
myCouponId:this.chooseCouponObj.id,//领取人编号
couponId:this.chooseCouponObj.couponId,//券id
isMerchant:this.chooseCouponObj.createSource,//是否是商户的券
myCouponId:this.chooseCouponObj.id,//领取人编号
couponType:this.chooseCouponObj.couponType,//券类型
couponPrice:this.chooseCouponObj.savedMoney,//券价格
couponCompanyId:this.chooseCouponObj.companyId,//公司Id
couponCompanyId:this.chooseCouponObj.companyId,//公司Id
}
]
}
}
let data = {
}
let data = {
companyId: this.companyId,
merchantId: this.merchantId,
userId:this.openid,
......@@ -453,46 +458,47 @@
payType: this.payType, //支付类型,
orderSource:this.orderSource,//订单来源 8扫码支付
couponList,//券列表
}
this.payBackground="#cccccc"
//重新加载优惠券
this.initCoupon()
this.$request("orderc/order/codePay", data).then((res) => {
setTimeout(() => {
this.payBackground="#1dce2e"
},1000)
if(res.code=="00") {
if (res.data.errorMessage) {
uni.showToast({
title:res.data.errorMessage,
icon:"none"
})
return
}
this.orderId=res.data.id
//微信入参
this.signType = res.data.signType
this.paySign = res.data.sign
this.timeStamp = res.data.timestamp
this.nonceStr = res.data.noncestr
this.package = res.data.package
//支付宝入参
this.orderInfo = res.data.payInfo || ""
this.goPay()
} else {
uni.showToast({
title:res.message,
icon:"none"
})
}
}).catch((err) => {
this.payBackground="#1dce2e"
})
},
goPay(){//---去支付
let _this=this
// #ifdef MP-WEIXIN
uni.requestPayment({
extendInfo:this.extendInfo,//额外信息
}
this.payBackground='#cccccc'
//重新加载优惠券
this.initCoupon()
this.$request('orderc/order/codePay', data).then((res) => {
setTimeout(() => {
this.payBackground='#1dce2e'
},1000)
if(res.code=='00') {
if (res.data.errorMessage) {
uni.showToast({
title:res.data.errorMessage,
icon:'none'
})
return
}
this.orderId=res.data.id
//微信入参
this.signType = res.data.signType
this.paySign = res.data.sign
this.timeStamp = res.data.timestamp
this.nonceStr = res.data.noncestr
this.package = res.data.package
//支付宝入参
this.orderInfo = res.data.payInfo || ''
this.goPay()
} else {
uni.showToast({
title:res.message,
icon:'none'
})
}
}).catch((err) => {
this.payBackground='#1dce2e'
})
},
goPay(){//---去支付
let _this=this
// #ifdef MP-WEIXIN
uni.requestPayment({
provider: 'wxpay',
timeStamp:this.timeStamp,
nonceStr:this.nonceStr,
......@@ -500,79 +506,79 @@
signType:this.signType,
paySign:this.paySign,
success: function (res) {
if(_this.companyAttribute==5){//出租车跳转分销组合票页面
uni.navigateTo({
if(_this.companyAttribute==5){//出租车跳转分销组合票页面
uni.navigateTo({
url:_this.paydJumpUrl
})
}else{
uni.navigateTo({
url:"/pages/payment/paySuccess/paySuccess?orderId="+_this.orderId
})
}
})
}else{
uni.navigateTo({
url:'/pages/payment/paySuccess/paySuccess?orderId='+_this.orderId
})
}
},
fail: function (err) {
uni.showToast({
title:err.errMsg,
icon:"none"
})
title:err.errMsg,
icon:'none'
})
}
})
//#endif
})
//#endif
// #ifdef MP-ALIPAY
uni.requestPayment({
provider: 'alipay', // 服务提供商 支付宝支付: alipay 微信支付: wxpay
orderInfo: this.orderInfo, // 支付宝订单号
success: function (res) {
if(_this.companyAttribute==5){//出租车跳转分销组合票页面
uni.navigateTo({
// #ifdef MP-ALIPAY
uni.requestPayment({
provider: 'alipay', // 服务提供商 支付宝支付: alipay 微信支付: wxpay
orderInfo: this.orderInfo, // 支付宝订单号
success: function (res) {
if(_this.companyAttribute==5){//出租车跳转分销组合票页面
uni.navigateTo({
url:_this.paydJumpUrl
})
}else{
uni.navigateTo({
url:"/pages/payment/paySuccess/paySuccess?orderId="+_this.orderId
})
}
},
fail: function (err) {
uni.showToast({
title:err.errMsg,
icon:"none"
})
}
})
// #endif
}
},
watch: {
})
}else{
uni.navigateTo({
url:'/pages/payment/paySuccess/paySuccess?orderId='+_this.orderId
})
}
},
fail: function (err) {
uni.showToast({
title:err.errMsg,
icon:'none'
})
}
})
// #endif
}
},
watch: {
buyMoney(val, oldVal) {
if (val == "." && oldVal == "") { //首位数是小数点自动加上0
this.buyMoney = 0 + "."
if (val == '.' && oldVal == '') { //首位数是小数点自动加上0
this.buyMoney = 0 + '.'
}
if (val == "0" && oldVal == "") { //首位数是0自动加上小数点
this.buyMoney = 0 + "."
if (val == '0' && oldVal == '') { //首位数是0自动加上小数点
this.buyMoney = 0 + '.'
}
if (val.length == 2) { //防止回退之后出现01,02等状况
if (val.substr(0, 1) == 0 && val.substr(1, 2) != ".") {
if (val.length == 2) { //防止回退之后出现01,02等状况
if (val.substr(0, 1) == 0 && val.substr(1, 2) != '.') {
this.buyMoney = val.substr(1, 2)
}
}
if (isNaN(val) && val != ".") { //出现非数字,输入无效
}
if (isNaN(val) && val != '.') { //出现非数字,输入无效
this.buyMoney = oldVal
}
var x = String(this.buyMoney).indexOf('.') + 1; //小数点的位置
var y = String(this.buyMoney).length - x; //小数的位数
var x = String(this.buyMoney).indexOf('.') + 1 //小数点的位置
var y = String(this.buyMoney).length - x //小数的位数
if (y > 2 && x > 0) {
this.buyMoney = oldVal
}
if (parseFloat(this.buyMoney)) {
this.payBackground="#1dce2e"
} else {
this.payBackground="#cccccc"
}
if (parseFloat(this.buyMoney)) {
this.payBackground='#1dce2e'
} else {
this.payBackground='#cccccc'
}
}
}
}
}
}
</script>
<style lang="scss">
......
......@@ -37,7 +37,7 @@
}
this.ticketStatus()
intFun()
}, 1200)
}, 2000)
}
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