Commit edb2cecd by 李嘉林

进店规则

parent 2c03ab4d
......@@ -3,11 +3,12 @@
import shop from "@/api/shop";
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";
export default {
created() {
async created() {
console.log(new Date().getTime(),'load-----app-created')
// NODE_ENV
let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
console.log(extConfig, "-----------extConfig");
......@@ -48,7 +49,7 @@ export default {
mpvue.setStorageSync("logs", logs);
}
// 初始
this.getShopInfo(extConfig);
await this.getShopInfo(extConfig);
......@@ -56,7 +57,7 @@ export default {
this.getThemePage(extConfig);
// 商城配置
this.shopConfiguration()
await this.shopConfiguration()
setTimeout(() => {
let mpApp = getApp();
......@@ -176,8 +177,8 @@ export default {
return JSON.stringify(pageData);
},
//商城配置
getShopInfo({ mixid }) {
shop.getShopInfo({ shopMixId: mixid }).then((res) => {
async getShopInfo({ mixid }) {
await shop.getShopInfo({ shopMixId: mixid }).then((res) => {
console.log("--app---getShopInfo")
if (res.data.code == 200) {
// 收集用户数据
......@@ -252,8 +253,8 @@ export default {
});
},
//商城配置
shopConfiguration(){
shop.get_shop_configuration().then(res=>{
async shopConfiguration(){
await shop.get_shop_configuration().then(res=>{
if (res.data.code == 200) {
let mpApp = getApp();
mpApp.shop_configuration = res.data.data
......@@ -262,9 +263,9 @@ export default {
})
},
async getThemePage({ mixid, shopid }) {
let {offlineShopCode} = getStoreInfo();
await shop
.themePagesInfo({
shopid,
shopMixId: mixid,
homePageFlag: false
})
......
......@@ -57,5 +57,26 @@ export default {
`${process.env.OLSHOP_URL}/shop/get_thousands_stores_offline_store`,
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";
import { DFSImg } from "@/utils/index";
import {setStoreInfo, getStoreInfo} from "@/utils/mayi"
const app = getApp();
const { log } = app;
export default {
data() {
return {
......@@ -25,17 +26,18 @@ export default {
userLatitude: "", //纬度
userLongitude: "", //经度
offlineStoreReq: {
channelType: 2, //渠道类型(0:pc,1:app,2:小程序)
latitude: "",
longitude: "",
pageNum: 0,
pageSize: 100,
shopName: "",
whetherOnlineShop: 1 //是否网店(0:不是,1:是) 给1 或 null
}
},
enterShopId: "", //进店规则门店id
};
},
onLoad() {
this.getShopList();
this.getLocationHandle(() => {
this.getShopList();
});
},
computed: {
shopName() {
......@@ -50,7 +52,29 @@ export default {
}
},
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) {
// 未开启连锁商城初始化
setStoreInfo({
......@@ -59,14 +83,38 @@ export default {
});
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;
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')
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) => {
if (item.shopName == offlineShopName) {
isStore = true;
......@@ -78,7 +126,7 @@ export default {
if (offlineShopName && isStore) {
console.log("判断列表中是否存在(未关闭网店)");
this.name = offlineShopName;
// this.$emit("toUpdate");
this.$emit("toUpdate");
} else {
console.log("如果关闭网店,重新选择列表第一个");
setStoreInfo({
......@@ -86,9 +134,8 @@ export default {
offlineShopName: this.storeList[0].shopName,
});
this.name = this.storeList[0].shopName;
// this.$emit("toUpdate");
this.$emit("toUpdate");
}
// this.$emit("toUpdate");
} else {
console.log("如果列表为空--选择商城");
setStoreInfo({
......@@ -96,12 +143,14 @@ export default {
offlineShopName: this.shopName,
});
this.name = this.shopName;
this.$emit("toUpdate");
}
}
});
},
// 去切换门店页面
pushStorePage() {
this.$emit("toPageLoading");
app.$themeToLink({
type: 1,
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 {
$themeArticleLike,
getCoupon,
themeMemberCardClick,
themeScanningCodeClick
themeScanningCodeClick,
getStoreInfo
} from "@/utils/mayi";
// import { $themeToLink, $themeAddToCard, $themeArticleLike } from "@/utils/mayi";
import "@/utils/themeModule";
......@@ -143,13 +144,14 @@ mpApp.DFSImg = DFSImg;
mpApp.concatUrl = concatUrl;
mpApp.spokesmanApi = spokesmanApi
// mpApp.getThemePage = getThemePage
mpApp.getThemePage = getThemePage
mpApp.themeColor = {}
mpApp.log = log
mpApp.tool = tool
function getThemePage({mixid,shopid}) {
let {offlineShopCode} = getStoreInfo();
shop
.themePagesInfo({
shopMixId: mixid,
......@@ -166,6 +168,9 @@ function getThemePage({mixid,shopid}) {
if (mpApp.pageCallBack) {
mpApp.pageCallBack(data);
}
if(mpApp.indexBgCallBack){
mpApp.indexBgCallBack(data)
}
}
}
})
......
<template>
<div class="domain" :style="{'--main-color':themeColor['--main-color'],'--minor-color':themeColor['--minor-color']}">
<div style="position:relative;">
<div v-if="showSpokesManHome">
<get-index-homepage class="getIndexHomePage"></get-index-homepage>
</div>
<ThemeDataPlant></ThemeDataPlant>
<StoreAddr></StoreAddr>
<pageLoading v-if="pageLoading"></pageLoading>
<div style="position:relative;">
<div v-if="showSpokesManHome">
<get-index-homepage class="getIndexHomePage"></get-index-homepage>
</div>
<ThemeDataPlant></ThemeDataPlant>
<StoreAddr @toUpdate="toUpdate" @toPageLoading="toPageLoading"></StoreAddr>
<template v-if="!pageLoading">
<div v-for="(item,index) in pageData" :key="index">
<div v-if="item.componentCode=='banner' && item.componentInfo.visible == 1">
<banner :datas="item"></banner>
</div>
<div v-else-if="item.componentCode=='goods-list' && item.componentInfo.visible == 1" style="height:100%;">
<!-- ***这个商品列表组件中需要对数据做缓存,可能有多个地方同时引用此组件
必须在缓存前加个唯一标识不然所有组件全部操作同一个缓存
-->
必须在缓存前加个唯一标识不然所有组件全部操作同一个缓存
-->
<goods-list :storageKey="'home'+index" :class="['goodsListItem' + index,'goodsListItemIndex0']" :datas="item" :datasIndex="0" :goodsListIndex="0"></goods-list>
</div>
<div v-else-if="item.componentCode == 'area-navigation' && item.componentInfo.visible == 1">
......@@ -68,37 +70,37 @@
<video-player :class="'VideoPlayer' + index" :datas="item" :indexs="index"></video-player>
</div>
<div v-if="item.componentCode == 'official-account' && item.componentInfo.visible == 1">
<official-account></official-account>
<official-account></official-account>
</div>
<div v-if="item.componentCode == 'transverse-label' && item.componentInfo.visible == 1">
<transverse-label :datas="item" :componentIndex="index"></transverse-label>
<transverse-label :datas="item" :componentIndex="index"></transverse-label>
</div>
<div v-if="item.componentCode == 'photo-gallery' && item.componentInfo.visible == 1">
<photo-gallery :datas="item"></photo-gallery>
<photo-gallery :datas="item"></photo-gallery>
</div>
<div v-if="item.componentCode == 'live-broadcast' && item.componentInfo.visible == 1">
<live-broadcast :datas="item"></live-broadcast>
<live-broadcast :datas="item"></live-broadcast>
</div>
<div v-if="item.componentCode == 'information' && item.componentInfo.visible == 1">
<information :datas="item"></information>
<information :datas="item"></information>
</div>
<div v-if="item.componentCode == 'share-picture' && item.componentInfo.visible == 1">
<share-picture :datas="item"></share-picture>
<share-picture :datas="item"></share-picture>
</div>
<div v-if="item.componentCode == 'merchants-list' && item.componentInfo.visible == 1">
<merchants-list :class="'merchants-list' +index" :datas="item"></merchants-list>
<merchants-list :class="'merchants-list' +index" :datas="item"></merchants-list>
</div>
<div v-if="item.componentCode == 'spell-group' && item.componentInfo.visible == 1">
<spell-group :datas="item"></spell-group>
<spell-group :datas="item"></spell-group>
</div>
<div v-if="item.componentCode == 'wo-timeout' && item.componentInfo.visible == 1">
<wo-timeout :datas="item"></wo-timeout>
<wo-timeout :datas="item"></wo-timeout>
</div>
<div v-if="item.componentCode == 'custom-list' && item.componentInfo.visible == 1">
<custom-list :datas="item"></custom-list>
<custom-list :datas="item"></custom-list>
</div>
<div v-if="item.componentCode == 'rich-text' && item.componentInfo.visible == 1">
<rich-text :datas="item"></rich-text>
<rich-text :datas="item"></rich-text>
</div>
<div v-if="item.componentCode == 'member-info' && item.componentInfo.visible == 1">
<member-info :datas="item"></member-info>
......@@ -106,37 +108,38 @@
<div v-if="item.componentCode == 'brand-list' && item.componentInfo.visible == 1">
<brandList :datas="item"></brandList>
</div>
</div>
<bottomCont v-if="showbottomCont"></bottomCont>
</div>
<share-popup></share-popup>
<div v-if="showMyCard">
<my-card></my-card>
</div>
<div v-if="showHomepage">
<set-my-homepage :getDistributorHomepageName="getDistributorHomepageName"></set-my-homepage>
</div>
<div v-if="applySucessEntry && applySucessEntryFlag">
<apply-sucess-entry></apply-sucess-entry>
</div>
<NewUser :showNewUser="showNewUser" @togiftbag="togiftbag"></NewUser>
<new-polite :showgiftBag="showgiftBag" @closeHandle="closeHandle" :MyNewGiftList="newGiftList"></new-polite>
<!-- 底部栏 -->
<custom-tab-bar class="custom-tab-bar" :selected="active"></custom-tab-bar>
</template>
</div>
<share-popup></share-popup>
<div v-if="showMyCard">
<my-card></my-card>
</div>
<div v-if="showHomepage">
<set-my-homepage :getDistributorHomepageName="getDistributorHomepageName"></set-my-homepage>
</div>
<div v-if="applySucessEntry && applySucessEntryFlag">
<apply-sucess-entry></apply-sucess-entry>
</div>
<NewUser :showNewUser="showNewUser" @togiftbag="togiftbag"></NewUser>
<new-polite :showgiftBag="showgiftBag" @closeHandle="closeHandle" :MyNewGiftList="newGiftList"></new-polite>
<!-- 底部栏 -->
<custom-tab-bar class="custom-tab-bar" :selected="active"></custom-tab-bar>
<!-- 生日弹窗 -->
<keep-alive>
<birth-popup :birthGifts="birthGifts" :isShowBirth="isShowBirth" v-show="true"></birth-popup>
</keep-alive>
<!-- 生日弹窗 -->
<keep-alive>
<birth-popup :birthGifts="birthGifts" :isShowBirth="isShowBirth" v-show="true"></birth-popup>
</keep-alive>
<couponPopup></couponPopup>
<!-- 商品筛选 -->
<GoodsFliters></GoodsFliters>
<!-- 选规格 -->
<SelectGoods></SelectGoods>
<!-- 选规格(开启了企业要货) -->
<TwoBAddCart></TwoBAddCart>
<couponPopup></couponPopup>
<!-- 商品筛选 -->
<GoodsFliters></GoodsFliters>
<!-- 选规格 -->
<SelectGoods></SelectGoods>
<!-- 选规格(开启了企业要货) -->
<TwoBAddCart></TwoBAddCart>
</div>
</template>
......@@ -177,6 +180,7 @@ 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";
import pageLoading from "@/components/common/pageLoading.vue";
const app = getApp();
const { log } = app;
export default {
......@@ -209,6 +213,7 @@ export default {
birthGifts: "",
showbottomCont: false, //展示底部logo
showSpe: false,
pageLoading: true,
};
},
components:{
......@@ -238,7 +243,8 @@ export default {
SelectGoods,
TwoBAddCart,
brandList,
StoreAddr
StoreAddr,
pageLoading
},
computed: {
applySucessEntryFlag() {
......@@ -400,7 +406,7 @@ export default {
if(this.changeLocation == 1){
log.info('this.$store.state.extConfig',this.$store.state.extConfig)
app.getShopInfo(this.$store.state.extConfig);
app.getThemePage(this.$store.state.extConfig);
this.getThemeList();
}
let that = this;
if(wx.getStorageSync("sessionid")) {
......@@ -467,7 +473,8 @@ export default {
console.log('storageGoodsList---detory');
},
onShow(options) {
onShow() {
// this.pageLoading = false;
console.log(new Date().getTime(),'load-----home-onShow')
// 设置显示条件
console.log(new Date().getTime(),'--------on--------------show')
......@@ -497,6 +504,13 @@ export default {
},200),
methods: {
toUpdate() {
// 切换门店重新加载
this.getThemeList();
},
toPageLoading() {
// this.pageLoading = true;
},
async setVisible(pageList, cb) {
// 首页显示条件
let pageInfo = pageList.filter((item) => item.pageCode == 1)[0];
......@@ -967,6 +981,11 @@ export default {
this.isShowBirth = true;
log.info(this.isShowBirth, JSON.stringify(res) + 'tzToggleData')
this.birthGifts = res;
},
async getThemeList() {
this.pageLoading = true;
await app.getThemePage(this.$store.state.extConfig);
this.pageLoading = false;
}
},
async onShareAppMessage(res){
......@@ -1048,7 +1067,7 @@ export default {
}, 1500);
log.info('onPullDownRefresh',this.$store.state.extConfig)
app.getShopInfo(this.$store.state.extConfig);
app.getThemePage(this.$store.state.extConfig);
this.getThemeList();
}
......
......@@ -3,6 +3,7 @@
"van-tabs": "/static/vant/tabs/index",
"van-tab": "/static/vant/tab/index",
"van-card": "/static/vant/card/index",
"van-loading": "/static/vant/loading/index",
"banner": "/static/nativeComponents/Banner/index",
"goods-list": "/static/nativeComponents/GoodsList/index",
"custom-tab-bar": "/static/nativeComponents/custom-tab-bar/index",
......
......@@ -6,12 +6,13 @@
<script>
let forUrlAddKey = require("mayi-front-tools/forUrlAddKey").default;
let getUrlKey = require("mayi-front-tools/getUrlKey").default;
import spokesman from "@/api/spokesman.js";
import shop from "@/api/shop.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 { getStoreInfo } from "@/utils/mayi.js";
import { getStoreInfo, setStoreInfo } from "@/utils/mayi.js";
const app = getApp();
const { log } = app;
export default {
......@@ -72,6 +73,12 @@ export default {
if (offlineShopCode) {
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,'************')
let pageUrl1 = (this.page.startsWith('http://') || this.page.startsWith('https://'))? (this.page + this.params) : this.link+this.page+this.params
console.log(pageUrl1,'--------pageUrl1--')
......@@ -136,6 +143,7 @@ export default {
}
},
onLoad(options) {
// this.getLocationHandle();
console.log(options,'---options')
if(wx.getStorageSync("sessionid")) {
......@@ -146,13 +154,13 @@ 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) {
let offlineShopCode = getUrlKey(decodeURIComponent(options.params), "offlineShopCode");
let offlineShopName = getUrlKey(decodeURIComponent(options.params), "offlineShopName");
if (offlineShopCode) {
// 存储h5url门店信息
setStoreInfo({
offlineShopCode:h5Params.offlineShopCode,
offlineShopName:h5Params.offlineShopName,
offlineShopCode,
offlineShopName
});
}
if(wx.getStorageSync("workBox")){
......@@ -481,17 +489,18 @@ export default {
}
},
getLocationHandle() {
let _this = this;
wx.getLocation({
type: "wgs84",
success: res => {
var latitude = res.latitude;
var longitude = res.longitude;
var speed = res.speed;
var accuracy = res.accuracy;
// latitude longitude speed accuracy
this.locationObj = res;
log.info("~~~~~~~~~1~~~~~~~", res);
console.log("~~~~~~~~~1~~~~~~~", res);
},
fail: 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