This commit is contained in:
2025-03-07 10:43:12 +08:00
parent 0020a80506
commit eb42140cae
9 changed files with 2784 additions and 2062 deletions

View File

@@ -42,8 +42,29 @@
<view class="order_top common_radius_box color_shandow goods_box">
<view
class="curriulum_title_box goods_item"
style="position: relative"
v-for="(v, i) in goodsDataList"
>
<span
v-if="v.isVipPrice == 1 && v.vipPrice != 0 && v.vipPrice != null"
style="
position: absolute;
z-index: 10;
top: 4px;
left: 0px;
margin-right: 10px;
text-align: center;
font-size: 18rpx;
background-color: #f94f04;
color: #fff;
font-weight: bold;
border-radius: 4px;
width: 80rpx;
padding: 2px 4px;
box-sizing: border-box;
"
>VIP优惠</span
>
<image
v-if="v.productImages && v.productImages != ''"
class="goods_item_img"
@@ -58,9 +79,12 @@
@click="goDetail(item.productId)"
></image>
<view class="normal_box">
<view class="normal_box_top" style="justify-content: space-between;position: relative;">
<view
class="normal_box_top"
style="justify-content: space-between; position: relative"
>
<view class="curriulum_title">{{ v.productName }} </view>
<view
<!-- <view
style="
width: 120rpx !important;
text-align: right;
@@ -75,8 +99,8 @@
: v.price
}}
</view>
</view>
<view
</view> -->
<!-- <view
v-if="v.activityPrice > 0 && v.activityPrice < v.price"
style="
position: absolute;
@@ -86,9 +110,54 @@
text-decoration: line-through;
font-size: 24rpx;
"
>原价{{ v.price }}</view>
>原价{{ v.price }}</view> -->
</view>
<view>
<text
v-if="
v.isVipPrice == 1 && v.vipPrice != 0 && v.vipPrice != null
"
>
<text style="color: #e97512; font-size: 12px; font-weight: bold"
>¥{{ v.vipPrice.toFixed(2) }}</text
>
<text style="color: #fa2d12; font-size: 10px; margin-left: 4px"
>VIP到手价</text
>
<text
style="
color: #8a8a8a;
font-size: 10px;
margin-left: 4px;
font-weight: bold;
text-decoration: line-through;
"
>¥{{ Number(v.price).toFixed(2) }}</text
>
</text>
<text v-else-if="v.activityPrice && v.activityPrice > 0">
<text style="color: #e97512; font-size: 12px; font-weight: bold"
>¥{{ v.activityPrice.toFixed(2) }}</text
>
<text style="color: #613804; font-size: 10px; margin-left: 4px"
>活动价</text
>
<text
style="
color: #8a8a8a;
font-size: 10px;
margin-left: 4px;
font-weight: bold;
text-decoration: line-through;
"
>¥{{ Number(v.price).toFixed(2) }}</text
>
</text>
<text v-else style="font-size: 12px"
>¥{{ Number(v.price).toFixed(2) }}</text
>
<u-number-box v-model="orderNumber" style="float: right">
<view slot="minus" class="minus">
<u-icon name="minus" size="12"></u-icon>
@@ -168,19 +237,30 @@
style="display: inline-block"
></u-icon>
<text> {{ v.text }}</text>
<template v-if="v.type == 4">
<text v-if="v.type == 6">
<span
style="color: #f94f04; font-weight: bold; margin-right: 2px"
>VIP</span
>
专享立减</text
>
<text v-else> {{ v.text }}</text>
<template v-if="v.type == 4">
<text style="color: #aaa; margin-left: 10rpx">
(全部积分{{ initData.user.jf }})</text>
(全部积分:{{ initData.user.jf }})</text
>
</template>
</view>
<view class="right">
<template v-if="v.type == 1"> {{ totalPrice }}</template>
<template v-if="v.type == 1">
¥{{ Number(totalPrice).toFixed(2) }}</template
>
<template v-if="v.type == 2">
<text>
¥{{
isShowAddress ? freightNum.toFixed(2) : Number(0).toFixed(2)
}}</text>
}}</text
>
</template>
<template v-if="v.type == 3">
<template v-if="!curCoupon.id">
@@ -239,6 +319,16 @@
<template v-if="v.type == 4">
<text style="color: #fe6035"> -¥{{ jfNumberShow }}</text>
</template>
<template v-if="v.type == 5">
<text style="color: #fa2d12"
>- ¥{{ districtAmount.toFixed(2) }}</text
>
</template>
<template v-if="v.type == 6">
<text style="color: #fa2d12"
>- ¥{{ vipPrice.toFixed(2) }}</text
>
</template>
</view>
</view>
@@ -269,44 +359,55 @@
<view class="order_top common_radius_box color_shandow goods_box pay_box">
<view class="title">支付方式</view>
<!-- 商品是安卓环境支付,或者商品列表中没有课程 -->
<view
class="curriulum_title_box goods_item pay_item"
v-for="(v, i) in payList"
>
<view :class="isDefaultCurrency && i != 2 ? 'bgGrey top' : 'top'">
<view class="left">
<image
class="pay_item_img"
:src="v.imgUrl"
mode="aspectFil"
:style="v.style"
>
</image>
<template v-if="v.type == 4">
<text> {{ v.text }}</text>
<text
style="color: #258feb; font-weight: 600; margin-left: 10rpx"
>
(余额{{
initData && initData.user ? initData.user.peanutCoin : 0
}})</text
>
</template>
<view
class="curriulum_title_box goods_item pay_item"
v-for="(v, i) in payList"
>
<view :class="isDefaultCurrency && i != 2 ? 'bgGrey top' : 'top'">
<view class="left">
<image
class="pay_item_img"
:src="v.imgUrl"
mode="aspectFil"
:style="v.style"
>
</image>
<template v-if="v.type == 4">
<text> {{ v.text }}</text>
<text
style="color: #258feb; font-weight: 600; margin-left: 10rpx"
>
(余额:{{
initData && initData.user ? initData.user.peanutCoin : 0
}})</text
>
</template>
<text v-else> {{ v.text }}</text>
</view>
<template v-if="isDefaultCurrency">
<radio v-if="i == 2" :value="v.value" color="#258feb"
:checked="selectPayIndex == i ? true : false" @click="radioChange(i)" size="10" />
</template>
<template v-else>
<radio :value="v.value" color="#258feb" :checked="selectPayIndex == i ? true : false"
@click="radioChange(i)" size="10" />
</template>
</view>
</view>
<template v-if="selectPayIndex==2||$platform=='ios'">
<text v-else> {{ v.text }}</text>
</view>
<template v-if="isDefaultCurrency">
<radio
v-if="i == 2"
:value="v.value"
color="#258feb"
:checked="selectPayIndex == i ? true : false"
@click="radioChange(i)"
size="10"
/>
</template>
<template v-else>
<radio
:value="v.value"
color="#258feb"
:checked="selectPayIndex == i ? true : false"
@click="radioChange(i)"
size="10"
/>
</template>
</view>
</view>
<template v-if="selectPayIndex == 2 || $platform == 'ios'">
<view
class="goods_detail_list_title bg_box_shandow color_shandow bg_color"
>
@@ -369,8 +470,8 @@
</view>
</view>
</template>
</view>
</view>
<template>
<common-sticky
label="title"
@@ -397,13 +498,15 @@
<text class="price"
>合计:
<text class="total">{{ actualPayment }}</text>
<text class="total"
>¥{{ Number(actualPayment).toFixed(2) }}</text
>
</text>
</view>
</template>
</common-goods-nav>
</view>
<u-popup :show="show" mode="right">
<common-address
backState="3000"
@@ -478,22 +581,25 @@ export default {
watch: {
isDefaultCurrency: {
immediate: true,
handler(newRoute) { console.log('this.isDefaultCurrency at line 482:', this.isDefaultCurrency)
handler(newRoute) {
console.log(
"this.isDefaultCurrency at line 482:",
this.isDefaultCurrency
);
if (this.isDefaultCurrency) {
if (platform == "ios") {
this.selectPayIndex = 0;
} else {
this.selectPayIndex = 0;
}
if (platform == "ios") {
this.selectPayIndex = 0;
} else {
this.selectPayIndex = 0;
}
} else {
if (platform == "ios") {
this.selectPayIndex = 0;
} else {
this.selectPayIndex = 0;
}
if (platform == "ios") {
this.selectPayIndex = 0;
} else {
this.selectPayIndex = 0;
}
}
this.payType = this.payList[this.selectPayIndex].type;
this.payType = this.payList[this.selectPayIndex].type;
this.$forceUpdate();
},
},
@@ -502,7 +608,10 @@ export default {
handler(newRoute) {
if (this.orderNumber >= 1) {
this.$nextTick(async () => {
await this.getActiveCouponList();
await this.getGoodsList();
// await this.getVipFei();
// await this.getDistrictAmount();
// await this.getActiveCouponList();
});
}
this.$forceUpdate();
@@ -511,6 +620,8 @@ export default {
},
data() {
return {
vipPrice: 0,
districtAmount: 0,
historyOrderInfo: undefined, //上一个订单的参数
isDefaultCurrency: false,
isShowAddress: false,
@@ -650,27 +761,12 @@ export default {
async onLoad(options) {
var that = this;
this.options = JSON.parse(options.data);
this.goodsDataList = this.options.goods;
var list = [...this.options.goods];
list = list.map((e) => e.goodsType);
this.haveCourse = list.some((ele) => ele === "05");
if (this.options.sourceType == "curriculum") {
this.goToInfo = {
url: "/pages/curriculum/order/index/index",
type: 2,
};
} else {
this.goToInfo = {
url: "/pages/bookShop/orderList",
type: 1,
};
}
that.initPrepareOrder();
// this.getGoodsList();
},
async onShow() {
this.curCouponId = undefined;
var that = this;
// this.getGoodsList();
await uni.$on("returnData", function (data) {
if (data) {
that.addressData = {
@@ -683,49 +779,160 @@ export default {
that.getUserAddress();
} else {
}
});
if(platform=='ios'){
this.payList= [
{
text: "天医币",
imgUrl: require("@/static/icon/pay_3.png"),
type: 4,
value: "2",
},
]
this.selectPayIndex = 0;
this.payType=4
}else{
this.payList= [{
text: "支付宝",
imgUrl: require("@/static/icon/pay_1.png"),
type: 2,
value: "0",
},
{
text: "微信",
imgUrl: require("@/static/icon/pay_2.png"),
type: 1,
value: "1",
},
{
text: "天医币",
imgUrl: require("@/static/icon/pay_3.png"),
type: 4,
value: "2",
},
]
this.selectPayIndex = 1;
this.payType=1
}
if (platform == "ios") {
this.payList = [
{
text: "天医币",
imgUrl: require("@/static/icon/pay_3.png"),
type: 4,
value: "2",
},
];
this.selectPayIndex = 0;
this.payType = 4;
} else {
this.payList = [
{
text: "支付宝",
imgUrl: require("@/static/icon/pay_1.png"),
type: 2,
value: "0",
},
{
text: "微信",
imgUrl: require("@/static/icon/pay_2.png"),
type: 1,
value: "1",
},
{
text: "天医币",
imgUrl: require("@/static/icon/pay_3.png"),
type: 4,
value: "2",
},
];
this.selectPayIndex = 1;
this.payType = 1;
}
},
computed: {
...mapState(["userInfo"]),
},
methods: {
getGoodsList() {
this.$http
.request({
// url: "book/buyOrder/calculateTransportPrice/",
url: "/book/buyOrder/getShopProductListByIds",
// url: "book/buyorder/getTransPrice/" + this.adressMoRen.areaidpath + "?" + dataToString,
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data: {
productIds: this.options.goods.map((e) => e.productId).toString(),
},
header: {
//默认 无 说明:请求头
"Content-Type": "application/json",
},
})
.then(async (res) => {
this.goodsDataList = res.shopProductList;
console.log("this.goodsDataList at line 780:", this.goodsDataList);
await this.getVipFei();
await this.getDistrictAmount();
await this.getActiveCouponList();
var list = [...this.goodsDataList];
list = list.map((e) => e.goodsType);
this.haveCourse = list.some((ele) => ele === "05");
if (this.options.sourceType == "curriculum") {
this.goToInfo = {
url: "/pages/curriculum/order/index/index",
type: 2,
};
} else {
this.goToInfo = {
url: "/pages/bookShop/orderList",
type: 1,
};
}
this.initPrepareOrder();
});
},
async getVipFei() {
let key = [];
let dataToString = "";
// console.log(this.adressMoRen, '默认地址')
this.goodsDataList.forEach((item, index) => {
key.push({
productId: item.productId,
quantity: this.orderNumber,
});
// dataToString = dataToString.concat(item.productId+"="+item.productAmount+"&")
});
// console.log(key,'this.adressMoRen.areaidpath')
await $http
.request({
// url: "book/buyOrder/calculateTransportPrice/",
url: "/book/buyOrder/getVipDiscountAmount",
// url: "book/buyorder/getTransPrice/" + this.adressMoRen.areaidpath + "?" + dataToString,
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data: {
productList: key,
},
header: {
//默认 无 说明:请求头
"Content-Type": "application/json",
},
})
.then(async(res) => {
if (res.code == 0) {
console.log("res.code at line 538:", res);
this.vipPrice = res.discountAmount;
// console.log('需要的运费', res.result)
await this.getTotalPrice();
}
});
},
async getDistrictAmount() {
let key = [];
let dataToString = "";
this.goodsDataList.forEach((item, index) => {
key.push({
productId: item.productId,
quantity: this.orderNumber,
});
// dataToString = dataToString.concat(item.productId+"="+item.productAmount+"&")
});
console.log(key, "this.adressMoRen.areaidpath");
await $http
.request({
// url: "book/buyOrder/calculateTransportPrice/",
url: "/book/buyOrder/getDistrictAmount",
// url: "book/buyorder/getTransPrice/" + this.adressMoRen.areaidpath + "?" + dataToString,
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data: {
productList: key,
},
header: {
//默认 无 说明:请求头
"Content-Type": "application/json",
},
})
.then(async(res) => {
if (res.code == 0) {
console.log("res.code at line 538111111111111111:", res);
this.districtAmount = res.districtAmount;
// console.log('需要的运费', res.result)
await this.getTotalPrice();
}
});
},
closeCoupon() {
this.showCouponPup = false;
},
@@ -742,13 +949,13 @@ export default {
},
// 查询商品可用优惠券
async getActiveCouponList() {
if (this.goodsDataList.length <= 0) {
uni.showToast({
title: "商品参数错误,无法获取优惠券",
icon: "none",
});
return;
}
// if (this.goodsDataList.length <= 0) {
// uni.showToast({
// title: "商品参数错误,无法获取优惠券",
// icon: "none",
// });
// return;
// }
var list = [];
this.goodsDataList.forEach((e) => {
@@ -849,7 +1056,12 @@ export default {
couponAmount = this.curCoupon.couponEntity.couponAmount;
}
this.actualPayment =
this.totalPrice - couponAmount - this.jfNumber + this.freightNum;
this.totalPrice -
couponAmount -
this.jfNumber +
this.freightNum -
this.districtAmount -
this.vipPrice;
if (this.actualPayment == 0) {
this.isDefaultCurrency = true;
@@ -902,6 +1114,7 @@ export default {
imgUrl: "",
type: 2,
},
{
text: "优惠券",
imgUrl: "",
@@ -909,6 +1122,27 @@ export default {
},
];
}
if (
this.goodsDataList[0].activityPrice &&
this.goodsDataList[0].activityPrice > 0
) {
this.priceBreakdownList.push({
text: "活动立减",
imgUrl: "",
type: 5,
});
}
if (
this.goodsDataList[0].isVipPrice &&
this.goodsDataList[0].vipPrice &&
this.goodsDataList[0].vipPrice > 0
) {
this.priceBreakdownList.push({
text: "VIP专享立减",
imgUrl: "",
type: 6,
});
}
var data = {
uid: this.userInfo.id,
productList: this.goodsDataList.map((e) => {
@@ -932,8 +1166,10 @@ export default {
})
.then(async (res) => {
console.log('res at line 1168:', res)
if (res.code == 0) {
this.initData = res.data;
console.log(
"this.initData at line 初始化课程订单信息:",
this.initData
@@ -946,8 +1182,6 @@ export default {
type: 4,
});
}
}
this.$forceUpdate();
@@ -1056,10 +1290,10 @@ export default {
var that = this;
for (var i = this.goodsDataList.length - 1; i >= 0; i--) {
s +=
this.goodsDataList[i].activityPrice &&
this.goodsDataList[i].activityPrice > 0
? this.goodsDataList[i].activityPrice
: this.goodsDataList[i].price;
// this.goodsDataList[i].activityPrice &&
// this.goodsDataList[i].activityPrice > 0
// ? this.goodsDataList[i].activityPrice
this.goodsDataList[i].price;
}
that.totalPrice = s * this.orderNumber;
var couponAmount = 0;
@@ -1072,7 +1306,8 @@ export default {
couponAmount = 0;
}
if (!this.isShowAddress) {
if (this.initData.user.jf >= that.totalPrice) {
if(that.initData.user&&that.initData.user.jf){
if (this.initData.user.jf >= that.totalPrice) {
this.jfNumber = that.totalPrice - couponAmount;
this.jfNumberMax = that.totalPrice - couponAmount;
console.log("this.jfNumberMax at line 1303:", this.jfNumberMax);
@@ -1085,6 +1320,10 @@ export default {
this.jfNumberMax = this.initData.user.jf;
}
}
}else{
this.jfNumber=0
}
if (that.jfNumber == 0 || that.jfNumber == null) {
that.jfNumberShow = "0.00";
that.actualPayment = that.totalPrice - couponAmount;
@@ -1092,9 +1331,18 @@ export default {
that.jfNumberShow = that.jfNumber.toFixed(2);
that.actualPayment = that.totalPrice - that.jfNumber - couponAmount;
}
that.actualPayment = that.actualPayment + that.freightNum;
that.actualPayment =
that.actualPayment +
that.freightNum -
that.districtAmount -
that.vipPrice;
} else {
that.actualPayment = that.totalPrice + that.freightNum - couponAmount;
that.actualPayment =
that.totalPrice +
that.freightNum -
couponAmount -
that.districtAmount -
that.vipPrice;
}
if (this.actualPayment == 0 && !this.isShowAddress) {
this.isDefaultCurrency = true;
@@ -1188,6 +1436,8 @@ export default {
? this.curCoupon.couponEntity.couponName
: "", //优惠券名称
districtMoney: 0, //优惠金额
vipDiscountAmount: this.vipPrice, //折扣金额
districtMoney: this.districtAmount, //折扣金额
productList: this.goodsDataList.map((e) => {
return {
@@ -1234,7 +1484,7 @@ export default {
that.submitorder(data);
}
},
//支付操作
//支付操作
async submitorder(data) {
uni.showLoading({
title: "正在请求订单",
@@ -1705,7 +1955,7 @@ export default {
.curriulum_title {
// width: calc(100% - 80rpx);
width: calc(100% - 130rpx);
width: calc(100%);
font-weight: 500;
font-size: 30rpx;
// line-height: 40rpx;
@@ -1934,7 +2184,7 @@ export default {
.price {
.total {
font-size: 38rpx;
font-size: 30rpx;
color: red;
}
}