Ver Fonte

撤回版本

shish há 2 meses atrás
pai
commit
b75c501101

+ 17 - 92
ghsPad/src/pages/home/components/rightItem.vue

@@ -19,33 +19,21 @@
         </view>
 
         <view class="cat-list-area">
-            <!-- 小程序端 @click="fn(item)" 对 v-for 变量传递不稳定,改用 data-index + 列表取项 -->
-            <view
-                v-for="(catItem, catIdx) in globalRightItemClass"
-                :key="categoryTabKey(catItem, catIdx)"
-                :class="[globalRightItemCategoryId===catItem.id?'active':'']"
-                :data-cid="catItem.id"
-                :data-cat-index="catIdx"
-                @click.stop="handleCategoryClick"
-            >
-                <text class="cat-tab-name">{{ catItem.name }}</text>
-            </view>
+            <view v-for="item in globalRightItemClass" :key="item.id" :class="[globalRightItemCategoryId===item.id?'active':'']" @click="handleCategoryClick(item)" > {{item.name}} </view>
         </view>
         <view class="shop-show_box">
             <view v-if="filteredItemList.length === 0" class="no-data-tip">
                 <text>{{ searchKeyword ? '未找到相关花材' : '暂无花材' }}</text>
             </view>
-            <!-- key:id+property+下标,避免任意重复键;名称须用 text,避免 App 端 view 插值与 image 异步刷新不同步出现「名错图对」 -->
-            <view v-for="(item, flowerIdx) in filteredItemList" :key="flowerItemRowKey(item, flowerIdx)" class="show-shop_box">
+            <view v-for="item in filteredItemList" :key="item.id" class="show-shop_box">
                 <view class="item-detail" @click="popAddModelFn(item)">
-                    <!-- 收银格图片小,关闭懒加载可减少原生 image 与底部文案层的刷新不同步(偶发相邻标题串位) -->
-                    <image class="img" :key="flowerItemRowKey(item, flowerIdx)" :src="item.cover" :lazy-load="false" mode="scaleToFill" ></image>
+                    <image class="img" :src="item.cover" lazy-load="true" :lazy-load-margin="0" mode="scaleToFill" ></image>
                     <!-- 多颜色类型标识 -->
                     <view v-if="item.variety == 1" class="variety-badge"></view>
                     <view class="shop-info_price">
                         <view>
-                            <text class="flower-card-name" :key="'nm-' + item.id + '-' + flowerIdx" @click.stop="quickAddItem(item)">{{ item.name }}</text>
-                            <view class="flower-card-meta" @click.stop="quickAddItem(item)">
+                            <view>{{item.name}}</view>
+                            <view style="display:flex;justify-content: space-between;padding-right:2upx;">
                                 <text>¥{{parseFloat(item.price)}}</text>
                                 <text v-if="Number(item.reachNumDiscount)>0 && Number(item.reachNum)>0" style="color:#FFEB3B;">{{ item.reachNum }}↓{{ item.reachNumDiscount?parseFloat(item.reachNumDiscount):0 }}</text>
                                 <text>剩{{parseFloat(item.stock)}}</text>
@@ -169,17 +157,6 @@ export default {
         }
     },
     methods:{
-        /** 顶部分类 tab:id + 下标,避免 App 端同结构列表偶发文字与点击项不一致 */
-        categoryTabKey(catItem, index) {
-            const id = catItem && catItem.id != null ? catItem.id : 'noid'
-            return `cat-${id}-${index}`
-        },
-        /** 列表行 key:优先 id+property(多规格),再拼下标保证唯一,避免 v-for 在部分端上节点复用异常 */
-        flowerItemRowKey(item, index) {
-            const id = item && item.id != null ? item.id : 'noid'
-            const prop = item && item.property !== undefined && item.property !== null ? item.property : 1
-            return `fl-${id}-${prop}-${index}`
-        },
         addToClear(){
             this.$msg('请扫码打开')
         },
@@ -189,26 +166,11 @@ export default {
                 this.closeSearchBox()
             }
         },
