فهرست منبع

页面优化与问题解决

shizhongqi 11 ماه پیش
والد
کامیت
0c12c46463

+ 7 - 7
hdApp/src/admin/chat/chatPage.vue

@@ -50,7 +50,7 @@
                   <!-- <view class="sales-info">
                     <text class="delivery-time">48小时发</text>
                   </view> -->
-                  <text v-if="message.goodsInfo.goodsPriceType == 1" class="goods-price">¥{{ message.goodsInfo.goodsPrice }}</text>
+                  <text v-if="message.goodsInfo.goodsPriceType == 1" class="goods-price">¥{{ parseFloat(message.goodsInfo.goodsPrice).toFixed(2) }}</text>
                 </view>
               </view>
               <view class="goods-footer">
@@ -67,7 +67,7 @@
               <!-- 报价类型显示重新报价 -->
               <view v-if="message.goodsInfo.goodsPriceType == 2 && isExpired(message.timestamp)" class="action-buttons">
                 <form @submit.prevent="createQrotedPrice(message)">
-                  <text class="goods-price" v-if="message.goodsInfo.lastPrice || message.goodsInfo.goodsPrice">¥{{message.goodsInfo.lastPrice || message.goodsInfo.goodsPrice}}</text>
+                  <text class="goods-price" v-if="message.goodsInfo.lastPrice || message.goodsInfo.goodsPrice">¥{{parseFloat(message.goodsInfo.lastPrice || message.goodsInfo.goodsPrice).toFixed(2)}}</text>
                   <input class="price-input" type="number" v-model="message.quotedPrice" placeholder="输入价格" />
                   <button class="action-btn buy-btn" form-type="submit">重新报价</button>
                 </form>
@@ -104,7 +104,7 @@
                   <view class="sales-info">
                     <!-- <text class="delivery-time">48小时发</text> -->
                   </view>
-                  <text v-if="message.goodsInfo.goodsPriceType == 1" class="goods-price">¥{{ message.goodsInfo.goodsPrice }}</text>
+                  <text v-if="message.goodsInfo.goodsPriceType == 1" class="goods-price">¥{{ parseFloat(message.goodsInfo.goodsPrice).toFixed(2) }}</text>
                 </view>
               </view>
               <view class="goods-footer">
