Jelajahi Sumber

fix(shop): unify DanShop order operations — cancel/confirm/pay now route to DanShop API not CFC

- order-list: onPay() → navigate to payment page (DanShop flow)
  instead of calling CFC productOrderPay which had wrong order system
- order-list: onCancel() → danshopOrderCancel (DanShop) not productOrderCancel (CFC)
- order-list: onConfirm() → danshopOrderConfirm (DanShop) not productOrderConfirm (CFC)
- checkout: fix address selection eventChannel — both events{} and success{}
  callbacks now set selectedAddress (was empty stub, blocking order creation)

Co-authored-by: Sisyphus <sisyphus@ohmyopencode.dev>
liaoxg 3 bulan lalu
induk
melakukan
28cb33ac5f

+ 3 - 2
cfc-frontend/pages/shop/checkout/checkout.vue

@@ -148,16 +148,17 @@ export default {
       })
     },
     goSelectAddress() {
+      var self = this
       uni.navigateTo({
         url: '/pages/shop/address/address?selectMode=1',
         events: {
           onAddressSelect: function(data) {
-            // handled in event channel
+            self.selectedAddress = data
           }
         },
         success: function(res) {
           res.eventChannel.on('onAddressSelect', function(data) {
-            // This will use getApp() or global approach
+            self.selectedAddress = data
           })
         }
       })

+ 8 - 16
cfc-frontend/pages/shop/order-list/order-list.vue

@@ -58,7 +58,7 @@
               <button
                 v-if="item.status === 'pending'"
                 class="btn-small btn-pay"
-                @click.stop="onPay(item.orderNo)"
+                @click.stop="onPay(item.orderNo, item.totalAmount)"
               >支付</button>
               <button
                 v-if="item.status === 'paid'"
@@ -80,7 +80,7 @@
 </template>
 
 <script>
-import { danshopOrderList, productOrderPay, productOrderCancel, productOrderConfirm } from '@/utils/api.js'
+import { danshopOrderList, danshopOrderCancel, danshopOrderConfirm } from '@/utils/api.js'
 
 export default {
   data() {
@@ -165,18 +165,10 @@ export default {
     goDetail(orderNo) {
       uni.navigateTo({ url: '/pages/shop/order-detail/order-detail?orderNo=' + orderNo })
     },
-    onPay(orderNo) {
-      uni.showLoading({ title: '支付中...' })
-      productOrderPay({ orderNo }).then(res => {
-        uni.hideLoading()
-        if (res.code === 200) {
-          uni.showToast({ title: '支付成功', icon: 'success' })
-          this.onRefresh()
-        } else {
-          uni.showToast({ title: res.message || '支付失败', icon: 'none' })
-        }
-      }).catch(() => {
-        uni.hideLoading()
+    onPay(orderNo, amount) {
+      // Navigate to payment page — DanShop payment flow (same as checkout)
+      uni.navigateTo({
+        url: '/pages/shop/payment/payment?orderNo=' + orderNo + '&amount=' + (amount || 0)
       })
     },
     onCancel(orderNo) {
@@ -185,7 +177,7 @@ export default {
         content: '确定取消该订单吗?',
         success: (confirm) => {
           if (confirm.confirm) {
-            productOrderCancel({ orderNo }).then(res => {
+            danshopOrderCancel({ orderNo }).then(res => {
               if (res.code === 200) {
                 uni.showToast({ title: '订单已取消', icon: 'success' })
                 this.onRefresh()
@@ -198,7 +190,7 @@ export default {
       })
     },
     onConfirm(orderNo) {
-      productOrderConfirm({ orderNo }).then(res => {
+      danshopOrderConfirm({ orderNo }).then(res => {
         if (res.code === 200) {
           uni.showToast({ title: '订单已完成', icon: 'success' })
           this.onRefresh()