Số dư: {{addCommas(user.balance)}}đ
Đăng xuất
Xin chào {{user.display_name}}
Số dư: {{addCommas(user.balance)}}đ
above */ import indexPage from 'https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//public/partials/pages/dashboard.js?ver=1.0.4'; import collaboratorPage from 'https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//public/partials/pages/dashboard-2.js?ver=1.0.4'; import historyPage from 'https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//public/partials/pages/history.js?ver=1.0.4'; import paymentPage from 'https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//public/partials/pages/payment.js?ver=1.0.4'; import userPage from 'https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//public/partials/pages/user.js?ver=1.0.4'; import toolPage from 'https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//public/partials/pages/tool.js?ver=1.0.4'; import loginPage from 'https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//public/partials/pages/login.js?ver=1.0.4'; import registerPage from 'https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//public/partials/pages/register.js?ver=1.0.4'; import profilePage from 'https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//public/partials/pages/user-profile.js?ver=1.0.4'; import bannerPage from 'https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//public/partials/pages/banner.js?ver=1.0.4'; import emptyComponent from 'https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//admin/partials/components/data-empty.js?ver=1.0.4'; import loading from 'https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//admin/partials/components/loading.js?ver=1.0.4'; import { getConfigs } from "https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//admin/partials/api/config.js?ver=1.0.4"; import { getUserProfile, logout } from "https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//public/partials/api/user.js?ver=1.0.4"; import { route } from "https://shopnhanh.vn/wp-content/plugins/wp-affiliate-mhss//public/partials/constants/constants.js?ver=1.0.4"; // import VueEasyLightbox from 'https://unpkg.com/vue-easy-lightbox@next/dist/vue-easy-lightbox.esm.min.js'; const EventBus = new Vue() let router = null try{ router = new VueRouter({ routes: [ { path: '/', component: indexPage }, // Root IndexIndex { path: '/tai-khoan', component: profilePage }, { path: '/dang-nhap', component: loginPage }, { path: '/dang-ky', component: registerPage }, { path: '/thong-ke-cong-tac-vien', component: collaboratorPage }, { path: '/lich-su', component: historyPage }, { path: '/thanh-toan', component: paymentPage }, { path: '/cong-tac-vien', component: userPage }, { path: '/cong-cu', component: toolPage }, { path: '/banner', component: bannerPage }, ] }); }catch(e){ } Vue.prototype.$eventBus = EventBus Vue.component('empty-component', emptyComponent) Vue.component('loading-component', loading) Vue.mixin({ methods: { openURL(url) { Quasar.utils.openURL(url) }, addCommas(nStr) { nStr += ''; let x = nStr.split('.'); let x1 = x[0]; let x2 = x.length > 1 ? '.' + x[1] : ''; let rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; }, formatDateRange(date) { const replaceW = (d) => { return d.split('/').join('-'); } if (date == '') return ''; if (typeof date == 'object') return { from: replaceW(date.from), to: replaceW(date.to) } else return { from: replaceW(date), to: replaceW(date) } }, formatDateMoment(mysqlDate, format = 'DD/MM/YYYY HH:mm') { return moment(mysqlDate, "YYYY/MM/DD HH:mm:ss").format(format) }, buildFormData(formData, data, parentKey) { if (data && typeof data === 'object' && !(data instanceof Date) && !(data instanceof File)) { Object.keys(data).forEach(key => { this.buildFormData(formData, data[key], parentKey ? `${parentKey}[${key}]` : key); }); } else { const value = data == null ? '' : data; formData.append(parentKey, value); } }, jsonToFormData(data) { const formData = new FormData(); this.buildFormData(formData, data); return formData; }, NOTIFY(msg, type = true) { this.$q.notify({ message: msg, progress: true, type: type == true ? 'positive' : 'negative', color: type == true ? 'green' : 'red', position: 'top', timeout: 2000 }) }, PROMPT(text) { return new Promise((res, rej) => { this.$q.dialog({ title: 'Xác nhận', message: text, prompt: { model: '', type: 'text' // optional }, cancel: true, persistent: true }).onOk((data) => { res(data) }).onCancel(() => { res(false) }) }) }, CONFIRM(text) { return new Promise((res, rej) => { this.$q.dialog({ title: 'Xác nhận', message: text, cancel: true, persistent: true, }).onOk(() => { res(true) }).onCancel(() => { res(false) }) }) }, deepMerge(target, source) { Object.entries(source).forEach(([key, value]) => { if (value && typeof value === 'object') { this.deepMerge(target[key] = target[key] || {}, value); return; } target[key] = value; }); return target; }, getConfigs() { return new Promise((resolve, reject) => { if (window.hasOwnProperty('aff_settings')) resolve(window.aff_settings) else { getConfigs().then(res => { window.aff_settings = res.data.data resolve(window.aff_settings) }) } }) }, isNormal(){ const settings = window.aff_settings return settings.hasOwnProperty('version') && settings.version == 'normal' ? true : false } } }) if(router) new Vue({ router, el: '#q-app', data: function() { return { configs: {}, page_title: 'WP Affiliate MH', settings: { }, logo: `${window.RV_CONFIGS.plugin_url}/public/images/virus.svg`, leftDrawerOpen: false, navs: [{ label: "Thống kê của bạn", to: "/", icon: "favorite_border", login: false }, { label: "Lịch sử số dư", to: "/lich-su", icon: "fingerprint", login: "all" // children: [] }, { label: "Thanh toán", to: "/thanh-toan", icon: "credit_card", login: false }, { label: "Banner CTV", to: "/banner", icon: "photo_library", login: false }, { label: "Tài khoản của bạn", to: "/tai-khoan", icon: "person", login: false }, { label: "Công cụ hỗ trợ", to: "/cong-cu", icon: "gesture", login: false }], user: { balance: 0, display_name: '', aff_active: 0 }, } }, methods: { setPageTitle(title) { this.page_title = title }, async getUserProfile(id = ''){ const res = await getUserProfile(id) const { data } = res.data console.log(data); if(data) this.user = data }, getC(){ const { RV_CONFIGS } = window this.configs = RV_CONFIGS }, getLoggedInfo(){ this.getC(); this.getUserProfile() this.getConfigs().then(res => { this.settings = res this.navs = this.isNormal() ? route.normal : route.pro }) }, async logout(){ const confirm = await this.CONFIRM('Bạn chắc chắn muốn đăng xuất') if(!confirm) return await logout() window.RV_CONFIGS.user_id = '' window.RV_CONFIGS.user_login = '' this.configs.user_id = '' this.configs.user_login = '' this.$router.push('/dang-nhap') }, }, components: { }, created() { document.querySelector('#q-app').classList.remove('d-none') this.getConfigs().then(res => { this.settings = res this.navs = this.isNormal() ? route.normal : route.pro }) this.getC(); if(!this.configs.user_id && this.$route.path != '/dang-nhap' && this.$route.path != '/dang-ky'){ console.log(this.$route.path); this.$router.push('/dang-nhap') } if(this.$route.path == '/dang-nhap' && this.configs.user_id) this.$router.push('/') if(this.configs.user_id) this.getLoggedInfo() EventBus.$on('set.page_title', this.setPageTitle); EventBus.$on('user.refresh', this.getUserProfile); EventBus.$on('user.login', this.getLoggedInfo); } // });