完成扫一扫功能

This commit is contained in:
赵毅 2025-09-22 15:16:24 +08:00
parent 845e9bafce
commit ed3a8f6e55
2 changed files with 56 additions and 38 deletions

View File

@ -1,32 +1,17 @@
<template>
<view class="foot-fixed">
<view v-for="(item, index) in navList" :key="index">
<view
id="navIndex"
:style="{ width: foot_width }"
@click="jump"
:data-idx="index"
:data-url="item.url"
:class="{ 'foot-item': true, 'scan-item': item.isScan }"
>
<view id="navIndex" :style="{ width: foot_width }" @click="jump" :data-idx="index" :data-url="item.url"
:class="{ 'foot-item': true, 'scan-item': item.isScan }">
<view class="foot-icon-box">
<image
class="foot-icon"
:src="item.photo"
mode="widthFix"
v-if="current != index"
:style="{
width: item.photo.includes('footer_localLife.png')
? '70rpx'
: '',
}"
></image>
<image class="foot-icon" :src="item.photo" mode="widthFix" v-if="current != index" :style="{
width: item.photo.includes('footer_localLife.png')
? '70rpx'
: '',
}"></image>
<image
:class="{ 'foot-icon3': item.photo.includes('footer_richScan.png'), 'foot-icon2': !item.photo.includes('footer_richScan.png') }"
:src="item.photoAc"
mode="widthFix"
v-if="current == index"
></image>
:src="item.photoAc" mode="widthFix" v-if="current == index"></image>
</view>
<text class="foot-label" id="navIndexLabel">{{ item.nav_name }}</text>
@ -36,6 +21,9 @@
</template>
<script>
import { NavgateTo } from "../../utils";
export default {
name: "nav",
props: {
@ -163,15 +151,36 @@ export default {
const url = e.currentTarget.dataset.url;
const index = e.currentTarget.dataset.idx;
const item = this.navList[index];
//
if (item.isScan) {
// uni-appAPI
uni.scanCode({
success: (res) => {
//
console.log('扫码结果:', res.result);
//
console.log('扫码结果:', res);
// respath
if (res.path) {
console.log('扫码结果中的path:', res.path);
// pathscene
const pathParts = res.path.split('?');
if (pathParts.length > 1) {
const queryParams = pathParts[1].split('&');
for (const param of queryParams) {
const [key, value] = param.split('=');
if (key === 'scene') {
const params = {
id: value
}
uni.setStorageSync('merchantInfo', params);
NavgateTo('/packages/localLife/detail/index')
break;
}
}
}
}
},
fail: (err) => {
console.log('扫码失败:', err);
@ -179,7 +188,7 @@ export default {
});
return;
}
// url
if (!url || url.trim() === '') {
this.NotOpen();

View File

@ -1,11 +1,12 @@
<template>
<view class="container">
<view class="white_container">
<swiper class="swiper" autoplay>
<image class="pic" :src="picUrl + info.album_images" />
<!-- <swiper class="swiper" autoplay>
<swiper-item v-for="(item, pageIndex) in info.bigImg" :key="pageIndex">
<image class="pic" :src="picUrl + item" />
</swiper-item>
</swiper>
</swiper> -->
<view class="main">
<view class="title">{{ info.merchant_name }}</view>
@ -28,7 +29,7 @@
</view>
<view class="table">
<view class="label">营业地址</view>
<view class="desc">{{ info.comAddress }}</view>
<view class="desc" v-if="info.ad">{{ info.ad.ad_name ? info.ad.ad_name.replace(/,/g, "") : "" }}{{ info.address }}</view>
</view>
<view class="table mb32">
<view class="label">特色服务</view>
@ -97,7 +98,7 @@
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/Index_add.png" mode="" />
<view>导航</view>
</view>
<view class="left_label" @click="handlePhoneClick">
<view class="left_label" @click="handlePhoneClick" v-if="info.phone">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/localLife_detail_Frame.png"
mode="" />
<view>电话</view>
@ -136,14 +137,22 @@ export default {
};
},
onLoad(options) {
this.info = uni.getStorageSync("merchantInfo")
const params = {
id: uni.getStorageSync("merchantInfo").id
}
request(apiArr.getMerchantInfo, "POST", params).then(res => {
this.info = res
// onLoad
this.page_num = 1
this.flag = false
this.commentList = []
this.getCommentList()
this.getMerchantInfo()
})
},
onShow() {
this.page_num = 1
this.flag = false
this.commentList = []
this.getCommentList()
this.getMerchantInfo()
// onLoad
},
onReachBottom() {
if (this.flag) {
@ -169,7 +178,7 @@ export default {
} else {
this.flag = false;
}
this.isShow = res.rows[0].merchant_info.quick_purchase_enabled == 1
this.isShow = res.rows[0]?.merchant_info.quick_purchase_enabled == 1
const list = res.rows.filter((item) => {
return item.status == 2;
});