cashier_wx/pages/index/components/category.vue

115 lines
2.3 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="fourcontent flex-between" v-if="menu">
<view class="fourcontent_item flex-start" v-for="(item,index) in menu" :key="index"
@click="viewHistorycategoryss(item,index)"
:class="!item.isChild && viewHistoryindex == index ? 'fourcontent_itemactev':''">
<text>{{item.name}}</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {};
},
props: {
menu: {
type: Array,
default () {
return []
}
},
title: {
type: String,
default: '每日特价'
},
viewHistoryindex: {
type: String,
default: ''
},
},
methods: {
viewHistorycategoryss(item, index) {
console.log(item, index)
uni.$emit('viewHistory', {
item:item,
index:index
});
},
clickdistrict(item) {
switch (item.jumpType) {
case 'absolute':
uni.pro.navigateTo('webview/webview', {
url: item.absUrl
});
break;
case 'relative':
uni.pro.navigateTo(item.absUrl, item);
break;
case 'scan':
if (!uni.utils.pluschooseImage()) {
return false
}
// #ifdef H5
if (this.wxSdk) {
wx.scanQRCode({
needResult: 1, // 默认为0扫描结果由微信处理1则直接返回扫描结果
scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
success: res => {
// 当needResult 为 1 时,扫码返回的结果
console.log(res.resultStr, res)
}
});
} else {
uni.showModal({
title: '注意',
content: '微信sdk初始化失败请重新加载',
success: res => {
window.location.reload();
}
});
}
// #endif
// #ifdef APP || MP-WEIXIN
uni.scanCode({
success: res => {
console.log(res.result, res)
}
});
// #endif
break;
}
}
}
};
</script>
<style scoped lang="scss">
.fourcontent {
padding: 32rpx 28rpx 32rpx 28rpx;
overflow-x: auto;
flex-wrap: nowrap;
.fourcontent_item {
flex-wrap: nowrap;
margin-left: 22rpx;
padding: 4rpx 14rpx;
background: #FFFFFF;
border-radius: 8rpx 8rpx 8rpx 8rpx;
text {
width: max-content;
}
}
.fourcontent_itemactev {
background: #fee06a;
}
.fourcontent_item:nth-child(1) {
margin-left: 0;
}
}
</style>