| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571 |
- <template>
- <div v-loading="loading" class="dashboard-editor-container">
- <!-- <github-corner class="github-corner" /> -->
- <el-row class="system-carousel">
- <el-carousel trigger="click" indicator-position="none" :height="bannerHeight+'px'" :interval="6000" arrow="always" :indicator-position="outside">
- <el-carousel-item v-for="(item,key) in slides" :key="key">
- <template v-if="item.TYPE==='1'">
- <router-link :to="`/shop/index`" target="_self" class="islide">
- <img ref="bannerHeight" :src="imageArticle(item.IMAGE)" alt="" @load="imgLoad">
- </router-link>
- </template>
- <template v-else>
- <router-link to="#" target="_self" class="islide">
- <img ref="bannerHeight" :src="imageArticle(item.IMAGE)" alt="" @load="imgLoad" @click="handleArticle(item.CONTENT)">
- </router-link>
- </template>
- </el-carousel-item>
- </el-carousel>
- </el-row>
- <el-card class="dashboard-member-card" shadow="never">
- <div class="dashboard-member-header">
- <el-avatar :src="avatar" :size="48" />
- <div class="dashboard-member-identity">
- <h2 class="dashboard-member-name">{{ memberName }}</h2>
- <p class="dashboard-member-id">Member ID: {{ memberId || '—' }}</p>
- </div>
- <el-button type="text" class="dashboard-member-signout" @click="handleMemberLogout">Sign out</el-button>
- </div>
- <div class="dashboard-member-details">
- <div v-for="item in memberDetails" :key="item.label" class="dashboard-member-detail">
- <i :class="item.icon" class="dashboard-member-icon" aria-hidden="true" />
- <div class="dashboard-member-detail-text">
- <span class="dashboard-member-label">{{ item.label }}</span>
- <span class="dashboard-member-value">{{ item.value }}</span>
- </div>
- </div>
- </div>
- <div class="dashboard-member-referral">
- <div class="dashboard-member-referral-copy">
- <p class="dashboard-member-eyebrow">INVITE & EARN</p>
- <h3 class="dashboard-member-referral-title">Your referral link</h3>
- <p class="dashboard-member-referral-note">Share this link. When friends order <strong>without signing in</strong>, their order's BV is credited to your member ID.</p>
- </div>
- <div class="dashboard-member-referral-actions">
- <el-input :value="referralLink" placeholder="Your referral link" readonly aria-label="Your referral link" />
- <el-dropdown trigger="click" placement="bottom-start" @command="handleShareLink">
- <el-button type="primary" native-type="button" icon="el-icon-share" :disabled="!memberId">
- Share link <i class="el-icon-arrow-down el-icon--right" aria-hidden="true" />
- </el-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item command="whatsapp" :disabled="!memberId">WhatsApp</el-dropdown-item>
- <el-dropdown-item command="facebook" :disabled="!memberId">Facebook</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- <el-button native-type="button" :disabled="!memberId" icon="el-icon-copy-document" @click="handleClipboard(referralLink, $event)">Copy link</el-button>
- </div>
- </div>
- </el-card>
- <!-- <panel-group @handleSetLineChartData="handleSetLineChartData" :rmBv="rmBv" :endTime="endTime" :heightEmpLv='heightEmpLv' :eliteLv='eliteLv' :decLv="decLv" :key="num" :cycle="cycle" />-->
- <el-row v-loading="loading" :gutter="40">
- <el-col v-for="(item,key) in news" :key="key" :xs="24" :sm="24" :lg="12">
- <el-card class="box-card">
- <el-table :data="item.LISTS" lazy stripe fit highlight-current-row>
- <el-table-column align="left" :label="$t('article.title')" prop="TITLE">
- <template slot-scope="{row}">
- <span @click="handleArticle(row.ID)">
- <el-link type="primary" href="#" target="_self">{{ row.TITLE }}</el-link>
- </span>
- </template>
- </el-table-column>
- <el-table-column align="right">
- <template slot="header" slot-scope="scope">
- <el-button type="text" class="box-card-more">
- <router-link :to="`/article/article-list`">{{ $t('dashboard.more') }}+</router-link>
- </el-button>
- </template>
- <template slot-scope="{row}">
- <span>{{ tool.convertToNigeriaDayTime(row.CREATED_AT) }}</span>
- </template>
- </el-table-column>
- </el-table>
- </el-card>
- </el-col>
- </el-row>
- <!-- <el-row :gutter="8">
- <el-col :xs="{span: 24}" :sm="{span: 24}" :md="{span: 24}" :lg="{span: 12}" :xl="{span: 12}" style="padding-right:8px;margin-bottom:30px;">
- <transaction-table />
- </el-col>
- <el-col :xs="{span: 24}" :sm="{span: 12}" :md="{span: 12}" :lg="{span: 6}" :xl="{span: 6}" style="margin-bottom:30px;">
- <todo-list />
- </el-col>
- <el-col :xs="{span: 24}" :sm="{span: 12}" :md="{span: 12}" :lg="{span: 6}" :xl="{span: 6}" style="margin-bottom:30px;">
- <box-card />
- </el-col>
- </el-row> -->
- <el-dialog title="" :visible.sync="dialog" :width="screenWidth" center style="margin-top: -80px;">
- <div class="white-box" style="margin-top: -20px; padding: 0;">
- <div class="white-box-title" style="text-align: center">
- <h1>{{ article.TITLE }}</h1>
- <span>{{ tool.convertToNigeriaTime(article.CREATED_AT) }}</span>
- </div>
- <div class="white-box-content" v-html="article.CONTENT" />
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import GithubCorner from '@/components/GithubCorner'
- import PanelGroup from './components/PanelGroup'
- import LineChart from './components/LineChart'
- import RaddarChart from './components/RaddarChart'
- import PieChart from './components/PieChart'
- import BarChart from './components/BarChart'
- import TransactionTable from './components/TransactionTable'
- import TodoList from './components/TodoList'
- import BoxCard from './components/BoxCard'
- import tool from '@/utils/tool'
- import usersInfo from '@/utils/usersInfo'
- import handleClipboard from '@/utils/clipboard'
- import { getScreenWidth } from '@/utils'
- import { fetchArticleOne } from '@/api/article'
- import avatar from '@/assets/user_images/avatar.png'
- const lineChartData = {
- newVisitis: {
- expectedData: [100, 120, 161, 134, 105, 160, 165],
- actualData: [120, 82, 91, 154, 162, 140, 145]
- },
- messages: {
- expectedData: [200, 192, 120, 144, 160, 130, 140],
- actualData: [180, 160, 151, 106, 145, 150, 130]
- },
- purchases: {
- expectedData: [80, 100, 121, 104, 105, 90, 100],
- actualData: [120, 90, 100, 138, 142, 130, 130]
- },
- shoppings: {
- expectedData: [130, 140, 141, 142, 145, 150, 160],
- actualData: [120, 82, 91, 154, 162, 140, 130]
- }
- }
- export default {
- name: 'DashboardAdmin',
- components: {
- GithubCorner,
- PanelGroup,
- LineChart,
- RaddarChart,
- PieChart,
- BarChart,
- TransactionTable,
- TodoList,
- BoxCard
- },
- data() {
- return {
- avatar: avatar,
- lineChartData: lineChartData.newVisitis,
- myEmpLv: { 'ID': 0, 'LEVEL_NAME': null, 'ICON_TYPE': 0, 'ICON_NUM': 0 },
- bannerHeight: '',
- slides: [],
- news: [],
- periodNum: '',
- decLvName: '',
- myRemainPv: '',
- activeEnd: '',
- baseEmpLevels: [],
- heightEmpLv: '', // 最高级别
- eliteLv: '',
- decLv: '', // 当前等级
- cycle: '', // 当前业绩期
- rmBv: '',
- endTime: '',
- num: 0,
- memberId: usersInfo.userName() || '',
- memberData: usersInfo.baseData() || {},
- memberBaseInfo: usersInfo.getBaseInfo() || {},
- memberNowTime: Date.now(),
- memberClock: null,
- loading: false,
- dialog: false,
- article: {
- ID: '',
- CID: '',
- TITLE: '',
- CONTENT: '',
- CREATED_AT: ''
- },
- outside: 'outside',
- screenWidth: getScreenWidth() > 600 ? '70%' : getScreenWidth() + 'px',
- labelPosition: getScreenWidth() > 600 ? 'right' : 'top'
- }
- },
- computed: {
- tool() {
- return tool
- },
- memberName() {
- return this.memberData.REAL_NAME || this.memberId || '—'
- },
- memberSystemTime() {
- return this.$moment(this.memberNowTime).utcOffset('+0100').format('YYYY-MM-DD HH:mm:ss') + ' (WAT)'
- },
- referralLink() {
- return 'https://meads.elken.com/#/login?ref=' + this.memberId
- },
- memberDetails() {
- return [
- { label: 'SYSTEM TIME', icon: 'el-icon-time', value: this.memberSystemTime },
- { label: 'SETTLEMENT CYCLE', icon: 'el-icon-date', value: this.cycle || this.memberBaseInfo.periodNum || '—' },
- { label: 'MEMBER LEVEL', icon: 'el-icon-star-off', value: this.memberLevelName('decLvs', 'decLevels', this.decLv || this.memberData.DEC_LV) },
- { label: 'HIGHEST HONOR LEVEL', icon: 'el-icon-medal', value: this.memberLevelName('empLevels', 'empLevels', this.heightEmpLv || this.memberData.EMP_LV) },
- { label: 'ELITE LEVEL', icon: 'el-icon-medal-1', value: this.memberLevelName('eliteLevels', 'eliteLevels', this.eliteLv || this.memberData.ELITE_LV) }
- ]
- }
- },
- beforeDestroy() {
- window.clearInterval(this.memberClock)
- },
- mounted() {
- this.memberClock = window.setInterval(() => {
- this.memberNowTime = Date.now()
- }, 1000)
- this.$store.dispatch('dashboard/getIndex', {})
- .then(response => {
- this.num++
- const ret = response.data
- this.slides = ret.slides
- this.news = ret.news
- this.periodNum = ret.periodNum
- this.decLvName = ret.decLvName
- this.myRemainPv = ret.myRemainPv
- this.activeEnd = ret.activeEnd
- this.decLv = ret.decLv
- this.heightEmpLv = ret.empLv
- this.eliteLv = ret.eliteLv
- this.cycle = ret.periodNum
- this.rmBv = ret.myRemainPv
- this.endTime = ret.activeEnd
- this.imgLoad()
- })
- .catch((error) => {
- })
- window.addEventListener('resize', () => {
- this.imgLoad()
- }, false)
- },
- methods: {
- handleClipboard,
- handleShareLink(channel) {
- if (!this.memberId) return
- // 编码完整推荐链接,避免 Hash 路由和 ref 参数被当作分享地址自身的参数。
- const link = encodeURIComponent(this.referralLink)
- const shareUrls = {
- whatsapp: 'https://wa.me/?text=' + link,
- facebook: 'https://www.facebook.com/sharer/sharer.php?u=' + link
- }
- if (channel !== 'whatsapp' && channel !== 'facebook') return
- window.open(shareUrls[channel], '_blank', 'noopener,noreferrer')
- },
- memberLevelName(messages, levels, id) {
- if (!id) return '—'
- const key = messages + '.' + id
- if (this.$te(key, 'en')) return this.$t(key, 'en')
- const level = (this.memberBaseInfo[levels] || {})[id]
- return level ? level.LEVEL_NAME : '—'
- },
- async handleMemberLogout() {
- await this.$store.dispatch('user/logout')
- this.$router.push(`/login?redirect=${this.$route.fullPath}`)
- },
- handleSetLineChartData(type) {
- this.lineChartData = lineChartData[type]
- },
- sub_str(str, len = 15) {
- if (str) return str.slice(0, len)
- },
- imgLoad() {
- const _this = this
- if (_this.$refs.bannerHeight) {
- _this.$nextTick(function() {
- _this.bannerHeight = _this.$refs.bannerHeight[0] && _this.$refs.bannerHeight[0].height
- ? _this.$refs.bannerHeight[0].height
- : _this.bannerHeight
- })
- }
- },
- imageArticle(imageUrl) {
- return tool.getArImage(imageUrl, '/files/')
- },
- formatDate(data) {
- return tool.formatDate(data, false)
- },
- handleArticle(id) {
- this.loading = true
- fetchArticleOne(id).then(response => {
- this.article = response.data
- this.dialog = true
- setTimeout(() => {
- this.loading = false
- }, 0.5 * 1000)
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .dashboard-member-card {
- margin-bottom: 24px;
- //border-radius: 12px;
- }
- .dashboard-member-header {
- display: flex;
- align-items: center;
- gap: 16px;
- }
- .dashboard-member-identity {
- flex: 1;
- min-width: 0;
- }
- .dashboard-member-name {
- margin: 0;
- color: #202259;
- font-size: 22px;
- overflow-wrap: anywhere;
- }
- .dashboard-member-id {
- margin: 6px 0 0;
- color: #909399;
- font-size: 13px;
- overflow-wrap: anywhere;
- }
- .dashboard-member-signout {
- flex-shrink: 0;
- color: #202259;
- }
- .dashboard-member-details {
- display: grid;
- grid-template-columns: repeat(5, minmax(0, 1fr));
- gap: 20px;
- margin: 24px 0;
- padding: 20px 0;
- border-top: 1px solid #ebeef5;
- border-bottom: 1px solid #ebeef5;
- }
- .dashboard-member-detail {
- display: flex;
- align-items: center;
- gap: 12px;
- min-width: 0;
- }
- .dashboard-member-icon {
- flex-shrink: 0;
- padding: 8px;
- border-radius: 8px;
- background: #e8f4f8;
- color: #202259;
- }
- .dashboard-member-detail-text {
- min-width: 0;
- }
- .dashboard-member-label,
- .dashboard-member-value {
- display: block;
- line-height: 1.5;
- }
- .dashboard-member-label {
- color: #909399;
- font-size: 12px;
- }
- .dashboard-member-value {
- color: #606266;
- font-size: 14px;
- overflow-wrap: anywhere;
- }
- .dashboard-member-referral {
- display: flex;
- align-items: flex-end;
- gap: 24px;
- }
- .dashboard-member-referral-copy {
- flex: 1;
- min-width: 0;
- }
- .dashboard-member-eyebrow {
- margin: 0 0 8px;
- color: #2585a2;
- font-size: 12px;
- font-weight: bold;
- letter-spacing: 1px;
- }
- .dashboard-member-referral-title {
- margin: 0 0 8px;
- color: #202259;
- font-size: 16px;
- }
- .dashboard-member-referral-note {
- margin: 0;
- color: #909399;
- font-size: 13px;
- line-height: 1.5;
- }
- .dashboard-member-referral-actions {
- display: flex;
- align-items: center;
- gap: 12px;
- flex: 1.3;
- min-width: 0;
- .el-input {
- flex: 1;
- min-width: 0;
- }
- .el-button {
- margin-left: 0;
- }
- .el-dropdown {
- flex-shrink: 0;
- }
- }
- @media (max-width: 1200px) {
- .dashboard-member-details {
- grid-template-columns: repeat(3, minmax(0, 1fr));
- }
- .dashboard-member-referral {
- align-items: stretch;
- flex-direction: column;
- }
- }
- @media (max-width: 600px) {
- .dashboard-member-details {
- grid-template-columns: minmax(0, 1fr);
- }
- .dashboard-member-referral-actions {
- flex-wrap: wrap;
- .el-input {
- flex-basis: 100%;
- }
- }
- .dashboard-member-header {
- flex-wrap: wrap;
- }
- .dashboard-member-signout {
- flex-basis: 100%;
- text-align: right;
- }
- .dashboard-member-name {
- font-size: 18px;
- }
- }
- // img {
- // max-height:350px;
- // max-width:400px;
- // margin: 0 auto;
- // }
- .islide {
- display: block;
- text-align: center;
- }
- .islide img {
- max-width: 100%;
- max-height: 330px;
- }
- .box-card .item{
- line-height: 30px;
- }
- .box-card .item span {
- float: right;
- color: #999;
- font-size: 12px;
- }
- .box-card .item:nth-of-type(odd) {
- background: #FAFAFA;
- }
- ::v-deep .el-carousel__container {
- text-align: center !important;
- }
- .dashboard-editor-container {
- padding: 32px;
- background-color: rgb(240, 242, 245);
- position: relative;
- .github-corner {
- position: absolute;
- top: 0px;
- border: 0;
- right: 0;
- }
- .chart-wrapper {
- background: #fff;
- padding: 16px 16px 0;
- margin-bottom: 32px;
- }
- }
- .box-card-more {
- float: right;
- padding: 3px 10px;
- border: 1px solid #ddd;
- border-radius: 10px;
- }
- .box-card-more a {
- color: #666;
- }
- .box-card-more:hover {
- border-color: #409EFF;
- }
- // carousel
- .system-carousel {
- margin-left: 0px !important;
- margin-right: 0px !important;
- margin-top: -10px;
- }
- // carousel
- @media (max-width:1024px) {
- .chart-wrapper {
- padding: 8px;
- }
- }
- ::v-deep .el-carousel__button {
- border: 1px solid gray;
- width: 8px;
- height: 8px;
- border-radius: 50%;
- }
- </style>
|