Merge pull request #63 from ronger-x/master

🎨 钱包账号调整为手动激活
This commit is contained in:
ronger 2022-11-01 22:54:41 +08:00 committed by GitHub
commit 69487c3d06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 241 additions and 283 deletions

View File

@ -90,7 +90,8 @@
</el-link> </el-link>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="user">个人中心</el-dropdown-item> <el-dropdown-item command="user">个人中心</el-dropdown-item>
<el-dropdown-item command="answer">每日一题</el-dropdown-item> <el-dropdown-item command="answer" v-if="$auth.user.bankAccount">每日一题</el-dropdown-item>
<el-dropdown-item command="answer" v-else :disabled="true">每日一题<small>(开通钱包账号激活)</small></el-dropdown-item>
<el-dropdown-item command="drafts" divided>我的草稿</el-dropdown-item> <el-dropdown-item command="drafts" divided>我的草稿</el-dropdown-item>
<el-dropdown-item command="wallet">我的钱包</el-dropdown-item> <el-dropdown-item command="wallet">我的钱包</el-dropdown-item>
<el-dropdown-item command="user-info" divided>设置</el-dropdown-item> <el-dropdown-item command="user-info" divided>设置</el-dropdown-item>
@ -184,8 +185,6 @@ export default {
}, },
handleSelectMenu(item) { handleSelectMenu(item) {
let _ts = this; let _ts = this;
let activeMenu = _ts.$store.state.activeMenu;
if (activeMenu !== item) {
switch (item) { switch (item) {
case 'topic': case 'topic':
_ts.$router.push({ _ts.$router.push({
@ -220,7 +219,6 @@ export default {
} }
) )
} }
}
}, },
handleCommand(item) { handleCommand(item) {
let _ts = this; let _ts = this;

View File

@ -4,7 +4,7 @@
<header-view/> <header-view/>
</el-header> </el-header>
<el-main> <el-main>
<nuxt :nuxt-child-key="$route.name" keep-alive :keep-alive-props="{max: 16}"/> <nuxt keep-alive/>
</el-main> </el-main>
<el-footer height="5rem"> <el-footer height="5rem">
<footer-view/> <footer-view/>

View File

@ -3,7 +3,7 @@
<el-col v-if="hasPermissions" :span="20"> <el-col v-if="hasPermissions" :span="20">
<el-col :span="4"> <el-col :span="4">
<el-menu <el-menu
:default-active="getActiveMenu" :default-active="activeMenu"
class="el-menu-vertical-demo" class="el-menu-vertical-demo"
@select="handleSelectMenu"> @select="handleSelectMenu">
<template v-for="menu in menus"> <template v-for="menu in menus">
@ -15,7 +15,7 @@
</el-menu> </el-menu>
</el-col> </el-col>
<el-col :span="20"> <el-col :span="20">
<el-tabs v-model="editableTabsValue" type="card" @tab-remove="handleRemoveTab" @tab-click="handleClick"> <el-tabs :value="editableTabsValue" type="card" @tab-remove="handleRemoveTab" @tab-click="handleClick">
<el-tab-pane <el-tab-pane
:key="item.name" :key="item.name"
v-for="(item, index) in editableTabs" v-for="(item, index) in editableTabs"
@ -23,7 +23,7 @@
:name="item.name" :name="item.name"
:closable="item.closable" :closable="item.closable"
> >
<nuxt keep-alive :nuxt-child-key="item.name"/> <nuxt-child keep-alive :keep-alive-props="{exclude: ['login', 'register', 'admin-dashboard'],max: 10}"/>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</el-col> </el-col>
@ -42,6 +42,7 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import {mapState} from 'vuex';
export default { export default {
name: "Admin", name: "Admin",
@ -130,23 +131,18 @@ export default {
} }
}, },
computed: { computed: {
...mapState({
editableTabs() { editableTabs() {
return this.$store.state.admin.tabs; return this.$store.state.admin.tabs;
}, },
editableTabsValue: { editableTabsValue() {
get() {
return this.$store.state.admin.activeTab; return this.$store.state.admin.activeTab;
}, },
set(value) { activeMenu: state => state.activeMenu,
this.$store.commit('admin/updateActiveTab', value);
}
},
getActiveMenu() {
return this.$store.state.activeMenu;
},
hasPermissions() { hasPermissions() {
return this.$auth.hasScope('admin') || this.$auth.hasScope('blog_admin'); return this.$auth.hasScope('admin') || this.$auth.hasScope('blog_admin');
} }
})
}, },
methods: { methods: {
handleRemoveTab(targetName) { handleRemoveTab(targetName) {
@ -162,35 +158,13 @@ export default {
} }
}); });
} }
this.$store.commit('admin/updateActiveTab', activeName);
this.$store.commit('admin/updateTags', tabs.filter(tab => tab.name !== targetName)) this.$store.commit('admin/updateTags', tabs.filter(tab => tab.name !== targetName))
this.$router.push({ this.handleSelectMenu(activeName)
name: activeName,
params: {
reset: '0'
}
})
}, },
handleClick(item) { handleClick(item) {
let _ts = this this.handleSelectMenu(item.name)
this.$store.commit('admin/updateActiveTab', item.name);
let result = _.findIndex(_ts.editableTabs, function (tab) {
return tab.name === item.name;
})
if (result === -1) {
let index = _.findIndex(_ts.menus, function (menu) {
return menu.name === item.name;
})
_ts.$store.commit('admin/pushTags', _ts.menus[index])
}
_ts.$router.push({
name: item.name,
params: {
reset: '0'
}
})
}, },
handleSelectTab(item) { handleSelectTab(item) {
let _ts = this let _ts = this
@ -221,6 +195,9 @@ export default {
_ts.handleSelectTab(item) _ts.handleSelectTab(item)
} }
} }
},
mounted() {
this.handleSelectMenu(this.$route.name)
} }
} }
</script> </script>

