cashier_admin_app/pageProduct/index/components/goods.vue

265 lines
5.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class=" goods">
<view class="u-flex u-row-between">
<view class="u-flex">
<view class="color-333">
<text class="">排序</text>
<text class="u-m-l-20">{{data.sort}}</text>
</view>
<view class="color-333 u-m-l-42 u-flex">
<text class="stock">库存</text>
<text class="font-bold u-m-l-10">{{data.stockNumber}}</text>
<uni-icons type="right" size="16" color="#000"></uni-icons>
</view>
</view>
<text class="u-font-28 color-666" @click="changeClick">修改</text>
</view>
<view class="u-m-t-48 u-flex">
<view v-if="props.showChecked">
<label class="radio">
<radio :color="ColorMain" style="transform: scale(0.7);" @click="radioClick"
:checked="props.data.checked" /><text></text>
</label>
</view>
<image :src="data.coverImg" lazy-load class="img"></image>
<view class="h-100 u-p-l-16 u-flex u-flex-col u-row-between">
<view class="color-333"> <text class="u-m-r-24">{{data.name}}</text><uni-tag size="small" type="primary"
custom-style="background-color: #318AFE;" :text="data.typeEnum"></uni-tag></view>
<view class="price">¥{{data.lowPrice}}</view>
</view>
</view>
<view class="u-m-t-16 skus u-text-center" v-if="showDetail&&data.skuList.length>=2">
<view class="u-flex u-row-between font-bold">
<view class="u-flex-1">商品信息</view>
<view class="u-flex-1">售价</view>
<view class="u-flex-1">库存</view>
</view>
<view v-for="(item,index) in data.skuList" :key="index">
<view class="u-flex u-m-t-10">
<view class="color-333 u-flex-1"> <text class="u-m-r-24">{{item.specSnap||''}}</text></view>
<view class="price u-flex-1">¥{{data.lowPrice||0}}</view>
<view class=" u-flex-1">{{item.stockNumber||0}} {{data.unitName||''}}</view>
</view>
</view>
<!-- <view class="u-flex">
<view class="sku">做法</view>
<view class="u-flex u-flex-wrap u-flex-1 skds">
<view class="skd">
<view class="tag-primary tag">上架中</view>
</view>
<view class="skd">
<view class="tag-primary tag">上架中</view>
</view>
</view>
</view> -->
</view>
<view class="u-m-t-24 u-flex u-row-between">
<view class="u-flex">
<view class="u-m-r-18 color-999">设置热门</view>
<my-switch v-model="data.isHot" @change="isHotChange"></my-switch>
<!-- <view class="u-m-r-18 color-999">售罄</view>
<my-switch v-model="isSellNone" @change="isSellNoneChange"></my-switch> -->
</view>
<view class="u-flex">
<!-- <view class="btn-default btn" @tap="xiajia">下架商品</view> -->
<view class="btn-default btn" @tap="del">删除</view>
<view class="btn-primary btn u-m-l-38" @click="toEdit">编辑</view>
</view>
</view>
</view>
</template>
<script setup>
import {
ref,
watchEffect
} from 'vue';
import {$goodsIsHot} from '@/http/yskApi/goods.js'
import mySwitch from '@/components/my-components/my-switch.vue'
import go from '@/commons/utils/go.js';
import {
ColorMain
} from '@/commons/color.js'
const emits = defineEmits(['radioClick', 'changeClick', 'xiajia','del'])
const props = defineProps({
index: {
type: Number
},
data: {
type: Object,
default: () => {
return {}
}
},
showChecked: {
type: Boolean,
default: false
},
showDetail: {
type: Boolean,
default: false
}
})
function isHotChange(e){
$goodsIsHot({
id:props.data.id,
isHot:props.data.isHot
}).then(res=>{
uni.showToast({
title:'修改成功',
icon:'none'
})
})
}
let isSellNone = ref(false)
isSellNone.value = props.isSellNone
function isSellNoneChange() {
console.log(isSellNone.value);
console.log('isSellNoneChange');
}
let checked = ref(false)
function radioClick() {
console.log(props.index);
emits('radioClick', props.index)
}
function changeClick() {
emits('changeClick', props.index)
}
function xiajia() {
emits('xiajia', props.index)
}
function del(){
emits('del', props.index)
}
//携带参数type edit跳转到商品添加页面编辑与添加同一页面根据type值来判断
function toEdit() {
go.to('PAGES_PRODUCT_ADD', {
type: 'edit',
productId: props.data.id
})
}
</script>
<style lang="scss" scoped>
$imgSize: 126rpx;
$price-color: #F02C45;
.btn {
padding: 6rpx 28rpx;
border-radius: 100rpx;
border: 2rpx solid transparent;
}
.btn-primary {
border-color: $my-main-color;
;
color: $my-main-color;
}
.btn-default {
border-color: #F4F4F4;
color: #999;
}
.price {
color: $price-color;
}
.h-100 {
height: $imgSize;
}
.img {
width: $imgSize;
height: $imgSize;
}
.icon-arrow-right {
width: 32rpx;
height: 32rpx;
}
.stock {
// padding-right: 46rpx;
position: relative;
}
.stock::after {
// content: '';
// position: absolute;
// right: 10rpx;
// top: 50%;
// transform: translateY(-50%);
// display: block;
// width: 16rpx;
// border: 2rpx solid #333333;
}
.goods {
border-radius: 10rpx 10rpx 10rpx 10rpx;
background-color: #fff;
padding: 24rpx 28rpx 16rpx 28rpx;
font-size: 28rpx;
.skus {
background: #F9F9F9;
border-radius: 14rpx 14rpx 14rpx 14rpx;
padding: 28rpx 42rpx;
.sku {
color: #000;
font-weight: 700;
padding: 6rpx 40rpx;
}
.skds {
gap: 10rpx 50rpx;
}
.skd {
padding: 14rpx 40rpx;
background: #F0F2F5;
border-radius: 4rpx;
position: relative;
color: #666;
overflow: hidden;
.tag {
position: absolute;
right: 0;
top: 0;
font-size: 12rpx;
right: 0;
padding: 2rpx 4rpx;
border-radius: 0rpx 4rpx 4rpx 4rpx;
}
.tag-primary {
background-color: $my-main-color;
color: #fff;
}
}
}
}
</style>