123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <template>
- <view class="tm-cartCellListFood px-20 py-32 flex-top-start" :class="[
- bgColor,
- black_tmeme ? 'grey-darken-4' : '',
- black_tmeme ? 'bk' : '',
- border === 'top' ? 'border-t-1' : '',
- border === 'bottom' ? 'border-b-1' : '',
- ]">
- <view v-if="mdata[keyMap['img']]" class="tm-cartCellListFood-img" :style="{
- width:imgWidth+'rpx',
- height:imgWidth+'rpx'
- }">
- <tm-images :width="imgWidth" :height="imgWidth" :round="3" :src="mdata[keyMap['img']]"></tm-images>
- </view>
- <view class="tm-cartCellListFood-r fulled ">
- <view class="pl-15">
- <view class="title text-size-s text-weight-b text-overflow-2" style="line-height: 32rpx;" :class="[black_tmeme ? 'bk' : '',]">
- {{mdata[keyMap['title']]}}
- </view>
- <view style="min-height: 64rpx;" >
- <view v-if="!dense&&mdata[keyMap['label']]" class="tm-cartCellListFood-label text-size-s text-grey py-8">{{mdata[keyMap['label']]}}</view>
- <view v-if="mdata[keyMap['saleLabel']]&&!dense" class="tm-cartCellListFood-sale text-size-s text-grey">
- <block v-for="(item,index) in mdata[keyMap['saleLabel']]" :key="index">
- <tm-tags :black="black_tmeme" :color="color" v-if="index<4" size="xs">{{item}}</tm-tags>
- </block>
- </view>
- </view>
- <view class="tm-cartCellListFood-price flex-between">
- <view>
- <text class="text-size-xs text-red">¥</text>
- <text class="text-size-n text-red text-weight-b px-5">{{mdata[keyMap['price']]}}</text>
- <text v-if="mdata[keyMap['unit']]" class="text-size-xs text-grey pr-10">/{{mdata[keyMap['unit']]}}</text>
- <text v-if="mdata[keyMap['salePrice']]" class="text-delete text-size-xxs text-grey">¥{{mdata[keyMap['salePrice']]}}</text>
-
- </view>
- <view class="flex">
- <block v-if="cNum>0">
- <view :style="{
- width:`${actionSize}rpx`,
- height:`${actionSize}rpx`,
- }" :class="[color,black_tmeme ? 'bk' : '',]" @click="jian" class="tm-cartCellListFood-actions rounded flex-center outlined">
- <text class="iconfont icon-minus text-size-xxs"></text>
- </view>
- <view class="px-12 text-size-n " :class="[black_tmeme ? 'bk' : '',]">{{cNum}}</view>
- </block>
- <view :style="{
- width:`${actionSize}rpx`,
- height:`${actionSize}rpx`,
- }" :class="[color,`border-${color}-a-1`,black_tmeme ? 'bk' : '',]" @click="jia" class="tm-cartCellListFood-actions rounded flex-center ">
- <text class="iconfont icon-plus text-size-xs"></text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
-
- import tmSliderNav from "@/tm-vuetify/components/tm-sliderNav/tm-sliderNav.vue"
- import tmImages from "@/tm-vuetify/components/tm-images/tm-images.vue"
- import tmTags from "@/tm-vuetify/components/tm-tags/tm-tags.vue"
- export default {
- components:{tmSliderNav,tmImages,tmTags},
- name:"tm-cartCellListFood",
- props:{
- imgWidth:{
- type:Number,
- default:140,
- },
- cartNum:{
- type:Number,
- default:0
- },
- color:{
- type:String,
- default:'primary'
- },
- bgColor:{
- type:String,
- default:'white'
- },
-
- keyMap:{
- type:Object,
- default:()=>{
- return {
- img:'img',
- title:'title',
- label:'label',
- price:'price',
- salePrice:'salePrice',
- saleLabel:'saleLabel',
- unit:'unit',
- buy:'buy'
- }
- }
- },
-
- dense:{
- type:Boolean|String,
- default:false
- },
-
- actionSize:{
- type:Number,
- default:38
- },
-
- border: {
- type: String,
- default: 'top'
- },
- black:{
- type:Boolean|String,
- default:null
- },
- mdata:{
- type:Object,
- default:()=>{
-
-
-
-
-
-
-
-
-
-
- return {};
- }
- }
- },
- watch:{
- 'mdata.buy':function(val){
- if(this.cart_num==val) return;
- this.cart_num = val;
- },
- },
- computed:{
- black_tmeme: function() {
- if (this.black !== null) return this.black;
- return this.$tm.vx.state().tmVuetify.black;
- },
-
- cart_num:{
- get:function(){
- return this.cNum;
- },
- set:function(val){
- this.cNum = val;
- this.$emit("update:cartNum",val)
-
- this.$nextTick(function(){
- this.$emit("change",val)
- })
-
-
-
- this.$emit("change",val)
-
-
- }
- }
- },
- data() {
- return {
- cNum:0,
- };
- },
- mounted() {
- this.cNum = this.mdata.buy;
- },
- methods:{
- jian(){
- const buyNum = this.cNum;
- if(buyNum<=0) {
- this.cart_num = 0;
- return
- }
- this.cart_num = buyNum-1
-
- },
- jia(){
- const buyNum = this.cNum;
- this.cart_num = parseInt(buyNum) + 1
- },
- }
- }
- </script>
- <style lang="less">
- </style>
|