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

站内调用原生方法

上级 291276fc
......@@ -7,7 +7,7 @@ import { mapGetters } from 'vuex';
module.exports = {
data: function () {
return {
token: 'weewfwefw'
token: '',
}
},
created: function () {
......@@ -235,7 +235,11 @@ module.exports = {
};
this.GET("campaign/admin/task/checkToken", param).then(res => {
if (res.code !== "000000") {
this.goLogin();
if(Window.__isWeb) {
this.goLogin();
} else {
rocNative.gotoLogin();
}
} else {
cb && cb()
}
......
<template>
<div class="goods-details-wrapper">
<!-- 轮播 -->
<div class="swiper-box">
<van-swipe :show-indicators="false" @change="onSwiperChange">
<van-swipe-item
v-for="(item, index) in swiperList"
:key="index">
<img class="img" :src="item.goodsImgUrl" alt="" />
</van-swipe-item>
</van-swipe>
<div class="indicator">
{{ swiperCurtIndex + 1 }}/{{ swiperList.length }}
</div>
</div>
<!-- 商品信息 -->
<div class="info-box border-line">
<p class="title">{{ goods.goodsName }}</p>
<div class="price">
<div class="money">
<span class="yuan">{{ goods.salePrice.yuan }}</span><span class="fen">.{{ goods.salePrice.fen }}</span><span v-if="goods.hasDiscount" class="del">原价: ¥{{ goods.costPriceText }}</span>
</div>
<div class="bought">{{ goods.saledNum }}购买</div>
</div>
</div>
<!-- 购买数量、支付方式 -->
<div class="buy-box border-line">
<div class="flex">
<div class="name">购买数量</div>
<div class="buy-num">
<div class="reduce" @click="onReduce"></div>
<div class="num">{{ goodsNum }}</div>
<div class="plus" @click="onPlus"></div>
</div>
</div>
<div class="flex buy-way">
<div class="name ">
优惠券
</div>
<div @click="showCouponPopup" class="coupon-select coupon-pc">-¥100</div>
</div>
<div class="flex buy-way">
<div class="name">
支付方式
<span>目前只支持微信支付</span>
</div>
<div class="way">微信支付</div>
</div>
</div>
<!-- tab切换 -->
<div class="tab-box">
<div
class="tab-item"
:class="{'tab-active': curtTabIdx === index}"
v-for="(tab, index) in tabs"
:key="index"
@click="tabToggle(index)">
{{ tab.name }}
</div>
<div class="tab-line" :style="{left: `${tabLeft}px`}"></div>
</div>
<!-- 详情 -->
<div class="detail-box deep-img-w100" v-html="tabs[curtTabIdx] && tabs[curtTabIdx]['detail']"></div>
<!-- 底部购买 -->
<div class="btn-box">
<div class="money">
<p>合计:<span class="yuan">{{ totalPrice.yuan }}</span><span class="fen">.{{ totalPrice.fen }}</span><span v-if="goods.hasDiscount" class="del">原价: ¥{{ totalPrice.costPriceText }}</span></p>
<!-- <p v-if="totalPrice.savePrice" class="coupon">已使用优惠券,为您再优惠{{ totalPrice.savePrice }}</p> -->
</div>
<div
class="btn"
:class="[goods.isSale === 2 ? 'cannot-buy' : 'can-but']"
@click="createOrder">
{{ goods.isSale === 2 ? '商品已下架' : '确认支付' }}
</div>
</div>
<Loading v-show="showLoading" />
<!--去激活-->
<ChangeCard
:changeErrorMsg="changeCardErrorMsg"
:isShow="showChangeCard"
@cancle="cancleChangeCard"
@confirm="changeCardAction">
</ChangeCard>
<CourseDialog
content="微信授权"
subContent='<p style="font-size: 16px; font-weight: bold; text-align: center;">云鹊医申请以下权限:</p><p style="font-size: 14px; color: #999; text-align: center; padding-bottom: 10px;">获得你的公开信息(头像,昵称等)</p>'
cancleBtnText="取消"
confirmBtnText="允许"
needSubContent
:isShowDialog="isShowDialog"
@handlerAction="handlerAction"
></CourseDialog>
</div>
</template>
<script>
import { Swipe, SwipeItem } from 'vant';
import Loading from "@/components/common/common-loading";
import CourseDialog from "@/components/course/course-dialog";
import ChangeCard from "@/components/coupon/coupon-select-list";
import { wxConfig, chooseWXPay } from '@/utils/wxShare';
import { getAPPID, getTradeType, getWebPageUrl, isWeiXin, wxOauth, debounce } from '@/utils';
import { mapGetters } from "vuex";
const isWechat = isWeiXin();
// wxConfig(location.href);
export default {
components: {
Swipe,
SwipeItem,
Loading,
CourseDialog,
ChangeCard
},
data() {
return {
goods: {
salePrice: {},
}, // 商品信息
totalPrice: {}, // 底部价格
swiperList: [], // 轮播图
swiperCurtIndex: 0, // 轮播当前下标
goodsNum: 1, // 数量
tabs: [],
curtTabIdx: 0,
tabW: 0, // tab的宽度
showLoading: false,
isShowDialog: false,
showChangeCard: false, //是否展示激活弹框,
changeCardErrorMsg: "",
}
},
computed: {
...mapGetters(["logged"]),
// logged() {
// return this.$store.getters.logged;
// },
wxInfo() {
return this.$store.state.user.wxInfo;
},
wxCode() {
return this.$store.state.user.wxCode;
},
tabLeft() {
const num = this.curtTabIdx + 0.25 + 15 / 115;
return this.tabW * num;
},
},
created() {
console.log('in goods detail new', 111111111);
let href = location.href;
this.shareUrl = href;
this.projectId = this.$route.query.projectId;
this.goodsId = this.$route.query.goodsId || 74;
if (href.indexOf("singlemessage") >= 0 || href.indexOf("wx_code") >= 0) {
if(this.projectId) {
this.shareUrl = getWebPageUrl(`profexam/#/goods-detail?goodsId=${this.goodsId}&projectId=${this.projectId}`);
} else {
this.shareUrl = getWebPageUrl(`profexam/#/goods-detail?goodsId=${this.goodsId}`);
}
location.replace(this.shareUrl);
}
localStorage.setItem('returnUrl', this.shareUrl);
},
mounted() {
this.getGoodsInfo();
this.getTabW();
const { token, info } = this.$store.state.user;
if (token && !info.id) {
this.$store.dispatch('getUserInfo');
}
// // 微信内先去授权
// if (isWechat && !this.wxInfo.openid) {
// if (location.search.indexOf('code') >= 0 || this.wxCode) {
// // 避免code中转页再次授权
// return;
// }
// wxOauth();
// return;
// }
// 数量加减
this.curtGoodsNum = this.goodsNum;
this.countTotalPrice = debounce(this.getTotalPrice, 300);
// 记录参数,授权登录返回时重新赋值,在main.js
sessionStorage.setItem('goodsDetailParams', JSON.stringify(this.$route.query))
},
methods: {
cancleChangeCard() {
this.showChangeCard = false;
},
changeCardAction(cardKey, isInTips) {
},
showCouponPopup() {
this.showChangeCard = true;
},
// tab切换
tabToggle(index) {
this.curtTabIdx = index;
this.$sendBuriedData({
component_tag: `888#8880${index + 4}`
});
},
getGoodsInfo() {
this.GET(`trade/goods/goodInfo/${this.goodsId}`, {}).then(res => {
if (res.code == "000000") {
const goods = res.data;
const tabs = [];
let price = goods.couponPrice || goods.preferentialPrice || goods.costPrice;
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.couponDTO) {
// goods.couponAmountText = (goods.couponDTO.discountAmount / 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.goods = goods;
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...");
}
);
} else {
this.$toast(res.message);
}
})
},
// 多件商品的价格
getTotalPrice() {
const num = this.curtGoodsNum;
this.GET(`trade/goods/getPrice/${this.goodsId}/${num}`, {}).then(res => {
if (res.code == "000000") {
const { couponPrice, preferentialPrice, costPrice, savePrice } = res.data;
let price = couponPrice || preferentialPrice || costPrice;
this.totalPrice = {
...this.formatPrice(price),
preferentialPrice,
costPrice: costPrice,
costPriceText: (costPrice / 100).toFixed(2),
savePrice: savePrice ? (savePrice / 100).toFixed(2) : 0,
}
this.goodsNum = num;
} else if (res.code === "200006") {
this.$store.dispatch('logout')
}
})
},
// 价格转成元、分
formatPrice(price) {
let yuan = (price / 100).toFixed(0);
let fen = price % 100;
fen = fen < 10 ? `0${fen}` : fen;
return {
yuan,
fen
}
},
// 获取切换标签宽度
getTabW() {
if (this.tabs.length === 0) {
return;
}
this.$nextTick(() => {
const { width } = this.$el.querySelector('.tab-item').getBoundingClientRect();
this.tabW = width;
})
},
// 轮播切换
onSwiperChange(index) {
this.swiperCurtIndex = index;
},
// 数量增
onPlus() {
this.$sendBuriedData({
component_tag: `888#88801`
});
if (!this.logged) {
this.goLogin();
return;
}
let num = this.curtGoodsNum;
if (this.goods.limitPurchase && this.goods.limitPurchaseNum && num >= this.goods.limitPurchaseNum) {
this.$toast('已达最大限购数量')
return;
}
if (this.goods.goodsStocks && num >= this.goods.goodsStocks) {
this.$toast('库存不足')
return;
}
this.curtGoodsNum = num + 1;
this.countTotalPrice();
},
// 数量减
onReduce() {
this.$sendBuriedData({
component_tag: `888#88802`
});
if (!this.logged) {
this.goLogin();
return;
}
let num = this.curtGoodsNum;
if (num <= 1) {
this.$toast('最少购买一张哦')
return;
}
this.curtGoodsNum = num - 1;
this.countTotalPrice();
},
goLogin() {
this.$store.dispatch('goLogin');
},
handlerAction(type) {
if (type === 2) {
wxOauth();
}
this.isShowDialog = false;
},
// 创建订单
createOrder() {
this.$sendBuriedData({
component_tag: `888#88803`
});
if (!this.logged) {
this.goLogin();
return;
}
// 微信内先去授权
if (isWechat && !this.wxInfo.openid) {
this.isShowDialog = true;
return;
}
// 避免多次支付
if (this.showLoading) {
return;
}
const { id, couponDTO, isSale } = this.goods;
const { preferentialPrice, costPrice } = this.totalPrice;
if (!id || isSale !== 1) {
return;
}
const orderData = {
couponId: couponDTO ? couponDTO.couponId : 0,
goodsId: id,
goodsQuantity: this.goodsNum,
orderSource: 3,
preferentialPrice: this.goods.preferentialPrice,
price: this.goods.costPrice,
}
console.log('orderData...', orderData);
this.showLoading = true;
this.POST('trade/center/order/createV2', orderData).then(res => {
if (res.code == "000000") {
const orderId = res.data.orderId;
if (isWechat) {
this.goWxPayInner(orderId);
} else {
this.goWxPayOut(orderId);
}
if (this.projectId) {
this.createRelation(this.projectId, orderId);
}
} else {
this.$toast(res.message);
this.showLoading = false;
if (res.code === "200006") {
this.$store.dispatch('logout')
}
}
}).catch(() => {
this.showLoading = false;
});
},
// 微信内支付
goWxPayInner(orderId) {
const data = {
openId: this.wxInfo.openid,
orderId,
payChannel: 1,
tradeType: getTradeType(),
userId: this.$store.state.user.info.id
}
this.POST('trade/center/jsapi_prepay', data).then(res => {
if (res.code == "000000" && res.data) {
// console.log('______prepay_____', res.data);
const that = this;
const payData = {
...res.data,
appid: res.data.appId,
timestamp: res.data.timeStamp,
success: function() {
let query = { orderId };
if (that.projectId) {
query.projectId = that.projectId
}
that.$router.push({ path: '/prezult', query });
},
fail: function() {
that.$toast('支付失败,请重试~');
},
cancel: function() {
// that.$toast('支付取消~');
},
complete: function() {},
};
chooseWXPay(payData);
} else {
this.$toast(res.message);
}
this.showLoading = false;
}).catch(() => {
this.showLoading = false;
})
},
// 站外微信支付
goWxPayOut(orderId) {
const data = {
// openId: getAPPID(),
orderId,
payChannel: 1,
tradeType: getTradeType(),
}
this.POST('trade/center/mweb_prepay', data).then(res => {
if (res.code == "000000") {
if (res.data) {
let redirectUrl = this.getRedirectUrl(orderId);
let jumpLink = res.data + '&redirect_url=' + encodeURIComponent(redirectUrl);
window.location.href = jumpLink;
}
} else {
this.$toast(res.message || '暂时不能支付');
}
this.showLoading = false;
}).catch(() => {
this.showLoading = false;
})
},
getRedirectUrl(orderId) {
let path = `profexam/#/prezult?orderId=${orderId}`;
if (this.projectId) {
path += `&projectId=${this.projectId}`
}
return getWebPageUrl(path);
},
// 绑定项目和订单的关系(idType=1)
createRelation(projectId, orderId) {
this.POST(`cme/projectCard/correlation/1/${projectId}/${orderId}`, {channel: 3}).then(res => {
if (res.code == "000000") {
//
} else {
this.$toast(res.message);
}
})
}
},
}
</script>
<style lang="less" scoped>
.goods-details-wrapper {
.swiper-box{
position: relative;
.indicator{
position: absolute;
right: 10px;
bottom: 10px;
width: 40px;
height: 22px;
line-height: 22px;
color: #fff;
font-size: 12px;
text-align: center;
padding: 0 8px;
border-radius: 11px;
background: rgba(0, 0, 0, 0.2);
}
.img{
display: block;
width: 100%;
}
}
.border-line{
padding: 20px 15px;
border-bottom: 6px solid #F8F9FA;
}
.info-box{
.title{
font-size: 18px;
font-weight: bold;
padding-bottom: 12px;
}
.price{
display: flex;
align-items: baseline;
font-size: 12px;
}
.money{
flex: 1;
width: 100px;
}
.yuan{
color: #FB5B52;
font-size: 18px;
font-weight: bold;
}
.fen{
color: #FB5B52;
font-weight: bold;
}
.del{
color: #979899;
text-decoration: line-through;
margin-left: 6px;
}
.bought{
color: #979899;
}
}
.buy-box{
font-size: 14px;
.flex{
display: flex;
align-items: center;
}
.name{
flex: 1;
width: 100px;
font-weight: bold;
}
.buy-num{
display: flex;
}
.reduce{
position: relative;
width: 22px;
height: 22px;
background: url('~@/images/reduce.png') no-repeat center center;
background-size: 20px auto;
}
.num{
width: 30px;
height: 22px;
line-height: 22px;
text-align: center;
}
.plus{
position: relative;
width: 22px;
height: 22px;
background: url('~@/images/plus.png') no-repeat center center;
background-size: 20px auto;
}
.buy-way{
margin-top: 25px;
span{
color: #979899;
font-size: 12px;
margin-left: 6px;
}
}
.way{
line-height: 18px;
padding-left: 28px;
background: url('~@/images/wxpay.png') no-repeat left center;
background-size: 18px auto;
}
.coupon-select {
// line-height: 12px;
padding-right: 15px;
background: url('~@/images/coupon/arrow-right.png') no-repeat right center;
background-size: 12px auto;
}
}
.tab-box{
display: flex;
position: relative;
height: 50px;
padding: 0 15px;
background-color: #fff;
&::after{
position: absolute;
content: "";
left: 0;
bottom: 0;
width: 200%;
height: 0;
border-bottom: 1px solid #F0F1F2;
transform: scale(0.5);
transform-origin: left center;
}
}
.tab-item{
color: #979899;
font-size: 15px;
width: 115px;
height: 50px;
line-height: 50px;
}
.tab-active{
color: #373839;
font-weight: bold;
}
.tab-line{
position: absolute;
left: 30px;
bottom: 3px;
width: 10px;
height: 3px;
background-color: #449284;
border-radius: 1.5px;
transform: translate3d(-5px, 0, 0);
transition: left 0.3s;
}
.detail-box{
font-size: 14px;
text-align: justify;
padding: 15px 15px 75px;
}
.btn-box{
display: flex;
align-items: center;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 60px;
padding: 10px 15px;
box-shadow: 0 -4px 4px rgba(240, 240, 240, 0.5);
background-color: #fff;
.money{
flex: 1;
width: 100px;
font-size: 14px;
}
.yuan{
color: #FB5B52;
font-size: 18px;
font-weight: bold;
}
.fen{
font-size: 12px;
color: #FB5B52;
font-weight: bold;
}
.del{
color: #979899;
font-size: 12px;
text-decoration: line-through;
margin-left: 6px;
}
.coupon{
color: #979899;
font-size: 12px;
}
.btn{
width: 125px;
height: 40px;
line-height: 40px;
text-align: center;
color: #fff;
font-size: 16px;
font-weight: bold;
border-radius: 20px;
}
.can-but{
background-image: linear-gradient(90deg, #FFA65F, #FF7A4B);
}
.cannot-buy{
background-color: #C7C8C9;
}
}
.coupon-pc {
font-weight: 400;
color: #FB5B52;
}
}
</style>
......@@ -78,12 +78,12 @@
</div>
<Loading v-show="showLoading" />
<!--去激活-->
<ChangeCard
<CouponSelectList
:changeErrorMsg="changeCardErrorMsg"
:isShow="showChangeCard"
@cancle="cancleChangeCard"
@confirm="changeCardAction">
</ChangeCard>
</CouponSelectList>
<CourseDialog
content="微信授权"
subContent='<p style="font-size: 16px; font-weight: bold; text-align: center;">云鹊医申请以下权限:</p><p style="font-size: 14px; color: #999; text-align: center; padding-bottom: 10px;">获得你的公开信息(头像,昵称等)</p>'
......@@ -101,10 +101,10 @@
import { Swipe, SwipeItem } from 'vant';
import Loading from "@/components/common/common-loading";
import CourseDialog from "@/components/course/course-dialog";
import ChangeCard from "@/components/coupon/coupon-select-list";
import CouponSelectList from "@/components/coupon/coupon-select-list";
import { wxConfig, chooseWXPay } from '@/utils/wxShare';
import { getAPPID, getTradeType, getWebPageUrl, isWeiXin, wxOauth, debounce } from '@/utils';
import { getAPPID, getTradeType, getWebPageUrl, isWeiXin, wxOauth, debounce, getHactiveUrl } from '@/utils';
import { mapGetters } from "vuex";
const isWechat = isWeiXin();
// wxConfig(location.href);
......@@ -115,10 +115,12 @@ export default {
SwipeItem,
Loading,
CourseDialog,
ChangeCard
CouponSelectList
},
data() {
return {
token: "",
isWeb: Window.__isWeb,
goods: {
salePrice: {},
}, // 商品信息
......@@ -133,13 +135,10 @@ export default {
isShowDialog: false,
showChangeCard: false, //是否展示激活弹框,
changeCardErrorMsg: "",
courseUrl: "",
}
},
computed: {
...mapGetters(["logged"]),
// logged() {
// return this.$store.getters.logged;
// },
wxInfo() {
return this.$store.state.user.wxInfo;
},
......@@ -152,11 +151,13 @@ export default {
},
},
created() {
let _this = this;
console.log('in goods detail new', 111111111);
let href = location.href;
this.shareUrl = href;
this.projectId = this.$route.query.projectId;
this.goodsId = this.$route.query.goodsId || 74;
this.courseUrl = this.$route.query.courseUrl || ''; //
if (href.indexOf("singlemessage") >= 0 || href.indexOf("wx_code") >= 0) {
if(this.projectId) {
this.shareUrl = getWebPageUrl(`profexam/#/goods-detail?goodsId=${this.goodsId}&projectId=${this.projectId}`);
......@@ -165,26 +166,36 @@ export default {
}
location.replace(this.shareUrl);
}
localStorage.setItem('returnUrl', this.shareUrl);
localStorage.setItem('returnUrl', this.shareUrl);
window.__getUserInfo4GD = function(param) {
// appVersion 安卓 3.2.2 iOS
console.log("__getUserInfo4GD", param);
_this.token = param.userToken;
_this.setUserInfo(param);
};
window.__refresh = function() {
_this.getAppUserInfo();
};
window.__WXpay = function(params){
_this.paycallback(params)
};
},
mounted() {
this.getGoodsInfo();
this.getTabW();
const { token, info } = this.$store.state.user;
if (token && !info.id) {
this.$store.dispatch('getUserInfo');
if(this.isWeb) {
const { token, info } = this.$store.state.user;
if (token && !info.id) {
this.$store.dispatch('getUserInfo');
}
} else {
this.getAppUserInfo();
}
// // 微信内先去授权
// if (isWechat && !this.wxInfo.openid) {
// if (location.search.indexOf('code') >= 0 || this.wxCode) {
// // 避免code中转页再次授权
// return;
// }
// wxOauth();
// return;
// }
// 数量加减
this.curtGoodsNum = this.goodsNum;
this.countTotalPrice = debounce(this.getTotalPrice, 300);
......@@ -192,6 +203,44 @@ export default {
sessionStorage.setItem('goodsDetailParams', JSON.stringify(this.$route.query))
},
methods: {
//获取用户信息
getAppUserInfo() {
rocNative.getUserInfo({
__funcName: "__getUserInfo4GD"
});
},
// 微信支付回调
paycallback(params) {
// 0成功 -1错误 -2 用户取消 -3 没有安装微信
let url = getHactiveUrl() + `/order?orderBack=1&id=${this.orderId}&courseUrl=${this.courseUrl}`;
if(params.result == -3) {
this.$toast('您未安装微信,暂不能支付');
} else if(params.result == -2) {
this.POST(`/trade/center/order/pay_cancelled`, {orderId: this.orderId}).then(res => {
this.jumpToOrder(url);
}).catch((err) => {})
} else {
this.jumpToOrder(url);
}
},
// 跳转到指定页面
jumpToOrder(pageUrl) {
let paramList = [
{
key: "pageUrl",
value: pageUrl,
type: 4,
seqNo: 1
}
]
rocNative.dispatchEventByModuleCode({
modeCode: "M300",
jsonString: paramList
});
},
cancleChangeCard() {
this.showChangeCard = false;
},
......@@ -323,38 +372,36 @@ export default {
this.$sendBuriedData({
component_tag: `888#88801`
});
if (!this.logged) {
this.goLogin();
return;
}
let num = this.curtGoodsNum;
if (this.goods.limitPurchase && this.goods.limitPurchaseNum && num >= this.goods.limitPurchaseNum) {
this.$toast('已达最大限购数量')
return;
}
if (this.goods.goodsStocks && num >= this.goods.goodsStocks) {
this.$toast('库存不足')
return;
}
this.curtGoodsNum = num + 1;
this.countTotalPrice();
this.commonCheckToken(() => {
let num = this.curtGoodsNum;
if (this.goods.limitPurchase && this.goods.limitPurchaseNum && num >= this.goods.limitPurchaseNum) {
this.$toast('已达最大限购数量')
return;
}
if (this.goods.goodsStocks && num >= this.goods.goodsStocks) {
this.$toast('库存不足')
return;
}
this.curtGoodsNum = num + 1;
this.countTotalPrice();
});
},
// 数量减
onReduce() {
this.$sendBuriedData({
component_tag: `888#88802`
});
if (!this.logged) {
this.goLogin();
return;
}
let num = this.curtGoodsNum;
if (num <= 1) {
this.$toast('最少购买一张哦')
return;
}
this.curtGoodsNum = num - 1;
this.countTotalPrice();
this.commonCheckToken(() => {
let num = this.curtGoodsNum;
if (num <= 1) {
this.$toast('最少购买一张哦')
return;
}
this.curtGoodsNum = num - 1;
this.countTotalPrice();
});
},
goLogin() {
this.$store.dispatch('goLogin');
......@@ -370,56 +417,70 @@ export default {
this.$sendBuriedData({
component_tag: `888#88803`
});
if (!this.logged) {
this.goLogin();
return;
}
this.commonCheckToken(() => {
// 微信内先去授权
if (isWechat && !this.wxInfo.openid) {
this.isShowDialog = true;
return;
}
// 微信内先去授权
if (isWechat && !this.wxInfo.openid) {
this.isShowDialog = true;
return;
}
// 避免多次支付
if (this.showLoading) {
return;
}
const { id, couponDTO, isSale } = this.goods;
const { preferentialPrice, costPrice } = this.totalPrice;
if (!id || isSale !== 1) {
return;
}
const orderData = {
couponId: couponDTO ? couponDTO.couponId : 0,
goodsId: id,
goodsQuantity: this.goodsNum,
orderSource: 3,
preferentialPrice: this.goods.preferentialPrice,
price: this.goods.costPrice,
}
console.log('orderData...', orderData);
this.showLoading = true;
this.POST('trade/center/order/createV2', orderData).then(res => {
if (res.code == "000000") {
const orderId = res.data.orderId;
// if (isWechat) {
// this.goWxPayInner(orderId);
// } else {
// this.goWxPayOut(orderId);
// }
// 避免多次支付
if (this.showLoading) {
return;
}
const { id, couponDTO, isSale } = this.goods;
const { preferentialPrice, costPrice } = this.totalPrice;
if (!id || isSale !== 1) {
return;
}
const orderData = {
couponId: couponDTO ? couponDTO.couponId : 0,
goodsId: id,
goodsQuantity: this.goodsNum,
orderSource: 3,
preferentialPrice: this.goods.preferentialPrice,
price: this.goods.costPrice,
}
console.log('orderData...', orderData);
this.showLoading = true;
this.POST('trade/center/order/createV2', orderData).then(res => {
if (res.code == "000000") {
const orderId = res.data.orderId;
if (isWechat) {
this.goWxPayInner(orderId);
// 在站外,则调用站外支付
if(isWeb) {
if (isWechat) {
this.goWxPayInner(orderId);
} else {
this.goWxPayOut(orderId);
}
} else {
// TODO 使用
rocNative.WXpay({
'__funcName': '__WXpay',
'orderId': String(orderId)
});
}
if (this.projectId) {
this.createRelation(this.projectId, orderId);
}
} else {
this.goWxPayOut(orderId);
}
if (this.projectId) {
this.createRelation(this.projectId, orderId);
this.$toast(res.message);
this.showLoading = false;
if (res.code === "200006") {
this.$store.dispatch('logout')
}
}
} else {
this.$toast(res.message);
}).catch(() => {
this.showLoading = false;
if (res.code === "200006") {
this.$store.dispatch('logout')
}
}
}).catch(() => {
this.showLoading = false;
});
});
},
// 微信内支付
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册