template:
<view style="margin-right: 10upx;">
<button v-if="isshow==0" @click="$noMultipleClicks(publish)" class="btn-or" style="width: 35vw;">支付并发布</button>
<button v-else @click="$noMultipleClicks(edit)" class="btn-or" style="width: 35vw;">编辑发布</button>
</view>
methods:
async publish() {
let that = this
// let id = localStorage.getItem('id')
// console.log(id)
console.log(that.id,'idddddd')
// return
console.log(that.type)
console.log(that.title)
console.log(that.info)
console.log(JSON.stringify(that.imgArr),'imgarr')
if(that.title == '' || that.info == '' || that.imgArr == ''){
showToast('不可为空哦');
return
}
// return
let params = {
'a_id': that.id,
'type': that.type,
'title': that.title,
'info': that.info,
'imgs': JSON.stringify(that.imgArr)
}
let request = await that.$api.myRequest({
url: '/api/activity_flow_user/add_item',
data: params,
})
console.log(request, '我是提交成功')
// if()
// if(request.surplus > 0){
// // showLoadingToast({
// // message: '此单将消耗您',
// // forbidClick: true,
// // });
// }else{
// }
let u = window.location.href
console.log(u)
let request1 = await that.$api.myRequest({
url: '/api/getwxconfig',
data: {
url: u
}
})
console.log(request1, 'share')
// console.log(that.title, 'thatjinxing')
// 微信分享授权
wx.config(request1.data)
let res = await that.$api.myRequest({
url: '/api/activity_flow_user/pay',
data: {
id: request.data
},
})
console.log(res,'ressssss pay isme')
if(res.msg == '支付成功'){ //走这一步是因为余额的money够支付的钱
showToast('余额支付成功');
setTimeout(()=>{
uni.navigateTo({
url:'/pages/list/detail-zhengji?id='+that.id
})
},1000)
return
}
wx.ready(function() {//不够需要支付
console.log('111')
wx.chooseWXPay({
// 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。
// 但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
timestamp: res.data.timeStamp,
// 支付签名随机串,不长于 32 位
nonceStr: res.data.nonceStr,
package: res.data.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
signType: res.data.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
paySign: res.data.paySign, // 支付签名
success: (res)=>{
console.log('success',res)
// 支付成功后的回调函数
uni.navigateTo({
url:'/pages/list/detail-zhengji?id='+that.id
})
},
fail: function(res) {
console.log('支付失败',res)
},
complete: function(res) {
console.log(res, 'complete')
}
})
})
// let res = await this.$api.myRequest({
// url: '/api/activity_flow_user/pay',
// data: {id:request.data},
// })
// wx.chooseWXPay({
// // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。
// // 但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
// timestamp: res.data.timeStamp,
// // 支付签名随机串,不长于 32 位
// nonceStr: res.data.nonceStr,
// package: res.data.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
// signType: res.data.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
// paySign: res.data.paySign, // 支付签名
// success: function(res) {
// // 支付成功后的回调函数
// },
// fail: function(res) {
// console.log('支付失败')
// },
// complete: function(res) {
// console.log(res, 'complete')
// }
// })
},