113 lines
2.5 KiB
Vue
113 lines
2.5 KiB
Vue
<template>
|
|
<view class="towcontent flex-between" v-if="district">
|
|
<view class="towcontent_item flex-colum" v-for="(item,index) in district" :key="index"
|
|
@click="clickdistrict(item,index)">
|
|
<image :src="item.coverImg" mode="aspectFill"></image>
|
|
<text>{{item.name}}</text>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import {
|
|
ref,
|
|
defineProps
|
|
} from 'vue';
|
|
const props = defineProps({
|
|
district: Array
|
|
});
|
|
const clickdistrict = (item) => {
|
|
console.log(item, '调试')
|
|
switch (item.jumpType) {
|
|
case 'absolute':
|
|
uni.pro.navigateTo('webview/webview', {
|
|
url: item.absUrl
|
|
});
|
|
break;
|
|
case 'scan_applet':
|
|
uni.navigateToMiniProgram(JSON.parse(item.value))
|
|
break;
|
|
case 'relative':
|
|
uni.setStorage({
|
|
key: 'itemData',
|
|
data: item,
|
|
});
|
|
uni.pro.navigateTo(item.absUrl, item.name);
|
|
break;
|
|
case 'scan':
|
|
if (!uni.utils.pluschooseImage()) {
|
|
return false
|
|
}
|
|
// #ifdef APP || MP-WEIXIN || MP-ALIPAY
|
|
uni.scanCode({
|
|
success: async (res) => {
|
|
let tableCode = getQueryString(decodeURIComponent(res.result), 'code')
|
|
uni.cache.set('tableCode', tableCode)
|
|
if (tableCode) {
|
|
let data = await this.api.productqueryShop({
|
|
code: uni.cache.get('tableCode'),
|
|
})
|
|
if (data.data.shopTableInfo && !data.data.shopTableInfo.choseCount) {
|
|
uni.pro.navigateTo('/pagesOrder/orderAMeal/index', {
|
|
tableCode: tableCode,
|
|
shopId: data.data.storeInfo.id,
|
|
})
|
|
} else {
|
|
uni.pro.navigateTo('order_food/order_food', {
|
|
tableCode: tableCode,
|
|
})
|
|
}
|
|
|
|
}
|
|
},
|
|
fail: (res) => {
|
|
console.log(res)
|
|
}
|
|
});
|
|
// #endif
|
|
|
|
break;
|
|
}
|
|
}
|
|
const getQueryString = (url, name) => { //解码
|
|
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
|
|
var r = url.substr(1).match(reg)
|
|
if (r != null) {
|
|
return r[2]
|
|
}
|
|
return null;
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.towcontent {
|
|
position: relative;
|
|
margin-top: -32rpx;
|
|
padding: 32rpx 40rpx;
|
|
width: 100%;
|
|
background: #F9F9F9;
|
|
border-radius: 48rpx 48rpx 0rpx 0rpx;
|
|
overflow-x: auto;
|
|
flex-wrap: nowrap;
|
|
box-sizing: border-box;
|
|
.towcontent_item {
|
|
width: 25%;
|
|
margin-left: 34rpx;
|
|
image {
|
|
width: 92rpx;
|
|
height: 92rpx;
|
|
}
|
|
text {
|
|
margin-top: 16rpx;
|
|
font-family: Source Han Sans CN, Source Han Sans CN;
|
|
font-weight: 400;
|
|
font-size: 28rpx;
|
|
color: #333333;
|
|
white-space: nowrap;
|
|
}
|
|
}
|
|
.towcontent_item:nth-child(1) {
|
|
margin-left: 0rpx;
|
|
}
|
|
}
|
|
</style> |