index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <template>
  2. <div v-loading="loading" class="dashboard-editor-container">
  3. <!-- <github-corner class="github-corner" /> -->
  4. <el-row class="system-carousel">
  5. <el-carousel trigger="click" indicator-position="none" :height="bannerHeight+'px'" :interval="6000" arrow="always" :indicator-position="outside">
  6. <el-carousel-item v-for="(item,key) in slides" :key="key">
  7. <template v-if="item.TYPE==='1'">
  8. <router-link :to="`/shop/index`" target="_self" class="islide">
  9. <img ref="bannerHeight" :src="imageArticle(item.IMAGE)" alt="" @load="imgLoad">
  10. </router-link>
  11. </template>
  12. <template v-else>
  13. <router-link to="#" target="_self" class="islide">
  14. <img ref="bannerHeight" :src="imageArticle(item.IMAGE)" alt="" @load="imgLoad" @click="handleArticle(item.CONTENT)">
  15. </router-link>
  16. </template>
  17. </el-carousel-item>
  18. </el-carousel>
  19. </el-row>
  20. <el-card class="dashboard-member-card" shadow="never">
  21. <div class="dashboard-member-header">
  22. <el-avatar :src="avatar" :size="48" />
  23. <div class="dashboard-member-identity">
  24. <h2 class="dashboard-member-name">{{ memberName }}</h2>
  25. <p class="dashboard-member-id">Member ID: {{ memberId || '—' }}</p>
  26. </div>
  27. <el-button type="text" class="dashboard-member-signout" @click="handleMemberLogout">Sign out</el-button>
  28. </div>
  29. <div class="dashboard-member-details">
  30. <div v-for="item in memberDetails" :key="item.label" class="dashboard-member-detail">
  31. <i :class="item.icon" class="dashboard-member-icon" aria-hidden="true" />
  32. <div class="dashboard-member-detail-text">
  33. <span class="dashboard-member-label">{{ item.label }}</span>
  34. <span class="dashboard-member-value">{{ item.value }}</span>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="dashboard-member-referral">
  39. <div class="dashboard-member-referral-copy">
  40. <p class="dashboard-member-eyebrow">INVITE &amp; EARN</p>
  41. <h3 class="dashboard-member-referral-title">Your referral link</h3>
  42. <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>
  43. </div>
  44. <div class="dashboard-member-referral-actions">
  45. <el-input :value="referralLink" placeholder="Your referral link" readonly aria-label="Your referral link" />
  46. <el-dropdown trigger="click" placement="bottom-start" @command="handleShareLink">
  47. <el-button type="primary" native-type="button" icon="el-icon-share" :disabled="!memberId">
  48. Share link <i class="el-icon-arrow-down el-icon--right" aria-hidden="true" />
  49. </el-button>
  50. <el-dropdown-menu slot="dropdown">
  51. <el-dropdown-item command="whatsapp" :disabled="!memberId">WhatsApp</el-dropdown-item>
  52. <el-dropdown-item command="facebook" :disabled="!memberId">Facebook</el-dropdown-item>
  53. </el-dropdown-menu>
  54. </el-dropdown>
  55. <el-button native-type="button" :disabled="!memberId" icon="el-icon-copy-document" @click="handleClipboard(referralLink, $event)">Copy link</el-button>
  56. </div>
  57. </div>
  58. </el-card>
  59. <!-- <panel-group @handleSetLineChartData="handleSetLineChartData" :rmBv="rmBv" :endTime="endTime" :heightEmpLv='heightEmpLv' :eliteLv='eliteLv' :decLv="decLv" :key="num" :cycle="cycle" />-->
  60. <el-row v-loading="loading" :gutter="40">
  61. <el-col v-for="(item,key) in news" :key="key" :xs="24" :sm="24" :lg="12">
  62. <el-card class="box-card">
  63. <el-table :data="item.LISTS" lazy stripe fit highlight-current-row>
  64. <el-table-column align="left" :label="$t('article.title')" prop="TITLE">
  65. <template slot-scope="{row}">
  66. <span @click="handleArticle(row.ID)">
  67. <el-link type="primary" href="#" target="_self">{{ row.TITLE }}</el-link>
  68. </span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column align="right">
  72. <template slot="header" slot-scope="scope">
  73. <el-button type="text" class="box-card-more">
  74. <router-link :to="`/article/article-list`">{{ $t('dashboard.more') }}+</router-link>
  75. </el-button>
  76. </template>
  77. <template slot-scope="{row}">
  78. <span>{{ tool.convertToNigeriaDayTime(row.CREATED_AT) }}</span>
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. </el-card>
  83. </el-col>
  84. </el-row>
  85. <!-- <el-row :gutter="8">
  86. <el-col :xs="{span: 24}" :sm="{span: 24}" :md="{span: 24}" :lg="{span: 12}" :xl="{span: 12}" style="padding-right:8px;margin-bottom:30px;">
  87. <transaction-table />
  88. </el-col>
  89. <el-col :xs="{span: 24}" :sm="{span: 12}" :md="{span: 12}" :lg="{span: 6}" :xl="{span: 6}" style="margin-bottom:30px;">
  90. <todo-list />
  91. </el-col>
  92. <el-col :xs="{span: 24}" :sm="{span: 12}" :md="{span: 12}" :lg="{span: 6}" :xl="{span: 6}" style="margin-bottom:30px;">
  93. <box-card />
  94. </el-col>
  95. </el-row> -->
  96. <el-dialog title="" :visible.sync="dialog" :width="screenWidth" center style="margin-top: -80px;">
  97. <div class="white-box" style="margin-top: -20px; padding: 0;">
  98. <div class="white-box-title" style="text-align: center">
  99. <h1>{{ article.TITLE }}</h1>
  100. <span>{{ tool.convertToNigeriaTime(article.CREATED_AT) }}</span>
  101. </div>
  102. <div class="white-box-content" v-html="article.CONTENT" />
  103. </div>
  104. </el-dialog>
  105. </div>
  106. </template>
  107. <script>
  108. import GithubCorner from '@/components/GithubCorner'
  109. import PanelGroup from './components/PanelGroup'
  110. import LineChart from './components/LineChart'
  111. import RaddarChart from './components/RaddarChart'
  112. import PieChart from './components/PieChart'
  113. import BarChart from './components/BarChart'
  114. import TransactionTable from './components/TransactionTable'
  115. import TodoList from './components/TodoList'
  116. import BoxCard from './components/BoxCard'
  117. import tool from '@/utils/tool'
  118. import usersInfo from '@/utils/usersInfo'
  119. import handleClipboard from '@/utils/clipboard'
  120. import { getScreenWidth } from '@/utils'
  121. import { fetchArticleOne } from '@/api/article'
  122. import avatar from '@/assets/user_images/avatar.png'
  123. const lineChartData = {
  124. newVisitis: {
  125. expectedData: [100, 120, 161, 134, 105, 160, 165],
  126. actualData: [120, 82, 91, 154, 162, 140, 145]
  127. },
  128. messages: {
  129. expectedData: [200, 192, 120, 144, 160, 130, 140],
  130. actualData: [180, 160, 151, 106, 145, 150, 130]
  131. },
  132. purchases: {
  133. expectedData: [80, 100, 121, 104, 105, 90, 100],
  134. actualData: [120, 90, 100, 138, 142, 130, 130]
  135. },
  136. shoppings: {
  137. expectedData: [130, 140, 141, 142, 145, 150, 160],
  138. actualData: [120, 82, 91, 154, 162, 140, 130]
  139. }
  140. }
  141. export default {
  142. name: 'DashboardAdmin',
  143. components: {
  144. GithubCorner,
  145. PanelGroup,
  146. LineChart,
  147. RaddarChart,
  148. PieChart,
  149. BarChart,
  150. TransactionTable,
  151. TodoList,
  152. BoxCard
  153. },
  154. data() {
  155. return {
  156. avatar: avatar,
  157. lineChartData: lineChartData.newVisitis,
  158. myEmpLv: { 'ID': 0, 'LEVEL_NAME': null, 'ICON_TYPE': 0, 'ICON_NUM': 0 },
  159. bannerHeight: '',
  160. slides: [],
  161. news: [],
  162. periodNum: '',
  163. decLvName: '',
  164. myRemainPv: '',
  165. activeEnd: '',
  166. baseEmpLevels: [],
  167. heightEmpLv: '', // 最高级别
  168. eliteLv: '',
  169. decLv: '', // 当前等级
  170. cycle: '', // 当前业绩期
  171. rmBv: '',
  172. endTime: '',
  173. num: 0,
  174. memberId: usersInfo.userName() || '',
  175. memberData: usersInfo.baseData() || {},
  176. memberBaseInfo: usersInfo.getBaseInfo() || {},
  177. memberNowTime: Date.now(),
  178. memberClock: null,
  179. loading: false,
  180. dialog: false,
  181. article: {
  182. ID: '',
  183. CID: '',
  184. TITLE: '',
  185. CONTENT: '',
  186. CREATED_AT: ''
  187. },
  188. outside: 'outside',
  189. screenWidth: getScreenWidth() > 600 ? '70%' : getScreenWidth() + 'px',
  190. labelPosition: getScreenWidth() > 600 ? 'right' : 'top'
  191. }
  192. },
  193. computed: {
  194. tool() {
  195. return tool
  196. },
  197. memberName() {
  198. return this.memberData.REAL_NAME || this.memberId || '—'
  199. },
  200. memberSystemTime() {
  201. return this.$moment(this.memberNowTime).utcOffset('+0100').format('YYYY-MM-DD HH:mm:ss') + ' (WAT)'
  202. },
  203. referralLink() {
  204. return 'https://meads.elken.com/#/login?ref=' + this.memberId
  205. },
  206. memberDetails() {
  207. return [
  208. { label: 'SYSTEM TIME', icon: 'el-icon-time', value: this.memberSystemTime },
  209. { label: 'SETTLEMENT CYCLE', icon: 'el-icon-date', value: this.cycle || this.memberBaseInfo.periodNum || '—' },
  210. { label: 'MEMBER LEVEL', icon: 'el-icon-star-off', value: this.memberLevelName('decLvs', 'decLevels', this.decLv || this.memberData.DEC_LV) },
  211. { label: 'HIGHEST HONOR LEVEL', icon: 'el-icon-medal', value: this.memberLevelName('empLevels', 'empLevels', this.heightEmpLv || this.memberData.EMP_LV) },
  212. { label: 'ELITE LEVEL', icon: 'el-icon-medal-1', value: this.memberLevelName('eliteLevels', 'eliteLevels', this.eliteLv || this.memberData.ELITE_LV) }
  213. ]
  214. }
  215. },
  216. beforeDestroy() {
  217. window.clearInterval(this.memberClock)
  218. },
  219. mounted() {
  220. this.memberClock = window.setInterval(() => {
  221. this.memberNowTime = Date.now()
  222. }, 1000)
  223. this.$store.dispatch('dashboard/getIndex', {})
  224. .then(response => {
  225. this.num++
  226. const ret = response.data
  227. this.slides = ret.slides
  228. this.news = ret.news
  229. this.periodNum = ret.periodNum
  230. this.decLvName = ret.decLvName
  231. this.myRemainPv = ret.myRemainPv
  232. this.activeEnd = ret.activeEnd
  233. this.decLv = ret.decLv
  234. this.heightEmpLv = ret.empLv
  235. this.eliteLv = ret.eliteLv
  236. this.cycle = ret.periodNum
  237. this.rmBv = ret.myRemainPv
  238. this.endTime = ret.activeEnd
  239. this.imgLoad()
  240. })
  241. .catch((error) => {
  242. })
  243. window.addEventListener('resize', () => {
  244. this.imgLoad()
  245. }, false)
  246. },
  247. methods: {
  248. handleClipboard,
  249. handleShareLink(channel) {
  250. if (!this.memberId) return
  251. // 编码完整推荐链接,避免 Hash 路由和 ref 参数被当作分享地址自身的参数。
  252. const link = encodeURIComponent(this.referralLink)
  253. const shareUrls = {
  254. whatsapp: 'https://wa.me/?text=' + link,
  255. facebook: 'https://www.facebook.com/sharer/sharer.php?u=' + link
  256. }
  257. if (channel !== 'whatsapp' && channel !== 'facebook') return
  258. window.open(shareUrls[channel], '_blank', 'noopener,noreferrer')
  259. },
  260. memberLevelName(messages, levels, id) {
  261. if (!id) return '—'
  262. const key = messages + '.' + id
  263. if (this.$te(key, 'en')) return this.$t(key, 'en')
  264. const level = (this.memberBaseInfo[levels] || {})[id]
  265. return level ? level.LEVEL_NAME : '—'
  266. },
  267. async handleMemberLogout() {
  268. await this.$store.dispatch('user/logout')
  269. this.$router.push(`/login?redirect=${this.$route.fullPath}`)
  270. },
  271. handleSetLineChartData(type) {
  272. this.lineChartData = lineChartData[type]
  273. },
  274. sub_str(str, len = 15) {
  275. if (str) return str.slice(0, len)
  276. },
  277. imgLoad() {
  278. const _this = this
  279. if (_this.$refs.bannerHeight) {
  280. _this.$nextTick(function() {
  281. _this.bannerHeight = _this.$refs.bannerHeight[0] && _this.$refs.bannerHeight[0].height
  282. ? _this.$refs.bannerHeight[0].height
  283. : _this.bannerHeight
  284. })
  285. }
  286. },
  287. imageArticle(imageUrl) {
  288. return tool.getArImage(imageUrl, '/files/')
  289. },
  290. formatDate(data) {
  291. return tool.formatDate(data, false)
  292. },
  293. handleArticle(id) {
  294. this.loading = true
  295. fetchArticleOne(id).then(response => {
  296. this.article = response.data
  297. this.dialog = true
  298. setTimeout(() => {
  299. this.loading = false
  300. }, 0.5 * 1000)
  301. })
  302. }
  303. }
  304. }
  305. </script>
  306. <style lang="scss" scoped>
  307. .dashboard-member-card {
  308. margin-bottom: 24px;
  309. //border-radius: 12px;
  310. }
  311. .dashboard-member-header {
  312. display: flex;
  313. align-items: center;
  314. gap: 16px;
  315. }
  316. .dashboard-member-identity {
  317. flex: 1;
  318. min-width: 0;
  319. }
  320. .dashboard-member-name {
  321. margin: 0;
  322. color: #202259;
  323. font-size: 22px;
  324. overflow-wrap: anywhere;
  325. }
  326. .dashboard-member-id {
  327. margin: 6px 0 0;
  328. color: #909399;
  329. font-size: 13px;
  330. overflow-wrap: anywhere;
  331. }
  332. .dashboard-member-signout {
  333. flex-shrink: 0;
  334. color: #202259;
  335. }
  336. .dashboard-member-details {
  337. display: grid;
  338. grid-template-columns: repeat(5, minmax(0, 1fr));
  339. gap: 20px;
  340. margin: 24px 0;
  341. padding: 20px 0;
  342. border-top: 1px solid #ebeef5;
  343. border-bottom: 1px solid #ebeef5;
  344. }
  345. .dashboard-member-detail {
  346. display: flex;
  347. align-items: center;
  348. gap: 12px;
  349. min-width: 0;
  350. }
  351. .dashboard-member-icon {
  352. flex-shrink: 0;
  353. padding: 8px;
  354. border-radius: 8px;
  355. background: #e8f4f8;
  356. color: #202259;
  357. }
  358. .dashboard-member-detail-text {
  359. min-width: 0;
  360. }
  361. .dashboard-member-label,
  362. .dashboard-member-value {
  363. display: block;
  364. line-height: 1.5;
  365. }
  366. .dashboard-member-label {
  367. color: #909399;
  368. font-size: 12px;
  369. }
  370. .dashboard-member-value {
  371. color: #606266;
  372. font-size: 14px;
  373. overflow-wrap: anywhere;
  374. }
  375. .dashboard-member-referral {
  376. display: flex;
  377. align-items: flex-end;
  378. gap: 24px;
  379. }
  380. .dashboard-member-referral-copy {
  381. flex: 1;
  382. min-width: 0;
  383. }
  384. .dashboard-member-eyebrow {
  385. margin: 0 0 8px;
  386. color: #2585a2;
  387. font-size: 12px;
  388. font-weight: bold;
  389. letter-spacing: 1px;
  390. }
  391. .dashboard-member-referral-title {
  392. margin: 0 0 8px;
  393. color: #202259;
  394. font-size: 16px;
  395. }
  396. .dashboard-member-referral-note {
  397. margin: 0;
  398. color: #909399;
  399. font-size: 13px;
  400. line-height: 1.5;
  401. }
  402. .dashboard-member-referral-actions {
  403. display: flex;
  404. align-items: center;
  405. gap: 12px;
  406. flex: 1.3;
  407. min-width: 0;
  408. .el-input {
  409. flex: 1;
  410. min-width: 0;
  411. }
  412. .el-button {
  413. margin-left: 0;
  414. }
  415. .el-dropdown {
  416. flex-shrink: 0;
  417. }
  418. }
  419. @media (max-width: 1200px) {
  420. .dashboard-member-details {
  421. grid-template-columns: repeat(3, minmax(0, 1fr));
  422. }
  423. .dashboard-member-referral {
  424. align-items: stretch;
  425. flex-direction: column;
  426. }
  427. }
  428. @media (max-width: 600px) {
  429. .dashboard-member-details {
  430. grid-template-columns: minmax(0, 1fr);
  431. }
  432. .dashboard-member-referral-actions {
  433. flex-wrap: wrap;
  434. .el-input {
  435. flex-basis: 100%;
  436. }
  437. }
  438. .dashboard-member-header {
  439. flex-wrap: wrap;
  440. }
  441. .dashboard-member-signout {
  442. flex-basis: 100%;
  443. text-align: right;
  444. }
  445. .dashboard-member-name {
  446. font-size: 18px;
  447. }
  448. }
  449. // img {
  450. // max-height:350px;
  451. // max-width:400px;
  452. // margin: 0 auto;
  453. // }
  454. .islide {
  455. display: block;
  456. text-align: center;
  457. }
  458. .islide img {
  459. max-width: 100%;
  460. max-height: 330px;
  461. }
  462. .box-card .item{
  463. line-height: 30px;
  464. }
  465. .box-card .item span {
  466. float: right;
  467. color: #999;
  468. font-size: 12px;
  469. }
  470. .box-card .item:nth-of-type(odd) {
  471. background: #FAFAFA;
  472. }
  473. ::v-deep .el-carousel__container {
  474. text-align: center !important;
  475. }
  476. .dashboard-editor-container {
  477. padding: 32px;
  478. background-color: rgb(240, 242, 245);
  479. position: relative;
  480. .github-corner {
  481. position: absolute;
  482. top: 0px;
  483. border: 0;
  484. right: 0;
  485. }
  486. .chart-wrapper {
  487. background: #fff;
  488. padding: 16px 16px 0;
  489. margin-bottom: 32px;
  490. }
  491. }
  492. .box-card-more {
  493. float: right;
  494. padding: 3px 10px;
  495. border: 1px solid #ddd;
  496. border-radius: 10px;
  497. }
  498. .box-card-more a {
  499. color: #666;
  500. }
  501. .box-card-more:hover {
  502. border-color: #409EFF;
  503. }
  504. // carousel
  505. .system-carousel {
  506. margin-left: 0px !important;
  507. margin-right: 0px !important;
  508. margin-top: -10px;
  509. }
  510. // carousel
  511. @media (max-width:1024px) {
  512. .chart-wrapper {
  513. padding: 8px;
  514. }
  515. }
  516. ::v-deep .el-carousel__button {
  517. border: 1px solid gray;
  518. width: 8px;
  519. height: 8px;
  520. border-radius: 50%;
  521. }
  522. </style>