|
|
@@ -248,7 +248,6 @@
|
|
|
<v-snackbar v-model="showSnackBar" :color="snackBarColor" top>
|
|
|
{{ snackBarMsg }}
|
|
|
</v-snackbar>
|
|
|
-
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -261,8 +260,14 @@ import {
|
|
|
getHotCourses,
|
|
|
setCourseLike
|
|
|
} from "@/api/course";
|
|
|
-import {cancelCoupon, createOrder, getOrderById, payOrder, useCoupon} from "@/api/order";
|
|
|
-import {getAvailableCouponsForOrder} from "@/api/coupon";
|
|
|
+import {
|
|
|
+ cancelCoupon,
|
|
|
+ createOrder,
|
|
|
+ getOrderById,
|
|
|
+ payOrder,
|
|
|
+ useCoupon
|
|
|
+} from "@/api/order";
|
|
|
+import { getAvailableCouponsForOrder } from "@/api/coupon";
|
|
|
|
|
|
export default {
|
|
|
name: "StudentCourseList",
|
|
|
@@ -331,9 +336,7 @@ export default {
|
|
|
value: "sharable"
|
|
|
}
|
|
|
],
|
|
|
- coupons: [
|
|
|
-
|
|
|
- ],
|
|
|
+ coupons: [],
|
|
|
selectedCoupons: [],
|
|
|
settleDialog: false,
|
|
|
currentOrder: {}
|
|
|
@@ -377,27 +380,27 @@ export default {
|
|
|
},
|
|
|
openSettleDialog() {
|
|
|
const uid = window.localStorage.getItem("userId");
|
|
|
- createOrder(uid,this.currentCourseId).then(res=>{
|
|
|
-
|
|
|
- if(res.code === 0){
|
|
|
- this.snackBarColor = 'error'
|
|
|
- this.snackBarMsg = res.msg
|
|
|
- this.showSnackBar = true
|
|
|
- this.dialog = false
|
|
|
- return
|
|
|
+ createOrder(uid, this.currentCourseId).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.snackBarColor = "error";
|
|
|
+ this.snackBarMsg = res.msg;
|
|
|
+ this.showSnackBar = true;
|
|
|
+ this.dialog = false;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
this.dialog = false;
|
|
|
this.settleDialog = true;
|
|
|
- this.currentOrder = res.data
|
|
|
+ this.currentOrder = res.data;
|
|
|
|
|
|
- getAvailableCouponsForOrder(this.currentOrder.id).then(res=>{
|
|
|
- this.selectedCoupons = this.currentOrder.usedCoupons ? this.currentOrder.usedCoupons : []
|
|
|
+ getAvailableCouponsForOrder(this.currentOrder.id).then(res => {
|
|
|
+ this.selectedCoupons = this.currentOrder.usedCoupons
|
|
|
+ ? this.currentOrder.usedCoupons
|
|
|
+ : [];
|
|
|
|
|
|
- this.coupons = [...res.data,...this.selectedCoupons] // 将当前可用的 和 已经用的 合并起来展示,若之前创建过订单没有付款,再次进入时需要这样
|
|
|
-
|
|
|
- })
|
|
|
- })
|
|
|
+ this.coupons = [...res.data, ...this.selectedCoupons]; // 将当前可用的 和 已经用的 合并起来展示,若之前创建过订单没有付款,再次进入时需要这样
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
handleGetCoursesByType(page, type) {
|
|
|
const uid = window.localStorage.getItem("userId");
|
|
|
@@ -444,23 +447,23 @@ export default {
|
|
|
|
|
|
onSelectCoupon({ item, value }) {
|
|
|
if (value) {
|
|
|
- useCoupon(this.currentOrder, item.id).then((res)=>{
|
|
|
- this.snackBarColor = 'success'
|
|
|
- this.snackBarMsg = res.msg
|
|
|
- this.showSnackBar = true
|
|
|
- getOrderById(this.currentOrder.id).then(res=>{
|
|
|
- this.currentOrder = res.data
|
|
|
- })
|
|
|
- })
|
|
|
+ useCoupon(this.currentOrder, item.id).then(res => {
|
|
|
+ this.snackBarColor = "success";
|
|
|
+ this.snackBarMsg = res.msg;
|
|
|
+ this.showSnackBar = true;
|
|
|
+ getOrderById(this.currentOrder.id).then(res => {
|
|
|
+ this.currentOrder = res.data;
|
|
|
+ });
|
|
|
+ });
|
|
|
} else {
|
|
|
- cancelCoupon(this.currentOrder,item.id).then((res)=>{
|
|
|
- this.snackBarColor = 'success'
|
|
|
- this.snackBarMsg = res.msg
|
|
|
- this.showSnackBar = true
|
|
|
- getOrderById(this.currentOrder.id).then(res=>{
|
|
|
- this.currentOrder = res.data
|
|
|
- })
|
|
|
- })
|
|
|
+ cancelCoupon(this.currentOrder, item.id).then(res => {
|
|
|
+ this.snackBarColor = "success";
|
|
|
+ this.snackBarMsg = res.msg;
|
|
|
+ this.showSnackBar = true;
|
|
|
+ getOrderById(this.currentOrder.id).then(res => {
|
|
|
+ this.currentOrder = res.data;
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -479,22 +482,22 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- confirmPayment(){
|
|
|
- this.settleDialog = false
|
|
|
- payOrder(this.currentOrder.id).then((res)=>{
|
|
|
- this.snackBarColor = 'success'
|
|
|
- this.snackBarMsg = res.msg
|
|
|
- this.showSnackBar = true
|
|
|
- })
|
|
|
+ confirmPayment() {
|
|
|
+ this.settleDialog = false;
|
|
|
+ payOrder(this.currentOrder.id).then(res => {
|
|
|
+ this.snackBarColor = "success";
|
|
|
+ this.snackBarMsg = res.msg;
|
|
|
+ this.showSnackBar = true;
|
|
|
+ });
|
|
|
},
|
|
|
- leaveSettlement(){
|
|
|
- this.currentOrder = {}
|
|
|
- this.currentCourseId = 0
|
|
|
- this.currentCoursePrice = 0
|
|
|
- this.currentCourseName = ''
|
|
|
- this.coupons = []
|
|
|
- this.selectedCoupons = []
|
|
|
- this.settleDialog = false
|
|
|
+ leaveSettlement() {
|
|
|
+ this.currentOrder = {};
|
|
|
+ this.currentCourseId = 0;
|
|
|
+ this.currentCoursePrice = 0;
|
|
|
+ this.currentCourseName = "";
|
|
|
+ this.coupons = [];
|
|
|
+ this.selectedCoupons = [];
|
|
|
+ this.settleDialog = false;
|
|
|
}
|
|
|
},
|
|
|
|