Browse Source

update pay step,do makeOrder before pay

dev
赵明涛 7 months ago
parent
commit
4a23eb8c71
  1. 52
      uniapp_project_code/src/pages/index/index.vue
  2. 10
      uniapp_project_code/src/pages/pay/index.vue

52
uniapp_project_code/src/pages/index/index.vue

@ -193,7 +193,7 @@
let skulist = await this.searchGoodBySku("10000012") let skulist = await this.searchGoodBySku("10000012")
this.shopList = this.shopList.concat(skulist) this.shopList = this.shopList.concat(skulist)
}, },
clickToPay() {
async clickToPay() {
// shopList { // shopList {
// "id": 57, // "id": 57,
// "name": "", // "name": "",
@ -224,7 +224,57 @@
if(this.shopListTotalPrice<=0){ if(this.shopListTotalPrice<=0){
return util.showNone("请先添加商品") return util.showNone("请先添加商品")
} }
util.showLoad()
await this.makeOrder(_query).then((order_res)=>{
util.hideLoad()
if(order_res.order_no){
_query["order_no"]=order_res.order_no
util.routeTo(`/pages/pay/index?query=${JSON.stringify(_query)}`, 'rL'); util.routeTo(`/pages/pay/index?query=${JSON.stringify(_query)}`, 'rL');
}else{
util.showNone(order_res.message||order_res.msg||"error:生成订单失败")
}
console.log(order_res)
}).catch((err)=>{
util.hideLoad()
console.log(err)
util.showNone(err)
})
},
async makeOrder(res){
let {brand_id,token} = getApp().globalData.accountInfo
let store_id = uni.getStorageSync("stadiumInfo").id||""
let _dataQuery = {
goods_data:res.shopList,
amount:res.shopListTotalPrice,
}
let {goods_data,amount} = _dataQuery
brand_id = parseInt(brand_id)
amount = parseFloat(amount)
let urlParams = {
store_id,brand_id,token,amount,
"goods_data": goods_data,
"pay_type": 7,
"other_pay_type":"付款码支付",
"card_no": "",
"mark": ""
}
console.log("makeOrder urlParams:", urlParams)
return ox.post({
url: API.makeOrder,
data: urlParams,
isDefaultGet: true,
failMsg: '操作失败!'
})
.then(res => {
util.hideLoad();
console.log("makeOrder suc: ", res)
return res
})
}, },
clickToUse() { clickToUse() {
util.routeTo(`/pages/login/success`, 'nT'); util.routeTo(`/pages/login/success`, 'nT');

10
uniapp_project_code/src/pages/pay/index.vue

@ -82,7 +82,7 @@
async onReady() { async onReady() {
await this.setPageHeight() await this.setPageHeight()
// this.testAcceptScanCode() // this.testAcceptScanCode()
this.preMakeOrder()
// this.preMakeOrder() //0627 , order_id,
}, },
onUnload(){ onUnload(){
this.clearMakeOrder() this.clearMakeOrder()
@ -111,10 +111,11 @@
let _data = { let _data = {
goods_data:res.shopList, goods_data:res.shopList,
amount:res.shopListTotalPrice, amount:res.shopListTotalPrice,
order_no :res.order_no
} }
console.log("setPayData2:",_data) console.log("setPayData2:",_data)
this.dataQuery = _data this.dataQuery = _data
// this.makeInfo.order_no = res.order_no
}, },
// 101112131415WECHAT_MICROPAY,28ALI_BARCODEPAY // 101112131415WECHAT_MICROPAY,28ALI_BARCODEPAY
getPayType(code){ getPayType(code){
@ -157,9 +158,8 @@
// pay_code,pay_type // pay_code,pay_type
// }) // })
// }) // })
let order_no = this.makeInfo?.order_no||""
if(!order_no)return util.showNone("支付失败,请重新下单!")
let order_no = this.dataQuery?.order_no||""
if(!order_no)return util.showNone("支付失败,请重新下单!01")
await this.payOrder({ await this.payOrder({
"order_no":order_no, "order_no":order_no,
pay_code,pay_type pay_code,pay_type

Loading…
Cancel
Save