| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- <template>
- <view class="container">
- <!-- 商家信息-->
- <view class="store-card">
- <view class="info-top">
- <view class="left">
- <image class="storeImg" :src="merchantInfo.merchantLogo" mode="aspectFit"></image>
- </view>
- <view class="center">
- <view class="name">{{merchantInfo.merchantName}}</view>
- </view>
- </view>
- <view class="desc">{{merchantInfo.merchantDescribe}}</view>
- <view class="tel">
- <image class="phone mr20" src="@/static/images/phone2.png" mode="widthFix"></image>
- <text>联系电话:{{merchantInfo.merchantPhone}}</text>
- <image class="phone fr" src="@/static/images/phoneyellow.png" mode="widthFix"></image>
- </view>
- </view>
- <!-- 商品-->
- <up-tabs :list="tabList"
- @click="tabChange"
- lineColor="#333333"
- :itemStyle="{
- flex:1,
- height:'44px',
- }"
- :activeStyle="{
- color: '#333333',
- fontWeight: 'bold',
- transform: 'scale(1.05)'
- }"
- :inactiveStyle="{
- color: '#666666',
- transform: 'scale(1)'
- }"></up-tabs>
- <!-- 商品列表-->
- <view class="index-product-wrapper">
- <view
- class="list-box animated"
- :class="goodsList.length > 0 ? 'fadeIn on' : ''"
- >
- <view
- class="item"
- v-for="(item, index) in calculatedProducts"
- :key="index"
- @click="goDetail(item)"
- >
- <view class="pictrue">
- <image :src="item.image" mode=""></image>
- </view>
- <view class="text-info">
- <view class="title" >
- <view class="text line1">{{ item.storeName }}</view>
- <view class="weight">{{ item.weight }}g</view>
- </view>
- <view class="bottom-row">
- <!-- <text class="price">工费: {{ item.price }}/克</text> -->
- <text class="price">¥ {{ item.totalLaborCost }}</text>
- <text class="sales">
- 销量:{{ Number(item.sales || 0) + Number(item.ficti || 0) }}件
- </text>
- <!-- <view class="txt">券</view> -->
- </view>
- <view class="bottom-row">
- <!-- <text class="price">工费: {{ item.price }}/克</text> -->
- <text class="sales">工费: {{ item.totalLaborCost }}</text>
- <text class="sales">
- 附加费: {{ item.totalLaborCost }}
- </text>
- <!-- <view class="txt">券</view> -->
- </view>
- </view>
- </view>
- </view>
- <view class="loadingicon acea-row row-center-wrapper" v-if="goodScroll">
- <text
- class="loading iconfont icon-jiazai"
- :hidden="loading == false"
- ></text>
- </view>
- <view class="no-data" v-if="isNoDataState">
- <image
- src="https://my-go-easy-im.oss-cn-shenzhen.aliyuncs.com/goeasy-im-%E6%B0%B4%E8%B4%9D%E5%95%86%E5%9F%8E/zhanwu_20250827104005_1720_6.png"
- />
- </view>
- <view class="mores-txt flex" v-if="!goodScroll && !isNoDataState">
- <text>我是有底线的</text>
- </view>
- </view>
- </view>
- </template>
- <script setup>
- import {computed, ref} from 'vue';
- import { onLoad, onShow, onReachBottom } from "@dcloudio/uni-app";
- import { getSbmerchantInfo } from "@/api/merchant.js";
- import {
- getGroomList as getGroomListApi,
- } from "@/api/store.js";
- // 获取实时金价
- import useRealGoldPrice from "@/hooks/useRealGoldPrice";
- // 实时价格处理
- const {
- realGoldprice, // 黄金实时销售价(基础)
- realPtprice, // 铂金实时销售价(基础)
- realAgprice, // 白银实时销售价(基础)
- } = useRealGoldPrice({});
- const query = ref({});
- const merchantInfo = ref({});
- const tabList = ref([
- {name:'推荐商品'},
- {name:'商品分类'}
- ])
- const goodsList = ref([]);
- const goodType = ref(1);
- // Pagination
- const params = ref({
- page: 1,
- limit: 10,
- });
- const loading = ref(false);
- const goodScroll = ref(true);
- const calculatedProducts = computed(() => {
- // 计算逻辑与原代码一致,但基于响应式数据 products
- return goodsList.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);
- return {
- ...product,
- calculatedTotal: formattedTotal, // 新增计算结果字段
- };
- });
- });
- const isNoDataState = computed(() => {
- return goodsList.value.length === 0 && !loading.value;
- });
- onLoad((options) => {
- query.value = options;
- getSbmerchantInfoFn();
- getGroomList();
- });
- onReachBottom(() => {
- getGroomList();
- });
- const getSbmerchantInfoFn = () => {
- let data = {
- merchantId:query.value.merchantId
- }
- getSbmerchantInfo(data).then((res) => {
- console.log(res);
- merchantInfo.value = res.data;
- })
- }
- const tabChange = (item) => {
- console.log('item',item)
- }
- // Product Lists
- const getGroomList = async () => {
- if (!goodScroll.value) return;
- try {
- loading.value = true;
- query.value.merchantId!='' ? params.value.merchantId = query.value.merchantId:'';
- const { data } = await getGroomListApi(goodType.value, params.value);
- goodsList.value = [...goodsList.value, ...data.productList.list] || [];
- goodScroll.value = data.productList.list.length >= params.value.limit;
- params.value.page++;
- } catch (err) {
- console.error(err);
- } finally {
- loading.value = false;
- }
- };
- </script>
- <style scoped lang="scss">
- .container{
- padding: 30rpx;
- box-sizing: border-box;
- }
- .store-card{
- background: #ffffff;
- border-radius: 16rpx;
- padding: 20rpx;
- margin-bottom: 10rpx;
- .info-top{
- display: flex;
- justify-content: center;
- align-items: center;
- background-color: #F9F7F0;
- border-radius: 16rpx;
- .left{
- width: 140rpx;
- .storeImg{
- width: 100rpx;
- height: 100rpx;
- }
- }
- .center{
- width: 70%;
- .name{
- font-size: 32rpx;
- color: #333;line-height: 60rpx;
- }
- }
- }
- .desc{
- font-size: 24rpx;
- color: #666;
- line-height: 40rpx;
- padding: 20rpx 0;
- }
- .tel{
- font-size: 28rpx;
- color:#333;
- line-height: 40rpx;
- .phone{
- width: 34rpx;
- vertical-align: middle;
- }
- }
- }
- .mr20{
- margin-right: 20rpx;
- }
- .fr{
- float: right;
- }
- .index-product-wrapper {
- //padding: 0 30rpx;
- margin-bottom: 110rpx;
- min-height: 700rpx;
- margin-top: 30rpx;
- //background: #fff;
- &.on {
- min-height: 1500rpx;
- }
- .list-box {
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- .item {
- width: 48.99%;
- height: 490rpx;
- background-color: #ffffff;
- box-shadow: 0rpx 3rpx 13rpx 0rpx rgba(0, 0, 0, 0.13);
- border-radius: 20rpx;
- margin-bottom: 20rpx;
- overflow: hidden;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .pictrue {
- position: relative;
- image {
- width: 100%;
- height: 330rpx;
- }
- }
- .text-info {
- padding: 10rpx 20rpx 15rpx;
- .title {
- color: #222222;
- display: flex;
- align-items: center;
- justify-items: space-between;
- .tip {
- width: 61rpx;
- height: auto;
- font-size: 22rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- color: #ffffff;
- position: relative;
- margin-right: 5rpx;
- background-color: #ef4800;
- border-radius: 5rpx;
- }
- .text{
- width: 80%;
- }
- .weight{
- background-color: rgba(197, 128, 3, 0.10);
- color: #C58003;
- font-size: 24rpx;
- padding: 8rpx 16rpx;
- border-radius: 8rpx;
- float: right;
- }
- }
- .bottom-row {
- color: $theme-color;
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-size: 28rpx;
- margin: 10rpx 0 0;
- .price {
- padding-bottom: 4rpx;
- font-weight: 800;
- white-space: nowrap;
- font-size: 28rpx;
- color: #f16327;
- }
- .sales {
- color: #b4b4b4;
- font-size: 22rpx;
- white-space: nowrap;
- color: #6e6e6e;
- }
- }
- }
- }
- &.on {
- display: flex;
- }
- }
- }
- .no-data {
- margin: 150rpx auto 0;
- text-align: center;
- img {
- width: 65%;
- height: auto;
- }
- }
- .mores-txt {
- width: 100%;
- align-items: center;
- justify-content: center;
- height: 70rpx;
- color: #999;
- font-size: 24rpx;
- .iconfont {
- margin-top: 2rpx;
- font-size: 20rpx;
- }
- }
- </style>
|