<template>
  <view class="orderGoods borRadius14">
    <view class="total"
      >共{{ orderProNum ? orderProNum : totalNmu }}件商品</view
    >
    <view class="goodWrapper pad30">
      <view
        class="item acea-row row-between-wrapper"
        v-for="(item, index) in cartInfo"
        :key="index"
        @click="jumpCon(item.productId)"
      >
        <view class="pictrue">
          <image :src="item.image"></image>
        </view>
        <view class="text">
          <view class="acea-row row-between-wrapper">
            <view class="name line1">
              {{ item.productName ? item.productName : item.storeName }}
            </view>
            <view class="num">
              x {{ item.payNum ? item.payNum : item.cartNum }}
            </view>
          </view>
          <view class="attr line1" v-if="item.sku">属性: {{ item.sku }}</view>
          <view v-if="mallType === 0" class="money font-color">
            ￥{{ Number(item.storePrice).toFixed(2) }}
          </view>
          <view v-else class="money font-color">
            贝币:{{ Number(item.storePrice).toFixed(2) }}
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref, watch } from "vue";

const props = defineProps({
  evaluate: {
    type: Number,
    default: 0,
  },
  mallType: {
    type: Number,
    default: 0, // 0: 水贝商城, 1: 贝币商城
  },
  cartInfo: {
    type: Array,
    default: () => [],
  },
  orderId: {
    type: String,
    default: "",
  },
  ids: {
    type: Number,
    default: 0,
  },
  jump: {
    type: Boolean,
    default: false,
  },
  orderProNum: {
    type: Number,
    default: 0,
  },
  productType: {
    type: Number,
    default: 0,
  },
});

const totalNmu = ref("");

watch(
  () => props.cartInfo,
  (nVal) => {
    let num = 0;
    nVal.forEach((item) => {
      num += item.cartNum;
    });
    totalNmu.value = num;
  },
  { immediate: true }
);

function evaluateTap(item) {
  uni.navigateTo({
    url: `/pages/users/goods_comment_con/index?unique=${item.attrId}&orderId=${props.orderId}&id=${props.ids}`,
  });
}

function jumpCon(id) {
  let type = props.productType == 0 ? "normal" : "video";
  if (props.jump) {
    uni.navigateTo({
      url: `/pages/goods_details/index?id=${id}&type=${type}`,
    });
  }
}
</script>

<style scoped lang="scss">
.orderGoods {
  background-color: #fff;
  margin-top: 15rpx;
}

.orderGoods .total {
  width: 100%;
  height: 86rpx;
  padding: 0 24rpx;
  border-bottom: 2rpx solid #f0f0f0;
  font-size: 30rpx;
  color: #282828;
  line-height: 86rpx;
  box-sizing: border-box;
}

.pictrue image {
  background: #f4f4f4;
}
</style>
