|
|
@@ -21,7 +21,7 @@
|
|
|
</view>
|
|
|
<view>
|
|
|
<view class='name line1'>{{item.storeName}}</view>
|
|
|
- <view class='money font-color'>¥{{item.price}}</view>
|
|
|
+ <view class='money font-color'>¥{{item.totalPrice}}</view>
|
|
|
</view>
|
|
|
</navigator>
|
|
|
</view>
|
|
|
@@ -51,7 +51,7 @@
|
|
|
<!-- <recommend :hostProduct="hostProduct"></recommend>-->
|
|
|
</view>
|
|
|
|
|
|
- <home></home>
|
|
|
+<!-- <home></home>-->
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
@@ -64,7 +64,13 @@ import { HTTP_REQUEST_URL_IMG } from "@/config/app";
|
|
|
import { getCollectUserList, getProductHot, collectDelete } from '@/api/store.js';
|
|
|
import { toLogin } from "@/libs/login.js";
|
|
|
import recommend from '@/components/recommend';
|
|
|
-
|
|
|
+// 获取实时金价
|
|
|
+import useRealGoldPrice from "@/hooks/useRealGoldPrice";
|
|
|
+const {
|
|
|
+ realGoldprice, // 黄金实时销售价(基础)
|
|
|
+ realPtprice, // 铂金实时销售价(基础)
|
|
|
+ realAgprice, // 白银实时销售价(基础)
|
|
|
+} = useRealGoldPrice({});
|
|
|
import home from '@/components/home';
|
|
|
import Util from '@/utils/util';
|
|
|
|
|
|
@@ -78,7 +84,7 @@ const hostProduct = ref([]);
|
|
|
const loadTitle = ref('加载更多');
|
|
|
const loading = ref(false);
|
|
|
const loadend = ref(false);
|
|
|
-const collectProductList = ref([]);
|
|
|
+const collectList = ref([]);
|
|
|
const limit = 8;
|
|
|
const page = ref(1);
|
|
|
const isAuto = ref(false);
|
|
|
@@ -92,6 +98,30 @@ const delBtnWidth = 80;
|
|
|
const totals = ref(0);
|
|
|
const startX = ref(0);
|
|
|
|
|
|
+
|
|
|
+const collectProductList = computed(() => {
|
|
|
+ // 计算逻辑与原代码一致,但基于响应式数据 products
|
|
|
+ return collectList.value.map((product) => {
|
|
|
+ // 1. 将price字符串转为数字
|
|
|
+ const price = Number(product.price);
|
|
|
+ // 2. 计算乘积
|
|
|
+ const total = (price + product.sales) * realGoldprice.value;
|
|
|
+ // 3. 向上取整到两位小数(先放大100倍取整,再缩小100倍)
|
|
|
+ const roundedTotal = Math.ceil(total * 100) / 100;
|
|
|
+ // 4. 格式化保留两位小数
|
|
|
+ const formattedTotal = roundedTotal.toFixed(2);
|
|
|
+
|
|
|
+ const totalLaborCost = Number(product.totalLaborCost);
|
|
|
+ const additionalAmount = Number(product.additionalAmount);
|
|
|
+ const totalPrice = (totalLaborCost+additionalAmount).toFixed(2);
|
|
|
+ console.log('totalPrice',totalPrice)
|
|
|
+ return {
|
|
|
+ ...product,
|
|
|
+ calculatedTotal: formattedTotal, // 新增计算结果字段
|
|
|
+ totalPrice
|
|
|
+ };
|
|
|
+ });
|
|
|
+});
|
|
|
// #ifdef MP
|
|
|
// 触摸开始
|
|
|
const drawStart = (e) => {
|
|
|
@@ -143,7 +173,7 @@ const checkboxChange = (event) => {
|
|
|
});
|
|
|
|
|
|
selectValue.value = values.toString();
|
|
|
- isAllSelect.value = collectProductList.value.length === values.length;
|
|
|
+ isAllSelect.value = calculatedProducts.value.length === values.length;
|
|
|
};
|
|
|
|
|
|
// 全选变化
|
|
|
@@ -205,9 +235,9 @@ const get_user_collect_product = async () => {
|
|
|
const collectProductListData = res.data.list;
|
|
|
const isLoadend = collectProductListData.length < limit;
|
|
|
|
|
|
- collectProductList.value = Util.SplitArray(collectProductListData, collectProductList.value);
|
|
|
+ collectList.value = Util.SplitArray(collectProductListData, collectProductList.value);
|
|
|
|
|
|
- if (collectProductList.value.length === 0) {
|
|
|
+ if (collectList.value.length === 0) {
|
|
|
// get_host_product();
|
|
|
}
|
|
|
|
|
|
@@ -329,7 +359,6 @@ onReachBottom(() => {
|
|
|
|
|
|
.collectionGoods {
|
|
|
.nav {
|
|
|
- width: 92%;
|
|
|
height: 90rpx;
|
|
|
background-color: #fff;
|
|
|
padding: 0 24rpx;
|
|
|
@@ -338,16 +367,16 @@ onReachBottom(() => {
|
|
|
font-size: 28rpx;
|
|
|
color: #282828;
|
|
|
position: fixed;
|
|
|
- left: 30rpx;
|
|
|
+ left: 20rpx;
|
|
|
z-index: 5;
|
|
|
- top: 30rpx;
|
|
|
+ top: 20rpx;
|
|
|
+ right: 20rpx;
|
|
|
border-bottom: 1px solid #EEEEEE;
|
|
|
- border-top-left-radius: 14rpx;
|
|
|
- border-top-right-radius: 14rpx;
|
|
|
+ border-radius: 16rpx;
|
|
|
}
|
|
|
|
|
|
.list {
|
|
|
- padding: 30rpx;
|
|
|
+ padding: 20rpx;
|
|
|
margin-top: 110rpx;
|
|
|
|
|
|
.name {
|