View File

@ -200,9 +200,6 @@ export default {
openLink(link) { openLink(link) {
window.open(link); window.open(link);
} }
},
mounted() {
this.$store.commit("setActiveMenu", "admin-articles");
} }
} }
</script> </script>

View File

@ -147,9 +147,6 @@ export default {
endDate: endDate endDate: endDate
}) })
} }
},
mounted() {
this.$store.commit("setActiveMenu", "admin-bank-accounts");
} }
} }
</script> </script>

View File

@ -157,9 +157,6 @@ export default {
} }
}) })
} }
},
mounted() {
this.$store.commit("setActiveMenu", "admin-banks");
} }
} }
</script> </script>

View File

@ -150,9 +150,6 @@ export default {
}) })
}, },
toggleStatus() {} toggleStatus() {}
},
mounted() {
this.$store.commit("setActiveMenu", "admin-comments");
} }
} }
</script> </script>

View File

@ -151,9 +151,6 @@ export default {
} }
}) })
} }
},
mounted() {
this.$store.commit("setActiveMenu", "admin-currency-rules");
} }
} }
</script> </script>

View File

@ -42,143 +42,91 @@
<el-col :span="24" style="text-align: left;"> <el-col :span="24" style="text-align: left;">
<h3>新增文章列表</h3> <h3>新增文章列表</h3>
</el-col> </el-col>
<el-table <el-table :data="articles.list" style="width: 100%">
:data="articles.list" <el-table-column label="#" width="60" prop="idArticle">
style="width: 100%">
<el-table-column
label="#"
width="60"
prop="idArticle">
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="标题" prop="articleTitle">
label="标题"
prop="articleTitle">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="openLink(scope.row.articlePermalink)">{{ scope.row.articleTitle }}</el-button> <el-button type="text" @click="openLink(scope.row.articlePermalink)">{{ scope.row.articleTitle }}
</el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="标签" prop="articleTitle">
label="标签"
prop="articleTitle">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag <el-tag style="margin-left: 0.5rem;" v-for="tag in scope.row.tags" :key="tag.idTag" size="mini"
style="margin-left: 0.5rem;"
v-for="tag in scope.row.tags"
:key="tag.idTag"
size="mini"
effect="plain"> effect="plain">
# {{ tag.tagTitle }} # {{ tag.tagTitle }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="最后更新时间" width="180" prop="updatedTime">
label="最后更新时间"
width="180"
prop="updatedTime">
</el-table-column> </el-table-column>
<el-table-column label="操作"> <el-table-column label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button v-if="scope.row.articlePerfect === '1'" size="mini" @click="cancelPreference(scope.$index, scope.row.idArticle)" plain>取消优选</el-button> <el-button v-if="scope.row.articlePerfect === '1'" size="mini"
<el-button v-else size="mini" @click="setPreference(scope.$index, scope.row.idArticle)" plain>设为优选</el-button> @click="cancelPreference(scope.$index, scope.row.idArticle)" plain>取消优选</el-button>
<el-button size="mini" type="primary" <el-button v-else size="mini" @click="setPreference(scope.$index, scope.row.idArticle)" plain>设为优选
@click="updateTags(scope.$index, scope.row)" plain>编辑标签 </el-button>
<el-button size="mini" type="primary" @click="updateTags(scope.$index, scope.row)" plain>编辑标签
</el-button> </el-button>
<el-button v-if="scope.row.articleStatus === '0'" size="mini" type="danger" <el-button v-if="scope.row.articleStatus === '0'" size="mini" type="danger"
@click="toggleStatus(scope.$index, scope.row)" plain>下架 @click="toggleStatus(scope.$index, scope.row)" plain>下架
</el-button> </el-button>
<el-button v-else size="mini" type="success" <el-button v-else size="mini" type="success" @click="toggleStatus(scope.$index, scope.row)" plain>上架
@click="toggleStatus(scope.$index, scope.row)" plain>上架
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-col> </el-col>
<el-col> <el-col>
<el-pagination <el-pagination :hide-on-single-page="true" @size-change="handleArticleSizeChange"
:hide-on-single-page="true" @current-change="handleArticleCurrentChange" :current-page="articles.pageNum"
@size-change="handleArticleSizeChange" :page-sizes="[10, 20, 50, 100]" :page-size="articles.pageSize"
@current-change="handleArticleCurrentChange" layout="total, sizes, prev, pager, next, jumper" :total="articles.total">
:current-page="articles.pageNum"
:page-sizes="[10, 20, 50, 100]"
:page-size="articles.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="articles.total">
</el-pagination> </el-pagination>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-col :span="24" style="text-align: left;"> <el-col :span="24" style="text-align: left;">
<h3>新增用户列表</h3> <h3>新增用户列表</h3>
</el-col> </el-col>
<el-table :data="users.list" <el-table :data="users.list" style="width: 100%">
style="width: 100%"> <el-table-column label="#" width="40" prop="idUser">
<el-table-column
label="#"
width="40"
prop="idUser">
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="头像" width="60" prop="avatarUrl">
label="头像"
width="60"
prop="avatarUrl">
<template slot-scope="scope"> <template slot-scope="scope">
<el-avatar v-if="scope.row.avatarUrl" size="medium" :src="scope.row.avatarUrl"></el-avatar> <el-avatar v-if="scope.row.avatarUrl" size="medium" :src="scope.row.avatarUrl"></el-avatar>
<el-avatar v-else size="medium" src="https://rymcu.com/article/1578475481946.png"></el-avatar> <el-avatar v-else size="medium" src="https://rymcu.com/article/1578475481946.png"></el-avatar>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="昵称" width="140" prop="nickname">
label="昵称"
width="140"
prop="nickname">
<template slot-scope="scope"> <template slot-scope="scope">
<el-link type="primary" :href="getUserPath(scope.row.account)" :underline="false"> <el-link type="primary" :href="getUserPath(scope.row.account)" :underline="false">
{{ scope.row.nickname }} {{ scope.row.nickname }}
</el-link> </el-link>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="注册时间" width="180" prop="createdTime">
label="注册时间"
width="180"
prop="createdTime">
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-col> </el-col>
<el-col> <el-col>
<el-pagination <el-pagination :hide-on-single-page="true" @size-change="handleUserSizeChange"
:hide-on-single-page="true" @current-change="handleUserCurrentChange" :current-page="users.pageNum" :page-sizes="[10, 20, 50, 100]"
@size-change="handleUserSizeChange" :page-size="users.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="users.total">
@current-change="handleUserCurrentChange"
:current-page="users.pageNum"
:page-sizes="[10, 20, 50, 100]"
:page-size="users.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="users.total">
</el-pagination> </el-pagination>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-col :span="24" style="text-align: left;"> <el-col :span="24" style="text-align: left;">
<h3>新增账户列表</h3> <h3>新增账户列表</h3>
</el-col> </el-col>
<el-table :data="bankAccounts.list" <el-table :data="bankAccounts.list" style="width: 100%">
style="width: 100%"> <el-table-column label="#" width="40" prop="idBank">
<el-table-column
label="#"
width="40"
prop="idBank">
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="银行账户" width="180" prop="bankAccount">
label="银行账户"
width="180"
prop="bankAccount">
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="账户所有者" width="180" prop="accountOwnerName">
label="账户所有者"
width="180"
prop="accountOwnerName">
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="账户余额 (巴旦木)" width="180" prop="accountBalance">
label="账户余额 (巴旦木)"
width="180"
prop="accountBalance">
</el-table-column> </el-table-column>
<el-table-column label="操作"> <el-table-column label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
@ -188,15 +136,10 @@
</el-table> </el-table>
</el-col> </el-col>
<el-col> <el-col>
<el-pagination <el-pagination :hide-on-single-page="true" @size-change="handleBankAccountSizeChange"
:hide-on-single-page="true" @current-change="handleBankAccountCurrentChange" :current-page="bankAccounts.pageNum"
@size-change="handleBankAccountSizeChange" :page-sizes="[10, 20, 50, 100]" :page-size="bankAccounts.pageSize"
@current-change="handleBankAccountCurrentChange" layout="total, sizes, prev, pager, next, jumper" :total="bankAccounts.total">
:current-page="bankAccounts.pageNum"
:page-sizes="[10, 20, 50, 100]"
:page-size="bankAccounts.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="bankAccounts.total">
</el-pagination> </el-pagination>
</el-col> </el-col>
</div> </div>
@ -229,10 +172,7 @@
</el-col> </el-col>
<el-col> <el-col>
<el-dialog :visible.sync="tagsDialogVisible"> <el-dialog :visible.sync="tagsDialogVisible">
<edit-tags <edit-tags :idArticle="idArticle" :tags="articleTags" @closeDialog="closeTagsDialog">
:idArticle="idArticle"
:tags="articleTags"
@closeDialog="closeTagsDialog">
</edit-tags> </edit-tags>
</el-dialog> </el-dialog>
</el-col> </el-col>
@ -241,7 +181,7 @@
<script> <script>
import Vue from 'vue'; import Vue from 'vue';
import {mapState} from 'vuex'; import { mapState } from 'vuex';
import echarts from 'echarts'; import echarts from 'echarts';
import EditTags from '~/components/widget/tags'; import EditTags from '~/components/widget/tags';
@ -253,11 +193,11 @@ export default {
EditTags EditTags
}, },
fetch() { fetch() {
let {store, params, error} = this.$nuxt.context let { store, params, error } = this.$nuxt.context
return Promise.all([ return Promise.all([
store store
.dispatch('dashboard/fetchDashboard', params) .dispatch('dashboard/fetchDashboard', params)
.catch(err => error({statusCode: 404})), .catch(err => error({ statusCode: 404 })),
store.dispatch("dashboard/fetchLastThirtyDays", params), store.dispatch("dashboard/fetchLastThirtyDays", params),
store.dispatch("dashboard/fetchHistory", params), store.dispatch("dashboard/fetchHistory", params),
store.dispatch("dashboard/fetchNewUsers", params), store.dispatch("dashboard/fetchNewUsers", params),
@ -540,7 +480,7 @@ export default {
_ts.$set(_ts, 'articleTags', article.articleTags); _ts.$set(_ts, 'articleTags', article.articleTags);
_ts.$set(_ts, 'tagsDialogVisible', true); _ts.$set(_ts, 'tagsDialogVisible', true);
}, },
toggleStatus() {}, toggleStatus() { },
closeTagsDialog() { closeTagsDialog() {
this.$set(this, 'tagsDialogVisible', false); this.$set(this, 'tagsDialogVisible', false);
}, },
@ -593,7 +533,6 @@ export default {
this.initLastThirtyDaysCharts(this.lastThirtyDays) this.initLastThirtyDaysCharts(this.lastThirtyDays)
this.initHistoryCharts(this.history) this.initHistoryCharts(this.history)
}, 500); }, 500);
} }
} }
</script> </script>

