Commit 26b624b5 by 杨北旺

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

1 parent 75ab3d9e
......@@ -10,9 +10,9 @@ import store from "./store"
import axios from 'axios'
Vue.use(VueWechatTitle)
Vue.use(Vant)
// import VConsole from 'vconsole'
// const vConsole = new VConsole()
// Vue.use(vConsole)
import VConsole from 'vconsole'
const vConsole = new VConsole()
Vue.use(vConsole)
import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
Vue.use(preview)
......
......@@ -125,6 +125,9 @@ const setUserInfo = params => {
localStorage.setItem('APPID', params.appId)
}
sessionStorage.setItem('URL_PARAM', JSON.stringify(params))
if (user.freecard) {
localStorage.setItem('bindinfo', JSON.stringify(user.bingInfo))
}
user.nickName = user.phone
store.commit('setUserInfo', user)
} else {
......
......@@ -5,6 +5,13 @@
<span class="card_title">{{ equityName }}</span>
<span class="card_title_1">尊享100+专属权益</span>
</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">
<img class="img_bg" :src="imgBase_url + 'scrm_opening.png'" />
</div>
......@@ -15,7 +22,7 @@
@click="jumpOpen"
/>
</div>
<div style="height:110px"></div>
<div style="height: 110px"></div>
<div class="fixed_wrapper">
<div class="btn_wrap">
<div
......@@ -141,6 +148,7 @@ export default {
payStatus: 0,
isOpen: 0,
channelType: 0, // 2是广汇
platform:{}
};
},
created() {
......@@ -356,6 +364,13 @@ export default {
let url = `${href}/#/cardRoll/agreement?sessionId=${sessionId}`;
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() {
clearInterval(this.timer);
......@@ -401,6 +416,12 @@ export default {
text-shadow: 0 2px 4px rgba(255, 123, 43, 0.24);
}
}
.activity_widget {
.img_bg {
width: 100%;
height: 100%;
}
}
.image_widget {
margin-top: 16px;
.img_bg {
......@@ -415,7 +436,7 @@ export default {
height: 90px;
}
}
.fixed_wrapper{
.fixed_wrapper {
position: fixed;
left: 0;
right: 0;
......
......@@ -122,7 +122,13 @@
v-if="isHaveInventory"
@click="toBuyGoods"
>
<span>{{ isOpen || !selectData.noMemberPrice?selectData.salesPrice:selectData.noMemberPrice }}元</span>立即购买
<span
>{{
isOpen || !selectData.noMemberPrice
? selectData.salesPrice
: selectData.noMemberPrice
}}元</span
>立即购买
</div>
<div class="recharge-operation disabled" v-if="!isHaveInventory">
该商品已售罄
......@@ -183,6 +189,7 @@
import { pay } from "@/mixins";
import { commodity, equity } from "@r/api";
// import { Dialog } from 'vant'
import AMap from "AMap";
import WxConfig from "@u/WxConfig";
const WX = new WxConfig(["openLocation", "getLocation"]);
import MyModal from "../../components/MyModal.vue";
......@@ -207,6 +214,7 @@ export default {
showModal: false,
diffPrice: 0,
isLogin: true,
showAuthBtn: false,
};
},
created() {
......@@ -215,88 +223,96 @@ export default {
this.isLogin = JSON.parse(sessionStorage.getItem("LOGIN_TYPE"));
}
this.platform = sign;
},
mounted() {
this.showLoading();
// const ua = navigator.userAgent.toLowerCase()
// let { latitude, longitude } = this.$store.state.address;
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, 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;
if (sign.platform == "mini") {
let address = this.getLocalStorage("addressInfo");
let showLocation = this.getLocalStorage("isShowLoacationModal");
if (showLocation) {
this.showAuthBtn = true;
this.getBusineInfo()
return;
} else {
//开启定位
if(address){
console.log(1111110);
this.getBusineInfo()
}else{
this.initLocation();
}
}
}
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];
// 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);
}
});
},
mounted() {
if(this.platform.platform!='mini'){
this.getBusineInfo()
}
},
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() {
if (!this.isLogin) {
return;
......@@ -391,22 +407,59 @@ export default {
},
// 精选进来自动滚动
autoSelect() {
setTimeout(()=>{
setTimeout(() => {
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.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;
}
}
});
}
}, 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 {
};
},
mounted() {
this.authcode()
let sign = this.getEnvironmentAndSource();
this.platform = sign
if(sign.platform=='H5'){
this.authcode()
}
if (countDownTime) clearInterval(countDownTime);
let nowTime = Math.round(new Date() / 1000);
let count = 60;
......@@ -100,7 +104,9 @@ export default {
const ua = navigator.userAgent.toLowerCase()
if (ua.match(/MicroMessenger/i) == 'micromessenger'){//微信环境
para.appId = appId
para.code = params.code
if(this.platform.platform=='H5'){
para.code = params.code
}
this.removeLocalStorage('bindinfo')
this.removeLocalStorage('showMydialog')
this.removeLocalStorage('showMydialog1')
......@@ -113,7 +119,14 @@ export default {
return
}
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{//非微信环境
equity.bindExpCard(para).then(res=>{
......
......@@ -21,6 +21,9 @@
<script type='text/ecmascript-6'>
import BusinessItem from "./businesstem.vue";
import { equity } from "@r/api.js";
import AMap from "AMap";
import WxConfig from "@u/WxConfig";
const WX = new WxConfig(["openLocation", "getLocation"]);
export default {
name: "",
components: { BusinessItem },
......@@ -35,6 +38,7 @@ export default {
bsloding: false,
bsfinshed: false,
homeBusinessList: [],
showAuthBtn: false,
};
},
mounted() {
......@@ -47,14 +51,29 @@ export default {
sessionStorage.setItem("URL_PARAM", options.urlParam);
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: {
getBusinessList() {
if(this.businessParam.pageSize==0){
if (this.businessParam.pageSize == 0) {
this.showLoading();
}
let { latitude, longitude } = this.addressInfo;
......@@ -97,6 +116,44 @@ export default {
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>
......
......@@ -365,7 +365,7 @@ export default {
//微信环境
isWXH5Environment: true,
//定位信息
addressInfo: {},
addressInfo: null,
//金刚区数据
menuList: [],
menuH: true,
......@@ -409,6 +409,7 @@ export default {
bsloding: false,
bsfinshed: false,
homeBusinessList: [],
showAuthBtn: false,
};
},
mixins: [indexMixin],
......@@ -426,7 +427,7 @@ export default {
this.platform = sign;
if (sign.platform == "mini") {
this.tabText = ["直充优惠", "附近优惠"];
this.activeItem = '直充优惠'
this.activeItem = "直充优惠";
document.title = "权益中心";
}
this.getMemberInfoData();
......@@ -449,7 +450,18 @@ export default {
// 页面入口判断
this.judgeFrom(routerQuery, result);
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: {
// 轮播图当前指标index
......@@ -714,6 +726,16 @@ export default {
changeTab(index, item) {
this.curTabIndex = index;
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() {
......@@ -752,6 +774,9 @@ export default {
this.getBusinessList();
this.$store.commit("setAddress", this.addressInfo);
this.setLocalStorage("addressInfo", this.addressInfo);
if (this.platform.platform == "mini") {
this.setLocalStorage("isShowLoacationModal", false);
}
} else {
console.log("获取定位失败", info);
}
......@@ -832,7 +857,7 @@ export default {
// 跳转到权益页面
toNewPage(item) {
let { sessionId } = this.$store.state;
let { latitude, longitude } = this.addressInfo;
// let { latitude, longitude } = this.addressInfo;
if (item.appearance == 1) {
let [href] = window.location.href.split("/#/");
let url = `${href}/#/commodity/business?sessionId=${sessionId}&supplier=${item.supplier}&brandName=${item.brandName}`;
......@@ -840,8 +865,8 @@ export default {
sessionId: sessionId,
supplier: item.supplier,
brandName: item.brandName,
lat: latitude,
lng: longitude,
// lat: latitude,
// lng: longitude,
};
this.openWindows(url, "commodity.business", query);
} 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!