Commit edb2cecd by 李嘉林

进店规则

parent 2c03ab4d
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
import shop from "@/api/shop"; import shop from "@/api/shop";
import spokesman from "@/api/spokesman"; import spokesman from "@/api/spokesman";
import { themeColor, checkShowConditionIds } from "@/utils/mayi"; import { themeColor, checkShowConditionIds, getStoreInfo } from "@/utils/mayi";
import { query_isEntry } from "@/utils/mayi_fenxiao"; import { query_isEntry } from "@/utils/mayi_fenxiao";
export default { export default {
created() { async created() {
console.log(new Date().getTime(),'load-----app-created')
// NODE_ENV // NODE_ENV
let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}; let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
console.log(extConfig, "-----------extConfig"); console.log(extConfig, "-----------extConfig");
...@@ -48,7 +49,7 @@ export default { ...@@ -48,7 +49,7 @@ export default {
mpvue.setStorageSync("logs", logs); mpvue.setStorageSync("logs", logs);
} }
// 初始 // 初始
this.getShopInfo(extConfig); await this.getShopInfo(extConfig);
...@@ -56,7 +57,7 @@ export default { ...@@ -56,7 +57,7 @@ export default {
this.getThemePage(extConfig); this.getThemePage(extConfig);
// 商城配置 // 商城配置
this.shopConfiguration() await this.shopConfiguration()
setTimeout(() => { setTimeout(() => {
let mpApp = getApp(); let mpApp = getApp();
...@@ -176,8 +177,8 @@ export default { ...@@ -176,8 +177,8 @@ export default {
return JSON.stringify(pageData); return JSON.stringify(pageData);
}, },
//商城配置 //商城配置
getShopInfo({ mixid }) { async getShopInfo({ mixid }) {
shop.getShopInfo({ shopMixId: mixid }).then((res) => { await shop.getShopInfo({ shopMixId: mixid }).then((res) => {
console.log("--app---getShopInfo") console.log("--app---getShopInfo")
if (res.data.code == 200) { if (res.data.code == 200) {
// 收集用户数据 // 收集用户数据
...@@ -252,8 +253,8 @@ export default { ...@@ -252,8 +253,8 @@ export default {
}); });
}, },
//商城配置 //商城配置
shopConfiguration(){ async shopConfiguration(){
shop.get_shop_configuration().then(res=>{ await shop.get_shop_configuration().then(res=>{
if (res.data.code == 200) { if (res.data.code == 200) {
let mpApp = getApp(); let mpApp = getApp();
mpApp.shop_configuration = res.data.data mpApp.shop_configuration = res.data.data
...@@ -262,9 +263,9 @@ export default { ...@@ -262,9 +263,9 @@ export default {
}) })
}, },
async getThemePage({ mixid, shopid }) { async getThemePage({ mixid, shopid }) {
let {offlineShopCode} = getStoreInfo();
await shop await shop
.themePagesInfo({ .themePagesInfo({
shopid,
shopMixId: mixid, shopMixId: mixid,
homePageFlag: false homePageFlag: false
}) })
......
...@@ -57,5 +57,26 @@ export default { ...@@ -57,5 +57,26 @@ export default {
`${process.env.OLSHOP_URL}/shop/get_thousands_stores_offline_store`, `${process.env.OLSHOP_URL}/shop/get_thousands_stores_offline_store`,
data data
); );
} },
// 首页获取线下门店列表v2
changingOverShopForXinHua(data) {
return requestPOST(
`${process.env.OLSHOP_URL}/shop/changingOverShopForXinHua`,
data
);
},
// 保存进店记录
saveEnterShopRecord(data) {
return requestPOST(
`${process.env.OLSHOP_URL}/enterShopRule/saveEnterShopRecord`,
data
);
},
// 进店规则获取门店id
getEnterShopId(data) {
return requestPOST(
`${process.env.OLSHOP_URL}/enterShopRule/getEnterShopId`,
data
);
},
}; };
...@@ -16,6 +16,7 @@ import shop from "@/api/shop"; ...@@ -16,6 +16,7 @@ import shop from "@/api/shop";
import { DFSImg } from "@/utils/index"; import { DFSImg } from "@/utils/index";
import {setStoreInfo, getStoreInfo} from "@/utils/mayi" import {setStoreInfo, getStoreInfo} from "@/utils/mayi"
const app = getApp(); const app = getApp();
const { log } = app;
export default { export default {
data() { data() {
return { return {
...@@ -25,17 +26,18 @@ export default { ...@@ -25,17 +26,18 @@ export default {
userLatitude: "", //纬度 userLatitude: "", //纬度
userLongitude: "", //经度 userLongitude: "", //经度
offlineStoreReq: { offlineStoreReq: {
channelType: 2, //渠道类型(0:pc,1:app,2:小程序)
latitude: "", latitude: "",
longitude: "", longitude: "",
pageNum: 0,
pageSize: 100,
shopName: "", shopName: "",
whetherOnlineShop: 1 //是否网店(0:不是,1:是) 给1 或 null },
} enterShopId: "", //进店规则门店id
}; };
}, },
onLoad() { onLoad() {
this.getLocationHandle(() => {
this.getShopList(); this.getShopList();
});
}, },
computed: { computed: {
shopName() { shopName() {
...@@ -50,7 +52,29 @@ export default { ...@@ -50,7 +52,29 @@ export default {
} }
}, },
methods: { methods: {
getShopList() { getLocationHandle(callback) {
let _this = this;
wx.getLocation({
type: "wgs84",
success: res => {
// latitude longitude speed accuracy
log.info("~~~~~~~~~1~~~~~~~", res);
console.log("~~~~~~~~~1~~~~~~~", res);
this.offlineStoreReq.latitude = res.latitude;
this.offlineStoreReq.longitude = res.longitude;
// 存缓存
wx.setStorageSync("locationObj", JSON.stringify(res));
callback(res);
},
fail: res => {
log.info("++++++++++2++++++", res);
console.log("++++++++++2++++++", res);
wx.setStorageSync("locationObj", "");
callback(res);
}
});
},
async getShopList() {
if (!this.openThousandsStoresFlag) { if (!this.openThousandsStoresFlag) {
// 未开启连锁商城初始化 // 未开启连锁商城初始化
setStoreInfo({ setStoreInfo({
...@@ -59,14 +83,38 @@ export default { ...@@ -59,14 +83,38 @@ export default {
}); });
return; return;
}; };
shop.getThousandsStoresOfflineStore(this.offlineStoreReq).then(res1 => { // 进店规则获取门店id
let query = {
channelType: 2, //设备类型(0:pc,1:app,2:小程序)
consumerLongitude: this.$store.state.wxLocation.longitude, //经度,小程序和app可以获取到就要传,没有不传
consumerLatitude: this.$store.state.wxLocation.latitude, //纬度,小程序和app可以获取到就要传,没有不传
distributionOfficerShopId: "" //分销员门店id,没有不传
}
let enterShopRes = await shop.getEnterShopId(query);
if (enterShopRes && enterShopRes.code == 200) {
this.enterShopId = enterShopRes.data;
}
shop.changingOverShopForXinHua(this.offlineStoreReq).then(res1 => {
let res = res1.data; let res = res1.data;
if (res.code == 200) { if (res.code == 200) {
if (res.data && res.data.length != 0) { if (res.data && res.data.length != 0) {
this.storeList = res.data; this.storeList = res.data;
let isStore = false; let isStore = false;
let { offlineShopName, offlineShopCode } = getStoreInfo(); let { offlineShopName, offlineShopCode } = getStoreInfo();
console.log(offlineShopName,offlineShopCode, '------------------sa114') console.log(offlineShopName, offlineShopCode, '------------------sa114')
if(this.enterShopId) {
// 如果有进店规则门店id则直接匹配存入
let ruleShop = this.storeList.filter(item => item.id == this.enterShopId);
if(ruleShop && ruleShop.length > 0) {
this.$store.dispatch("setShopCode", {
shopCode: ruleShop[0].shopCode,
});
this.$store.dispatch("setShopName", {
shopName: ruleShop[0].shopName,
});
}
return;
}
this.storeList.forEach((item, index) => { this.storeList.forEach((item, index) => {
if (item.shopName == offlineShopName) { if (item.shopName == offlineShopName) {
isStore = true; isStore = true;
...@@ -78,7 +126,7 @@ export default { ...@@ -78,7 +126,7 @@ export default {
if (offlineShopName && isStore) { if (offlineShopName && isStore) {
console.log("判断列表中是否存在(未关闭网店)"); console.log("判断列表中是否存在(未关闭网店)");
this.name = offlineShopName; this.name = offlineShopName;
// this.$emit("toUpdate"); this.$emit("toUpdate");
} else { } else {
console.log("如果关闭网店,重新选择列表第一个"); console.log("如果关闭网店,重新选择列表第一个");
setStoreInfo({ setStoreInfo({
...@@ -86,9 +134,8 @@ export default { ...@@ -86,9 +134,8 @@ export default {
offlineShopName: this.storeList[0].shopName, offlineShopName: this.storeList[0].shopName,
}); });
this.name = this.storeList[0].shopName; this.name = this.storeList[0].shopName;
// this.$emit("toUpdate"); this.$emit("toUpdate");
} }
// this.$emit("toUpdate");
} else { } else {
console.log("如果列表为空--选择商城"); console.log("如果列表为空--选择商城");
setStoreInfo({ setStoreInfo({
...@@ -96,12 +143,14 @@ export default { ...@@ -96,12 +143,14 @@ export default {
offlineShopName: this.shopName, offlineShopName: this.shopName,
}); });
this.name = this.shopName; this.name = this.shopName;
this.$emit("toUpdate");
} }
} }
}); });
}, },
// 去切换门店页面 // 去切换门店页面
pushStorePage() { pushStorePage() {
this.$emit("toPageLoading");
app.$themeToLink({ app.$themeToLink({
type: 1, type: 1,
link: `/chooseStores`, link: `/chooseStores`,
......
<template>
<div class="loadings">
<div class="img flex">
<image :src="shopLogo" alt="" mode="aspectFill"></image>
<van-loading color="black" size="60px" />
</div>
</div>
</template>
<script>
import { DFSImg } from "@/utils/index";
export default {
props: {
toHide: {
type: Boolean,
default: true
}
},
data() {
return {};
},
computed: {
shopLogo() {
let logoUrl = this.mpApp.globalData.shopInfo.logoUrl;
return logoUrl?DFSImg(logoUrl):"";
},
},
created() { },
mounted() { }
};
</script>
<style lang="scss" scoped>
.loadings {
position: fixed;
background: #fafafa;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 3000;
.img{
width: 50px;
height: 50px;
border-radius: 50%;
position: relative;
padding: 2px;
margin: 60% auto 0;
justify-content: center;
align-items: center;
image{
width: 50px;
height: 50px;
position: relative;
z-index: 1;
}
}
._van-loading{
position: absolute;
}
.van-loading {
position: absolute;
top: -2px;
left: -2px;
.van-loading__spinner {
display: block;
margin: 0 auto;
color: #333 !important;
}
}
}
</style>
...@@ -20,7 +20,8 @@ import { ...@@ -20,7 +20,8 @@ import {
$themeArticleLike, $themeArticleLike,
getCoupon, getCoupon,
themeMemberCardClick, themeMemberCardClick,
themeScanningCodeClick themeScanningCodeClick,
getStoreInfo
} from "@/utils/mayi"; } from "@/utils/mayi";
// import { $themeToLink, $themeAddToCard, $themeArticleLike } from "@/utils/mayi"; // import { $themeToLink, $themeAddToCard, $themeArticleLike } from "@/utils/mayi";
import "@/utils/themeModule"; import "@/utils/themeModule";
...@@ -143,13 +144,14 @@ mpApp.DFSImg = DFSImg; ...@@ -143,13 +144,14 @@ mpApp.DFSImg = DFSImg;
mpApp.concatUrl = concatUrl; mpApp.concatUrl = concatUrl;
mpApp.spokesmanApi = spokesmanApi mpApp.spokesmanApi = spokesmanApi
// mpApp.getThemePage = getThemePage mpApp.getThemePage = getThemePage
mpApp.themeColor = {} mpApp.themeColor = {}
mpApp.log = log mpApp.log = log
mpApp.tool = tool mpApp.tool = tool
function getThemePage({mixid,shopid}) { function getThemePage({mixid,shopid}) {
let {offlineShopCode} = getStoreInfo();
shop shop
.themePagesInfo({ .themePagesInfo({
shopMixId: mixid, shopMixId: mixid,
...@@ -166,6 +168,9 @@ function getThemePage({mixid,shopid}) { ...@@ -166,6 +168,9 @@ function getThemePage({mixid,shopid}) {
if (mpApp.pageCallBack) { if (mpApp.pageCallBack) {
mpApp.pageCallBack(data); mpApp.pageCallBack(data);
} }
if(mpApp.indexBgCallBack){
mpApp.indexBgCallBack(data)
}
} }
} }
}) })
......
<template> <template>
<div class="domain" :style="{'--main-color':themeColor['--main-color'],'--minor-color':themeColor['--minor-color']}"> <div class="domain" :style="{'--main-color':themeColor['--main-color'],'--minor-color':themeColor['--minor-color']}">
<pageLoading v-if="pageLoading"></pageLoading>
<div style="position:relative;"> <div style="position:relative;">
<div v-if="showSpokesManHome"> <div v-if="showSpokesManHome">
<get-index-homepage class="getIndexHomePage"></get-index-homepage> <get-index-homepage class="getIndexHomePage"></get-index-homepage>
</div> </div>
<ThemeDataPlant></ThemeDataPlant> <ThemeDataPlant></ThemeDataPlant>
<StoreAddr></StoreAddr> <StoreAddr @toUpdate="toUpdate" @toPageLoading="toPageLoading"></StoreAddr>
<template v-if="!pageLoading">
<div v-for="(item,index) in pageData" :key="index"> <div v-for="(item,index) in pageData" :key="index">
<div v-if="item.componentCode=='banner' && item.componentInfo.visible == 1"> <div v-if="item.componentCode=='banner' && item.componentInfo.visible == 1">
<banner :datas="item"></banner> <banner :datas="item"></banner>
...@@ -109,6 +111,7 @@ ...@@ -109,6 +111,7 @@
</div> </div>
<bottomCont v-if="showbottomCont"></bottomCont> <bottomCont v-if="showbottomCont"></bottomCont>
</template>
</div> </div>
<share-popup></share-popup> <share-popup></share-popup>
<div v-if="showMyCard"> <div v-if="showMyCard">
...@@ -177,6 +180,7 @@ import { throttle, concatUrl } from "../../utils/index.js" ...@@ -177,6 +180,7 @@ import { throttle, concatUrl } from "../../utils/index.js"
import mpvueCropper from '@/components/mpvue-cropper' import mpvueCropper from '@/components/mpvue-cropper'
import tool from '../../utils/tool.js' import tool from '../../utils/tool.js'
import StoreAddr from "@/components/common/StoreAddr.vue"; import StoreAddr from "@/components/common/StoreAddr.vue";
import pageLoading from "@/components/common/pageLoading.vue";
const app = getApp(); const app = getApp();
const { log } = app; const { log } = app;
export default { export default {
...@@ -209,6 +213,7 @@ export default { ...@@ -209,6 +213,7 @@ export default {
birthGifts: "", birthGifts: "",
showbottomCont: false, //展示底部logo showbottomCont: false, //展示底部logo
showSpe: false, showSpe: false,
pageLoading: true,
}; };
}, },
components:{ components:{
...@@ -238,7 +243,8 @@ export default { ...@@ -238,7 +243,8 @@ export default {
SelectGoods, SelectGoods,
TwoBAddCart, TwoBAddCart,
brandList, brandList,
StoreAddr StoreAddr,
pageLoading
}, },
computed: { computed: {
applySucessEntryFlag() { applySucessEntryFlag() {
...@@ -400,7 +406,7 @@ export default { ...@@ -400,7 +406,7 @@ export default {
if(this.changeLocation == 1){ if(this.changeLocation == 1){
log.info('this.$store.state.extConfig',this.$store.state.extConfig) log.info('this.$store.state.extConfig',this.$store.state.extConfig)
app.getShopInfo(this.$store.state.extConfig); app.getShopInfo(this.$store.state.extConfig);
app.getThemePage(this.$store.state.extConfig); this.getThemeList();
} }
let that = this; let that = this;
if(wx.getStorageSync("sessionid")) { if(wx.getStorageSync("sessionid")) {
...@@ -467,7 +473,8 @@ export default { ...@@ -467,7 +473,8 @@ export default {
console.log('storageGoodsList---detory'); console.log('storageGoodsList---detory');
}, },
onShow(options) { onShow() {
// this.pageLoading = false;
console.log(new Date().getTime(),'load-----home-onShow') console.log(new Date().getTime(),'load-----home-onShow')
// 设置显示条件 // 设置显示条件
console.log(new Date().getTime(),'--------on--------------show') console.log(new Date().getTime(),'--------on--------------show')
...@@ -497,6 +504,13 @@ export default { ...@@ -497,6 +504,13 @@ export default {
},200), },200),
methods: { methods: {
toUpdate() {
// 切换门店重新加载
this.getThemeList();
},
toPageLoading() {
// this.pageLoading = true;
},
async setVisible(pageList, cb) { async setVisible(pageList, cb) {
// 首页显示条件 // 首页显示条件
let pageInfo = pageList.filter((item) => item.pageCode == 1)[0]; let pageInfo = pageList.filter((item) => item.pageCode == 1)[0];
...@@ -967,6 +981,11 @@ export default { ...@@ -967,6 +981,11 @@ export default {
this.isShowBirth = true; this.isShowBirth = true;
log.info(this.isShowBirth, JSON.stringify(res) + 'tzToggleData') log.info(this.isShowBirth, JSON.stringify(res) + 'tzToggleData')
this.birthGifts = res; this.birthGifts = res;
},
async getThemeList() {
this.pageLoading = true;
await app.getThemePage(this.$store.state.extConfig);
this.pageLoading = false;
} }
}, },
async onShareAppMessage(res){ async onShareAppMessage(res){
...@@ -1048,7 +1067,7 @@ export default { ...@@ -1048,7 +1067,7 @@ export default {
}, 1500); }, 1500);
log.info('onPullDownRefresh',this.$store.state.extConfig) log.info('onPullDownRefresh',this.$store.state.extConfig)
app.getShopInfo(this.$store.state.extConfig); app.getShopInfo(this.$store.state.extConfig);
app.getThemePage(this.$store.state.extConfig); this.getThemeList();
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"van-tabs": "/static/vant/tabs/index", "van-tabs": "/static/vant/tabs/index",
"van-tab": "/static/vant/tab/index", "van-tab": "/static/vant/tab/index",
"van-card": "/static/vant/card/index", "van-card": "/static/vant/card/index",
"van-loading": "/static/vant/loading/index",
"banner": "/static/nativeComponents/Banner/index", "banner": "/static/nativeComponents/Banner/index",
"goods-list": "/static/nativeComponents/GoodsList/index", "goods-list": "/static/nativeComponents/GoodsList/index",
"custom-tab-bar": "/static/nativeComponents/custom-tab-bar/index", "custom-tab-bar": "/static/nativeComponents/custom-tab-bar/index",
......
...@@ -6,12 +6,13 @@ ...@@ -6,12 +6,13 @@
<script> <script>
let forUrlAddKey = require("mayi-front-tools/forUrlAddKey").default; let forUrlAddKey = require("mayi-front-tools/forUrlAddKey").default;
let getUrlKey = require("mayi-front-tools/getUrlKey").default;
import spokesman from "@/api/spokesman.js"; import spokesman from "@/api/spokesman.js";
import shop from "@/api/shop.js"; import shop from "@/api/shop.js";
import indexApi from "@/api/index.js"; import indexApi from "@/api/index.js";
import { serialize, getQueryVariable, DFSImg } from "@/utils/index"; import { serialize, getQueryVariable, DFSImg, parseQueryString } from "@/utils/index";
import login from "@/api/login"; import login from "@/api/login";
import { getStoreInfo } from "@/utils/mayi.js"; import { getStoreInfo, setStoreInfo } from "@/utils/mayi.js";
const app = getApp(); const app = getApp();
const { log } = app; const { log } = app;
export default { export default {
...@@ -72,6 +73,12 @@ export default { ...@@ -72,6 +73,12 @@ export default {
if (offlineShopCode) { if (offlineShopCode) {
this.params+=`&offlineShopCode=${offlineShopCode}&offlineShopName=${offlineShopName}` this.params+=`&offlineShopCode=${offlineShopCode}&offlineShopName=${offlineShopName}`
} }
// 定位信息
let locationObj = wx.getStorageSync("locationObj") ? JSON.parse(wx.getStorageSync("locationObj")) : "";
if (locationObj) {
let { latitude, longitude } = locationObj;
this.params+=`&latitude=${latitude}&longitude=${longitude}`
}
console.log(this.link,'=======',this.page,'++++++++++++++',this.params,'************') 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 let pageUrl1 = (this.page.startsWith('http://') || this.page.startsWith('https://'))? (this.page + this.params) : this.link+this.page+this.params
console.log(pageUrl1,'--------pageUrl1--') console.log(pageUrl1,'--------pageUrl1--')
...@@ -136,6 +143,7 @@ export default { ...@@ -136,6 +143,7 @@ export default {
} }
}, },
onLoad(options) { onLoad(options) {
// this.getLocationHandle();
console.log(options,'---options') console.log(options,'---options')
if(wx.getStorageSync("sessionid")) { if(wx.getStorageSync("sessionid")) {
...@@ -146,13 +154,13 @@ export default { ...@@ -146,13 +154,13 @@ export default {
this.options = options; this.options = options;
log.info(this.options,'----------------index-----options') log.info(this.options,'----------------index-----options')
Object.assign(this.$data, this.$options.data()); Object.assign(this.$data, this.$options.data());
let h5Params = options && options.params ? JSON.parse(decodeURIComponent(options.params)) : ""; let offlineShopCode = getUrlKey(decodeURIComponent(options.params), "offlineShopCode");
console.log(h5Params,'--h5Params') let offlineShopName = getUrlKey(decodeURIComponent(options.params), "offlineShopName");
if (h5Params) { if (offlineShopCode) {
// 存储h5url门店信息 // 存储h5url门店信息
setStoreInfo({ setStoreInfo({
offlineShopCode:h5Params.offlineShopCode, offlineShopCode,
offlineShopName:h5Params.offlineShopName, offlineShopName
}); });
} }
if(wx.getStorageSync("workBox")){ if(wx.getStorageSync("workBox")){
...@@ -481,17 +489,18 @@ export default { ...@@ -481,17 +489,18 @@ export default {
} }
}, },
getLocationHandle() { getLocationHandle() {
let _this = this;
wx.getLocation({ wx.getLocation({
type: "wgs84", type: "wgs84",
success: res => { success: res => {
var latitude = res.latitude; // latitude longitude speed accuracy
var longitude = res.longitude; this.locationObj = res;
var speed = res.speed;
var accuracy = res.accuracy;
log.info("~~~~~~~~~1~~~~~~~", res); log.info("~~~~~~~~~1~~~~~~~", res);
console.log("~~~~~~~~~1~~~~~~~", res);
}, },
fail: res => { fail: res => {
log.info("++++++++++2++++++", res); log.info("++++++++++2++++++", res);
console.log("++++++++++2++++++", 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