@@ -204,7 +204,7 @@ export default {
       isKeyboardShow: false, // 键盘是否显示
       inputFocus: false, // 输入框焦点
       isInputFocused: false, // 标记输入框是否聚焦
-      expireTime: 12 * 60 * 60, // 商品报价有效窗口时长 -- 12小时
+      expireTime: 23 * 60 * 60, // 商品报价有效窗口时长 -- 23小时
     };
   },
   onLoad(options) {
@@ -1017,14 +1017,14 @@ export default {
       // console.log("createPrice", message)
       createQuotedPrice({
         key: message.goodsInfo.key,
-        price: message.quotedPrice,
+        price: parseFloat(message.quotedPrice).toFixed(2),
       }).then(res => {
         // console.log("createQuotedPrice", res)
         if (res.code == 1) {
           this.$msg("报价成功")
           message.goodsInfo.goodsPriceType = 2;
-          message.goodsInfo.goodsPrice = message.quotedPrice;
-          message.goodsInfo.lastPrice = message.quotedPrice;
+          message.goodsInfo.goodsPrice = parseFloat(message.quotedPrice).toFixed(2);
+          message.goodsInfo.lastPrice = parseFloat(message.quotedPrice).toFixed(2);
           message.quotedPrice = '';
           this.sendMessageOfGoodsPrice(message.goodsInfo)
         }

+ 28 - 1
hdApp/src/utils/format.js

@@ -36,6 +36,7 @@ function formatLocation(longitude, latitude) {
 		latitude: latitude.toString().split('.')
 	}
 }
+
 var dateUtils = {
 	UNITS: {
 		'年': 31557600000,
@@ -73,8 +74,34 @@ var dateUtils = {
 	}
 }
 
+/**
+ * 格式化价格为两位小数
+ * @param {number|string} price - 需要格式化的价格
+ * @param {number} decimals - 小数位数,默认为2
+ * @returns {string} 格式化后的价格字符串
+ */
+function formatPrice(price, decimals = 2) {
+	// 输入验证
+	if (price === null || price === undefined || price === '') {
+		return '0.00';
+	}
+
+	// 转换为数字
+	const numPrice = typeof price === 'string' ? parseFloat(price) : price;
+
+	// 检查是否为有效数字
+	if (isNaN(numPrice)) {
+		console.warn('formatPrice: Invalid price value:', price);
+		return '0.00';
+	}
+
+	// 格式化为指定小数位数
+	return numPrice.toFixed(decimals);
+}
+
 module.exports = {
 	formatTime: formatTime,
 	formatLocation: formatLocation,
-	dateUtils: dateUtils
+	dateUtils: dateUtils,
+	formatPrice: formatPrice
 }

+ 10 - 8
mallApp/src/pages/chat/chatPage.vue

@@ -52,19 +52,21 @@
                   <!-- <view class="sales-info">
                     <text class="delivery-time">48小时发</text>
                   </view> -->
-                <!-- 2 是报价类型,专门为报价类型使用 -->
-                  <text v-if="message.goodsInfo.goodsPriceType == 2" class="goods-price">¥{{ message.goodsInfo.goodsPrice }}</text>
+                  <!-- 2 是报价类型,专门为报价类型使用 -->
+                  <text v-if="message.goodsInfo.goodsPriceType == 2" class="goods-price">¥{{ parseFloat(message.goodsInfo.goodsPrice).toFixed(2) }}</text>
                 </view>
               </view>
+
               <view class="goods-footer">
               </view>
+              
               <view v-if="message.goodsInfo.goodsPriceType == 2" class="action-buttons">
                 <button class="action-btn spec-btn" @click="toBuy(message.goodsInfo)">查看商品</button>
                 <button class="action-btn buy-btn" @click="toBuy(message.goodsInfo)">去购买</button>
               </view>
-              <view v-else>
+              <view v-else class="action-buttons">
                 <button class="action-btn spec-btn" @click="toGoodsDetail(message.goodsInfo)">查看商品</button>
-                <text>报价 {{ message.goodsInfo.goodsInfo.price }}</text>
+                <button v-if="message.goodsInfo.goodsPriceType == 1" class="action-btn buy-btn" @click="toBuy(message.goodsInfo)">去购买</button>
               </view>
             </view>
             <view class="message-time align-right">{{ message.time }}</view>
@@ -98,7 +100,7 @@
                   <view class="sales-info">
                     <!-- <text class="delivery-time">48小时发</text> -->
                   </view>
-                  <text v-if="message.goodsInfo.goodsPriceType == 1" class="goods-price">¥{{ message.goodsInfo.goodsPrice }}</text>
+                  <text v-if="message.goodsInfo.goodsPriceType == 1" class="goods-price">¥{{ parseFloat(message.goodsInfo.goodsPrice).toFixed(2) }}</text>
                 </view>
               </view>
               <view class="goods-footer">
@@ -132,7 +134,7 @@
         <image class="goods-image" :src="currentGoodsInfo.goodsImg" mode="aspectFill" />
         <view class="goods-details">
           <text class="goods-name">{{ currentGoodsInfo.goodsName }}</text>
-          <text v-if="currentGoodsInfo.goodsPriceType == 1" class="goods-price">¥{{ currentGoodsInfo.goodsPrice }}</text>
+          <text v-if="currentGoodsInfo.goodsPriceType == 1" class="goods-price">¥{{ parseFloat(currentGoodsInfo.goodsPrice).toFixed(2) }}</text>
         </view>
         <view class="goods-actions">
           <view class="close-icon" @click="closeGoodsCard">
@@ -1091,7 +1093,7 @@ export default {
               if (res.code == 1) {
                 if (res.data.price != -1) {
                   parsed.goodsPriceType = 2; // 报价类型
-                  parsed.goodsPrice = res.data.price;
+                  parsed.goodsPrice = parseFloat(res.data.price).toFixed(2);
                 }
               }
             }).catch(err => {
@@ -1146,7 +1148,7 @@ export default {
       const categoryId = parseInt(goodsInfo.categoryId);
       const hdId = parseInt(goodsInfo.hdId);
       const account = parseInt(goodsInfo.account);
-      const price = parseFloat(goodsInfo.goodsPrice);
+      const price = parseFloat(goodsInfo.goodsPrice).toFixed(2);
       const priceType = goodsInfo.goodsPriceType;
       if (isNaN(goodsId) || isNaN(categoryId) || isNaN(hdId) || isNaN(account) || isNaN(price)) {
         this.$msg("商品数据异常");

+ 47 - 37
mallApp/src/pages/goods/components/sel-popup.vue

@@ -8,22 +8,25 @@
             <div class="tui-number-box tui-bold tui-attr-title">
               <div class="tui-attr-title">数量</div>
               <div class="number-box-wrapper">
-                <number-box 
-                  :max="maxStock" 
-                  :min="1" 
-                  :value="buyNum" 
-                  :iconSize="36" 
-                  :height="60" 
-                  :width="120" 
+                <number-box
+                  :max="maxStock"
+                  :min="1"
+                  :value="buyNum"
+                  :iconSize="36"
+                  :height="60"
+                  :width="120"
                   :size="32"
-                  @change="change">
+                  @change="change"
+                >
                 </number-box>
               </div>
             </div>
           </div>
         </scroll-view>
         <div class="tui-popup-btn">
-          <button class="button-com red enhanced-btn" @click="nextFn">下一步</button>
+          <button class="button-com red enhanced-btn" @click="nextFn">
+            下一步
+          </button>
         </div>
       </div>
     </bottom-popup>
@@ -38,41 +41,41 @@ export default {
   components: {
     BottomPopup,
     NumberBox,
-    AppClose
+    AppClose,
   },
   props: {
     info: {
       type: Object,
       default: () => {
         return {};
-      }
+      },
     },
     buyNum: {
       type: Number,
-      default: 1
+      default: 1,
     },
     hdId: {
       type: Number,
-      default: 0
+      default: 0,
     },
-    account:{
-      type:Number,
-      default:0
+    account: {
+      type: Number,
+      default: 0,
     },
     show: {
       type: Boolean,
-      default: true
-    }
+      default: true,
+    },
   },
   data() {
     return {
-      selIndex: 0
+      selIndex: 0,
     };
   },
   computed: {
     maxStock() {
-      return 9999
-    }
+      return 9999;
+    },
   },
   methods: {
     change(e) {
@@ -82,14 +85,24 @@ export default {
       this.$emit("close");
     },
     nextFn() {
-      if(Number(this.info.price) <= 0){
-        this.$msg('商品还没有价格哦')
-        return false
+      if (Number(this.info.price) <= 0) {
+        this.$msg("商品还没有价格哦");
+        return false;
       }
-      uni.setStorageSync("buyGoodsDetil", this.info)
-      this.$util.pageTo({url:"/pages/order/buy?hdId="+this.hdId+'&goodsId='+this.info.id+'&goodsNum='+this.buyNum+'&selIndex='+this.selIndex+'&account='+this.account,type:2})
-    }
-  }
+      uni.setStorageSync("buyGoodsDetil", this.info);
+      this.$util.pageTo({
+        url: "/pages/order/buy",
+        query: {
+          hdId: this.hdId,
+          goodsId: this.info.id,
+          goodsNum: this.buyNum,
+          selIndex: this.selIndex,
+          account: this.account,
+        },
+        type: 2,
+      });
+    },
+  },
 };
 </script>
 
@@ -119,7 +132,7 @@ export default {
     @include disFlex(center, center);
     border-top: 1rpx solid $borderColor;
     background: #fff;
-    
+
     .button-com {
       width: 100%;
       font-size: 36rpx;
@@ -133,7 +146,7 @@ export default {
       justify-content: center;
       line-height: 1;
       padding: 0;
-      
+
       &.enhanced-btn {
         background: linear-gradient(135deg, #ff4757 0%, #e41f19 100%);
         border: none;
@@ -142,7 +155,6 @@ export default {
     }
   }
 
-
   .tui-popup-scroll {
     max-height: 400rpx;
     font-size: 28rpx;
@@ -152,7 +164,6 @@ export default {
     padding: 10rpx 0;
   }
 
-
   .tui-attr-title {
     padding: 0 0 20rpx 0;
     color: #333;
@@ -161,7 +172,6 @@ export default {
     text-align: left;
   }
 
-
   .tui-number-box {
     display: flex;
     align-items: center;
@@ -192,22 +202,22 @@ export default {
       justify-content: center;
       box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
       padding: 0;
-      
+
       &:before {
         font-size: 36rpx !important;
         font-weight: bold;
       }
-      
+
       &.tui-disabled {
         background: #f0f0f0;
         box-shadow: none;
-        
+
         &:before {
           color: #ccc !important;
         }
       }
     }
-    
+
     .tui-num-input {
       width: 120rpx !important;
       height: 60rpx !important;

+ 1 - 0
mallApp/src/pages/goods/detail.vue

@@ -12,6 +12,7 @@
           {{ data.price ? parseFloat(data.price).toFixed(2) : 0}}
         </text>
       </view>
+      <!--报价类型-->
       <view class="app-price app-bold" v-if="data.priceType == 2">
         <text>¥</text>
         <text class="app-size-34">

+ 3 - 4
mallApp/src/pages/order/buy.vue

@@ -54,7 +54,7 @@
 import TuiListCell from "@/components/plugin/list-cell";
 import AppDeliveryModule from "@/components/app-delivery";
 import AppListModule from "./components/app-order-list2";
-import { getShopUser } from "@/utils/auth";
+//import { getShopUser } from "@/utils/auth";
 import { getOrderShop } from "@/utils/config";
 import { createOrder,newFreight } from "@/api/order";
 import { getHasMap } from "@/api/express";
@@ -90,7 +90,7 @@ export default {
   },
   onLoad(option) {
     this.option = option || {};
-    this.init();
+    //this.init();
   },
   computed: {
     mayPayAmount(){
@@ -108,7 +108,7 @@ export default {
       this.isFreight = goodsInfo.freightType == '0'
 
       getOrderShop()
-      getShopUser();
+      //getShopUser();
 
       const goodsNum = Number(this.option.goodsNum || goodsInfo.buyNum || 0)
       goodsInfo.buyNum = goodsNum
@@ -123,7 +123,6 @@ export default {
       getHasMap().then(res => {
         this.hasMap = (res.data && res.data.hasMap) ? res.data.hasMap : 0
       })
-
     },
 		changeSendType(num){
 			this.form.sendType = num

+ 2 - 2
mallApp/src/pages/order/components/app-order-list2.vue

@@ -6,11 +6,11 @@
 					<image :src="info.cover" mode="aspectFill" style="width:130upx;height:130upx;"></image>
 				</div>
 				<div class="list-msg">
-					<div class="title">{{ info.name}}</div>
+					<div class="title">{{ info.name }}</div>
 				</div>
 			</div>
 			<div class="list-right">
-				<div class="price">¥{{info.price?parseFloat(Number((info.price).toFixed(2))):0}}</div>
+				<div class="price">¥{{info.price ? parseFloat(info.price).toFixed(2) : 0}}</div>
 				<div class="num">X{{info.buyNum}}</div>
 			</div>
 		</block>