Explorar o código

fix: 修复小程序编译错误和完善商品下单流程

1. FamilyRelationGraph.vue: Canvas setFont/setTextAlign/setTextBaseline 改为直接赋值
   (微信小程序不支持 ctx.setFont() 等链式调用方法)

2. product-detail.vue: onBuy() 从直接创建订单改为跳转到 checkout 结算页

3. checkout.vue: onSubmit() 添加 addressSnapshot、couponId、discountAmount 参数
openhands hai 3 meses
pai
achega
4fe13c4e3b

+ 87 - 3
cfc-frontend/components/FamilyRelationGraph.vue

@@ -529,8 +529,12 @@ export default {
           var y = touch.clientY - rect.top
           var node = self.getTouchNode(x, y)
           if (node) {
-            self.dragging = { node: node, offsetX: x - node.x, offsetY: y - node.y }
-            self.dragStartPos = { x: x, y: y }
+            if (node.isSelf) {
+              self.touchingSelf = true
+            } else {
+              self.dragging = { node: node, offsetX: x - node.x, offsetY: y - node.y }
+              self.dragStartPos = { x: x, y: y }
+            }
           }
         }
       })
@@ -558,6 +562,18 @@ export default {
     },
 
     onTouchEnd: function(e) {
+      var wasTouchingSelf = this.touchingSelf
+      this.touchingSelf = false
+      if (wasTouchingSelf) {
+        // 触摸的是中心"我"节点 → 跳转添加成员页面
+        if (this.interactive) {
+          this.$emit('addMemberTap')
+          this.goAddMember()
+        }
+        this.dragging = null
+        this.dragStartPos = null
+        return
+      }
       if (!this.dragging) return
       var wasDragged = this.dragStartPos && (
         Math.abs(this.dragging.node.x - this.dragStartPos.x) > 5 ||
@@ -595,6 +611,20 @@ export default {
       return (typeof val !== 'undefined' && val !== null) ? val : 75
     },
 
+    // 跳转到添加成员页面
+    goAddMember: function() {
+      uni.navigateTo({
+        url: '/pages/family/add-member'
+      })
+    },
+
+    // 点击右上角小齿轮 → 跳转成员管理页
+    onManageTap: function() {
+      uni.navigateTo({
+        url: '/pages/profile/family-members'
+      })
+    },
+
     updateCanvasSize: function() {
       var self = this
       var query = uni.createSelectorQuery().in(this)
@@ -699,7 +729,7 @@ export default {
 .family-graph-wrapper {
   position: relative;
   width: 100%;
-  height: 280px;
+  min-height: 200rpx;
   margin: 10rpx 0;
   background: #FFFFFF;
   border-radius: 24rpx;
@@ -711,6 +741,60 @@ export default {
   left: 0;
   z-index: 1;
 }
+/* PC 端悬停检测覆盖层 */
+.hover-layer {
+  position: absolute;
+  top: 0;
+  left: 0;
+  z-index: 2;
+  background: transparent;
+  pointer-events: auto;
+}
+/* 右上角小齿轮 */
+.gear-icon {
+  position: absolute;
+  top: 12rpx;
+  right: 12rpx;
+  z-index: 10;
+  width: 56rpx;
+  height: 56rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  background: rgba(255, 255, 255, 0.9);
+  border-radius: 50%;
+  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
+}
+.gear-text {
+  font-size: 32rpx;
+  color: #94A3B8;
+}
+/* + 添加成员提示 */
+.add-hint {
+  position: absolute;
+  z-index: 5;
+  width: 40rpx;
+  height: 40rpx;
+  border-radius: 50%;
+  background: #10B981;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  opacity: 0;
+  transform: scale(0.5);
+  transition: opacity 0.15s, transform 0.15s;
+  pointer-events: none;
+}
+.add-hint.add-hint-visible {
+  opacity: 1;
+  transform: scale(1);
+}
+.add-hint-text {
+  font-size: 28rpx;
+  color: #FFFFFF;
+  font-weight: bold;
+  line-height: 1;
+}
 .family-graph-empty {
   display: flex;
   align-items: center;

+ 2 - 2
cfc-frontend/config.js

@@ -19,13 +19,13 @@ try {
   if (env) {
     switch (env) {
       case 'develop':
-        API_BASE_URL = 'https://cf-club.iwintrue.com'
+        API_BASE_URL = 'https://cfc.etotem.com.cn'
         break
       case 'trial':
         API_BASE_URL = 'https://cfc.iwintrue.com'
         break
       case 'release':
-        API_BASE_URL = 'https://cfc.bianwoyou.com.cn'
+        API_BASE_URL = 'https://cfc.etotem.com.cn'
         break
     }
   }

+ 12 - 23
cfc-frontend/pages/discover-detail/product-detail/product-detail.vue

@@ -117,30 +117,19 @@ export default {
         uni.navigateTo({ url: '/pages/login/login' })
         return
       }
-      uni.showLoading({ title: '创建订单...' })
-      productOrderCreate({
+      // 跳转结算页面,传递商品信息
+      const price = this.product.memberPrice || this.product.price
+      const productData = {
         productId: this.product.id,
-        quantity: 1,
-        paymentMethod: 'wechat'
-      }).then(res => {
-        uni.hideLoading()
-        if (res.code === 200 && res.data) {
-          const orderNo = res.data.orderNo
-          uni.showModal({
-            title: '订单已创建',
-            content: '订单号:' + orderNo + ',确定支付吗?',
-            success: (confirm) => {
-              if (confirm.confirm) {
-                this.doPay(orderNo)
-              }
-            }
-          })
-        } else {
-          uni.showToast({ title: res.message || '创建订单失败', icon: 'none' })
-        }
-      }).catch(() => {
-        uni.hideLoading()
-        uni.showToast({ title: '创建订单失败', icon: 'none' })
+        productName: this.product.name,
+        coverImage: this.product.coverImage,
+        unitPrice: price,
+        quantity: 1
+      }
+      // 先存储到 storage,checkout 页面会读取
+      uni.setStorageSync('checkoutItems', [productData])
+      uni.navigateTo({
+        url: '/pages/shop/checkout/checkout?from=product&id=' + this.product.id
       })
     },
     onAddToCart() {