View File

@ -156,9 +156,6 @@ export default {
}) })
}, },
handleEdit(index ,row) {} handleEdit(index ,row) {}
},
mounted() {
this.$store.commit("setActiveMenu", "admin-products");
} }
} }
</script> </script>

View File

@ -346,7 +346,6 @@ export default {
}).then(() => { }).then(() => {
next(); next();
}).catch(() => { }).catch(() => {
_ts.$store.commit("setActiveMenu", "admin-tag-post");
return false return false
}); });
} else { } else {
@ -369,7 +368,6 @@ export default {
return '关闭提示'; return '关闭提示';
}); });
let _ts = this; let _ts = this;
_ts.$store.commit('setActiveMenu', 'admin-tag-post');
_ts.$axios.$get('/api/upload/simple/token').then(function (res) { _ts.$axios.$get('/api/upload/simple/token').then(function (res) {
if (res) { if (res) {
_ts.$store.commit('setUploadHeaders', res.uploadToken); _ts.$store.commit('setUploadHeaders', res.uploadToken);

View File

@ -104,9 +104,6 @@
path: '/admin/tag/post/' + id path: '/admin/tag/post/' + id
}) })
} }
},
mounted() {
this.$store.commit("setActiveMenu", "admin-tags");
} }
} }
</script> </script>

