首页扫一扫支持商品和店铺

master
gongfuxiang 2023-10-30 22:19:08 +08:00
parent 636df91992
commit cc1a83a9b2
3 changed files with 119 additions and 41 deletions

84
App.vue
View File

@ -66,14 +66,16 @@
weixin_privacy_setting_timer: null,
// 使0, 1线->->线 https://mp.weixin.qq.com/wxopen/plugindevdoc?appid=wx50b5593e81dd937a
is_weixin_open_location_use_plugins: 0,
// 0, 1APP
is_home_search_scan: 1,
// tabbar
tabbar_pages: ['/pages/index/index', '/pages/goods-category/goods-category', '/pages/cart/cart', '/pages/user/user'],
//
// request_url: 'https://new.shopxo.vip/',
request_url: 'http://shopxo.com/',
request_url: 'https://new.shopxo.vip/',
// request_url: 'http://shopxo.com/',
// publicpublichttps://d1.shopxo.vip/public/
// static_url: 'https://new.shopxo.vip/',
static_url: 'http://shopxo.com/',
static_url: 'https://new.shopxo.vip/',
// static_url: 'http://shopxo.com/',
// default
system_type: 'default',
//
@ -1119,12 +1121,21 @@
var is_redirect = parseInt(e.currentTarget.dataset.redirect || 0) == 1;
this.url_open(value, is_redirect);
},
// url
is_url(value) {
var arr = ['http:/', 'https:'];
return arr.indexOf(value.substr(0, 6)) != -1;
},
// page
is_page(value) {
var arr = ['/pages', 'pages/'];
return arr.indexOf(value.substr(0, 6)) != -1;
},
// url
url_open(value, is_redirect = false) {
if ((value || null) != null) {
// web
var http_arr = ['http:/', 'https:'];
if (http_arr.indexOf(value.substr(0, 6)) != -1) {
if (this.is_url(value)) {
this.open_web_view(value);
//
} else if (value.substr(0, 8) == 'appid://') {
@ -1144,6 +1155,7 @@
this.call_tel(value.substr(6));
//
} else {
if(this.is_page(value)) {
if (this.is_tabbar_pages(value)) {
var temp = value.split('?');
if (temp.length > 1 && (temp[1] || null) != null) {
@ -1165,6 +1177,9 @@
});
}
}
} else {
this.showToast('未知数据('+value+'');
}
}
}
},
@ -1937,6 +1952,63 @@
}
return width;
},
// weburlid
web_url_value_mate(url, rules) {
var value = null;
for(var i in rules) {
if(url.indexOf(rules[i]) != -1) {
var temp = url.split(rules[i]);
if(temp.length > 1) {
temp = temp[1].split('.');
if(temp.length > 0 && (temp[0] || null) != null) {
value = temp[0];
break;
}
}
}
}
return value;
},
//
scan_handle() {
var self = this;
uni.scanCode({
success: function (res) {
if(res.result !== '') {
var value = res.result;
// url
if(self.is_url(value)) {
//
var goods_arr = ['/goods-', '/goods/index/id/', '=goods/index/id/'];
var goods_id = self.web_url_value_mate(value, goods_arr);
if(goods_id != null) {
uni.navigateTo({
url: '/pages/goods-detail/goods-detail?id='+goods_id,
});
return;
}
//
var shop_arr = ['/shop-index-detail-', '/plugins/index/pluginsname/shop/pluginscontrol/index/pluginsaction/detail/id/', '=plugins/index/pluginsname/shop/pluginscontrol/index/pluginsaction/detail/id/'];
var shop_id = self.web_url_value_mate(value, shop_arr);
if(shop_id != null) {
uni.navigateTo({
url: '/pages/plugins/shop/detail/detail?id='+shop_id,
});
return;
}
// url
self.open_web_view(value);
} else {
self.url_open(value);
}
}
},
});
}
},
//
onLaunch(params) {},

View File

@ -187,7 +187,7 @@
z-index: 1;
left: 20rpx;
top: calc(50% - 14rpx);
line-height: 22rpx;
line-height: 26rpx;
}
.search-content input {

View File

@ -22,6 +22,8 @@
</view>
<!-- #endif -->
<view v-if="common_app_is_enable_search == 1" class="search-content-input dis-inline-block va-m" :style="top_content_search_style">
<!-- 是否开启搜索框前面icon扫一扫 -->
<block v-if="is_home_search_scan == 1">
<component-search
propPlaceholder="输入商品名称搜索"
propPlaceholderClass="cr-white"
@ -33,6 +35,15 @@
:propIsIconOnEvent="true"
<!-- #endif -->
></component-search>
</block>
<block v-else>
<component-search
propPlaceholder="输入商品名称搜索"
propPlaceholderClass="cr-white"
propIconColor="#fff"
propBgColor="rgb(255 255 255 / 0.5)"
></component-search>
</block>
</view>
<!-- #ifdef H5 || MP-TOUTIAO || APP -->
<!-- 右上角icon列表 -->
@ -329,6 +340,7 @@
data_bottom_line_status: false,
load_status: 0,
currency_symbol: app.globalData.data.currency_symbol,
is_home_search_scan: app.globalData.data.is_home_search_scan,
data_list: [],
banner_list: [],
navigation: [],
@ -635,13 +647,7 @@
// icon
search_icon_event(e) {
console.log(1)
uni.scanCode({
success: function (res) {
console.log(res.result)
app.globalData.open_web_view(res.result);
},
});
app.globalData.scan_handle();
}
}
};