HOTLINE: 099.752.8636 - 024.5678.0343
{{ course.title }} GV: {{ course.teacher }} Môn: {{ cbo.subject }}
{{ course.title }} GV: {{ course.teacher }} Môn: {{ subject.subject }}
Đã chọn
{{ cartItem.course.title }} GV: {{ cartItem.course.teacher }} Học phí: {{ cartItem.course.sale_price }}

Tổng: {{ moneyShowing(cartTotal) }}
Ưu đãi Giảm: {{ moneyShowing(cartDiscountTotal) }}

Học phí: {{ moneyShowing(cartFinalTotal) }}

Bạn đồng ý với các điều khoản khi nhấn Gửi Đăng ký.
Bạn chưa chọn khóa học.
" }, "blocks": [ { "component": "fullzone", "title": "Trung Học Phổ Thông", "id": "thpt", "link": "https://mclass.vn/blog/", "showBanners": 1, "banners": [ { "image": "https://cdn.mclass.vn/blog/uploads/2022/04/22210336/banner-on-thpt-min.jpg", "link": "/dang-ky-hoc?group=thpt" } ], "courses": [ { "course_id": 534 }, { "course_id": 493 }, { "course_id": 496 }, { "course_id": 624 }, { "course_id": 505 }, { "course_id": 511 }, { "course_id": 514 }, { "course_id": 517 } ], "teachers": [ { "id": 1, "title": "Hồ Thức Thuận", "image": "https://cdn.mclass.vn/blog/uploads/2022/06/02075019/ho-thuc-thuan-min.png", "headline": "Một buổi học trực tuyến có 85k học sinh theo học", "headline_link": "https://cafef.vn/mot-buoi-day-toan-qua-livestream-facebook-thu-hut-85000-nguoi-xem-20210727170210465.chn", "promotion_link": "https://mclass.vn/blog/ho-thuc-thuan/", "color": "#FFEFE4", "subject": "Môn Toán", "subject_id": 2, "socials": { "web": "https://mclass.vn/blog/ho-thuc-thuan/", "fanpage": "https://www.facebook.com/thaythuantoan", "youtube": "https://www.youtube.com/channel/UCvSIbYBD-bvOp-axVWx4eEA", "tiktok": "", "instagram": "" } }, { "id": 3, "title": "Vũ Tuấn Anh", "image": "https://cdn.mclass.vn/blog/uploads/2022/06/02075026/vu-tuan-anh-min.png", "headline": "", "headline_link": "", "promotion_link": "https://mclass.vn/blog/vu-tuan-anh/", "color": "#E4ECFF", "subject": "Vật Lý", "subject_id": 3, "socials": { "web": "https://mclass.vn/blog/vu-tuan-anh/", "fanpage": "https://www.facebook.com/vatlythayVuTuanAnh", "youtube": "https://www.youtube.com/c/thayvutuananhvatly", "tiktok": "", "instagram": "" } }, { "id": 2, "title": "Phạm Văn Thuận", "image": "https://cdn.mclass.vn/blog/uploads/2022/06/02075024/pham-van-thuan-min.png", "headline": "", "headline_link": "", "promotion_link": "https://mclass.vn/blog/pvt-2k5", "color": "#FFE4E4", "subject": "Hóa Học", "subject_id": 4, "socials": { "web": "https://mclass.vn/blog/pvt-2k5", "fanpage": "https://www.facebook.com/Hoathaythuan", "youtube": "https://www.youtube.com/channel/UCNRMZcAdDJ4p9P7HFhC_pXg", "tiktok": "", "instagram": "" } }, { "id": 20, "title": "Phạm Minh Nhật", "image": "https://cdn.mclass.vn/blog/uploads/2022/06/02075023/pham-minh-nhat-min.png", "headline": "", "headline_link": "", "promotion_link": "https://mclass.vn/blog/pham-minh-nhat/", "color": "#F7EDFF", "subject": "Ngữ Văn", "subject_id": 6, "socials": { "web": "https://mclass.vn/blog/pham-minh-nhat/", "fanpage": "https://www.facebook.com/thaytun.teacher", "youtube": "", "tiktok": "", "instagram": "https://www.instagram.com/minhnhat.191/" } }, { "id": 20, "title": "Nguyễn Hương Sen", "image": "https://cdn.mclass.vn/blog/uploads/2022/06/02075021/nguyen-huong-sen-min.png", "headline": "", "headline_link": "", "promotion_link": "https://mclass.vn/blog/nguyen-huong-sen/", "color": "#FFE4EE", "subject": "Lịch Sử", "subject_id": 8, "socials": { "web": "https://mclass.vn/blog/nguyen-huong-sen/", "fanpage": "https://www.facebook.com/lopsucosen", "youtube": "", "tiktok": "", "instagram": "https://www.instagram.com/lopsucosen/" } }, { "id": 20, "title": "Cô Phước - Dung", "image": "https://cdn.mclass.vn/blog/uploads/2022/06/02075018/co-phuoc-dung-min.png", "headline": "", "headline_link": "", "promotion_link": "", "color": "#E9F8E4", "subject": "Địa Lý", "subject_id": 13, "socials": { "web": "https://mclass.vn/blog/luyen-thi-khoa-2k4/co-phuoc-dung/", "fanpage": "https://www.facebook.com/lopdiacoPhuocDung", "youtube": "", "tiktok": "", "instagram": "" } }, { "id": 39, "title": "Đỗ Mạnh Linh", "image": "https://cdn.mclass.vn/blog/uploads/2022/06/02075019/do-linh-min.png", "headline": "", "headline_link": "", "promotion_link": "", "color": "#E4F9FF", "subject": "Tiếng Anh", "subject_id": 5, "socials": { "web": "", "fanpage": "https://www.facebook.com/tienganhcungthaylinh", "youtube": "", "tiktok": "", "instagram": "" } } ] }, { "component": "fullzone", "id": "dh", "title": " Đại Học", "link": "https://mclass.vn/category/bac-dai-hoc/", "showBanners": 1, "banners": [], "courses": [ { "course_id": 596 }, { "course_id": 599 }, { "course_id": 602 }, { "course_id": 600 }, { "course_id": 601 } ], "teachers": [] }, { "title": "TIN TỨC", "id": "news", "component": "news", "link": "https://mclass.vn/blog/tin-tuc/", "api": "https://mclass.vn/blog/wp-json/wp/v2/posts" } ] }`), courseType: ['combo', 'by_subject'], selectedGroup: null, carts: [], user: null, sending: false }, created() { this.selectedGroup = this.groups[0] }, mounted() { //console.log('mounted') let uri = window.location.search.substring(1) let params = new URLSearchParams(uri) if (params.get("group")) { const grpId = params.get("group") const newSelectedGroup = this.groups.find(grp => { return grpId === grp.id }) if (newSelectedGroup) this.selectedGroup = newSelectedGroup } //console.log(this.selectedGroup) if (localStorage.getItem('carts')) { try { this.carts = JSON.parse(localStorage.getItem('carts')) this.finalizeCarts() } catch(e) { localStorage.removeItem('carts') } } if (localStorage.getItem('_uid_uif')) { try { this.user = JSON.parse(localStorage.getItem('_uid_uif')) } catch(e) { localStorage.removeItem('_uid_uif') } } }, computed: { isCartNotEmpty: function (){ return this.carts.length > 0 }, cartTotal: function () { return this.carts.reduce((total, cartItem) => total + cartItem.course.price, 0) }, cartDiscountTotal: function () { return this.carts.reduce((discountTotal, cartItem) => discountTotal + (cartItem.course.price - cartItem.course.sale_price), 0) }, cartFinalTotal: function () { return this.carts.reduce((finalTotal, cartItem) => finalTotal + cartItem.course.sale_price, 0) }, isUserDataCollected: function () { return this.user != null } }, methods: { isSelectedGroup: function (_id) { return this.selectedGroup === _id }, setSelectedGroup: function (_id) { this.selectedGroup = this.groups.filter(function (grp) { return grp.id === _id ? grp : null }) }, selectCourse: function (groupId, courseType, subjectId, courseId) { if (this.isCourseSelected(courseId)) return; let selectedCourse; let tmpGrp = this.groups.find(grp => { return grp.id === groupId }); if (courseType === this.courseType[0]) { let tmpCbo = tmpGrp.combo.find(cbo => { return cbo.subject_id === subjectId }); let tmpCourse = tmpCbo.courses.find(c => { return c.course_id === courseId }); selectedCourse = { course_type: courseType, group_id: groupId, subject: tmpCbo.subject, subject_id: tmpCbo.subject_id, course_id: tmpCourse.course_id, course: tmpCourse } } else if (courseType === this.courseType[1]) { let tmpSbj = tmpGrp.by_subject.find(sbj => { return sbj.subject_id === subjectId }); let tmpCourse = tmpSbj.courses.find(c => { return c.course_id === courseId }); selectedCourse = { course_type: courseType, group_id: groupId, subject: tmpSbj.subject, subject_id: tmpSbj.subject_id, course_id: tmpCourse.course_id, course: tmpCourse } } if (selectedCourse) { this.carts.push(selectedCourse) this.saveCarts() } }, isCourseSelected: function (courseId) { return !!this.carts.find(c => { return c.course_id === courseId }) }, removeSelectedCourse: function (index) { this.carts.splice(index, 1) this.saveCarts() }, moneyShowing: function(val) { return (val).toLocaleString('vi-VN', { style: 'currency', currency: 'VND', }) }, saveCarts() { const parsed = JSON.stringify(this.carts); localStorage.setItem('carts', parsed); }, clearCarts() { this.carts.splice(0) this.saveCarts() }, sendCarts() { const btnLogin = document.getElementById('btnLogin') if(!this.user) { btnLogin?.click() return } if(this.sending) return this.sending = true axios.post('/api/v2/courses-register', { 'user' : this.user, 'courses' : this.carts }) .then((response) => { console.log(response) // clear cart, moving to review the order if(response?.status == 200) { toastr.success('Đăng Ký thành công. Tư Vấn Viên sẽ sớm liên lạc với bạn.') this.clearCarts() window.location.href = '/info-payment/' + response.data.data.order_id } }) .catch((error) => { console.log(error) if(error?.response?.status == 401) { toastr.error('Vui lòng đăng nhập!') btnLogin?.click() } else if(error?.response?.status == 422) { toastr.error(error.response.data.message) } }) .finally(() => { this.sending = false }) }, finalizeCarts: function() { var tmpCart = [...this.carts] this.carts.splice(0) tmpCart.forEach((item, index) => { this.selectCourse(item.group_id, item.course_type, item.subject_id, item.course.course_id) }); } } });