View File

@ -351,7 +351,6 @@ export default {
}).then(() => { }).then(() => {
next(); next();
}).catch(() => { }).catch(() => {
_ts.$store.commit("setActiveMenu", "admin-topic-post");
return false return false
}); });
} else { } else {
@ -374,7 +373,6 @@ export default {
return '关闭提示'; return '关闭提示';
}); });
let _ts = this; let _ts = this;
_ts.$store.commit("setActiveMenu", "admin-topic-post");
_ts.$axios.$get('/api/upload/simple/token').then(function (res) { _ts.$axios.$get('/api/upload/simple/token').then(function (res) {
if (res) { if (res) {
_ts.$store.commit('setUploadHeaders', res.uploadToken); _ts.$store.commit('setUploadHeaders', res.uploadToken);

View File

@ -65,9 +65,6 @@
path: '/admin/topic/post' path: '/admin/topic/post'
}) })
} }
},
mounted() {
this.$store.commit("setActiveMenu", "admin-topics");
} }
} }
</script> </script>

View File

@ -227,9 +227,6 @@ export default {
getUserPath(nickname) { getUserPath(nickname) {
return `/user/${nickname}` return `/user/${nickname}`
} }
},
mounted() {
this.$store.commit("setActiveMenu", "admin-users");
} }
} }
</script> </script>

