提交 9e001aa2 编写于 作者: guangjun.yang's avatar guangjun.yang

解决本地存储的问题

上级 92e4aefb
<template>
<section v-if="!isWeb" :class="isFixNavbar ? 'nav-top fixed' : 'nav-top'" :style="'height:' + navHeight">
<div
class="nav-part"
:style="'background:' + bgColor + ';'
+ 'padding-top:' + paddingTop + ';border-bottom:' + borderStyle"
>
<div class="nav-title">
<span class="nav-back" @click="goBack">
<img v-show="isBlack" src="../../images/left-array-black.png" alt="">
<img v-show="!isBlack" src="../../images/left-array-whiter.png" alt="">
</span>
<span class="nav-title-title" v-show="bgColor!=='none'">{{title}}</span>
<span v-if="isShowShare" class="nav-share" @click="goShare">
<img v-show="isBlack"
src="../../images/cme/share-icon-black.png"
>
<img v-show="!isBlack" src="../../images/cme/share-icon-white.png"/>
</span>
</div>
</div>
</section>
</template>
<script>
import { getWebPageUrl } from "@/utils/index";
import { mapGetters } from 'vuex';
export default {
name: "common-navbar",
data() {
return {
// isWeb: window.__isWeb,
navbarHeight: 28,
contentHeight: 35,
fontSize: 37.5,
content: "",
shareImageUrl:
"https://file.yunqueyi.com/logo.png?version=" + new Date().getTime(),
shareUrl: ''
};
},
props: {
isWeb: {
type: Boolean,
default: window.__isWeb
},
bgColor: {
type: String,
default: ""
},
title: {
type: String,
default: "暂无数据"
},
//是否fix定位
isFixNavbar: {
type: Boolean,
default: false
},
burialPoint: {
default: "",
type: String
},
backMethod: {
type: String,
default: "native" // inner native
},
isShowShare: {
type: Boolean,
default: false
},
borderStyle: {
type: String,
default: "1px solid #e7e7e7"
},
isBlack: {
type: Boolean,
default: true
},
shareTitle: {
type: String,
default: ""
},
shareTitleInfo: {
type: String,
default: ""
},
projectId: {
type: String | Number,
default: ""
},
limitTimes: {
type: String | Number,
default: 0
}
},
computed: {
...mapGetters(["userInfo"]),
navHeight() {
if (this.isFixNavbar) {
return 0;
// return (this.contentHeight) / this.fontSize + 'rem';
} else {
return (this.navbarHeight + this.contentHeight) / this.fontSize + "rem";
}
},
paddingTop() {
// return this.isWeb ? 0 : this.navbarHeight / this.fontSize + 'rem'
return this.navbarHeight / this.fontSize + "rem";
}
},
mounted() {
let htmlDom = document.getElementsByTagName("html")[0].style.fontSize;
this.fontSize = htmlDom;
},
methods: {
//返回
goBack() {
rocNative.goBack();
},
// 生成分享的url
goShare() {
this.$sendBuriedData({
component_tag: `882#88209`
});
let _this = this;
let videoUrl = this.$route.query.videoUrl || '';
let info = "";
if(videoUrl) {
info = JSON.stringify({
projectId: this.projectId,
videoUrl: videoUrl,
limitTimes: this.limitTimes || 0
})
} else {
info = JSON.stringify({
projectId: this.projectId,
})
}
let param = {
channel: 1, // 分享渠道 1:APP
info: info,
type: 3, // 业务类型 1:教培项目 2:继教项目 3:职称考项目
token: _this.userInfo.userToken,
setEntry: true
};
_this.NEW_POST("portal/shareParam/save", param).then(res => {
if (res.code == "000000") {
let url = getWebPageUrl(`profexam/#/sharecoop?uuid=${res.data}`);
_this.shareUrl = url;
_this.goShareAction();
}
}).catch( e => {
console.error(e);;
});
},
//分享
goShareAction() {
// let url = location.href,
let _this = this;
rocNative.shareWechat({
type: 6,
shareId: 0,
shareUrl: _this.shareUrl,
title1: _this.shareTitle,
title2: _this.shareTitleInfo,
shareImageUrl: "https://file.yunqueyi.com/logo.png?version=" + new Date().getTime()
});
}
}
};
</script>
<style lang="less" scoped>
.back {
position: absolute;
left: px;
top: 15px;
display: inline-block;
width: 50px;
height: 50px;
img {
padding: 10px;
width: 25px;
height: 25px;
}
}
.nav-top {
// height: 65px;
background: #fff;
color: #333;
position: relative;
z-index: 109;
.nav-back {
display: inline-block;
position: absolute;
left: 0px;
top: 0;
height: 25px;
width: 55px;
padding-left: 15px;
padding-right: 15px;
}
img {
display: block;
width: 100%;
height: 100%;
}
.nav-icon {
display: inline-block;
width: 50px;
height: 50px;
svg {
stroke: #000;
fill: #0000ff;
}
}
.nav-share {
position: absolute;
right: 16px;
top: 0;
height: 25px;
width: 25px;
}
.nav-title {
position: relative;
top: 10px;
left: 0;
display: inline-block;
width: 100%;
/* padding:0 33px;*/
height: 36px;
&-title {
height: 18px;
font-size: 18px;
font-weight: 700;
color: rgba(51, 51, 51, 1);
line-height: 26px;
display: inline-block;
max-width: 230px;
height: 36px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
.nav-part {
width: 100%;
font-size: 18px;
text-align: center;
padding: 0 0 10px 0;
/* height: 25px;*/
}
}
.nav-part {
position: fixed;
top: 0;
left: 0;
border-bottom: 1px solid #e7e7e7;
/* height: 25px;*/
}
</style>
......@@ -36,7 +36,7 @@ export default {
content: "",
shareImageUrl:
"https://file.yunqueyi.com/logo.png?version=" + new Date().getTime(),
shareUrl: ''
// shareUrl: ''
};
},
props: {
......@@ -52,8 +52,8 @@ export default {
type: String,
default: "暂无数据"
},
isFixNavbar: {
//是否fix定位
isFixNavbar: {
type: Boolean,
default: false
},
......@@ -92,6 +92,10 @@ export default {
limitTimes: {
type: String | Number,
default: 0
},
shareUrl: {
type: String | Number,
default: ""
}
},
computed: {
......@@ -116,7 +120,11 @@ export default {
methods: {
//返回
goBack() {
rocNative.goBack();
if(this.isWeb) {
window.history.back();
} else {
rocNative.goBack();
}
},
// 生成分享的url
......@@ -125,45 +133,50 @@ export default {
component_tag: `882#88209`
});
let _this = this;
let videoUrl = this.$route.query.videoUrl || '';
let info = "";
if(videoUrl) {
info = JSON.stringify({
projectId: this.projectId,
videoUrl: videoUrl,
limitTimes: this.limitTimes || 0
})
if(this.isInMergeDetail) {
let videoUrl = this.$route.query.videoUrl || '';
let info = "";
if(videoUrl) {
info = JSON.stringify({
projectId: this.projectId,
videoUrl: videoUrl,
limitTimes: this.limitTimes || 0
})
} else {
info = JSON.stringify({
projectId: this.projectId,
})
}
let param = {
channel: 1, // 分享渠道 1:APP
info: info,
type: 3, // 业务类型 1:教培项目 2:继教项目 3:职称考项目
token: _this.userInfo.userToken,
setEntry: true
};
_this.NEW_POST("portal/shareParam/save", param).then(res => {
if (res.code == "000000") {
let url = getWebPageUrl(`profexam/#/sharecoop?uuid=${res.data}`);
// _this.shareUrl = url;
_this.goShareAction(url);
}
}).catch( e => {
console.error(e);;
});
} else {
info = JSON.stringify({
projectId: this.projectId,
})
_this.goShareAction();
}
let param = {
channel: 1, // 分享渠道 1:APP
info: info,
type: 3, // 业务类型 1:教培项目 2:继教项目 3:职称考项目
token: _this.userInfo.userToken,
setEntry: true
};
_this.NEW_POST("portal/shareParam/save", param).then(res => {
if (res.code == "000000") {
let url = getWebPageUrl(`profexam/#/sharecoop?uuid=${res.data}`);
_this.shareUrl = url;
_this.goShareAction();
}
}).catch( e => {
console.error(e);;
});
},
//分享
goShareAction() {
goShareAction(shareUrl) {
// let url = location.href,
let _this = this;
rocNative.shareWechat({
type: 6,
shareId: 0,
shareUrl: _this.shareUrl,
shareUrl: shareUrl || _this.shareUrl,
title1: _this.shareTitle,
title2: _this.shareTitleInfo,
shareImageUrl: "https://file.yunqueyi.com/logo.png?version=" + new Date().getTime()
......
......@@ -20,6 +20,7 @@ import NoCoupon from "@/components/coupon/no-coupon";
import { getWebPageUrl, getHactiveUrl } from "@/utils";
import { mapGetters, mapActions } from "vuex";
import { Toast } from "vant";
import { setCookie, getCookie, delCookie } from '@/utils/index';
export default {
components: {
......@@ -92,7 +93,9 @@ export default {
mounted() {
// 如果在浏览器或微信里
if (this.isWeb) {
const { token, info } = this.$store.state.user;
let { token, info } = this.$store.state.user;
token = token || localStorage.getItem("token") || getCookie("token");
console.log("token && !info.id", !info.id, "wef", token);
if (!token) {
this.goLogin();
......
<template>
<div class="goods-details-wrapper">
<div class="goods-details-wrapper" :class="{'no-pt': !isWeb}">
<CommonNavbar
id="header"
:isWeb="!isWeb"
:bgColor="bgColor"
v-show="isShowNavbar"
:isBlack="isBlack"
:isShowShare="isShowShare"
:title="navTitle"
:shareTitle="goods.goodsName"
:shareTitleInfo="shareTitleInfo"
:isFixNavbar="isFixNavbar"
:shareUrl="shareUrl"
borderStyle="0px solid #fff"
></CommonNavbar>
<!-- 轮播 -->
<div class="swiper-box">
<van-swipe :show-indicators="false" @change="onSwiperChange">
......@@ -103,6 +117,7 @@ import Loading from "@/components/common/common-loading";
import CourseDialog from "@/components/course/course-dialog";
import CouponSelectList from "@/components/coupon/component-select-list";
import CommonNavbar from "@/components/common/common-navbar";
import { wxConfig, chooseWXPay } from "@/utils/wxShare";
import {
getAPPID,
......@@ -124,13 +139,15 @@ export default {
SwipeItem,
Loading,
CourseDialog,
CouponSelectList
CouponSelectList,
CommonNavbar
},
data() {
return {
token: "",
isWeb: window.__isWeb,
goods: {
goodsName: "",
salePriceNew: {},
salePrice: {}
}, // 商品信息
......@@ -148,6 +165,14 @@ export default {
defaultCouponId: "",
needSortAndSelect: true,
orderId: "",
bgColor: "#fff",
navTitle: "商品详情",
isFixNavbar: true,
isShowNavbar: true,
isBlack: true,
// shareTitle: goods.goodsName,
shareTitleInfo: "",
isShowShare: true,
};
},
computed: {
......@@ -236,7 +261,15 @@ export default {
);
if (this.isWeb) {
const { token, info } = this.$store.state.user;
let { token, info } = this.$store.state.user;
token = token || localStorage.getItem("token") || getCookie("token");
console.log("token && !info.id", !info.id, token);
if (!token) {
this.goLogin();
return;
}
if (token && !info.id) {
this.commonCheckToken(() => {
this.$store.dispatch("getUserInfo");
......@@ -415,81 +448,82 @@ export default {
},
// 获取商品信息
// TODO
getGoodsInfo() {
// this.GET(`trade/goods/goodInfo/${this.goodsId}`, {}).then(res => {
this.GET(`trade/goods/goodInfoV3/${this.goodsId}`, {}).then(res => {
if (res.code == "000000") {
const goods = res.data;
const tabs = [];
let priceNew = goods.preferentialPrice || goods.costPrice;
let price = goods.couponPrice || goods.preferentialPrice || goods.costPrice;
this.goods = goods;
this.defaultCouponId = (goods.couponDTO && goods.couponDTO.couponId) || '';
// 获取到商品后,再获取优惠券
this.getCanUseCoupons({
goodsType: goods.goodsType,
cardType: goods.cardType,
price: priceNew,
count: 0
});
goods.salePriceNew = this.formatPrice(priceNew);
goods.salePrice = this.formatPrice(price);
goods.costPriceText = (goods.costPrice / 100).toFixed(2);
goods.hasDiscount = !!(goods.couponPrice || goods.preferentialPrice);
let savePrice = 0;
if (goods.couponPrice) {
if (goods.preferentialPrice) {
savePrice = (
(goods.preferentialPrice - goods.couponPrice) /
100
).toFixed(2);
} else {
savePrice = ((goods.costPrice - goods.couponPrice) / 100).toFixed(
2
);
this.commonCheckToken(() => {
this.GET(`trade/goods/goodInfoV3/${this.goodsId}`, {}).then(res => {
if (res.code == "000000") {
const goods = res.data;
const tabs = [];
let priceNew = goods.preferentialPrice || goods.costPrice;
let price = goods.couponPrice || goods.preferentialPrice || goods.costPrice;
this.goods = goods;
this.defaultCouponId = (goods.couponDTO && goods.couponDTO.couponId) || '';
// 获取到商品后,再获取优惠券
this.getCanUseCoupons({
goodsType: goods.goodsType,
cardType: goods.cardType,
price: priceNew,
count: 0
});
goods.salePriceNew = this.formatPrice(priceNew);
goods.salePrice = this.formatPrice(price);
goods.costPriceText = (goods.costPrice / 100).toFixed(2);
goods.hasDiscount = !!(goods.couponPrice || goods.preferentialPrice);
let savePrice = 0;
if (goods.couponPrice) {
if (goods.preferentialPrice) {
savePrice = (
(goods.preferentialPrice - goods.couponPrice) /
100
).toFixed(2);
} else {
savePrice = ((goods.costPrice - goods.couponPrice) / 100).toFixed(
2
);
}
}
}
if (goods.goodsDescWhere) {
tabs.push({ name: "使用范围", detail: goods.goodsDescWhere });
}
if (goods.goodsDescHow) {
tabs.push({ name: "如何使用", detail: goods.goodsDescHow });
}
if (goods.goodsDescQaq) {
tabs.push({ name: "常见问题", detail: goods.goodsDescQaq });
}
this.totalPrice = {
...goods.salePrice,
preferentialPrice: goods.preferentialPrice,
costPrice: goods.costPrice,
costPriceText: goods.costPriceText,
savePrice
};
this.swiperList = (res.data && res.data.imgList) || [];
this.tabs = tabs;
this.getTabW();
let sharePrice = goods.preferentialPrice || goods.costPrice;
let shareDesc = "¥" + (sharePrice / 100).toFixed(2);
shareDesc += "\n" + (goods.shareContent || "");
let shareUrl = getWebPageUrl(
`profexam/#/goods-detail?goodsId=${this.goods.id}`
);
this.wechatShare(
{
link: shareUrl,
title: goods.goodsName,
friendtitle: goods.goodsName,
desc: shareDesc,
imgUrl: "https://file.yunqueyi.com/logo.png"
},
() => {
console.log("share success...");
if (goods.goodsDescWhere) {
tabs.push({ name: "使用范围", detail: goods.goodsDescWhere });
}
);
} else {
this.$toast(res.message);
}
if (goods.goodsDescHow) {
tabs.push({ name: "如何使用", detail: goods.goodsDescHow });
}
if (goods.goodsDescQaq) {
tabs.push({ name: "常见问题", detail: goods.goodsDescQaq });
}
this.totalPrice = {
...goods.salePrice,
preferentialPrice: goods.preferentialPrice,
costPrice: goods.costPrice,
costPriceText: goods.costPriceText,
savePrice
};
this.swiperList = (res.data && res.data.imgList) || [];
this.tabs = tabs;
this.getTabW();
let sharePrice = goods.preferentialPrice || goods.costPrice;
let shareTitleInfo = "¥" + (sharePrice / 100).toFixed(2);
shareTitleInfo += "\n" + (goods.shareContent || "");
let shareUrl = getWebPageUrl(
`profexam/#/goods-detail?goodsId=${this.goods.id}`
);
this.shareTitleInfo = shareTitleInfo;
this.wechatShare(
{
link: shareUrl,
title: goods.goodsName,
friendtitle: goods.goodsName,
desc: shareTitleInfo,
imgUrl: "https://file.yunqueyi.com/logo.png"
},
() => {
console.log("share success...");
}
);
} else {
this.$toast(res.message);
}
});
});
},
......@@ -791,6 +825,7 @@ export default {
<style lang="less" scoped>
.goods-details-wrapper {
padding-top: 80px;
.swiper-box {
position: relative;
.indicator {
......@@ -1006,5 +1041,8 @@ export default {
font-weight: 400;
color: #fb5b52;
}
&.no-pt {
padding-top: 0px;
}
}
</style>
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册