Commit 402a60ed by 李嘉林

选择门店

parent 6641f197
import { requestPOST, requestPOST1 } from "@/utils/request.js";
export default {
getShopInfo() {
return requestPOST(`${process.env.OLSHOP_URL}/shop/get_shop_info`);
......@@ -12,14 +11,13 @@ export default {
},
addWxMiniSubscribeMessageRecord(data) {
return requestPOST(
`${process.env.OLSHOP_URL}/shop/addWxMiniSubscribeMessageRecord`, data
`${process.env.OLSHOP_URL}/shop/addWxMiniSubscribeMessageRecord`,
data
);
},
// 页面数据
themePagesInfo(params) {
return requestPOST(
`${process.env.OLSHOP_URL}/cms/get_shop_install_pages?homePageFlag=${params.homePageFlag||false}`,
params
return requestPOST(`${process.env.OLSHOP_URL}/cms/get_shop_install_pages?homePageFlag=${params.homePageFlag || false}&shopMixId=${params.shopMixId}`,
);
},
checkShowCondition(params) {
......@@ -30,12 +28,9 @@ export default {
},
// 获取新版会员卡列表
getV3CardList(params) {
return requestPOST(
`${process.env.OLSHOP_URL}/user/membership_card_list`,
{
return requestPOST(`${process.env.OLSHOP_URL}/user/membership_card_list`, {
params
}
);
});
},
// 领取新版无门槛会员卡
drawV3Card(params) {
......@@ -45,13 +40,22 @@ export default {
},
//获取shop配置
get_shop_configuration(){
return requestPOST(
`${process.env.OLSHOP_URL}/shop/get_shop_configuration`
);
get_shop_configuration() {
return requestPOST(`${process.env.OLSHOP_URL}/shop/get_shop_configuration`);
},
// 获取系统配置
get_system_config_by_code(params) {
return requestPOST(`${process.env.OLSHOP_URL}/common/get_system_config_by_code?code=${params.code}`)
},
return requestPOST(
`${process.env.OLSHOP_URL}/common/get_system_config_by_code?code=${
params.code
}`
);
},
// 首页获取线下门店列表
getThousandsStoresOfflineStore(data) {
return requestPOST(
`${process.env.OLSHOP_URL}/shop/get_thousands_stores_offline_store`,
data
);
}
};
<template>
<div class="storeAddr flex" v-if="openThousandsStoresFlag">
<div class="left flex">
<div class="logo">
<image :src="shopLogo" alt=""></image>
</div>
<div class="contentInfo flex" v-if="name != ''">
<p class="info">{{ name }}</p>
<p class="change" @click="pushStorePage">[切换]</p>
</div>
</div>
</div>
</template>
<script>
import shop from "@/api/shop";
import { DFSImg } from "@/utils/index";
import {setStoreInfo, getStoreInfo} from "@/utils/mayi"
const app = getApp();
export default {
data() {
return {
show: false,
name: "",
storeList: [],
userLatitude: "", //纬度
userLongitude: "", //经度
offlineStoreReq: {
latitude: "",
longitude: "",
pageNum: 0,
pageSize: 100,
shopName: "",
whetherOnlineShop: 1 //是否网店(0:不是,1:是) 给1 或 null
}
};
},
onLoad() {
this.getShopList();
},
computed: {
shopName() {
return app.globalData.shopInfo.shopName;
},
shopLogo() {
return DFSImg(app.globalData.shopInfo.logoUrl, 400, 400);
},
// 开启连锁商城(千店千面)
openThousandsStoresFlag() {
return app.globalData.shopInfo.openThousandsStoresFlag == 1
}
},
methods: {
getShopList() {
if (!this.openThousandsStoresFlag) {
// 未开启连锁商城初始化
setStoreInfo({
offlineShopCode: "",
offlineShopName: "",
});
return;
};
shop.getThousandsStoresOfflineStore(this.offlineStoreReq).then(res1 => {
let res = res1.data;
if (res.code == 200) {
if (res.data && res.data.length != 0) {
this.storeList = res.data;
let isStore = false;
let { offlineShopName, offlineShopCode } = getStoreInfo();
console.log(offlineShopName,offlineShopCode, '------------------sa114')
this.storeList.forEach((item, index) => {
if (item.shopName == offlineShopName) {
isStore = true;
} else if (offlineShopCode == "") {
isStore = true;
}
});
console.log(offlineShopName, isStore, "sa97");
if (offlineShopName && isStore) {
console.log("判断列表中是否存在(未关闭网店)");
this.name = offlineShopName;
// this.$emit("toUpdate");
} else {
console.log("如果关闭网店,重新选择列表第一个");
setStoreInfo({
offlineShopCode: this.storeList[0].shopCode,
offlineShopName: this.storeList[0].shopName,
});
this.name = this.storeList[0].shopName;
// this.$emit("toUpdate");
}
// this.$emit("toUpdate");
} else {
console.log("如果列表为空--选择商城");
setStoreInfo({
offlineShopCode: "",
offlineShopName: this.shopName,
});
this.name = this.shopName;
}
}
});
},
// 去切换门店页面
pushStorePage() {
app.$themeToLink({
type: 1,
link: `/chooseStores`,
})
}
}
};
</script>
<style lang="scss" scoped>
.storeAddr {
padding: 6px 12px;
justify-content: space-between;
.left,
.right {
align-items: center;
i.iconfont {
font-size: 22px;
margin: 0 5px;
}
}
.left {
align-items: center;
.contentInfo {
align-items: flex-start;
.info {
font-size: 14px;
color: #999;
flex: 1;
}
.change {
flex-shrink: 0;
padding-left: 6px;
color: #333;
font-size: 14px;
}
}
.logo {
width: 30px;
height: 30px;
border-radius: 50%;
overflow: hidden;
margin-right: 10px;
image {
width: 100%;
height: 100%;
object-fit: cover;
}
}
}
.right {
i.iconfont {
font-size: 24px;
}
}
}
</style>
\ No newline at end of file
......@@ -18,6 +18,7 @@ import {
getUrlofQuery
} from "../utils/mayi.js";
import { serialize, DFSImg} from "@/utils/index";
import { getStoreInfo } from "@/utils/mayi.js";
const app = getApp();
const { log } = app;
......@@ -42,15 +43,19 @@ export default {
},
computed: {
pageUrl() {
console.log(this.link,'******',this.page,'-------',this.params,'++++++++')
return (
this.link +
this.page +
this.params +
console.log(this.link, '******', this.page, '-------', this.params, '++++++++')
this.params +=
`&native_test=1&tabbar=${this.index}&location_obj=${wx.getStorageSync(
"location"
)}` +
this.ss+this.timestamp
)}`
// url添加门店信息参数
let { offlineShopCode, offlineShopName } = getStoreInfo();
if (offlineShopCode) {
this.params+=`&offlineShopCode=${offlineShopCode}&offlineShopName=${offlineShopName}`
}
return (
this.link +
this.page + this.params + this.ss+this.timestamp
);
}
},
......
......@@ -143,7 +143,7 @@ mpApp.DFSImg = DFSImg;
mpApp.concatUrl = concatUrl;
mpApp.spokesmanApi = spokesmanApi
mpApp.getThemePage = getThemePage
// mpApp.getThemePage = getThemePage
mpApp.themeColor = {}
mpApp.log = log
......@@ -152,7 +152,6 @@ mpApp.tool = tool
function getThemePage({mixid,shopid}) {
shop
.themePagesInfo({
shopid,
shopMixId: mixid,
homePageFlag: true
})
......
<template>
<div class="domain" :style="{'--main-color':themeColor['--main-color'],'--minor-color':themeColor['--minor-color']}">
<!-- <view class="ant-daipinglun">1</view> -->
<!-- <goods-list id="goodsList"></goods-list> -->
<!-- <scroll-view @scroll="scrolls" @scrolltolower="scrolltolower" style="height:100vh;overflow-y:auto;" scroll-y="true"> -->
<div style="position:relative;">
<div v-if="showSpokesManHome">
<get-index-homepage class="getIndexHomePage"></get-index-homepage>
</div>
<ThemeDataPlant></ThemeDataPlant>
<StoreAddr></StoreAddr>
<div v-for="(item,index) in pageData" :key="index">
<div v-if="item.componentCode=='banner' && item.componentInfo.visible == 1">
<banner :datas="item"></banner>
......@@ -173,11 +171,12 @@ import memberInfo from "../../components/basicTool/member-info";
import GoodsFliters from "../../components/common/GoodsFliters";
import SelectGoods from "../../components/common/SelectGoods";
import TwoBAddCart from "../../components/common/TwoBAddCart";
import { setTabBarActive, checkTabbarPage,themeColor, checkShowConditionIds } from "../../utils/mayi.js";
import { setTabBarActive, checkTabbarPage,themeColor, checkShowConditionIds, setStoreInfo } from "../../utils/mayi.js";
import indexApi from "@/api/index.js";
import { throttle, concatUrl } from "../../utils/index.js"
import mpvueCropper from '@/components/mpvue-cropper'
import tool from '../../utils/tool.js'
import StoreAddr from "@/components/common/StoreAddr.vue";
const app = getApp();
const { log } = app;
export default {
......@@ -219,8 +218,8 @@ export default {
shopPopup,
bottomCont,
ThemeDataPlant,
'text-text':text,
'img-text':imgText,
"text-text": text,
"img-text": imgText,
coupon,
integralTurntable,
transverseLabel,
......@@ -232,14 +231,15 @@ export default {
birthPopup,
mpvueCropper,
woTimeout,
'custom-list':customList,
'rich-text':richText,
'member-info':memberInfo,
"custom-list": customList,
"rich-text": richText,
"member-info": memberInfo,
GoodsFliters,
SelectGoods,
TwoBAddCart,
brandList
},
brandList,
StoreAddr
},
computed: {
applySucessEntryFlag() {
// 高意匠不展示
......@@ -320,8 +320,18 @@ export default {
})
},
onLoad(options) {
console.log(new Date().getTime(),'load-----home-onLoad')
console.log(options,'---------home----options')
log.info(options,'---------home----options')
log.info(options, '---------home----options')
let h5Params = options && options.params ? JSON.parse(decodeURIComponent(options.params)) : "";
console.log(h5Params,'--h5Params')
if (h5Params) {
// 存储h5url门店信息
setStoreInfo({
offlineShopCode:h5Params.offlineShopCode,
offlineShopName:h5Params.offlineShopName,
});
}
//进页面存储需要绑定的信息
if(options.userId||options.spokesmanRelId) {
wx.setStorage({
......@@ -457,8 +467,10 @@ export default {
console.log('storageGoodsList---detory');
},
onShow() {
onShow(options) {
console.log(new Date().getTime(),'load-----home-onShow')
// 设置显示条件
console.log(new Date().getTime(),'--------on--------------show')
log.info('--------on--------------show')
//分销隔流
if(this.toHomePage) {
......
......@@ -11,6 +11,7 @@ import shop from "@/api/shop.js";
import indexApi from "@/api/index.js";
import { serialize, getQueryVariable, DFSImg } from "@/utils/index";
import login from "@/api/login";
import { getStoreInfo } from "@/utils/mayi.js";
const app = getApp();
const { log } = app;
export default {
......@@ -66,6 +67,11 @@ export default {
if(wx.getStorageSync("enterpriseAccount")){
this.params +=`&enterpriseAccount=${wx.getStorageSync("enterpriseAccount")}`;
}
// url添加门店信息参数
let { offlineShopCode, offlineShopName } = getStoreInfo();
if (offlineShopCode) {
this.params+=`&offlineShopCode=${offlineShopCode}&offlineShopName=${offlineShopName}`
}
console.log(this.link,'=======',this.page,'++++++++++++++',this.params,'************')
let pageUrl1 = (this.page.startsWith('http://') || this.page.startsWith('https://'))? (this.page + this.params) : this.link+this.page+this.params
console.log(pageUrl1,'--------pageUrl1--')
......@@ -81,6 +87,7 @@ export default {
return;
}
this.newPageUrl = this.pageUrl;
console.log('------------------index----2')
// 进入直播页面调用不息屏api
console.log(this.pageUrl,this.pageUrl.includes('/liveBroadcast/lived'),"this.pageUrl.includes('/liveBroadcast/lived')")
if(this.pageUrl.includes('/liveBroadcast/lived')){
......@@ -139,7 +146,15 @@ export default {
this.options = options;
log.info(this.options,'----------------index-----options')
Object.assign(this.$data, this.$options.data());
let h5Params = options && options.params ? JSON.parse(decodeURIComponent(options.params)) : "";
console.log(h5Params,'--h5Params')
if (h5Params) {
// 存储h5url门店信息
setStoreInfo({
offlineShopCode:h5Params.offlineShopCode,
offlineShopName:h5Params.offlineShopName,
});
}
if(wx.getStorageSync("workBox")){
this.params += `&workBox=${wx.getStorageSync("workBox")}`
}
......@@ -429,7 +444,7 @@ export default {
// var query = options.query.dentistId; // 参数二维码传递过来的场景参数
}
this.newPageUrl = this.pageUrl;
// this.newPageUrl = this.pageUrl;
this.init();
},
onShow(){
......
......@@ -9,6 +9,7 @@
<script type="text/ecmascript-6">
let forUrlAddKey = require("mayi-front-tools/forUrlAddKey").default;
import { serialize, getQueryVariable, DFSImg } from "@/utils/index";
import { getStoreInfo } from "@/utils/mayi.js";
const app = getApp();
const { log } = app;
export default {
......@@ -32,6 +33,11 @@ export default {
if (wx.getStorageSync("enterpriseAccount")) {
this.params += `&enterpriseAccount=${wx.getStorageSync("enterpriseAccount")}`;
}
// url添加门店信息参数
let { offlineShopCode, offlineShopName } = getStoreInfo();
if (offlineShopCode) {
this.params+=`&offlineShopCode=${offlineShopCode}&offlineShopName=${offlineShopName}`
}
console.log(this.baseUrl, '=======', this.page, '++++++++++++++', this.params, '************')
let pageUrl1 = (this.page.startsWith('http://') || this.page.startsWith('https://')) ? (this.page + this.params) : this.baseUrl + this.page + this.params
console.log(pageUrl1, '--------pageUrl1--')
......
......@@ -10,9 +10,6 @@ const mutations = {
setSubscribeMessageObj(state, subscribeMessageObj) {
state.subscribeMessageObj = subscribeMessageObj;
},
setOfflineShopCode(state, code) {
state.offlineShopCode = code;
},
//设置登录状态
setLoginStatus(state,val){
......
......@@ -17,7 +17,6 @@ const state = {
spokesmanRelId: "",
userId : "",
subscribeMessageObj: {},
offlineShopCode:"",
isLogin,
userInfo,
shopUserInfo: {},
......
import cart from "@/api/cart"
import shop from "@/api/shop"
import cart from "@/api/cart";
import shop from "@/api/shop";
import coupon from "@/api/coupon";
import goods from '@/api/goods';
import goods from "@/api/goods";
import classificationApi from "@/api/classification";
// 登录白名单 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"
];
// path
export const noLoginListPath = noLoginList.map(item => {
item = item.replace(/-/g, '/')
item = '/' + item
item == "/index" && (item = "/")
return item
})
item = item.replace(/-/g, "/");
item = "/" + item;
item == "/index" && (item = "/");
return item;
});
// 有底部栏页面
export const containFooterPage = ["/", "/goods/commodityMenu", "/shopCart/shoppingCart", "/personalCenter"]
export const containFooterPage = [
"/",
"/goods/commodityMenu",
"/shopCart/shoppingCart",
"/personalCenter"
];
// 主题色
export let themeColor = {
"--main-color": "#ffffff",
"--minor-color": "#ffffff"
}
};
// 获取link 中页面地址(link兼容 有object或者string)
export function getUrlofLink(data) {
if(typeof data == 'object' && data.link){
return data.link.split('?')[0]
if (typeof data == "object" && data.link) {
return data.link.split("?")[0];
}
if(typeof data == 'string'){
return data.split('?')[0]
if (typeof data == "string") {
return data.split("?")[0];
}
}
export function getUrlofQuery(data) {
return data.link.split('?')[1] || ''
return data.link.split("?")[1] || "";
}
// 全局跳转 data:link数据 option:是否为底部栏触发
export function $themeToLink(data, option) {
// console.log(currentPage,'currentPage',getUrlofLink(data))
// if(getUrlofLink(data).includes(currentPage)) return
......@@ -48,11 +90,14 @@ export function $themeToLink(data, option) {
let parseLink = getUrlofLink(data);
let parseQuery = getUrlofQuery(data);
let noLogin = noLoginListPath.includes(parseLink) || parseLink.substr(0, 7) == "/goods/" || parseLink.includes('/brandTopics');
let noLogin =
noLoginListPath.includes(parseLink) ||
parseLink.substr(0, 7) == "/goods/" ||
parseLink.includes("/brandTopics");
if (!noLogin && !wx.getStorageSync("sessionid")) {
let url = `/pages/login/main?back=${parseLink}`;
wx.navigateTo({ url });
return
return;
}
//判断是否市跳转到tabbar页面 替换首页位置
let isTabbarIndex = checkTabbarPage(parseLink);
......@@ -63,77 +108,97 @@ export function $themeToLink(data, option) {
// return
// }
isTabbarIndex = isTabbarIndex == 0 ? checkTabbarPage('/') : isTabbarIndex;
let url=parseLink == '/' ? `/pages/home/main` : `/pages/tabBar${isTabbarIndex}/main`;
isTabbarIndex = isTabbarIndex == 0 ? checkTabbarPage("/") : isTabbarIndex;
let url =
parseLink == "/"
? `/pages/home/main`
: `/pages/tabBar${isTabbarIndex}/main`;
let routes = getCurrentPages();
let currentPage = routes[routes.length - 1].route;
if (currentPage==url) return
if (currentPage == url) return;
let query=parseQuery?`?${parseQuery}`:'';
let query = parseQuery ? `?${parseQuery}` : "";
wx.reLaunch({
url:url+query
})
return
url: url + query
});
return;
}
}
// 历史数据
if (type == undefined || type == 'undefined') {
if (type == undefined || type == "undefined") {
if (data.length > 0) {
toPage(getUrlofLink(data), getUrlofQuery(data))
toPage(getUrlofLink(data), getUrlofQuery(data));
}
return
return;
}
// -----------------
if (type == 0) {//无链接
return
} else if (type == 1) {//h5页面
if (type == 0) {
//无链接
return;
} else if (type == 1) {
//h5页面
//兼容
if (data.link.substring(0, 1) == "/") {
toPage(getUrlofLink(data), getUrlofQuery(data))
toPage(getUrlofLink(data), getUrlofQuery(data));
} else {
if (data.link.startsWith('http') || data.link.startsWith('https')) {
wx.navigateTo({ url: '/pages/wxArticle/main?link=' + encodeURIComponent(data.link) });
if (data.link.startsWith("http") || data.link.startsWith("https")) {
wx.navigateTo({
url: "/pages/wxArticle/main?link=" + encodeURIComponent(data.link)
});
}
}
} else if (type == 1.1) {//小程序页面 可能增加登录态拦截
} else if (type == 1.1) {
//小程序页面 可能增加登录态拦截
wx.navigateTo({ url: data.link });
} else if (type == 1.2) { //第三方链接
if (data.link == 'outerChain:businessCenter') {
} else if (type == 1.2) {
//第三方链接
if (data.link == "outerChain:businessCenter") {
// 进入商家中心外链
let url = `${config.GUIDE_URL}/login?mixid=${this.$nuxt.$route.query.mixid}&back=${encodeURIComponent(window.location.href)}`;
wx.navigateTo({ url: '/pages/wxArticle/main?link=' + encodeURIComponent(url) });
return
let url = `${config.GUIDE_URL}/login?mixid=${
this.$nuxt.$route.query.mixid
}&back=${encodeURIComponent(window.location.href)}`;
wx.navigateTo({
url: "/pages/wxArticle/main?link=" + encodeURIComponent(url)
});
return;
}
if (data.link.substring(0, 1) == "/") {
toPage(getUrlofLink(data), getUrlofQuery(data))
toPage(getUrlofLink(data), getUrlofQuery(data));
} else {
wx.navigateTo({ url: '/pages/wxArticle/main?link=' + encodeURIComponent(data.link) });
wx.navigateTo({
url: "/pages/wxArticle/main?link=" + encodeURIComponent(data.link)
});
}
} else if (type == 2) {//功能
} else if (type == 2) {
//功能
let featureType = data.feature.type;
if (featureType == 'themeCouponClick' || featureType == 0) {//优惠券
if (featureType == "themeCouponClick" || featureType == 0) {
//优惠券
// this.$themeCouponClick(data.feature.value.couponCode, data.feature.value);
} else if (featureType == 1) {//分享
console.log('是分享了。。。。');
} else if (featureType == 1) {
//分享
console.log("是分享了。。。。");
app.shareInit({ itemList: data.feature.value });
} else if (featureType == "themeMemberCardClick" || featureType == 2) { //会员卡
} else if (featureType == "themeMemberCardClick" || featureType == 2) {
//会员卡
// this.$themeMemberCardClick(data.feature.value);
}
} else if (type == 3) { //小程序跳转到小程序
} else if (type == 3) {
//小程序跳转到小程序
wx.navigateTo({
url: `/pages/toMini/main?weappPage=${encodeURIComponent(data.link)}&weappAppId=${data.name}`,
})
url: `/pages/toMini/main?weappPage=${encodeURIComponent(
data.link
)}&weappAppId=${data.name}`
});
} else {
//向后兼容
if (data.length > 0) {
toPage(getUrlofLink(data), getUrlofQuery(data))
toPage(getUrlofLink(data), getUrlofQuery(data));
}
}
}
export function $themeAddToCard(item, callback = () => { }) {
export function $themeAddToCard(item, callback = () => {}) {
let errorMsg = "";
if (item.productNature == 5) {
errorMsg = "电子卡券不可加入购物车";
......@@ -147,7 +212,7 @@ export function $themeAddToCard(item, callback = () => { }) {
if (errorMsg) {
wx.showToast({
title: errorMsg,
icon: 'none',
icon: "none"
});
}
cart
......@@ -163,64 +228,70 @@ export function $themeAddToCard(item, callback = () => { }) {
}
function toPage(backPath, backParams = "") {
console.log(backPath, backParams,'--------------------------159');
console.log(backPath, backParams, "--------------------------159");
wx.navigateTo({
url: `../index/main?from=themeLink&backpath=${encodeURIComponent(backPath)}&params=${encodeURIComponent(backParams)}`
url: `../index/main?from=themeLink&backpath=${encodeURIComponent(
backPath
)}&params=${encodeURIComponent(backParams)}`
});
}
// check 链接是否为底部导航栏页面 返回索引
export function checkTabbarPage(link) {
let app = getApp()
if (!app.globalData.footerVal) return -1
let app = getApp();
if (!app.globalData.footerVal) return -1;
let footerVal = app.globalData.footerVal.componentData.list;
let isFooter = footerVal.findIndex(item => {
return getUrlofLink(item.link) == link.split('?')[0]
})
return isFooter
return getUrlofLink(item.link) == link.split("?")[0];
});
return isFooter;
}
// 当前底部栏选中项
export function setTabBarActive(data) {
// console.log(data,'sssssssssss',this.$mp.page.getTabBar(),data)
if (data < 0 || !this.$mp.page) return
if (typeof this.$mp.page.getTabBar === 'function' &&
this.$mp.page.getTabBar()) {
if (data < 0 || !this.$mp.page) return;
if (
typeof this.$mp.page.getTabBar === "function" &&
this.$mp.page.getTabBar()
) {
this.$mp.page.getTabBar().setData({
selected: data
})
});
}
}
// 遍历所有组件有显示条件的id 是否包含地区导航组件
export function checkShowConditionIds(list) {
let allCondition = [];
let isAreaNavigation = false;
list.forEach(element => {
// 有地区导航组件
if (element.componentCode == 'area-navigation') {
isAreaNavigation = true
if (element.componentCode == "area-navigation") {
isAreaNavigation = true;
}
pollCondition(element)
pollCondition(element);
});
function pollCondition(object) {
if (Object.prototype.toString.call(object) === '[object Object]') {
if (object.condition != '' && object.condition != undefined) {
if (Object.prototype.toString.call(object) === "[object Object]") {
if (object.condition != "" && object.condition != undefined) {
allCondition.push(object.condition);
}
for (const key in object) {
if (object.hasOwnProperty(key)) {
const element = object[key];
if (Object.prototype.toString.call(element) === '[object Object]') {
if (element.condition != '' && element.condition != undefined) {
if (Object.prototype.toString.call(element) === "[object Object]") {
if (element.condition != "" && element.condition != undefined) {
allCondition.push(element.condition);
}
pollCondition(element)
} else if (Object.prototype.toString.call(element) === '[object Array]' && element.length > 0) {
element.forEach((item) => {
pollCondition(item)
})
pollCondition(element);
} else if (
Object.prototype.toString.call(element) === "[object Array]" &&
element.length > 0
) {
element.forEach(item => {
pollCondition(item);
});
}
}
}
......@@ -229,13 +300,13 @@ export function checkShowConditionIds(list) {
return {
allCondition: [...new Set(allCondition)],
isAreaNavigation
}
};
}
export function $themeArticleLike(item, callback) {
let query = { articleId: item.id };
classificationApi.addLike(query).then(res => {
if (res.data.code == "200") {
if (res.data.data == 'true') {
if (res.data.data == "true") {
callback("true");
} else {
callback("false");
......@@ -250,7 +321,8 @@ export function getCoupon(code, item) {
let couponCode = code;
console.log(item, "------------------------242");
if (item.receiveCostType == 1) {
wx.showModal({
wx
.showModal({
confirmColor: "#CA173B",
content: `是否消耗${usingIntegrals}积分领取`
})
......@@ -264,7 +336,7 @@ export function getCoupon(code, item) {
} else {
useCoupon(1, couponCode, usingIntegrals);
}
};
}
function useCoupon(val, couponCode, usingIntegrals) {
coupon.receive_coupon(couponCode).then(res => {
console.log(res, "cou137");
......@@ -277,17 +349,17 @@ function useCoupon(val, couponCode, usingIntegrals) {
}
// item.receive=false;
} else {
wx.showToast({title:res.data.msg ,icon :"none"});
wx.showToast({ title: res.data.msg, icon: "none" });
// item.receive=true;
}
});
};
}
export function themeMemberCardClick(item) {
let query = {
portalCardId: item.id
};
shop.getV3CardList(query).then(res => {
console.log(res,'--------------------282')
console.log(res, "--------------------282");
if (res.data.code == 200) {
let cardData = "";
res.data.data.forEach(innerItem => {
......@@ -296,7 +368,9 @@ export function themeMemberCardClick(item) {
}
});
let cardId = cardData.id;
let userInfo = wx.getStorageSync("userInfo") ? JSON.parse(wx.getStorageSync("userInfo")) : "";
let userInfo = wx.getStorageSync("userInfo")
? JSON.parse(wx.getStorageSync("userInfo"))
: "";
if (cardData.receiveWay == 0) {
// 无门槛
shop.drawV3Card(cardId).then(res => {
......@@ -304,7 +378,7 @@ export function themeMemberCardClick(item) {
wx.showToast({
content: `开通【${cardData.title}】成功`,
showCancel: false,
confirmColor: '',
confirmColor: "",
success: res => {
let backParams = `&cardId=${cardData.id}`;
if (userInfo.mobilephone) {
......@@ -312,15 +386,15 @@ export function themeMemberCardClick(item) {
}
toPage("/personalCenter/membershipCard", backParams);
}
})
});
} else {
if (res.data.msg == "不能重复领卡") {
console.log("---------------------------to-----1")
console.log("---------------------------to-----1");
let backParams = `&cardId=${cardData.id}`;
if (userInfo.mobilephone) {
backParams += `&userTel=${userInfo.mobilephone}`;
}
toPage("/personalCenter/membershipCard",backParams);
toPage("/personalCenter/membershipCard", backParams);
} else {
wx.showToast({ title: res.data.msg, icon: "none" });
}
......@@ -332,11 +406,11 @@ export function themeMemberCardClick(item) {
} else if (cardData.receiveWay == 2) {
// 付费购买
if (cardData.receiveStatus == 0) {
console.log("---------------------------to-----2")
console.log("---------------------------to-----2");
let backParams = `&cardId=${cardData.id}`;
toPage("/pay/payCard", backParams);
} else {
console.log("---------------------------to-----3")
console.log("---------------------------to-----3");
let backParams = `&cardId=${cardData.id}`;
if (userInfo.mobilephone) {
backParams += `&userTel=${userInfo.mobilephone}`;
......@@ -347,91 +421,129 @@ export function themeMemberCardClick(item) {
console.error("无效的领取方式");
}
} else {
wx.showToast({title:res.data.msg,icon:"none"});
wx.showToast({ title: res.data.msg, icon: "none" });
if (res.data.code == 300) {
console.log('----------334')
console.log("----------334");
// 未登录
setTimeout(() => {
let url = `/pages/login/main?back=${encodeURIComponent('/')}`;
let url = `/pages/login/main?back=${encodeURIComponent("/")}`;
wx.navigateTo({ url: url });
}, 200);
}
}
});
};
}
// 扫码
export function themeScanningCodeClick() {
let app = getApp()
let app = getApp();
let { $themeToLink } = app;
console.log("themeScanningCodeClick")
console.log("themeScanningCodeClick");
wx.scanCode({
success(res) {
console.log(res, '-----scanCode-success')
let { scanType, path,result } = res;
console.log(res, "-----scanCode-success");
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') {
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") {
// 微信二维码
$themeToLink({
type :1.1,
link : path[0] == '/'?path:`/${path}`
type: 1.1,
link: path[0] == "/" ? path : `/${path}`
});
} else if (scanType == 'QR_CODE') {
} else if (scanType == "QR_CODE") {
// 二维码
// http链接或h5链接
// type 1h5页面 1.1小程序页面 1.2http链接
if (result.startsWith('http') || result.startsWith('/')) {
if (result.startsWith("http") || result.startsWith("/")) {
// 链接跳转
$themeToLink({
type: result.startsWith('http')?1.2:1,
type: result.startsWith("http") ? 1.2 : 1,
link: result
})
});
} else {
// 跳转搜索页
$themeToLink({
type: 1,
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 => {
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}`
link: `/goods/${item.productId}?terminalProductId=${
item.terminalProductId
}`
});
} else {
// 提示:对不起,无法正确识别该条形码。请直接联系导购员;
wx.showModal({
content: '对不起 无法正确识别该条形码\n请直接联系导购员',
content: "对不起 无法正确识别该条形码\n请直接联系导购员",
showCancel: false
});
}
}).catch(console.log);
})
.catch(console.log);
}
},
fail(res) {
console.log(res,'-----scanCode-fail')
console.log(res, "-----scanCode-fail");
},
complete(res) {
console.log(res,'-----scanCode-complete')
},
console.log(res, "-----scanCode-complete");
}
});
}
/**
* 缓存门店code、name
*/
export function setStoreInfo({ offlineShopCode, offlineShopName }) {
console.log(offlineShopCode, offlineShopName, '--setStoreInfo');
wx.setStorageSync("offlineShopCode", offlineShopCode);
wx.setStorageSync("offlineShopName", offlineShopName);
}
/**
*
* 获取门店code、name
*/
export function getStoreInfo() {
return {
offlineShopCode: wx.getStorageSync("offlineShopCode") || "",
offlineShopName: wx.getStorageSync("offlineShopName") || ""
};
}
......@@ -13,7 +13,7 @@ export async function requestGET(url, options) {
method: "GET",
header: {
"Shop-Mixid": store.state.mixid,
"Offline-Shop-Code": store.state.offlineShopCode,
"Offline-Shop-Code": wx.getStorageSync('offlineShopCode') || "",
"Authorization": wx.getStorageSync('sessionid') || "",
"Region-id" : wx.getStorageSync('location') ? JSON.parse(wx.getStorageSync('location')).systemRegionId : '',
"Area-Id": wx.getStorageSync('location') ? JSON.parse(wx.getStorageSync('location')).id : '',
......@@ -38,7 +38,7 @@ export async function requestPOST(url, options) {
header: {
"Shop-Mixid": store.state.mixid,
"Authorization": wx.getStorageSync('sessionid') || "",
"Offline-Shop-Code": store.state.offlineShopCode,
"Offline-Shop-Code": wx.getStorageSync('offlineShopCode') || "",
"openId": wx.getStorageSync("openid") || '',
"Region-id": wx.getStorageSync('location') ? JSON.parse(wx.getStorageSync('location')).systemRegionId : '',
"Area-Id": wx.getStorageSync('location') ? JSON.parse(wx.getStorageSync('location')).id : '',
......@@ -64,7 +64,7 @@ export function requestPOST1(url, options) {
"Content-Type": "application/x-www-form-urlencoded",
"Shop-Mixid": store.state.mixid,
Authorization: wx.getStorageSync('sessionid') || "",
"Offline-Shop-Code": store.state.offlineShopCode,
"Offline-Shop-Code": wx.getStorageSync('offlineShopCode') || "",
"Region-id": wx.getStorageSync('location') ? JSON.parse(wx.getStorageSync('location')).systemRegionId : '',
"Area-Id": wx.getStorageSync('location') ? JSON.parse(wx.getStorageSync('location')).id : '',
// "dubbo-tag": "ljx"
......
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