View File

@ -63,7 +63,8 @@ import {mapState} from 'vuex';
export default { export default {
name: "answer", name: "answer",
middleware: 'auth', middleware: 'auth',
fetch({store, params, error}) { fetch() {
let {store, params, error} = this.$nuxt.context
return Promise.all([ return Promise.all([
store store
.dispatch('answer/fetchDetail', params) .dispatch('answer/fetchDetail', params)

View File

@ -95,7 +95,7 @@
{{ article.articleThumbsUpCount }} {{ article.articleThumbsUpCount }}
</el-button> </el-button>
</el-tooltip> </el-tooltip>
<el-tooltip class="item" effect="dark" content="赞赏" placement="top-start"> <el-tooltip v-if="article.canSponsor" class="item" effect="dark" content="赞赏" placement="top-start" :disabled="!$auth.user.bankAccount">
<el-button v-if="user.idUser === article.articleAuthorId" type="text" <el-button v-if="user.idUser === article.articleAuthorId" type="text"
style="font-size: 1.2rem;"> style="font-size: 1.2rem;">
<svg width="24" height="24"> <svg width="24" height="24">

View File

@ -70,7 +70,8 @@
} }
return params.article_id && !isNaN(Number(params.article_id)) return params.article_id && !isNaN(Number(params.article_id))
}, },
fetch({store, params, error}) { fetch() {
let {store, params, error} = this.$nuxt.context
return Promise.all([ return Promise.all([
store.dispatch('article/fetchPostDetail', params) store.dispatch('article/fetchPostDetail', params)
.catch(err => error({statusCode: 404})) .catch(err => error({statusCode: 404}))

View File

@ -75,7 +75,8 @@
validate({params, store}) { validate({params, store}) {
return params.draft_id && !isNaN(Number(params.draft_id)) return params.draft_id && !isNaN(Number(params.draft_id))
}, },
fetch({store, params, error}) { fetch() {
let {store, params, error} = this.$nuxt.context
return Promise.all([ return Promise.all([
store store
.dispatch('draft/fetchDetail', params) .dispatch('draft/fetchDetail', params)

View File

@ -19,8 +19,10 @@ export default {
]) ])
}, },
watch: { watch: {
'$route.query': function () { '$route'(to, from) {
this.$store.dispatch('article/fetchList', {page: this.$route.query.page || 1}) if (from.query.page && to.query.page) {
this.$router.go()
}
} }
}, },
components: { components: {

View File

@ -47,7 +47,7 @@
<script> <script>
import Vue from 'vue'; import Vue from 'vue';
import {mapState} from 'vuex'; import { mapState } from 'vuex';
import echarts from 'echarts'; import echarts from 'echarts';
import gzh from "assets/rymcugzh.jpg"; import gzh from "assets/rymcugzh.jpg";
@ -55,11 +55,11 @@ Vue.prototype.$echarts = echarts;
export default { export default {
name: "openData", name: "openData",
fetch() { fetch() {
let {store, params, error} = this.$nuxt.context let { store, params, error } = this.$nuxt.context
return Promise.all([ return Promise.all([
store store
.dispatch('open-data/fetchLastThirtyDays', params) .dispatch('open-data/fetchLastThirtyDays', params)
.catch(err => error({statusCode: 404})), .catch(err => error({ statusCode: 404 })),
store.dispatch('open-data/fetchDashboard', params) store.dispatch('open-data/fetchDashboard', params)
]) ])
}, },
@ -163,14 +163,13 @@ export default {
</script> </script>
<style scoped> <style scoped>
.article__wrapper { .article__wrapper {
max-width: 980px; max-width: 980px;
margin: 20px auto; margin: 20px auto;
display: block; display: block;
padding-left: 1rem; padding-left: 1rem;
padding-right: 1rem; padding-right: 1rem;
box-sizing: border-box;; box-sizing: border-box;
} }
.mt-2rem { .mt-2rem {

View File

@ -60,7 +60,8 @@ export default {
validate({params, store}) { validate({params, store}) {
return params.portfolio_id && !isNaN(Number(params.portfolio_id)) return params.portfolio_id && !isNaN(Number(params.portfolio_id))
}, },
fetch({store, params, query, error}) { fetch() {
let {store, params, query, error} = this.$nuxt.context
params.page = query.page || 1 params.page = query.page || 1
return Promise.all([ return Promise.all([
store store
@ -70,11 +71,10 @@ export default {
]) ])
}, },
watch: { watch: {
'$route.query': function () { '$route'(to, from) {
this.$store.dispatch('portfolio/fetchArticleList', { if (from.query.page && to.query.page) {
page: this.$route.query.page || 1, this.$router.go()
portfolio_id: this.routePortfolioId }
})
} }
}, },
computed: { computed: {

View File

@ -66,7 +66,8 @@
validate({params, store}) { validate({params, store}) {
return params.portfolio_id && !isNaN(Number(params.portfolio_id)) return params.portfolio_id && !isNaN(Number(params.portfolio_id))
}, },
fetch({store, params, error}) { fetch() {
let {store, params, error} = this.$nuxt.context
return Promise.all([ return Promise.all([
store store
.dispatch('portfolio/fetchDetail', params) .dispatch('portfolio/fetchDetail', params)

View File

@ -31,7 +31,8 @@
validate({params, store}) { validate({params, store}) {
return params.portfolio_id && !isNaN(Number(params.portfolio_id)) return params.portfolio_id && !isNaN(Number(params.portfolio_id))
}, },
fetch({store, params, error}) { fetch() {
let {store, params, error} = this.$nuxt.context
return Promise.all([ return Promise.all([
store store
.dispatch('portfolio/fetchUnBindArticleList', params) .dispatch('portfolio/fetchUnBindArticleList', params)

View File

@ -25,8 +25,10 @@ export default {
]) ])
}, },
watch: { watch: {
'$route.query': function () { '$route'(to, from) {
this.$store.dispatch('portfolio/fetchList', {page: this.$route.query.page || 1}) if (from.query.page && to.query.page) {
this.$router.go()
}
} }
}, },
computed: { computed: {

View File

@ -24,7 +24,8 @@ export default {
validate({params, store}) { validate({params, store}) {
return params.product_id && !isNaN(Number(params.product_id)) return params.product_id && !isNaN(Number(params.product_id))
}, },
fetch({store, params, error}) { fetch() {
let {store, params, error} = this.$nuxt.context
return Promise.all([ return Promise.all([
store store
.dispatch('product/fetchDetail', params) .dispatch('product/fetchDetail', params)

View File

@ -22,8 +22,10 @@ export default {
]) ])
}, },
watch: { watch: {
'$route.query': function () { '$route'(to, from) {
this.$store.dispatch('product/fetchList', {page: this.$route.query.page || 1}) if (from.query.page && to.query.page) {
this.$router.go()
}
} }
}, },
computed: { computed: {

View File

@ -43,7 +43,8 @@ import { mapState } from 'vuex';
export default { export default {
name: "currency", name: "currency",
fetch({store, params, error}) { fetch() {
let {store, params, error} = this.$nuxt.context
return Promise.all([ return Promise.all([
store store
.dispatch('rule/fetchCurrencyRules', params) .dispatch('rule/fetchCurrencyRules', params)

View File

@ -30,12 +30,10 @@ export default {
]) ])
}, },
watch: { watch: {
'$route.query': function () { '$route'(to, from) {
let _ts = this if (from.query.page && to.query.page) {
_ts.$store.dispatch('article/fetchList', { this.$router.go()
topic_uri: _ts.defaultParams.topic_uri, }
page: _ts.defaultParams.page || 1
})
} }
}, },
computed: { computed: {

View File

@ -8,15 +8,21 @@
<span style="font-size: 24px;"> 账号:</span> <span style="color: red;">{{ bankAccount.bankAccount }}</span> <span style="font-size: 24px;"> 账号:</span> <span style="color: red;">{{ bankAccount.bankAccount }}</span>
</el-col> </el-col>
<el-col class="bank-account-item"> <el-col class="bank-account-item">
<span style="font-size: 24px;"> 余额:</span> <span style="color: red;">{{ bankAccount.accountBalance }}</span> <span <span style="font-size: 24px;"> 余额:</span> <span style="color: red;">{{ bankAccount.accountBalance }}</span>
<span
style="font-size: 24px;">巴旦木</span> style="font-size: 24px;">巴旦木</span>
</el-col> </el-col>
<el-col> <el-col>
<records :records="records" :bankAccount="bankAccount.bankAccount" @currentChange="handleCurrentChange" @searchTransactionRecord="searchTransactionRecord"></records> <records :records="records" :bankAccount="bankAccount.bankAccount" @currentChange="handleCurrentChange"
@searchTransactionRecord="searchTransactionRecord"></records>
</el-col> </el-col>
</el-col> </el-col>
<el-col v-else style="text-align: center;margin-top: 10vh;"> <el-col v-else style="text-align: center;margin-top: 10vh;">
<el-button type="primary">开通钱包账号</el-button> <p style="font-size: 24px;line-height: 48px;">
<code>钱包</code> 是社区非常重要的组成部分<br/>
开通钱包账号后可激活 <code>每日一题</code> , <code>赞赏</code> 等功能
</p>
<el-button type="primary" @click="createBankAccount">现在开通</el-button>
</el-col> </el-col>
</el-row> </el-row>
</template> </template>
@ -28,7 +34,8 @@ import Records from "../components/common/bank/account/records";
export default { export default {
name: "wallet", name: "wallet",
components: {Records}, components: {Records},
fetch({store, error}) { fetch() {
let {store, error} = this.$nuxt.context
return Promise.all([ return Promise.all([
store store
.dispatch('wallet/fetchDetail') .dispatch('wallet/fetchDetail')
@ -45,8 +52,7 @@ export default {
}) })
}, },
data() { data() {
return { return {}
}
}, },
methods: { methods: {
handleCurrentChange(search) { handleCurrentChange(search) {
@ -67,6 +73,14 @@ export default {
startDate: startDate, startDate: startDate,
endDate: endDate endDate: endDate
}) })
},
createBankAccount() {
let _ts = this
_ts.$axios.$post('/api/wallet/create').then(function (res) {
if (res) {
_ts.$fetch()
}
})
} }
}, },
mounted() { mounted() {
@ -80,4 +94,8 @@ export default {
font-size: 32px; font-size: 32px;
padding-left: 15vw; padding-left: 15vw;
} }
code {
color: red;
font-weight: bold;
}
</style> </style>

View File

@ -1,14 +1,54 @@
import {Message} from 'element-ui' import {Message} from 'element-ui'
export default function ({app, $axios, store, redirect}) { export default function ({app, $axios, store, redirect}) {
function generateReqKey(config) {
const { method, url, params, data } = config;
return [method, url, JSON.stringify(params), JSON.stringify(data)].join("&");
}
const pendingRequest = new Map();
function addPendingRequest(config) {
const requestKey = generateReqKey(config);
config.cancelToken = config.cancelToken || new $axios.CancelToken((cancel) => {
if (!pendingRequest.has(requestKey)) {
pendingRequest.set(requestKey, cancel);
}
});
}
function removePendingRequest(config) {
const requestKey = generateReqKey(config);
if (pendingRequest.has(requestKey)) {
const cancelToken = pendingRequest.get(requestKey);
cancelToken(requestKey);
pendingRequest.delete(requestKey);
}
}
$axios.onRequest(config => { $axios.onRequest(config => {
let fingerprint = store.state.fingerprint; let fingerprint = store.state.fingerprint;
if (fingerprint) { if (fingerprint) {
config.headers['fingerprint'] = fingerprint config.headers['fingerprint'] = fingerprint
} }
}) })
$axios.interceptors.request.use(
function (config) {
// 检查是否存在重复请求,若存在则取消已发的请求
removePendingRequest(config);
// 把当前请求信息添加到pendingRequest对象中
addPendingRequest(config);
return config;
},
(error) => {
return Promise.reject(error);
}
);
$axios.onResponse(response => { $axios.onResponse(response => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
removePendingRequest(response.config);
//返回数据逻辑处理 比如error_code错误处理 //返回数据逻辑处理 比如error_code错误处理
let message; let message;
if (typeof (response.data.data) !== 'undefined') { if (typeof (response.data.data) !== 'undefined') {
@ -36,11 +76,18 @@ export default function ({app, $axios, store, redirect}) {
}); });
$axios.onError(error => { $axios.onError(error => {
removePendingRequest(error.config || {}); // 从pendingRequest对象中移除请求
if ($axios.isCancel(error)) {
// console.log("已取消的重复请求:" + error.message);
} else {
// 添加异常处理
const code = parseInt(error.response && error.response.status) const code = parseInt(error.response && error.response.status)
if (code === 400) { if (code === 400) {
redirect('/400'); redirect('/400');
} else { } else {
console.log(error.data); console.log(error.data);
} }
}
}) })
} }