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

弹框:我知道了

上级 c455efc5
......@@ -8,11 +8,11 @@ export const envConfig = {
// baseUrl: 'http://10.177.15.180:10202/',
// baseUrl: 'http://192.168.140.14:10201/',
apiUrl: 'https://dev-api.yunqueyi.com/',
baseUrl: 'https://dev-sc.yunqueyi.com/',
webPageUrl: 'https://dev-phome.yunqueyi.com/',
hactiveUrl: 'https://dev-hactive.yunqueyi.com',
fileUrl: 'https://dev-www.yunqueyi.com',
apiUrl: 'https://test1-api.yunqueyi.com/',
baseUrl: 'https://test1-sc.yunqueyi.com/',
webPageUrl: 'https://test1-phome.yunqueyi.com/',
hactiveUrl: 'https://test1-hactive.yunqueyi.com',
fileUrl: 'https://test1-www.yunqueyi.com',
appId: 'wx08b383d002c73f26', // 用于微信授权登录
wxType: 15, // 分享、用户信息对应的appid
tradeType: 4,
......
......@@ -13,7 +13,7 @@
:isFixNavbar="isFixNavbar"
:shareUrl="shareUrl"
borderStyle="0px solid #fff"
></CommonNavbar>
></CommonNavbar>
<!-- 轮播 -->
<div class="swiper-box">
<van-swipe :show-indicators="false" @change="onSwiperChange">
......@@ -86,7 +86,7 @@
<div
class="btn"
:class="[goods.isSale === 2 ? 'cannot-buy' : 'can-but']"
@click="createOrder"
@click="preCreateOrder"
>{{ goods.isSale === 2 ? '商品已下架' : '确认支付' }}</div>
</div>
<Loading v-show="showLoading" />
......@@ -108,6 +108,15 @@
:isShowDialog="isShowDialog"
@handlerAction="handlerAction"
></CourseDialog>
<ShowCantBuyTips
subContent="您所在的省份暂无法录入该继续医学教育项目学分,请勿购买。"
cancleBtnText="我知道了"
isSingle
needSubContent
:isShowDialog="isShowCantBuyTips"
@handlerAction="isShowCantBuyTips=false"
></ShowCantBuyTips>
</div>
</template>
......@@ -115,6 +124,7 @@
import { Swipe, SwipeItem } from "vant";
import Loading from "@/components/common/common-loading";
import CourseDialog from "@/components/course/course-dialog";
import ShowCantBuyTips from "@/components/course/course-dialog";
import CouponSelectList from "@/components/coupon/component-select-list";
import CommonNavbar from "@/components/common/common-navbar";
......@@ -130,7 +140,7 @@ import {
} from "@/utils";
import { mapGetters, mapActions } from "vuex";
import { convertToYuan } from "@/utils";
import { setCookie, getCookie, delCookie } from '@/utils/index';
import { setCookie, getCookie, delCookie } from "@/utils/index";
const isWechat = isWeiXin();
// wxConfig(location.href);
......@@ -141,7 +151,8 @@ export default {
Loading,
CourseDialog,
CouponSelectList,
CommonNavbar
CommonNavbar,
ShowCantBuyTips
},
data() {
return {
......@@ -174,6 +185,7 @@ export default {
// shareTitle: goods.goodsName,
shareTitleInfo: "",
isShowShare: true,
isShowCantBuyTips: false,
};
},
computed: {
......@@ -205,7 +217,7 @@ export default {
}
},
deep: true
},
}
},
created() {
......@@ -264,7 +276,10 @@ export default {
if (this.isWeb) {
let { token, info } = this.$store.state.user;
token = token || localStorage.getItem("couponToken") || getCookie("couponToken");
token =
token ||
localStorage.getItem("couponToken") ||
getCookie("couponToken");
this.token = token;
console.log("token && !info.id", !info.id, token);
......@@ -276,7 +291,7 @@ export default {
if (token && !info.id) {
this.commonCheckToken(() => {
this.$store.dispatch("getUserInfo");
});
});
return;
}
// 从登陆页面过来时
......@@ -284,7 +299,6 @@ export default {
} else {
this.getUserInfo();
}
},
methods: {
...mapActions([
......@@ -300,7 +314,7 @@ export default {
// 有且选择了优惠券,则直接显示优惠券的优惠价格
if (this.currentCoupon.couponId) {
text = "-¥" + this.yuan(this.currentCoupon.discountAmount);
// 如果没有选择优惠券
// 如果没有选择优惠券
} else {
if (this.goodsInfo4Coupon.count) {
text = this.goodsInfo4Coupon.count + "张优惠券";
......@@ -314,24 +328,25 @@ export default {
// 查询我的可用优惠券
getCanUseCoupons(params) {
const { goodsType, cardType, price } = params;
this.GET(`trade/coupon/app/goodsCoupons`, { goodsType, cardType, amount: price }).then(
res => {
if (res.code == "000000") {
params.count = (res.data || []).length;
this.setGoodsInfo4Coupon(params);
this.handlerCouponList(res.data || [], params.price);
// 设置优惠券个数
} else {
params.count = 0;
this.setGoodsInfo4Coupon(params);
this.setCurrentCoupon({});
this.setSelectCouponList([]);
}
this.GET(`trade/coupon/app/goodsCoupons`, {
goodsType,
cardType,
amount: price
}).then(res => {
if (res.code == "000000") {
params.count = (res.data || []).length;
this.setGoodsInfo4Coupon(params);
this.handlerCouponList(res.data || [], params.price);
// 设置优惠券个数
} else {
params.count = 0;
this.setGoodsInfo4Coupon(params);
this.setCurrentCoupon({});
this.setSelectCouponList([]);
}
);
});
},
// 处理数据,并且先排序,再将不可用的放在最后
handlerCouponList(couponList, goodsPrice) {
if (!couponList.length) return [];
......@@ -341,12 +356,12 @@ export default {
firstCanCouponIndex = 0,
item = {},
count = 0;
for(let i = 0; i < couponList.length; i ++) {
for (let i = 0; i < couponList.length; i++) {
item = couponList[i];
// 要根据商品价格及券适用类型来计算
item.disabled = !item.enableFlag;
if(!item.disabled) {
count ++;
if (!item.disabled) {
count++;
}
// 是否已经选择
item.isChecked = !!item.checkFlag;
......@@ -357,7 +372,7 @@ export default {
newList.push(item);
}
this.setCurrentCoupon( JSON.parse(JSON.stringify(firstCanCoupon)) || {});
this.setCurrentCoupon(JSON.parse(JSON.stringify(firstCanCoupon)) || {});
this.setSelectCouponList(newList);
this.goodsInfo4Coupon.count = count;
this.setGoodsInfo4Coupon(this.goodsInfo4Coupon);
......@@ -427,7 +442,7 @@ export default {
showCouponPopup() {
this.commonCheckToken(() => {
this.isShowCoupon = true;
})
});
},
// 设置当前选中的优惠券
......@@ -452,7 +467,7 @@ export default {
// 获取商品信息
getGoodsInfo() {
if(!this.goodsId) {
if (!this.goodsId) {
return;
}
this.commonCheckToken(() => {
......@@ -461,9 +476,11 @@ export default {
const goods = res.data;
const tabs = [];
let priceNew = goods.preferentialPrice || goods.costPrice;
let price = goods.couponPrice || goods.preferentialPrice || goods.costPrice;
let price =
goods.couponPrice || goods.preferentialPrice || goods.costPrice;
this.goods = goods;
this.defaultCouponId = (goods.couponDTO && goods.couponDTO.couponId) || '';
this.defaultCouponId =
(goods.couponDTO && goods.couponDTO.couponId) || "";
// 获取到商品后,再获取优惠券
this.getCanUseCoupons({
goodsType: goods.goodsType,
......@@ -484,9 +501,10 @@ export default {
100
).toFixed(2);
} else {
savePrice = ((goods.costPrice - goods.couponPrice) / 100).toFixed(
2
);
savePrice = (
(goods.costPrice - goods.couponPrice) /
100
).toFixed(2);
}
}
if (goods.goodsDescWhere) {
......@@ -539,10 +557,13 @@ export default {
getTotalPrice(currentCoupon) {
const num = this.curtGoodsNum;
let couponId = 0;
if(currentCoupon) {
if (currentCoupon) {
couponId = currentCoupon.couponId || -1;
}
this.GET(`trade/goods/getPrice/${this.goodsId}/${num}/${couponId}`, {}).then(res => {
this.GET(
`trade/goods/getPrice/${this.goodsId}/${num}/${couponId}`,
{}
).then(res => {
if (res.code == "000000") {
const {
couponPrice,
......@@ -561,7 +582,7 @@ export default {
this.goodsInfo4Coupon.price = preferentialPrice || costPrice;
this.setGoodsInfo4Coupon(this.goodsInfo4Coupon);
this.goodsNum = num;
if(this.needSortAndSelect) {
if (this.needSortAndSelect) {
this.getCanUseCoupons(this.goodsInfo4Coupon);
// this.handlerCouponList(this.selectCouponList, preferentialPrice || costPrice);
}
......@@ -647,86 +668,112 @@ export default {
this.isShowDialog = false;
},
// 判断是否能购买
preCreateOrder() {
this.commonCheckToken(() => {
const { goodsType, cardType } = this.goods;
console.log('goodsType, cardType', goodsType, cardType);
// 只有一类卡才做相应判断
if (goodsType == 2 && cardType == 1) {
this.GET(
`trade/goods/sale/checkProvince?goodsType=${goodsType}&cardType=${cardType}`,
{}
).then(({ data }) => {
if (data == 1) {
this.createOrder();
} else {
this.isShowCantBuyTips = true;
}
});
} else {
this.createOrder();
}
});
},
// 创建订单
createOrder() {
this.$sendBuriedData({
component_tag: `888#88803`
});
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;
}
// 避免多次支付
if (this.showLoading) {
return;
}
const { id, couponDTO, isSale } = this.goods;
const { preferentialPrice, costPrice } = this.totalPrice;
if (!id || isSale !== 1) {
return;
}
// 重新使用优惠券
let couponId = this.currentCoupon && this.currentCoupon.couponId || 0;
const orderData = {
couponId: couponId,
// 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)
this.POST("trade/center/order/createV4", orderData)
.then(res => {
if (res.code == "000000") {
const orderId = res.data.orderId;
this.orderId = res.data.orderId;
// if (isWechat) {
// this.goWxPayInner(orderId);
// } else {
// this.goWxPayOut(orderId);
// }
// 重新使用优惠券
let couponId = (this.currentCoupon && this.currentCoupon.couponId) || 0;
const orderData = {
couponId: couponId,
// 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)
this.POST("trade/center/order/createV4", orderData)
.then(res => {
if (res.code == "000000") {
const orderId = res.data.orderId;
this.orderId = res.data.orderId;
// if (isWechat) {
// this.goWxPayInner(orderId);
// } else {
// this.goWxPayOut(orderId);
// }
// 在站外,则调用站外支付
console.log("this.isWeb ... isWechat - 2 this.orderId", this.isWeb, isWechat, this.orderId);
if (this.isWeb) {
console.log("in web...");
if (isWechat) {
this.goWxPayInner(orderId);
} else {
this.goWxPayOut(orderId);
}
// 在站外,则调用站外支付
console.log(
"this.isWeb ... isWechat - 2 this.orderId",
this.isWeb,
isWechat,
this.orderId
);
if (this.isWeb) {
console.log("in web...");
if (isWechat) {
this.goWxPayInner(orderId);
} else {
console.log("not in web...");
rocNative.WXpay({
__funcName: "__WXpay",
orderId: String(orderId)
});
}
if (this.projectId) {
this.createRelation(this.projectId, orderId);
this.goWxPayOut(orderId);
}
} else {
this.$toast(res.message);
this.showLoading = false;
if (res.code === "200006") {
this.$store.dispatch("logout");
}
console.log("not in web...");
rocNative.WXpay({
__funcName: "__WXpay",
orderId: String(orderId)
});
}
})
.catch(() => {
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;
});
},
// 微信内支付
......@@ -811,17 +858,21 @@ export default {
// 绑定项目和订单的关系(idType=1),这里只判断cardType是否为4
createRelation(projectId, orderId) {
let idType = 1, channel = 1;
if(this.goods.cardType == 4) {
let idType = 1,
channel = 1;
if (this.goods.cardType == 4) {
idType = 2;
}
if(this.isWeb) {
if (this.isWeb) {
channel = 3;
}
let cardType = this.goods.cardType;
this.POST(`cme/projectCard/correlation/${idType}/${projectId}/${orderId}`, {
channel: channel
}).then(res => {
this.POST(
`cme/projectCard/correlation/${idType}/${projectId}/${orderId}`,
{
channel: channel
}
).then(res => {
if (res.code == "000000") {
//
} else {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册