From d8282a52cdfeea41d56ead4daec244dd65549bb6 Mon Sep 17 00:00:00 2001 From: yuanteng0011 <1876787513@qq.com> Date: Tue, 17 Dec 2024 10:52:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E4=BD=93=E7=B1=BB=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=8E=A5=E5=85=A5=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E5=AD=97=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 4 +- pages.json | 13 +- pages/home/home.vue | 66 +- pages/mine/main/main.vue | 690 +++++++++--------- pages/order/product-unpay/product-unpay.vue | 452 ------------ .../order/product-waitpay/product-waitpay.vue | 61 +- .../ProductDetails/ProductDetails.vue | 29 +- pages/store-home/main/main.vue | 5 +- 8 files changed, 474 insertions(+), 846 deletions(-) delete mode 100644 pages/order/product-unpay/product-unpay.vue diff --git a/main.js b/main.js index b2b3543..f028e15 100644 --- a/main.js +++ b/main.js @@ -1,15 +1,15 @@ // #ifndef VUE3 +import setFonts from './common/setFonts.js' import Vue from 'vue' import App from './App' -Vue.config.productionTip = false +Vue.config.productionTip = false App.mpType = 'app' const app = new Vue({ ...App }) app.$mount() - // #endif // #ifdef VUE3 diff --git a/pages.json b/pages.json index 722f957..d6e7d06 100644 --- a/pages.json +++ b/pages.json @@ -4,7 +4,9 @@ "path" : "pages/home/home", "style" : { - "navigationBarTitleText" : "" + "navigationBarTitleText" : "首页", + "enablePullDownRefresh":true, //开启下拉刷新 + "navigationBarBackgroundColor": "#ede8e7" } }, { @@ -73,7 +75,7 @@ } }, { - "path" : "pages/order/product-unpay/product-unpay", + "path" : "pages/order/product-paysuccess/product-paysuccess", "style" : { "navigationBarTitleText" : "" @@ -196,6 +198,13 @@ { "navigationBarTitleText" : "" } + }, + { + "path" : "pages/store-home/main/testMain", + "style" : + { + "navigationBarTitleText" : "" + } } ], "globalStyle": { diff --git a/pages/home/home.vue b/pages/home/home.vue index 5ef96e8..8b43920 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -1,7 +1,7 @@ diff --git a/pages/mine/main/main.vue b/pages/mine/main/main.vue index 46646c9..63cb483 100644 --- a/pages/mine/main/main.vue +++ b/pages/mine/main/main.vue @@ -1,357 +1,353 @@ \ No newline at end of file diff --git a/pages/order/product-unpay/product-unpay.vue b/pages/order/product-unpay/product-unpay.vue deleted file mode 100644 index 9f0ddba..0000000 --- a/pages/order/product-unpay/product-unpay.vue +++ /dev/null @@ -1,452 +0,0 @@ - - - - - diff --git a/pages/order/product-waitpay/product-waitpay.vue b/pages/order/product-waitpay/product-waitpay.vue index e923396..4a7879f 100644 --- a/pages/order/product-waitpay/product-waitpay.vue +++ b/pages/order/product-waitpay/product-waitpay.vue @@ -166,6 +166,7 @@ import {onMounted, ref, toRaw} from 'vue' import emitter from '../../../utils/emitter' import { onLoad , onShow } from "@dcloudio/uni-app"; import { baseUrl } from '../../../api/request'; +import addressComponentVue from '../component/addressComponent.vue'; //导入组件 //一些暂时变量 const num = ref(1) const price = ref(138) @@ -246,30 +247,19 @@ const createOrder = async () => { cookie: wx.getStorageSync('cookie') }, data: { - userId: userInfo.id, orderType: productArr.value[0].goodVO.isGoodType ? 'product' : 'service' , userName: userInfo.userName, - orderNumber: "null", addressId: addressRealInfo.value.id, //地址信息id // contactsId: null, //联系人信息id // couponId: null, //优惠卷id totalAmount: sumprice.value, //实付价格 - orderStatus: '待支付', note: note.value, orderItemMainInfoAddRequestList: toRaw(totalInfo.value) } }) - console.log('后台返回订单响应==>',resOrder); + console.log('后台返回订单响应==>',resOrder.data.data); if(resOrder.data.code === 1) { - uni.navigateTo({ - url: '/pages/mine/OrderDetails/OrderDetails' - }) - } else { - uni.showToast({ - icon: 'error', - title: "购买失败,请求错误" - }) - return; + wxPay(resOrder.data.data) } } //根据商品id和购买数量获取商品信息 @@ -306,7 +296,50 @@ const addNum =(index)=>{ sumprice.value += productArr.value[index].goodVO.price * 1 } } - +const wxPay = async( oid )=> { //传入订单id + try { + const res = await uni.request({ + url: baseUrl + '/wechat/payment/create', + method: 'POST', + header: { + 'cookie': wx.getStorageSync("cookie") + }, + data: { id: oid } + }) + const paymentData = res.data.data + wx.requestPayment({ + appid: paymentData.appId, + nonceStr: paymentData.nonceStr, + package: paymentData.packageVal, + paySign: paymentData.paySign, + timeStamp: paymentData.timeStamp, + signType: paymentData.signType, + success(res) { + uni.showModal({ + content: '支付成功', + showCancel: false + }) + uni.navigateTo({ + url: '/pages/order/product-paysuccess/product-paysuccess' + }) + console.log(res); + }, + fail(e) { + uni.showModal({ + content: '支付失败,原因为:' + e.errMsg, + showCancel: false + }) + console.log(e.errMsg); + } + }) + }catch(error) { + console.error('支付请求失败',error); + uni.showModal({ + content: '支付请求失败,请重试。', + showCancel: false + }) + } +}