diff --git a/uniapp_project_code/src/pages/index/index.vue b/uniapp_project_code/src/pages/index/index.vue index f350194..c9558c2 100644 --- a/uniapp_project_code/src/pages/index/index.vue +++ b/uniapp_project_code/src/pages/index/index.vue @@ -193,7 +193,7 @@ let skulist = await this.searchGoodBySku("10000012") this.shopList = this.shopList.concat(skulist) }, - clickToPay() { + async clickToPay() { // 将shopList进行精简为 { // "id": 57, // "name": "光明纯牛奶", @@ -224,7 +224,57 @@ if(this.shopListTotalPrice<=0){ return util.showNone("请先添加商品") } - util.routeTo(`/pages/pay/index?query=${JSON.stringify(_query)}`, 'rL'); + + 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'); + }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() { util.routeTo(`/pages/login/success`, 'nT'); diff --git a/uniapp_project_code/src/pages/pay/index.vue b/uniapp_project_code/src/pages/pay/index.vue index bc10389..03d69f3 100644 --- a/uniapp_project_code/src/pages/pay/index.vue +++ b/uniapp_project_code/src/pages/pay/index.vue @@ -82,7 +82,7 @@ async onReady() { await this.setPageHeight() // this.testAcceptScanCode() - this.preMakeOrder() + // this.preMakeOrder() //0627 根据客户反馈, 应在进入该页面时拿到order_id, 因为客户进入该页面时已准备好支付码 }, onUnload(){ this.clearMakeOrder() @@ -111,10 +111,11 @@ let _data = { goods_data:res.shopList, amount:res.shopListTotalPrice, + order_no :res.order_no } console.log("setPayData2:",_data) this.dataQuery = _data - + // this.makeInfo.order_no = res.order_no }, // 字符数字10,11,12,13,14,15开头是WECHAT_MICROPAY,28是ALI_BARCODEPAY getPayType(code){ @@ -157,9 +158,8 @@ // 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({ "order_no":order_no, pay_code,pay_type