-        handleCategoryClick(e){
-            const cur = e && e.currentTarget ? e.currentTarget : (e && e.target)
-            const ds = cur && cur.dataset ? cur.dataset : {}
-            const list = this.globalRightItemClass || []
-            let cat = null
-            if (ds.cid !== undefined && ds.cid !== '') {
-                const cid = ds.cid
-                cat = list.find(function (c) { return String(c.id) === String(cid) })
-            }
-            if (!cat && ds.catIndex !== undefined && ds.catIndex !== '') {
-                const idx = Number(ds.catIndex)
-                if (!isNaN(idx)) {
-                    cat = list[idx]
-                }
-            }
-            if (!cat || cat.id == null) {
-                return
-            }
+        handleCategoryClick(item){
+            // 点击分类时清空搜索框
             this.searchKeyword = ''
-            this.globalChangeCategory(cat)
+            // 调用原来的分类切换方法
+            this.globalChangeCategory(item)
         },
         toggleSearchBox(){
             this.showSearchBox = !this.showSearchBox
@@ -223,37 +185,9 @@ export default {
             this.searchKeyword = ''
         },
 		popAddModelFn(info) {
-            const property = info.property !== undefined ? info.property : 1
-            this.notifyOperateItem({ ...info, property })
             this.$util.hitVoice()
-			this.showAddModelFn({ ...info, property, currentNum: 1, unitPrice: info.price,unitType:0})
+			this.showAddModelFn({ ...info, currentNum: 1, unitPrice: info.price,unitType:0})
 		},
-        quickAddItem(info){
-            const property = info.property !== undefined ? info.property : 1
-            this.notifyOperateItem({ ...info, property })
-            const hasItem = this.selectList.find(item => Number(item.id) == Number(info.id) && Number(item.property) == Number(property))
-            this.$util.hitVoice()
-            if(hasItem){
-                const currentNum = Number(hasItem.currentNum) || 0
-                this.replaceItemFn({ ...hasItem, currentNum: currentNum + 1 })
-                return
-            }
-            const unitName = property == 1 ? (info.bigUnit || info.unitName || '扎') : '份'
-            const unitPrice = property == 1 ? (info.bigPrice || info.price || info.unitPrice) : (info.price || info.unitPrice)
-            this.replaceItemFn({ ...info, property, currentNum: 1, unitPrice, unitType: 0, unitName})
-        },
-        notifyOperateItem(item){
-            this.$emit('operateItem', item)
-        },
-        addItemModelHidden() {
-            if(this.customData && this.customData.id){
-                this.notifyOperateItem(this.customData)
-            }
-            if(this.$refs.selectNumPriceRef){
-                this.$refs.selectNumPriceRef.close()
-            }
-            this.customData = {};
-        },
         refreshMyRightItem(customId){
 			this.globalRightItemCustomId = customId
 			this.itemRefresh()
@@ -316,18 +250,14 @@ export default {
                     box-sizing: border-box;
                     z-index: 10;
                     & > view {
-                        & > .flower-card-name {
-                            display: block;
+                        & > view:nth-child(1) {
                             overflow: hidden;
                             white-space: nowrap;
-                            width: 100%;
-                            font-size: 9upx;
+                            width:100%;
+                            font-size:9upx;
                         }
-                        & > .flower-card-meta {
-                            display: flex;
-                            justify-content: space-between;
-                            padding-right: 2upx;
-                            font-size: 7upx;
+                        & > view:nth-child(2) {
+                            font-size:7upx;
                         }
                     }
                 }
@@ -348,18 +278,13 @@ export default {
             padding: 8upx 0upx;
             font-size: 9upx;
             width: 68upx;
+            overflow: hidden;
+            white-space: nowrap;
             text-align: center;
             &.active {
                 background-color: #3385FF;
                 color: #ffffff;
             }
-            .cat-tab-name {
-                display: block;
-                overflow: hidden;
-                white-space: nowrap;
-                width: 100%;
-                font-size: 9upx;
-            }
         }
     }
     & .shop-show_box {

+ 10 - 39
hdPad/src/pages/home/components/rightItem.vue

@@ -30,10 +30,9 @@
                     <image class="img" :src="item.cover" lazy-load="true" :lazy-load-margin="0" mode="scaleToFill" ></image>
                     <view class="shop-info_price">
                         <view>
-                            <view @click.stop="quickAddItem(item)">{{item.name}}</view>
-                            <view style="display:flex;justify-content: space-between;padding-right:2upx;" @click.stop="quickAddItem(item)">
-                                <text>¥{{parseFloat(item.price)}}</text>
-                                <text>剩{{parseFloat(item.stock)}}</text>
+                            <view>{{item.name}}</view>
+                            <view style="display:flex;justify-content: space-between;padding-right:2upx;">
+                                <text>¥{{parseFloat(item.price)}}</text><text>剩{{parseFloat(item.stock)}}</text>
                             </view>
                         </view>
                     </view>
@@ -85,12 +84,12 @@ export default {
             default:0
         }
     },
-    // mounted(){ // watch.customId 处会自动调用globalGetRightItem
-    //     let id = this.customId>0 ? this.customId : 0
-    //     if(id>0){
-    //         this.globalGetRightItem(id)
-    //     }
-    // },
+    mounted(){
+        let id = this.customId>0 ? this.customId : 0
+        if(id>0){
+            this.globalGetRightItem(id)
+        }
+    },
 	created(){
 		this.listenScanItem()
     },
@@ -180,37 +179,9 @@ export default {
             this.searchKeyword = ''
         },
 		popAddModelFn(info) {
-            const property = info.property !== undefined ? info.property : 1
-            this.notifyOperateItem({ ...info, property })
             this.$util.hitVoice()
-			this.showAddModelFn({ ...info, property, currentNum: 1, unitPrice: info.price,unitType:0})
+			this.showAddModelFn({ ...info, currentNum: 1, unitPrice: info.price,unitType:0})
 		},
-        quickAddItem(info){
-            const property = info.property !== undefined ? info.property : 1
-            this.notifyOperateItem({ ...info, property })
-            const hasItem = this.selectList.find(item => Number(item.id) == Number(info.id) && Number(item.property) == Number(property))
-            this.$util.hitVoice()
-            if(hasItem){
-                const currentNum = Number(hasItem.currentNum) || 0
-                this.replaceItemFn({ ...hasItem, currentNum: currentNum + 1 })
-                return
-            }
-            const unitName = property == 1 ? (info.bigUnit || info.unitName || '扎') : '份'
-            const unitPrice = property == 1 ? (info.bigPrice || info.price || info.unitPrice) : (info.price || info.unitPrice)
-            this.replaceItemFn({ ...info, property, currentNum: 1, unitPrice, unitType: 0, unitName})
-        },
-        notifyOperateItem(item){
-            this.$emit('operateItem', item)
-        },
-        addItemModelHidden() {
-            if(this.customData && this.customData.id){
-                this.notifyOperateItem(this.customData)
-            }
-            if(this.$refs.selectNumPriceRef){
-                this.$refs.selectNumPriceRef.close()
-            }
-            this.customData = {};
-        },
         renewMyRightItem(customId){
             this.globalRightItemCustomId = customId
             this.globalItemRefresh(customId)