somewhere
This commit is contained in:
@@ -0,0 +1,172 @@
|
||||
export default {
|
||||
methods: {
|
||||
getCssCustomProperties() {
|
||||
if (process.client) {
|
||||
const cssCustomProperties = {}
|
||||
const sheets = document.styleSheets
|
||||
let cssText = ''
|
||||
for (let i = sheets.length - 1; i > -1; i--) {
|
||||
const rules = sheets[i].cssRules
|
||||
for (let j = rules.length - 1; j > -1; j--) {
|
||||
if (rules[j].selectorText === '.ie-custom-properties') {
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
cssText = rules[j].cssText
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (cssText) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-string-slice
|
||||
cssText = cssText.substring(cssText.lastIndexOf('{') + 1, cssText.lastIndexOf('}'))
|
||||
|
||||
cssText.split(';').forEach(property => {
|
||||
if (property) {
|
||||
const name = property.split(': ')[0]
|
||||
const value = property.split(': ')[1]
|
||||
if (name && value) {
|
||||
cssCustomProperties[`--${name.trim()}`] = value.trim()
|
||||
}
|
||||
}
|
||||
})
|
||||
return cssCustomProperties
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
},
|
||||
deepObjectsMerge(target, source) {
|
||||
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties
|
||||
for (const key of Object.keys(source)) {
|
||||
if (source[key] instanceof Object) {
|
||||
Object.assign(source[key], this.deepObjectsMerge(target[key], source[key]))
|
||||
}
|
||||
}
|
||||
|
||||
// Join `target` and modified `source`
|
||||
Object.assign(target || {}, source)
|
||||
return target
|
||||
},
|
||||
getColor(rawProperty, element = process.client ? document.body : null) {
|
||||
const property = `--${rawProperty}`
|
||||
const style = this.getStyle(property, element)
|
||||
return style || rawProperty
|
||||
},
|
||||
getStyle(property, element = process.client ? document.body : null) {
|
||||
if (process.client) {
|
||||
const minIEVersion = 10
|
||||
const isIE1x = () => Boolean(document.documentMode) && document.documentMode >= minIEVersion
|
||||
const isCustomProperty = property => property.match(/^--.*/i)
|
||||
///
|
||||
let style
|
||||
|
||||
if (isCustomProperty(property) && isIE1x()) {
|
||||
const cssCustomProperties = this.getCssCustomProperties()
|
||||
style = cssCustomProperties[property]
|
||||
} else {
|
||||
style = window.getComputedStyle(element, null).getPropertyValue(property).replace(/^\s/, '')
|
||||
}
|
||||
|
||||
return style
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
},
|
||||
hexToRgb(color) {
|
||||
if (typeof color === 'undefined') {
|
||||
throw new TypeError('Hex color is not defined')
|
||||
}
|
||||
|
||||
const hex = color.match(/^#(?:[0-9a-f]{3}){1,2}$/i)
|
||||
|
||||
if (!hex) {
|
||||
throw new Error(`${color} is not a valid hex color`)
|
||||
}
|
||||
|
||||
let r
|
||||
let g
|
||||
let b
|
||||
|
||||
if (color.length === 7) {
|
||||
r = parseInt(color.slice(1, 3), 16)
|
||||
g = parseInt(color.slice(3, 5), 16)
|
||||
b = parseInt(color.slice(5, 7), 16)
|
||||
} else {
|
||||
r = parseInt(color.slice(1, 2), 16)
|
||||
g = parseInt(color.slice(2, 3), 16)
|
||||
b = parseInt(color.slice(3, 5), 16)
|
||||
}
|
||||
|
||||
return `rgba(${r}, ${g}, ${b})`
|
||||
},
|
||||
hexToRgba(color, opacity = 100) {
|
||||
if (typeof color === 'undefined') {
|
||||
throw new TypeError('Hex color is not defined')
|
||||
}
|
||||
|
||||
const hex = color.match(/^#(?:[0-9a-f]{3}){1,2}$/i)
|
||||
|
||||
if (!hex) {
|
||||
throw new Error(`${color} is not a valid hex color`)
|
||||
}
|
||||
|
||||
let r
|
||||
let g
|
||||
let b
|
||||
|
||||
if (color.length === 7) {
|
||||
r = parseInt(color.slice(1, 3), 16)
|
||||
g = parseInt(color.slice(3, 5), 16)
|
||||
b = parseInt(color.slice(5, 7), 16)
|
||||
} else {
|
||||
r = parseInt(color.slice(1, 2), 16)
|
||||
g = parseInt(color.slice(2, 3), 16)
|
||||
b = parseInt(color.slice(3, 5), 16)
|
||||
}
|
||||
|
||||
return `rgba(${r}, ${g}, ${b}, ${opacity / 100})`
|
||||
},
|
||||
makeUid() {
|
||||
const key = Math.random().toString(36).substr(2)
|
||||
return 'uid-' + key
|
||||
},
|
||||
omitByKeys(originalObject, keys) {
|
||||
const newObj = {}
|
||||
const objKeys = Object.keys(originalObject)
|
||||
for (let i = 0; i < objKeys.length; i++) {
|
||||
!keys.includes(objKeys[i]) && (newObj[objKeys[i]] = originalObject[objKeys[i]])
|
||||
}
|
||||
return newObj
|
||||
},
|
||||
pickByKeys(originalObject, keys) {
|
||||
const newObj = {}
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
newObj[keys[i]] = originalObject[keys[i]]
|
||||
}
|
||||
return newObj
|
||||
},
|
||||
rgbToHex(color) {
|
||||
if (typeof color === 'undefined') {
|
||||
throw new TypeError('Hex color is not defined')
|
||||
}
|
||||
|
||||
if (color === 'transparent') {
|
||||
return '#00000000'
|
||||
}
|
||||
|
||||
const rgb = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i)
|
||||
|
||||
if (!rgb) {
|
||||
throw new Error(`${color} is not a valid rgb color`)
|
||||
}
|
||||
|
||||
const r = `0${parseInt(rgb[1], 10).toString(16)}`
|
||||
const g = `0${parseInt(rgb[2], 10).toString(16)}`
|
||||
const b = `0${parseInt(rgb[3], 10).toString(16)}`
|
||||
|
||||
return `#${r.slice(-2)}${g.slice(-2)}${b.slice(-2)}`
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
export default {
|
||||
mounted() {
|
||||
$(document).ready(() => {
|
||||
const elements = $('.fadeInAnim')
|
||||
|
||||
Object.keys(elements).forEach((item, index) => {
|
||||
if (index < elements.length) {
|
||||
this.$gsap.fromTo(
|
||||
elements[item],
|
||||
{ y: 20, opacity: 0 },
|
||||
{
|
||||
y: 0,
|
||||
opacity: 1,
|
||||
duration: 0.5,
|
||||
scrollTrigger: {
|
||||
trigger: elements[item],
|
||||
start: 'top 90%'
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
import { io } from 'socket.io/client-dist/socket.io'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
adminNotificationOffset: 60
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
userIsLoggedIn() {
|
||||
return this.$auth.loggedIn
|
||||
},
|
||||
adminWS: {
|
||||
get() {
|
||||
return this.$store.state.admin.adminWS
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit('front/set', ['adminWS', val])
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initAdminWS() {
|
||||
this.adminWS = true
|
||||
|
||||
/// /////////////////////////////////////////// connetct to ws server
|
||||
const socket = io(`${this.$config.WebSocketURL}/admin`, {
|
||||
reconnectionDelay: 20000,
|
||||
reconnectionDelayMax: 20000,
|
||||
auth: {
|
||||
token: this.$auth.strategy.token.get()
|
||||
}
|
||||
})
|
||||
|
||||
/// /////////////////////////////////////////// connection error
|
||||
|
||||
socket.on('connect_error', () => {
|
||||
this.$notify({
|
||||
type: 'error',
|
||||
title: 'خطا',
|
||||
message: 'دریافت اعلانات ادمین با مشکل مواجه شد',
|
||||
position: 'top-left',
|
||||
offset: this.adminNotificationOffset
|
||||
// duration: 0
|
||||
})
|
||||
})
|
||||
|
||||
/// /////////////////////////////////////////// events
|
||||
socket.on('connect', () => {
|
||||
// console.log('**************** You have access to admin notifications')
|
||||
})
|
||||
|
||||
socket.on(`admin:allNotifs`, data => {
|
||||
this.$store.commit('admin/set', ['unreadCuMsgs', data.unreadCuMsgs])
|
||||
this.$store.commit('admin/set', ['unreadTickets', data.unreadTickets])
|
||||
this.$store.commit('admin/set', ['newCustomers', data.newCustomers])
|
||||
this.$store.commit('admin/set', ['newRepresentations', data.newRepresentations])
|
||||
this.$store.commit('admin/set', ['newPieceRequests', data.newPieceRequests])
|
||||
this.$store.commit('admin/set', ['newOldPieceRequests', data.newOldPieceRequests])
|
||||
this.$store.commit('admin/set', ['newBufferRequests', data.newBufferRequests])
|
||||
this.$store.commit('admin/set', ['newGuaranteeReports', data.newGuaranteeReports])
|
||||
})
|
||||
|
||||
socket.on(`admin:notify`, data => {
|
||||
if (data.type === 'updateUnreadCuMsgs') {
|
||||
// update store
|
||||
this.$store.commit('admin/set', ['unreadCuMsgs', data.unreadCuMsgs])
|
||||
|
||||
// update DOM
|
||||
if (this.$route.name === 'admin-contact-us') {
|
||||
this.$nuxt.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'updateUnreadTickets') {
|
||||
// update store
|
||||
this.$store.commit('admin/set', ['unreadTickets', data.unreadTickets])
|
||||
|
||||
// update DOM
|
||||
if (this.$route.name === 'admin-tickets') {
|
||||
this.$nuxt.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'newTicketMsg') {
|
||||
if (this.$route.name === 'admin-tickets-ticket') {
|
||||
this.$nuxt.refresh()
|
||||
setTimeout(() => {
|
||||
window.scrollTo(0, document.body.scrollHeight)
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'updateNewCustomers') {
|
||||
this.$store.commit('admin/set', ['newCustomers', data.newCustomers])
|
||||
}
|
||||
|
||||
if (data.type === 'updateNewRepresentations') {
|
||||
// update store
|
||||
this.$store.commit('admin/set', ['newRepresentations', data.newRepresentations])
|
||||
|
||||
// update DOM
|
||||
if (this.$route.name === 'admin-representations') {
|
||||
this.$nuxt.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'updateNewPieceRequests') {
|
||||
// update store
|
||||
this.$store.commit('admin/set', ['newPieceRequests', data.newPieceRequests])
|
||||
|
||||
// update DOM
|
||||
if (this.$route.name === 'admin-piece-requests') {
|
||||
this.$nuxt.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'updateNewOldPieceRequests') {
|
||||
// update store
|
||||
this.$store.commit('admin/set', ['newOldPieceRequests', data.newOldPieceRequests])
|
||||
|
||||
// update DOM
|
||||
if (this.$route.name === 'admin-op-requests') {
|
||||
this.$nuxt.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'updateNewBufferRequests') {
|
||||
// update store
|
||||
this.$store.commit('admin/set', ['newBufferRequests', data.newBufferRequests])
|
||||
|
||||
// update DOM
|
||||
if (this.$route.name === 'admin-buffer-requests') {
|
||||
this.$nuxt.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'updateNewGuaranteeReports') {
|
||||
// update store
|
||||
this.$store.commit('admin/set', ['newGuaranteeReports', data.newGuaranteeReports])
|
||||
|
||||
// update DOM
|
||||
if (this.$route.name === 'admin-quarantee-reports') {
|
||||
this.$nuxt.refresh()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.userIsLoggedIn && !this.adminWS) {
|
||||
this.initAdminWS()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import { io } from 'socket.io/client-dist/socket.io'
|
||||
import Vue from 'vue'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
agentNotificationOffset: 60
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
user() {
|
||||
return this.$auth.user
|
||||
},
|
||||
userIsLoggedIn() {
|
||||
return this.$auth.loggedIn
|
||||
},
|
||||
agentWS: {
|
||||
get() {
|
||||
return this.$store.state.front.agentWS
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit('front/set', ['agentWS', val])
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initAgentWS() {
|
||||
this.agentWS = true
|
||||
|
||||
/// /////////////////////////////////////////// connetct to ws server
|
||||
const socket = io(`${this.$config.WebSocketURL}/agent`, {
|
||||
reconnectionDelay: 20000,
|
||||
reconnectionDelayMax: 20000,
|
||||
auth: {
|
||||
token: this.$auth.strategy.token.get()
|
||||
}
|
||||
})
|
||||
|
||||
Vue.prototype.$agentSocket = socket
|
||||
|
||||
/// /////////////////////////////////////////// connection error
|
||||
// eslint-disable-next-line node/handle-callback-err
|
||||
socket.on('connect_error', err => {})
|
||||
|
||||
/// /////////////////////////////////////////// events
|
||||
socket.on('connect', () => {
|
||||
// console.log('**************** You have access to agent notifications')
|
||||
socket.emit('agent:fetchAnnouncements')
|
||||
})
|
||||
|
||||
socket.on(`agent:allNotifs`, data => {
|
||||
this.$store.commit('front/set', ['agentInbox', data.agentInbox])
|
||||
})
|
||||
|
||||
socket.on(`agent:announcements`, data => {
|
||||
this.$store.commit('front/set', ['newAgentAnnosCount', data.newAgentAnnosCount])
|
||||
this.$store.commit('front/set', ['agentAnnouncements', data.agentAnnouncements])
|
||||
})
|
||||
|
||||
socket.on(`agent:fetchNewAnnouncements`, data => {
|
||||
socket.emit('agent:fetchAnnouncements')
|
||||
})
|
||||
|
||||
socket.on(`agent:notify`, data => {
|
||||
if (data.type === 'updateAgentInbox') {
|
||||
// update store
|
||||
this.$store.commit('front/set', ['agentInbox', data.agentInbox])
|
||||
|
||||
// update DOM
|
||||
if (this.$route.name === 'account-agents-inbox') {
|
||||
this.$nuxt.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'newAgentInbox') {
|
||||
// sent ui notif
|
||||
this.$notify({
|
||||
type: 'success',
|
||||
title: 'توجه',
|
||||
message: ' فرم گارانتی جدید در صندوق ورودی شما قرار گرفت',
|
||||
position: 'top-left',
|
||||
offset: this.agentNotificationOffset,
|
||||
duration: 10 * 1000
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
socket.on(`agent:notifyAll`, data => {
|
||||
if (data.type === 'fetchNewAnnouncements') {
|
||||
socket.emit('agent:fetchAnnouncements')
|
||||
this.$notify({
|
||||
type: 'success',
|
||||
title: 'توجه',
|
||||
message: 'پیام جدید در اطلاعیه های نمایندگان دارید',
|
||||
position: 'top-left',
|
||||
offset: this.userNotificationOffset
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.userIsLoggedIn && this.user.isAgent && !this.agentWS) {
|
||||
this.initAgentWS()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
import { io } from 'socket.io/client-dist/socket.io'
|
||||
import Vue from 'vue'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
userNotificationOffset: 60
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
userIsLoggedIn() {
|
||||
return this.$auth.loggedIn
|
||||
},
|
||||
userWS: {
|
||||
get() {
|
||||
return this.$store.state.front.userWS
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit('front/set', ['userWS', val])
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initUserWS() {
|
||||
this.userWS = true
|
||||
|
||||
/// /////////////////////////////////////////// connetct to ws server
|
||||
const socket = io(`${this.$config.WebSocketURL}/user`, {
|
||||
reconnectionDelay: 20000,
|
||||
reconnectionDelayMax: 20000,
|
||||
auth: {
|
||||
token: this.$auth.strategy.token.get()
|
||||
}
|
||||
})
|
||||
|
||||
Vue.prototype.$userSocket = socket
|
||||
|
||||
/// /////////////////////////////////////////// connection error
|
||||
// eslint-disable-next-line node/handle-callback-err
|
||||
socket.on('connect_error', err => {
|
||||
this.$notify({
|
||||
type: 'error',
|
||||
title: 'خطا',
|
||||
message: 'دریافت اعلانات با مشکل مواجه شد',
|
||||
position: 'top-left',
|
||||
offset: this.userNotificationOffset
|
||||
// duration: 0
|
||||
})
|
||||
})
|
||||
|
||||
/// /////////////////////////////////////////// events
|
||||
socket.on('connect', () => {
|
||||
// console.log('**************** You have access to notifications')
|
||||
socket.emit('user:fetchAnnouncements')
|
||||
})
|
||||
|
||||
socket.on(`user:allNotifs`, data => {
|
||||
this.$store.commit('front/set', ['unreadTickets', data.unreadTickets])
|
||||
this.$store.commit('front/set', ['draftsCount', data.draftsCount])
|
||||
})
|
||||
|
||||
socket.on(`user:announcements`, data => {
|
||||
this.$store.commit('front/set', ['newUserAnnosCount', data.newUserAnnosCount])
|
||||
this.$store.commit('front/set', ['userAnnouncements', data.userAnnouncements])
|
||||
})
|
||||
|
||||
socket.on(`user:fetchNewAnnouncements`, data => {
|
||||
socket.emit('user:fetchAnnouncements')
|
||||
})
|
||||
|
||||
socket.on(`user:notify`, data => {
|
||||
if (data.type === 'updateUnreadTickets') {
|
||||
// update store
|
||||
this.$store.commit('front/set', ['unreadTickets', data.unreadTickets])
|
||||
|
||||
// update DOM
|
||||
if (this.$route.name === 'account-tickets') {
|
||||
this.$nuxt.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'newTicketMsg') {
|
||||
this.$notify({
|
||||
type: 'success',
|
||||
title: 'توجه',
|
||||
message: 'پیام دارید',
|
||||
position: 'top-left',
|
||||
offset: this.userNotificationOffset
|
||||
})
|
||||
|
||||
if (this.$route.name === 'account-tickets-ticket') {
|
||||
this.$nuxt.refresh()
|
||||
setTimeout(() => {
|
||||
window.scrollTo(0, document.body.scrollHeight)
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'updateDraftsCount') {
|
||||
// update store
|
||||
this.$store.commit('front/set', ['draftsCount', data.draftsCount])
|
||||
|
||||
// update DOM
|
||||
if (this.$route.name === 'account-drafts') {
|
||||
this.$nuxt.refresh()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
socket.on(`user:notifyAll`, data => {
|
||||
if (data.type === 'fetchNewAnnouncements') {
|
||||
socket.emit('user:fetchAnnouncements')
|
||||
this.$notify({
|
||||
type: 'success',
|
||||
title: 'توجه',
|
||||
message: 'پیام جدید در اعلانات دارید',
|
||||
position: 'top-left',
|
||||
offset: this.userNotificationOffset
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.userIsLoggedIn && this.$auth.hasScope('user') && !this.userWS) {
|
||||
this.initUserWS()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
axiosConfig: {
|
||||
onUploadProgress: progressEvent => {
|
||||
if (progressEvent.total / 1024 > 100) {
|
||||
const text = 'درحال آپلود '
|
||||
const uploadLayout = this.$loading({
|
||||
lock: true,
|
||||
text,
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
})
|
||||
document.querySelector('.el-loading-text').innerText =
|
||||
text + Math.floor((progressEvent.loaded / progressEvent.total) * 100) + '%'
|
||||
if ((progressEvent.loaded / progressEvent.total) * 100 === 100) {
|
||||
uploadLayout.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
export default {
|
||||
mounted() {
|
||||
setTimeout(() => {
|
||||
this.$alert(
|
||||
'کاربر گرامی سایت در حال حاضر نسخه آزمایشی میباشد و ممکن است در بعضی بخش ها ایراداتی داشته باشد که به زودی برطرف خواهند شد، با تشکر از صبوری شما.',
|
||||
'توجه',
|
||||
{
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
}, 2000)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user