Commit 839e6449 by HouTiZhuo

扫码搜书

parent c8b8cc6b
...@@ -4,6 +4,10 @@ export default { ...@@ -4,6 +4,10 @@ export default {
queryProductInfo(data) { queryProductInfo(data) {
return requestPOST(`${process.env.OLSHOP_URL}/product/query_product_info`, data); return requestPOST(`${process.env.OLSHOP_URL}/product/query_product_info`, data);
}, },
// 扫码查询商品
selectProductInfoOnEs(data) {
return requestPOST(`${process.env.OLSHOP_URL}/product/select_product_info_on_es`, data);
},
queryBriefProductInfo(data) { queryBriefProductInfo(data) {
return requestPOST(`${process.env.OLSHOP_URL}/product/query_brief_product_info`, data); return requestPOST(`${process.env.OLSHOP_URL}/product/query_brief_product_info`, data);
}, },
......
import cart from "@/api/cart" import cart from "@/api/cart"
import shop from "@/api/shop" import shop from "@/api/shop"
import coupon from "@/api/coupon"; import coupon from "@/api/coupon";
import goods from '@/api/goods';
import classificationApi from "@/api/classification"; import classificationApi from "@/api/classification";
// 登录白名单 name // 登录白名单 name
export const noLoginList = ["index", "media-video", "goods-goodsInfo", "goods-commodityMenu", "goodsSearch-goodsSearch", "contentSearch-contentSearch", "chooseStores", "activty-receivingGift", "activty", "login-register", "login-phoneLogin", "login-authInformation", "login-forgetPassWord", "login-accountLogin", "login-wxRegister", "pay-payList", "comment-evaluateList", "goods-commonProblemList", "article-articlePage", "article-articleList", "goods-posters", "liveBroadcast", "liveBroadcast-list", "personalCenter-coupon-getCoupon", "buyerShow-showDetail", "goods-addGoodsList", "personalCenter-CDkey-exchange", "giftCards-linkReceive", "giftCoupon-preview", "smartForm", "shopCart-shareShopCart", "groupBuying-beInvite", "brandTopics", "personalCenter-spokesmanCenter", "personalCenter-spokesmanCenter-mine-spokesmanHomePage", "liveBroadcast-lived", "personalCenter-spokesmanCenter-mine-getBusinessCard", "changeAdr"]; export const noLoginList = ["index", "media-video", "goods-goodsInfo", "goods-commodityMenu", "goodsSearch-goodsSearch", "contentSearch-contentSearch", "chooseStores", "activty-receivingGift", "activty", "login-register", "login-phoneLogin", "login-authInformation", "login-forgetPassWord", "login-accountLogin", "login-wxRegister", "pay-payList", "comment-evaluateList", "goods-commonProblemList", "article-articlePage", "article-articleList", "goods-posters", "liveBroadcast", "liveBroadcast-list", "personalCenter-coupon-getCoupon", "buyerShow-showDetail", "goods-addGoodsList", "personalCenter-CDkey-exchange", "giftCards-linkReceive", "giftCoupon-preview", "smartForm", "shopCart-shareShopCart", "groupBuying-beInvite", "brandTopics", "personalCenter-spokesmanCenter", "personalCenter-spokesmanCenter-mine-spokesmanHomePage", "liveBroadcast-lived", "personalCenter-spokesmanCenter-mine-getBusinessCard", "changeAdr"];
...@@ -367,6 +368,10 @@ export function themeScanningCodeClick() { ...@@ -367,6 +368,10 @@ export function themeScanningCodeClick() {
success(res) { success(res) {
console.log(res, '-----scanCode-success') console.log(res, '-----scanCode-success')
let { scanType, path,result } = res; let { scanType, path,result } = res;
// 所有一维码类型
const barCodeTypes = ['AZTEC', 'CODABAR', 'CODE_39', 'CODE_93', 'CODE_128',
'EAN_8', 'EAN_13', 'ITF', 'MAXICODE', 'RSS_14', 'RSS_EXPANDED', 'UPC_A',
'UPC_E', 'UPC_EAN_EXTENSION', 'CODE_25'];
if (scanType == 'WX_CODE') { if (scanType == 'WX_CODE') {
// 微信二维码 // 微信二维码
$themeToLink({ $themeToLink({
...@@ -390,6 +395,36 @@ export function themeScanningCodeClick() { ...@@ -390,6 +395,36 @@ export function themeScanningCodeClick() {
link: '/contentSearch/contentSearch?placeHolderText=' + result link: '/contentSearch/contentSearch?placeHolderText=' + result
}) })
} }
} else if (barCodeTypes.includes(scanType)) {
// 一维码类型
const data = {
"searchWord": result,
"page": 1,
"rows": 10
}
goods.selectProductInfoOnEs(data).then(response => {
const res = response.data.data;
if (res.total > 1) {
// 多个 SKU 跳转商品搜索结果页,搜索框显示扫码内容,页面自动展示搜索结果;
$themeToLink({
type: 1,
link: `/goodsSearch/goodsSearch?placeHolderText=${result}&search_txt=${result}`
})
} else if (res.total == 1) {
const item = res.list[0];
// 唯一 SKU 跳转商品详情
$themeToLink({
type: 1,
link: `/goods/${item.productId}?terminalProductId=${item.terminalProductId}`
});
} else {
// 提示:对不起,无法正确识别该条形码。请直接联系导购员;
wx.showModal({
content: '对不起 无法正确识别该条形码\n请直接联系导购员',
showCancel: false
});
}
}).catch(console.log);
} }
}, },
fail(res) { fail(res) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment