ext.liuqiwen3 4 dní pred
rodič
commit
a4f0436112

+ 1 - 2
components/productWindow/index.vue

@@ -25,7 +25,7 @@
             >附加费: {{ attr.productSelect.additionalAmount || "0" }}元</text
             >
           </view>
-          <view class="font-color" >
+          <view class="font-color" style="display: flex;align-items: center;margin-top: 24rpx;" >
             <view class="carnum acea-row row-left">
               <view
                   class="item reduce"
@@ -409,7 +409,6 @@ function getCheckedValue() {
   }
   .carnum {
     height: 54rpx;
-    margin-top: 24rpx;
     border: 2rpx solid #DCDFE6;
     display: inline-flex;
 

+ 2 - 0
pages/goods/goods_details/index.vue

@@ -1305,10 +1305,12 @@ function setCollect () {
     if (userCollect.value) {
       collectDel(productInfo.value.id).then(res => {
         userCollect.value = !userCollect.value;
+        uni.showToast({title:'取消收藏成功',icon:'none'})
       })
     } else {
       collectAdd(productInfo.value.id).then(res => {
         userCollect.value = !userCollect.value;
+        uni.showToast({title:'收藏成功',icon:'none'})
       })
     }
   }

+ 1 - 1
pages/goods_cate/goods_cate.vue

@@ -68,7 +68,7 @@ const getAllCategory = async () => {
   try {
     let obj = {
       type: 1,
-      status: -1
+      status: 1
     }
     const { data }= await productCategory(obj);
     const newArr = []

+ 1 - 1
pages/index/index.vue

@@ -456,7 +456,7 @@ onReachBottom(() => {
 });
 // Product Details
 const goDetail = async (item) => {
-  await goShopDetail(item, uid);
+  // await goShopDetail(item, uid);
   uni.navigateTo({ url: `/pages/goods/goods_details/index?id=${item.id}` });
 };
 function getAllCategory () {

+ 1 - 1
pages/merchantCenters/components/merchant_cate.vue

@@ -68,7 +68,7 @@ const getAllCategory = async () => {
   try {
     let obj = {
       type: 1,
-      status: -1
+      status: 1
     }
     const { data }= await productCategory(obj);
     const newArr = []

+ 0 - 1
pages/merchantCenters/merchant.vue

@@ -223,7 +223,6 @@ const makePhoneCall = () => {
   });
 };
 const goDetail = async (item) => {
-  await goShopDetail(item, uid);
   uni.navigateTo({ url: `/pages/goods/goods_details/index?id=${item.id}` });
 };
 </script>

+ 72 - 61
pages/order_addcart/order_addcart.vue

@@ -77,23 +77,23 @@
                                 <view v-if="item.attrStatus">
                                   <view
                                       class="carnum acea-row row-center-wrapper"
-                                      v-if="item.editNum"
+                                      v-show="item.editNum"
                                   >
                                     <view
                                         class="reduce"
                                         :class="item.numSub ? 'on' : ''"
-                                        @click.stop="subCart(index)"
+                                        @click.stop="subCart(item.id, merchantIndex, index)"
                                     >-</view
                                     >
                                     <view class="num">{{ item.cartNum }}</view>
                                     <view
                                         class="plus"
                                         :class="item.numAdd ? 'on' : ''"
-                                        @click.stop="addCart(index)"
+                                        @click.stop="addCart(item.id, merchantIndex, index)"
                                     >+</view
                                     >
                                   </view>
-                                  <view class="carnumTag" v-if="!item.editNum" @click.stop="item.editNum = true">
+                                  <view class="carnumTag" v-show="!item.editNum" @click.stop="item.editNum = true">
                                     X{{ item.cartNum }}
                                   </view>
                                 </view>
@@ -337,7 +337,7 @@
       @submit="handleSubmit"
       @myevent="onMyEvent"
       @ChangeAttr="ChangeAttr"
-      @ChangeCartNum="ChangeCartNum"
+      @ChangeCartNum="ChangeCartNumFn"
       @attrVal="attrVal"
       @iptCartNum="iptCartNum"
       id="product-window"
@@ -453,9 +453,10 @@ onShow(() => {
     hotLimit.value = 10;
     cartList.valid = [];
     cartList.invalid = [];
-    isAllSelect.value = false;
-    selectValue.value = [];
-    selectCountPrice.value = 0.0;
+    // 不要重置选中状态
+    // isAllSelect.value = false;
+    // selectValue.value = [];
+    // selectCountPrice.value = 0.0;
     cartCount.value = 0;
     isShowAuth.value = false;
   }
@@ -703,7 +704,7 @@ function attrVal(val) {
     attr.productAttr[val.indexw].attrValues[val.indexn];
 }
 
-function ChangeCartNum(changeValue) {
+function ChangeCartNumFn(changeValue) {
   let productSelect = productValue.value[attrValue.value];
   if (productSelect === undefined && !attr.productAttr.length)
     productSelect = attr.productSelect;
@@ -912,36 +913,15 @@ function setAllSelectValue(status) {
 
 function checkboxChange(value) {
   const valid = cartList.valid;
-  let checkedItems = [];
-  let uncheckedItems = [];
-  let invalidItems = [];
 
+  // 更新所有商品的选中状态
   valid.forEach(item => {
-    if (value.includes(item.id)) {
-      if (footerswitch.value) {
-        if (item.attrStatus) {
-          item.checked = true;
-          checkedItems.push(item);
-        } else {
-          item.checked = false;
-        }
-      } else {
-        item.checked = true;
-        checkedItems.push(item);
-      }
-    } else {
-      item.checked = false;
-      uncheckedItems.push(item);
-    }
+    item.checked = value.includes(item.id);
   });
 
-  if (footerswitch.value) {
-    invalidItems = uncheckedItems.filter(item => !item.attrStatus);
-  }
-
   cartList.valid = [...valid];
-  // isAllSelect.value = valid.length === checkedItems.length + invalidItems.length;
   selectValue.value = value;
+
   // 计算全选状态
   if (footerswitch.value) {
     // 结算模式下,只计算有效商品
@@ -967,19 +947,33 @@ function switchSelect() {
   const validList = cartList.valid;
   const selectValueArr = selectValue.value;
   let selectCount = 0.0;
+
+  console.log('switchSelect called', {
+    validListLength: validList.length,
+    selectValueArrLength: selectValueArr.length,
+    selectValueArr: selectValueArr
+  });
+
   if (selectValueArr.length < 1) {
-    selectCountPrice.value = selectCount;
+    selectCountPrice.value = '0.00';
   } else {
     for (let index in validList) {
       if (inArray(validList[index].id, selectValueArr)) {
-        selectCount = util.$h.Add(
-          selectCount,
-          util.$h.Mul(validList[index].cartNum, validList[index].storePrice)
-        );
+        console.log('Calculating item:', {
+          id: validList[index].id,
+          cartNum: validList[index].cartNum,
+          storePrice: validList[index].storePrice,
+          checked: validList[index].checked
+        });
+        const itemTotal = util.$h.Mul(validList[index].cartNum, validList[index].storePrice);
+        selectCount = util.$h.Add(selectCount, itemTotal);
       }
     }
-    selectCountPrice.value = selectCount;
+    // 保留两位小数
+    selectCountPrice.value = selectCount.toFixed(2);
   }
+
+  console.log('Final selectCountPrice:', selectCountPrice.value);
 }
 
 function iptCartNumInput(index) {
@@ -997,10 +991,11 @@ function blurInput(index) {
   }
 }
 
-function subCart(index) {
+function subCart(cartIdVal, merchantIndex, productIndex) {
+  const item = groupedCartList.value[merchantIndex].products[productIndex];
   let status = false;
-  const item = cartList.valid[index];
   item.cartNum = Number(item.cartNum) - 1;
+
   if (item.cartNum < 1) status = true;
   if (item.cartNum <= 1) {
     item.cartNum = 1;
@@ -1009,18 +1004,20 @@ function subCart(index) {
     item.numSub = false;
     item.numAdd = false;
   }
+
   if (false == status) {
     setCartNum(item.id, item.cartNum, function (data) {
-      cartList.valid[index] = item;
       switchSelect();
       getCartNum();
     });
   }
 }
 
-function addCart(index) {
-  const item = cartList.valid[index];
+function addCart(cartIdVal, merchantIndex, productIndex) {
+  console.log(cartIdVal)
+  const item = groupedCartList.value[merchantIndex].products[productIndex];
   item.cartNum = Number(item.cartNum) + 1;
+
   if (item.cartNum >= item.stock) {
     item.cartNum = item.stock;
     item.numAdd = true;
@@ -1029,8 +1026,9 @@ function addCart(index) {
     item.numAdd = false;
     item.numSub = false;
   }
+
   setCartNum(item.id, item.cartNum, function (data) {
-    cartList.valid[index] = item;
+    // 更新UI
     switchSelect();
     getCartNum();
   });
@@ -1051,16 +1049,24 @@ function getCartNum() {
 function getCartData(data) {
   return new Promise((resolve, reject) => {
     getCartList(data)
-      .then((res) => {
-        resolve(res.data);
-      })
-      .catch(function (err) {
-        loading.value = false;
-        canShow.value = true;
-        Toast({
-          title: err,
+        .then((res) => {
+          // 加载数据后,同步选中状态
+          const data = res.data;
+          if (data.list && data.list.length > 0) {
+            data.list.forEach(item => {
+              // 如果这个商品ID在选中列表中,设置checked为true
+              item.checked = selectValue.value.includes(item.id);
+            });
+          }
+          resolve(data);
+        })
+        .catch(function (err) {
+          loading.value = false;
+          canShow.value = true;
+          Toast({
+            title: err,
+          });
         });
-      });
   });
 }
 
@@ -1084,6 +1090,7 @@ async function getCartListFn() {
       let valid = cartListData.list;
       let validList = [...cartList.valid, ...valid];
       let selectValueArr = [];
+
       if (validList.length > 0) {
         for (let index in validList) {
           // 购物车加减状态
@@ -1106,9 +1113,13 @@ async function getCartListFn() {
 
           // attrStatus 判断商品是否有效
           if (validList[index].attrStatus) {
-            // validList[index].checked = true;
-            // selectValueArr.push(validList[index].id);
-            validList[index].checked = false;
+            // 关键修改:根据 selectValue 中的ID来设置选中状态
+            if (selectValue.value.includes(validList[index].id)) {
+              validList[index].checked = true;
+              selectValueArr.push(validList[index].id);
+            } else {
+              validList[index].checked = false;
+            }
           } else {
             validList[index].checked = false;
           }
@@ -1116,12 +1127,12 @@ async function getCartListFn() {
       }
       cartList.valid = validList;
       data.page += 1;
-      selectValue.value = selectValueArr;
+      // 不要重置 selectValue,保持原来的选中状态
+      // selectValue.value = selectValueArr;
+
       let newArr = validList.filter((item) => item.attrStatus);
       // 全选状态
-      // isAllSelect.value =
-        // newArr.length == selectValueArr.length && newArr.length;
-      isAllSelect.value = false;
+      isAllSelect.value = newArr.length > 0 && selectValue.value.length === newArr.length;
       switchSelect();
     }
     loading.value = false;

+ 8 - 5
pages/users/user_address/index.vue

@@ -67,9 +67,9 @@
           </view>
         </view>
         <view class="default acea-row row-middle borRadius14">
-          <checkbox-group @change="ChangeIsDefault">
-            <checkbox :checked="userAddress.isDefault" />设置为默认地址
-          </checkbox-group>
+          <up-checkbox-group @change="ChangeIsDefault" shape="circle" class="check-box">
+            <up-checkbox :checked="userAddress.isDefault" activeColor="#F8C008" />设置为默认地址
+          </up-checkbox-group>
         </view>
 
         <button class="keepBnt bg-color" form-type="submit">立即保存</button>
@@ -491,8 +491,8 @@ function ChangeIsDefault() {
   line-height: 86rpx;
   margin: 0 auto;
   font-size: 32rpx;
-  color: #e93323;
-  border: 1px solid #e93323;
+  color: #F8C008;
+  border: 1px solid #F8C008;
 }
 
 .relative {
@@ -515,4 +515,7 @@ function ChangeIsDefault() {
   // background-color: #E93323;
   height: var(--status-bar-height);
 }
+:deep(.u-checkbox-group){
+  align-items: center;
+}
 </style>

+ 50 - 29
pages/users/user_address_list/index.vue

@@ -13,10 +13,12 @@
       class="address-management"
       :class="addressList.length < 1 && page > 1 ? 'fff' : ''"
     >
-      <radio-group
+      <up-radio-group
         class="radio-group"
         @change="radioChange"
         v-if="addressList.length"
+        activeColor="#F8C008"
+        v-model="currentCheckedValue"
       >
         <view
           class="item borRadius14"
@@ -35,18 +37,18 @@
           </view>
           <view class="operation acea-row row-between-wrapper">
             <!-- #ifndef MP -->
-            <radio
+            <up-radio
               class="radio"
               :value="index.toString()"
-              :checked="item.isDefault"
+              :name="item.id"
             >
               <text>设为默认</text>
-            </radio>
+            </up-radio>
             <!-- #endif -->
             <!-- #ifdef MP -->
-            <radio class="radio" :value="index" :checked="item.isDefault">
+            <up-radio class="radio" :name="item.id">
               <text>设为默认</text>
-            </radio>
+            </up-radio>
             <!-- #endif -->
             <view class="acea-row row-middle">
               <view @click="editAddressFn(item.id)"
@@ -58,7 +60,7 @@
             </view>
           </view>
         </view>
-      </radio-group>
+      </up-radio-group>
       <view
         class="loadingicon acea-row row-center-wrapper"
         v-if="addressList.length"
@@ -144,6 +146,7 @@ const secKill = ref(false);
 const preOrderNo = ref(0);
 const isFlashSale = ref(false); // 是否为秒杀订单
 const isGroupBuy = ref(false); // 是否为团购订单
+const currentCheckedValue = ref("");
 
 watch(
   () => appStore.isLogin,
@@ -302,6 +305,17 @@ function getAddressListFn(isPage) {
       let list = res.data.list;
       let isLoadend = list.length < limit.value;
       addressList.value = [...addressList.value, ...list];
+
+      const defaultAddress = addressList.value.find(item => item.isDefault);
+      console.log(defaultAddress)
+      if (defaultAddress) {
+        currentCheckedValue.value = defaultAddress.id;
+      } else if (addressList.value.length > 0) {
+        // 如果没有默认地址,选择第一个
+        currentCheckedValue.value = newList[0].id;
+      }
+      console.log('currentCheckedValue.value',currentCheckedValue.value)
+
       loadend.value = isLoadend;
       loadTitle.value = isLoadend ? "我也是有底线的" : "加载更多";
       page.value = page.value + 1;
@@ -315,29 +329,35 @@ function getAddressListFn(isPage) {
 
 // 设置默认地址
 function radioChange(e) {
-  let index = parseInt(e.detail.value);
-  let address = addressList.value[index];
-  if (address == undefined) return Toast({ title: "您设置的默认地址不存在!" });
-  setAddressDefault(address.id)
-    .then(() => {
-      addressList.value.forEach((item, i) => {
-        item.isDefault = i === index;
-      });
-      Toast(
-        {
-          title: "设置成功",
-          icon: "success",
-        },
-        () => {
-          addressList.value = [...addressList.value];
-        }
-      );
-    })
-    .catch((err) => {
-      return Toast({
-        title: err,
+  const addressId = e.detail.value; // 现在是地址ID
+  const address = addressList.value.find(item => item.id === addressId);
+  if (!address) return Toast({ title: "您设置的默认地址不存在!" });
+
+  setAddressDefault(addressId)
+      .then(() => {
+        // 更新所有地址的isDefault状态
+        addressList.value.forEach(item => {
+          item.isDefault = item.id === addressId;
+        });
+
+        // 更新当前选中的值
+        currentCheckedValue.value = addressId;
+
+        Toast(
+            {
+              title: "设置成功",
+              icon: "success",
+            },
+            () => {
+              addressList.value = [...addressList.value];
+            }
+        );
+      })
+      .catch((err) => {
+        return Toast({
+          title: err,
+        });
       });
-    });
 }
 
 // 编辑地址
@@ -442,6 +462,7 @@ onReachBottom(() => {
   background-color: #fff;
   padding: 0 20rpx;
   margin-bottom: 20rpx;
+  width: 100%;
 }
 
 .address-management .item .address {