Commit 26b624b5 by 杨北旺

修改小程序定位/体验卡/开通页面

1 parent 75ab3d9e
...@@ -10,9 +10,9 @@ import store from "./store" ...@@ -10,9 +10,9 @@ import store from "./store"
import axios from 'axios' import axios from 'axios'
Vue.use(VueWechatTitle) Vue.use(VueWechatTitle)
Vue.use(Vant) Vue.use(Vant)
// import VConsole from 'vconsole' import VConsole from 'vconsole'
// const vConsole = new VConsole() const vConsole = new VConsole()
// Vue.use(vConsole) Vue.use(vConsole)
import preview from 'vue-photo-preview' import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css' import 'vue-photo-preview/dist/skin.css'
Vue.use(preview) Vue.use(preview)
......
...@@ -125,6 +125,9 @@ const setUserInfo = params => { ...@@ -125,6 +125,9 @@ const setUserInfo = params => {
localStorage.setItem('APPID', params.appId) localStorage.setItem('APPID', params.appId)
} }
sessionStorage.setItem('URL_PARAM', JSON.stringify(params)) sessionStorage.setItem('URL_PARAM', JSON.stringify(params))
if (user.freecard) {
localStorage.setItem('bindinfo', JSON.stringify(user.bingInfo))
}
user.nickName = user.phone user.nickName = user.phone
store.commit('setUserInfo', user) store.commit('setUserInfo', user)
} else { } else {
......
...@@ -5,6 +5,13 @@ ...@@ -5,6 +5,13 @@
<span class="card_title">{{ equityName }}</span> <span class="card_title">{{ equityName }}</span>
<span class="card_title_1">尊享100+专属权益</span> <span class="card_title_1">尊享100+专属权益</span>
</div> </div>
<div v-if="platform.platform!='app'" class="activity_widget">
<img
class="img_bg"
:src="imgBase_url + 'open_activity.png'"
@click="toArticle"
/>
</div>
<div class="image_widget"> <div class="image_widget">
<img class="img_bg" :src="imgBase_url + 'scrm_opening.png'" /> <img class="img_bg" :src="imgBase_url + 'scrm_opening.png'" />
</div> </div>
...@@ -15,7 +22,7 @@ ...@@ -15,7 +22,7 @@
@click="jumpOpen" @click="jumpOpen"
/> />
</div> </div>
<div style="height:110px"></div> <div style="height: 110px"></div>
<div class="fixed_wrapper"> <div class="fixed_wrapper">
<div class="btn_wrap"> <div class="btn_wrap">
<div <div
...@@ -141,6 +148,7 @@ export default { ...@@ -141,6 +148,7 @@ export default {
payStatus: 0, payStatus: 0,
isOpen: 0, isOpen: 0,
channelType: 0, // 2是广汇 channelType: 0, // 2是广汇
platform:{}
}; };
}, },
created() { created() {
...@@ -356,6 +364,13 @@ export default { ...@@ -356,6 +364,13 @@ export default {
let url = `${href}/#/cardRoll/agreement?sessionId=${sessionId}`; let url = `${href}/#/cardRoll/agreement?sessionId=${sessionId}`;
this.openWindows(url, "cardRoll.agreement"); this.openWindows(url, "cardRoll.agreement");
}, },
toArticle() {
if (this.channelType == 2) {
this.openWindows("https://mp.weixin.qq.com/s/q-01zUdBjlOc4z_5HO-ruA");
} else {
this.openWindows("https://mp.weixin.qq.com/s/Gj3PE3n31PHMOMc5S1CYkg");
}
},
}, },
beforeDestroy() { beforeDestroy() {
clearInterval(this.timer); clearInterval(this.timer);
...@@ -401,6 +416,12 @@ export default { ...@@ -401,6 +416,12 @@ export default {
text-shadow: 0 2px 4px rgba(255, 123, 43, 0.24); text-shadow: 0 2px 4px rgba(255, 123, 43, 0.24);
} }
} }
.activity_widget {
.img_bg {
width: 100%;
height: 100%;
}
}
.image_widget { .image_widget {
margin-top: 16px; margin-top: 16px;
.img_bg { .img_bg {
...@@ -415,7 +436,7 @@ export default { ...@@ -415,7 +436,7 @@ export default {
height: 90px; height: 90px;
} }
} }
.fixed_wrapper{ .fixed_wrapper {
position: fixed; position: fixed;
left: 0; left: 0;
right: 0; right: 0;
......
...@@ -122,7 +122,13 @@ ...@@ -122,7 +122,13 @@
v-if="isHaveInventory" v-if="isHaveInventory"
@click="toBuyGoods" @click="toBuyGoods"
> >
<span>{{ isOpen || !selectData.noMemberPrice?selectData.salesPrice:selectData.noMemberPrice }}元</span>立即购买 <span
>{{
isOpen || !selectData.noMemberPrice
? selectData.salesPrice
: selectData.noMemberPrice
}}元</span
>立即购买
</div> </div>
<div class="recharge-operation disabled" v-if="!isHaveInventory"> <div class="recharge-operation disabled" v-if="!isHaveInventory">
该商品已售罄 该商品已售罄
...@@ -183,6 +189,7 @@ ...@@ -183,6 +189,7 @@
import { pay } from "@/mixins"; import { pay } from "@/mixins";
import { commodity, equity } from "@r/api"; import { commodity, equity } from "@r/api";
// import { Dialog } from 'vant' // import { Dialog } from 'vant'
import AMap from "AMap";
import WxConfig from "@u/WxConfig"; import WxConfig from "@u/WxConfig";
const WX = new WxConfig(["openLocation", "getLocation"]); const WX = new WxConfig(["openLocation", "getLocation"]);
import MyModal from "../../components/MyModal.vue"; import MyModal from "../../components/MyModal.vue";
...@@ -207,6 +214,7 @@ export default { ...@@ -207,6 +214,7 @@ export default {
showModal: false, showModal: false,
diffPrice: 0, diffPrice: 0,
isLogin: true, isLogin: true,
showAuthBtn: false,
}; };
}, },
created() { created() {
...@@ -215,88 +223,96 @@ export default { ...@@ -215,88 +223,96 @@ export default {
this.isLogin = JSON.parse(sessionStorage.getItem("LOGIN_TYPE")); this.isLogin = JSON.parse(sessionStorage.getItem("LOGIN_TYPE"));
} }
this.platform = sign; this.platform = sign;
}, if (sign.platform == "mini") {
mounted() { let address = this.getLocalStorage("addressInfo");
this.showLoading(); let showLocation = this.getLocalStorage("isShowLoacationModal");
// const ua = navigator.userAgent.toLowerCase() if (showLocation) {
// let { latitude, longitude } = this.$store.state.address; this.showAuthBtn = true;
let address = this.getLocalStorage("addressInfo"); this.getBusineInfo()
let { latitude, longitude } = address return;
if (this.platform.platform == "H5") { } else {
let options = this.$route.query; //开启定位
document.title = options.brandName; if(address){
this.brandName = options.brandName; console.log(1111110);
this.supplier = options.supplier; this.getBusineInfo()
if (options.selectedId) { }else{
//首页选择的元素 this.initLocation();
this.selectedId = options.selectedId;
}
} else if (this.platform.platform == "app") {
let params = this.getParams(window.location.href);
this.brandName = decodeURI(params.brandName);
this.supplier = params.supplier;
document.title = decodeURI(params.brandName);
if (params.selectedId) {
//首页选择的元素
this.selectedId = params.selectedId;
}
} else if (this.platform.platform == "mini") {
let options = this.$route.query;
if (options.urlParam) {
let { sessionId, brandName, supplier, selectedId, lat, lng } =
JSON.parse(options.urlParam);
this.sessionId = sessionId;
sessionStorage.setItem("URL_PARAM", options.urlParam);
document.title = brandName;
this.brandName = brandName;
this.supplier = supplier;
latitude = lat;
longitude = lng;
if (selectedId) {
//首页选择的元素
this.selectedId = selectedId;
} }
} }
} }
let para = { },
brandName: this.brandName, mounted() {
supplier: this.supplier, if(this.platform.platform!='mini'){
lat: latitude, this.getBusineInfo()
lng: longitude, }
};
this.getCardInfo();
commodity.getCouponDetail(para).then((res) => {
let { code, data, message } = res;
this.hideLoading();
if (code == 0) {
// 新版外包了一层经纬度,所以这里得处理一下
this.addressInfo = {
gasAddressLatitude: data.latitude,
gasAddressLongitude: data.longitude,
gasAddress: data.localAddress,
localAddressDistance: data.localAddressDistance,
};
this.businessList = data.goodsDetailList;
this.selectData = this.businessList[0];
// if(this.selectedId){//存在则是从精选处跳转进来的
// this.businessList.forEach((el,index)=>{
// if(el.id==this.selectedId){
// this.selectData = this.businessList[index]
// this.bindex = index
// if(this.businessList.length>3) {
// document.querySelector('.business-select').scrollLeft = document.querySelector(`.select-${index}`).offsetLeft - 10;
// }
// }
// })
// }
this.checkInventory(this.selectData.id);
this.autoSelect()
} else {
this.showToast(message);
}
});
}, },
methods: { methods: {
// 获取商品详情
getBusineInfo() {
this.showLoading();
let address = this.getLocalStorage("addressInfo");
let { latitude, longitude } = address;
if (this.platform.platform == "H5") {
let options = this.$route.query;
document.title = options.brandName;
this.brandName = options.brandName;
this.supplier = options.supplier;
if (options.selectedId) {
//首页选择的元素
this.selectedId = options.selectedId;
}
} else if (this.platform.platform == "app") {
let params = this.getParams(window.location.href);
this.brandName = decodeURI(params.brandName);
this.supplier = params.supplier;
document.title = decodeURI(params.brandName);
if (params.selectedId) {
//首页选择的元素
this.selectedId = params.selectedId;
}
} else if (this.platform.platform == "mini") {
let options = this.$route.query;
if (options.urlParam) {
let { sessionId, brandName, supplier, selectedId} =
JSON.parse(options.urlParam);
this.sessionId = sessionId;
sessionStorage.setItem("URL_PARAM", options.urlParam);
document.title = brandName;
this.brandName = brandName;
this.supplier = supplier;
if (selectedId) {
//首页选择的元素
this.selectedId = selectedId;
}
}
}
let para = {
brandName: this.brandName,
supplier: this.supplier,
lat: latitude,
lng: longitude,
};
this.getCardInfo();
commodity.getCouponDetail(para).then((res) => {
let { code, data, message } = res;
this.hideLoading();
if (code == 0) {
// 新版外包了一层经纬度,所以这里得处理一下
this.addressInfo = {
gasAddressLatitude: data.latitude,
gasAddressLongitude: data.longitude,
gasAddress: data.localAddress,
localAddressDistance: data.localAddressDistance,
};
this.businessList = data.goodsDetailList;
this.selectData = this.businessList[0];
this.checkInventory(this.selectData.id);
this.autoSelect();
} else {
this.showToast(message);
}
});
},
getCardInfo() { getCardInfo() {
if (!this.isLogin) { if (!this.isLogin) {
return; return;
...@@ -391,22 +407,59 @@ export default { ...@@ -391,22 +407,59 @@ export default {
}, },
// 精选进来自动滚动 // 精选进来自动滚动
autoSelect() { autoSelect() {
setTimeout(()=>{ setTimeout(() => {
if (this.selectedId) { if (this.selectedId) {
//存在则是从精选处跳转进来的 //存在则是从精选处跳转进来的
this.businessList.forEach((el, index) => { this.businessList.forEach((el, index) => {
if (el.id == this.selectedId) { if (el.id == this.selectedId) {
this.selectData = this.businessList[index]; this.selectData = this.businessList[index];
this.bindex = index; this.bindex = index;
if (this.businessList.length > 3) { if (this.businessList.length > 3) {
document.querySelector(".business-select").scrollLeft = document.querySelector(".business-select").scrollLeft =
document.querySelector(`.select-${index}`).offsetLeft - 10; document.querySelector(`.select-${index}`).offsetLeft - 10;
}
} }
});
}
}, 500);
},
// 小程序端定位
initLocation() {
this.setLocalStorage("isShowLoacationModal", true);
WX.getLocation().then((res) => {
this.mapChange(res);
});
},
mapChange(e) {
AMap.plugin("AMap.Geocoder", () => {
const geocoder = new AMap.Geocoder();
let { longitude, latitude } = e;
let lnglat = [longitude, latitude];
geocoder.getAddress(lnglat, (status, result) => {
let {
info,
regeocode: {
formattedAddress,
addressComponent: { adcode },
},
} = result;
if (status === "complete" && info === "OK") {
// result为对应的地理位置详细信息
this.addressInfo = {
longitude,
latitude,
cityCode: adcode,
address: formattedAddress,
};
this.$store.commit("setAddress", this.addressInfo);
this.setLocalStorage("addressInfo", this.addressInfo);
this.setLocalStorage("isShowLoacationModal", false);
this.getBusineInfo()
} else {
console.log("获取定位失败", info);
} }
}); });
} });
},500)
}, },
}, },
}; };
......
...@@ -39,7 +39,11 @@ export default { ...@@ -39,7 +39,11 @@ export default {
}; };
}, },
mounted() { mounted() {
this.authcode() let sign = this.getEnvironmentAndSource();
this.platform = sign
if(sign.platform=='H5'){
this.authcode()
}
if (countDownTime) clearInterval(countDownTime); if (countDownTime) clearInterval(countDownTime);
let nowTime = Math.round(new Date() / 1000); let nowTime = Math.round(new Date() / 1000);
let count = 60; let count = 60;
...@@ -100,7 +104,9 @@ export default { ...@@ -100,7 +104,9 @@ export default {
const ua = navigator.userAgent.toLowerCase() const ua = navigator.userAgent.toLowerCase()
if (ua.match(/MicroMessenger/i) == 'micromessenger'){//微信环境 if (ua.match(/MicroMessenger/i) == 'micromessenger'){//微信环境
para.appId = appId para.appId = appId
para.code = params.code if(this.platform.platform=='H5'){
para.code = params.code
}
this.removeLocalStorage('bindinfo') this.removeLocalStorage('bindinfo')
this.removeLocalStorage('showMydialog') this.removeLocalStorage('showMydialog')
this.removeLocalStorage('showMydialog1') this.removeLocalStorage('showMydialog1')
...@@ -113,7 +119,14 @@ export default { ...@@ -113,7 +119,14 @@ export default {
return return
} }
sessionStorage.setItem("LOGIN_TYPE", true); sessionStorage.setItem("LOGIN_TYPE", true);
window.location.href = `${window.location.href.split('?')[0]}#/equity/index?pageFrom=expcard` if(this.platform.platform=='H5'){
window.location.href = `${window.location.href.split('?')[0]}#/equity/index?pageFrom=expcard`
}else if(this.platform.platform=='mini'){
let temp =encodeURIComponent(JSON.stringify(res))
wx.miniProgram.switchTab({
url: `/pages/tab/equity/equity?freecard=${temp}`
})
}
}) })
}else{//非微信环境 }else{//非微信环境
equity.bindExpCard(para).then(res=>{ equity.bindExpCard(para).then(res=>{
......
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import BusinessItem from "./businesstem.vue"; import BusinessItem from "./businesstem.vue";
import { equity } from "@r/api.js"; import { equity } from "@r/api.js";
import AMap from "AMap";
import WxConfig from "@u/WxConfig";
const WX = new WxConfig(["openLocation", "getLocation"]);
export default { export default {
name: "", name: "",
components: { BusinessItem }, components: { BusinessItem },
...@@ -35,6 +38,7 @@ export default { ...@@ -35,6 +38,7 @@ export default {
bsloding: false, bsloding: false,
bsfinshed: false, bsfinshed: false,
homeBusinessList: [], homeBusinessList: [],
showAuthBtn: false,
}; };
}, },
mounted() { mounted() {
...@@ -47,14 +51,29 @@ export default { ...@@ -47,14 +51,29 @@ export default {
sessionStorage.setItem("URL_PARAM", options.urlParam); sessionStorage.setItem("URL_PARAM", options.urlParam);
this.addressInfo = addressInfo; this.addressInfo = addressInfo;
} }
let showLocation = this.getLocalStorage("isShowLoacationModal");
if (showLocation) {
this.showAuthBtn = true;
return;
} else {
//开启定位
let address = this.getLocalStorage("addressInfo");
if (address) {// 如果首页已经定位过,则不需要重新定位
this.addressInfo = address;
this.getBusinessList();
} else {
this.initLocation();
}
}
} else {
let address = this.getLocalStorage("addressInfo");
this.addressInfo = address;
this.getBusinessList();
} }
let address = this.getLocalStorage("addressInfo");
this.addressInfo = address;
this.getBusinessList();
}, },
methods: { methods: {
getBusinessList() { getBusinessList() {
if(this.businessParam.pageSize==0){ if (this.businessParam.pageSize == 0) {
this.showLoading(); this.showLoading();
} }
let { latitude, longitude } = this.addressInfo; let { latitude, longitude } = this.addressInfo;
...@@ -97,6 +116,44 @@ export default { ...@@ -97,6 +116,44 @@ export default {
this.getBusinessList(); this.getBusinessList();
} }
}, },
// 小程序端定位
initLocation() {
this.setLocalStorage("isShowLoacationModal", true);
WX.getLocation().then((res) => {
this.mapChange(res);
});
},
mapChange(e) {
AMap.plugin("AMap.Geocoder", () => {
const geocoder = new AMap.Geocoder();
let { longitude, latitude } = e;
let lnglat = [longitude, latitude];
geocoder.getAddress(lnglat, (status, result) => {
let {
info,
regeocode: {
formattedAddress,
addressComponent: { adcode },
},
} = result;
if (status === "complete" && info === "OK") {
// result为对应的地理位置详细信息
this.addressInfo = {
longitude,
latitude,
cityCode: adcode,
address: formattedAddress,
};
this.$store.commit("setAddress", this.addressInfo);
this.setLocalStorage("addressInfo", this.addressInfo);
this.setLocalStorage("isShowLoacationModal", false);
this.getBusinessList();
} else {
console.log("获取定位失败", info);
}
});
});
},
}, },
}; };
</script> </script>
......
...@@ -365,7 +365,7 @@ export default { ...@@ -365,7 +365,7 @@ export default {
//微信环境 //微信环境
isWXH5Environment: true, isWXH5Environment: true,
//定位信息 //定位信息
addressInfo: {}, addressInfo: null,
//金刚区数据 //金刚区数据
menuList: [], menuList: [],
menuH: true, menuH: true,
...@@ -409,6 +409,7 @@ export default { ...@@ -409,6 +409,7 @@ export default {
bsloding: false, bsloding: false,
bsfinshed: false, bsfinshed: false,
homeBusinessList: [], homeBusinessList: [],
showAuthBtn: false,
}; };
}, },
mixins: [indexMixin], mixins: [indexMixin],
...@@ -426,7 +427,7 @@ export default { ...@@ -426,7 +427,7 @@ export default {
this.platform = sign; this.platform = sign;
if (sign.platform == "mini") { if (sign.platform == "mini") {
this.tabText = ["直充优惠", "附近优惠"]; this.tabText = ["直充优惠", "附近优惠"];
this.activeItem = '直充优惠' this.activeItem = "直充优惠";
document.title = "权益中心"; document.title = "权益中心";
} }
this.getMemberInfoData(); this.getMemberInfoData();
...@@ -449,7 +450,18 @@ export default { ...@@ -449,7 +450,18 @@ export default {
// 页面入口判断 // 页面入口判断
this.judgeFrom(routerQuery, result); this.judgeFrom(routerQuery, result);
this.getRechargeList(); this.getRechargeList();
this.initLocation(); // 小程序端不默认定位
if (this.platform.platform != "mini") {
this.initLocation();
} else {
let address = this.getLocalStorage("addressInfo");
if (address) {
// 如果首页已经定位过,则不需要重新定位
console.log(1111);
this.addressInfo = address;
this.getBusinessList();
}
}
}, },
methods: { methods: {
// 轮播图当前指标index // 轮播图当前指标index
...@@ -714,6 +726,16 @@ export default { ...@@ -714,6 +726,16 @@ export default {
changeTab(index, item) { changeTab(index, item) {
this.curTabIndex = index; this.curTabIndex = index;
this.activeItem = item; this.activeItem = item;
let showLocation = this.getLocalStorage("isShowLoacationModal");
if (showLocation) {
this.showAuthBtn = true;
return;
}
let address = this.getLocalStorage("addressInfo");
if (item == "附近优惠" && this.platform.platform == "mini"&&!address) {
this.initLocation();
this.setLocalStorage("isShowLoacationModal", true);
}
}, },
// 初始化定位环境---考虑到存在位置移动情况,所以每次页面返回都定位请求一次 // 初始化定位环境---考虑到存在位置移动情况,所以每次页面返回都定位请求一次
initLocation() { initLocation() {
...@@ -752,6 +774,9 @@ export default { ...@@ -752,6 +774,9 @@ export default {
this.getBusinessList(); this.getBusinessList();
this.$store.commit("setAddress", this.addressInfo); this.$store.commit("setAddress", this.addressInfo);
this.setLocalStorage("addressInfo", this.addressInfo); this.setLocalStorage("addressInfo", this.addressInfo);
if (this.platform.platform == "mini") {
this.setLocalStorage("isShowLoacationModal", false);
}
} else { } else {
console.log("获取定位失败", info); console.log("获取定位失败", info);
} }
...@@ -832,7 +857,7 @@ export default { ...@@ -832,7 +857,7 @@ export default {
// 跳转到权益页面 // 跳转到权益页面
toNewPage(item) { toNewPage(item) {
let { sessionId } = this.$store.state; let { sessionId } = this.$store.state;
let { latitude, longitude } = this.addressInfo; // let { latitude, longitude } = this.addressInfo;
if (item.appearance == 1) { if (item.appearance == 1) {
let [href] = window.location.href.split("/#/"); let [href] = window.location.href.split("/#/");
let url = `${href}/#/commodity/business?sessionId=${sessionId}&supplier=${item.supplier}&brandName=${item.brandName}`; let url = `${href}/#/commodity/business?sessionId=${sessionId}&supplier=${item.supplier}&brandName=${item.brandName}`;
...@@ -840,8 +865,8 @@ export default { ...@@ -840,8 +865,8 @@ export default {
sessionId: sessionId, sessionId: sessionId,
supplier: item.supplier, supplier: item.supplier,
brandName: item.brandName, brandName: item.brandName,
lat: latitude, // lat: latitude,
lng: longitude, // lng: longitude,
}; };
this.openWindows(url, "commodity.business", query); this.openWindows(url, "commodity.business", query);
} else if (item.appearance == 2) { } else if (item.appearance == 2) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!