39 Star 80 Fork 83

Discuz/Discuz-Q-Web

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.vue 18.63 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
<template>
<div class="site-info-container">
<div v-if="forums">
<div class="logo-content">
/*IFTRUE_default*/
<img
:src="
forums.set_site && forums.set_site.site_logo
? forums.set_site.site_logo
: require('@/assets/logo.png')
"
alt="logo"
class="logo"
>
/*FITRUE_default*/
/*IFTRUE_pay*/
<img
:src="
forums.set_site && forums.set_site.site_logo
? forums.set_site.site_logo
: require('@/assets/pay_imgs/logo_pay.png')
"
alt="logo"
class="logo"
>
/*FITRUE_pay*/
</div>
<div class="site-info">
<div class="avatar">
<avatar
v-if="forums.set_site && forums.set_site.site_author"
:user="{
id: forums.set_site.site_author.id,
username: forums.set_site.site_author.username,
avatarUrl: forums.set_site.site_author.avatar
}"
:size="40"
:round="true"
/>
<avatar
v-else
:user="{ id: 0, username: '无', avatarUrl: '' }"
:prevent-jump="true"
:size="40"
:round="true"
/>
<div
v-if="forums.set_site && forums.set_site.site_author"
class="right"
>
<div class="label">{{ $t("site.circlemaster") }}</div>
<div class="value name text-hidden">
{{ forums.set_site && forums.set_site.site_author.username }}
</div>
</div>
</div>
<div class="member" @click="jump2ManagePage">
<div class="label">{{ $t("home.theme") }}</div>
<div class="value">
{{ forums.other && forums.other.count_users }}
</div>
</div>
<div class="threads">
<div class="label">{{ $t("manage.contents") }}</div>
<div class="value">
{{ forums.other && forums.other.count_threads }}
</div>
</div>
<div class="create-time">
<div class="label">{{ $t("manage.creationtime") }}</div>
<div
v-if="forums && forums.set_site && forums.set_site.site_install"
class="value"
>
{{
(forums.set_site && forums.set_site.site_install).substr(0, 10)
}}
</div>
</div>
</div>
<div class="site-detail">
<div class="header">
<div class="title base-font-size">
{{ $t("manage.siteintroduction") }}
</div>
<div v-if="+groupsId === 1" class="modify" @click="handleModify">
{{ $t("profile.modify") }}
</div>
</div>
<div
v-if="forums && forums.set_site && forums.set_site.site_introduction"
class="content base-font-size"
>
{{ forums.set_site.site_introduction }}
</div>
<div v-else class="content base-font-size grey-color">
{{ $t("modify.noSiteInfo") }}
</div>
<el-dialog
:title="$t('modify.modifySiteInfo')"
:visible.sync="isModify"
width="620px"
custom-class="custom-dialog"
append-to-body
:close-on-click-modal="false"
>
<div class="dialog-main">
<el-input
v-model="inputInfo"
type="textarea"
:rows="5"
class="custom-input"
:placeholder="$t('modify.siteInfoPlaceholder')"
/>
</div>
<div class="dialog-footer">
<el-button
type="primary"
size="medium"
:loading="loading"
@click="confirmModify"
>
{{ $t("discuzq.ok") }}
</el-button>
<el-button size="medium" @click="isModify = false">
{{ $t("discuzq.msgBox.cancel") }}
</el-button>
</div>
</el-dialog>
</div>
<div v-if="forums && forums.set_site" class="circlemode">
<div class="title base-font-size">
{{ $t("site.circlemode") }} \ {{ $t("site.price") }}
</div>
<div
v-if="forums.set_site && forums.set_site.site_mode === 'public'"
class="content base-font-size grey-color"
>
{{ $t("site.publicmode") }} \ {{ $t("post.free") }}
</div>
<div v-else class="content base-font-size grey-color">
{{ $t("site.paymentmode") }} \ {{ $t("post.yuanItem")
}}{{ forums.set_site.site_price }}{{
forums.set_site.site_expire
? $t("site.periodvalidity") +
forums.set_site.site_expire +
$t("site.day")
: $t("site.permanent")
}}
</div>
</div>
<div class="permission">
<div class="title base-font-size">
{{ $t("manage.myRole") }} \ {{ $t("site.permission") }}
</div>
<div v-if="userInfo" class="user-detail">
<div class="avatar">
<avatar
:user="{
id: userInfo.id,
username: userInfo.username,
avatarUrl: userInfo.avatarUrl
}"
:prevent-jump="true"
:size="50"
:round="true"
/>
</div>
<div class="user-info">
<div class="name base-font-size">{{ userInfo.username }}</div>
<div class="role">
{{ $t("site.role") }}
{{
(forums.user &&
forums.user.groups &&
forums.user.groups.length > 0 &&
forums.user.groups[0].name) ||
""
}}
</div>
<div v-if="userInfo.joinedAt" class="join-time">
{{ $t("manage.joinedTime") }}
{{ userInfo.joinedAt.substr(0, 10) }}
<div
v-if="forums && forums.set_site.site_mode === 'pay'"
class="inline"
>
, {{
$t("site.periodvalidity") +
$t("site.to") + '' +
handleExpiredAt(userInfo.expiredAt)
}}
<!-- <template v-if="userInfo.expiredAt">
({{ $t('pay.surplus') + (handleDays('userInfo.expiredAt') > 0
? handleDays('userInfo.expiredAt') : 0) + $t('site.day') }})
</template> -->
<!-- ({{
forums.set_site.site_expire
? $t("pay.surplus") +
forums.set_site.site_expire +
$t("site.day")
: $t("site.permanent")
}}) -->
</div>
<div
v-if="forums.set_site && forums.set_site.site_mode === 'pay' && forums.set_site.site_expire !== ''"
class="inline renewal"
@click="renewal"
>
{{ day === '' ? $t('site.renewal') : $t('site.renewalTime', { num:day }) }}
</div>
</div>
<div class="permission-list">
<div
v-for="(item, index) in permissionList"
:key="index"
class="item"
>
<!-- {{ $t(`permission.${item.permission.replace(/\./g, '_')}`) }} -->
{{ handlePermission(item.permission) }}
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 收银台 -->
<topic-checkout-counter
v-if="showCheckoutCounter"
:thread-type="10"
:user="currentUser || {}"
:be-asked-user="{}"
:amount="0"
:show-anonymous="false"
:show-wechat-pay="canWechatPay"
reward-or-pay="renewal"
:offer-money="+2"
:lowest-price="price"
@close="showCheckoutCounter = false"
@paying="paying"
/>
<!-- 微信支付 -->
<topic-wx-pay
v-if="showWxPay"
:qr-code="wechatQrCode"
@close="showWxPay = false"
/>
<!-- 密码 -->
<topic-password
v-if="showPasswordInput"
:price="price"
:password-error.sync="passwordError"
:password-error-tip="passwordErrorTip"
@close="showPasswordInput = passwordError = false"
@password="onPasswordInputCompleted"
@findPassword="onFindPassword"
/>
<!-- 找回密码 -->
<find-paypwd
v-if="findPassword && currentUser.originalMobile"
:mobile="currentUser.mobile"
:phonenum="currentUser.originalMobile"
@close="findPassword = false"
/>
<!-- 找回密码,没绑定手机 -->
<without-phone
v-if="findPassword && !currentUser.originalMobile"
@close="findPassword = false"
/>
</div>
</template>
<script>
import handleError from '@/mixin/handleError';
import head from '@/mixin/head';
import { timestamp2day } from '@/utils/time';
import payment from '@/mixin/payment';
export default {
name: 'SiteInfo',
mixins: [handleError, head, payment],
layout: 'center_layout',
data() {
return {
showCheckoutCounter: false,
title: this.$t('manage.circleinfo'),
userId: this.$store.state.user.info.id, // 获取当前登陆用户的ID
groupsId: '',
inputInfo: '',
isModify: false,
loading: false,
permissionList: [], // 用户权限
showWxPay: false,
wechatQrCode: '',
showPasswordInput: false,
passwordError: false,
findPassword: false,
passwordErrorTip: ''
};
},
computed: {
currentUser() {
return this.$store.state.user.info.attributes || {};
},
forums() {
const forums = this.$store.state.site.info.attributes;
return forums;
},
userInfo() {
return this.$store.state.user.info.attributes || {};
},
day() {
const info = this.$store.state.site.info.attributes;
if (info && info.set_site && info.set_site.site_expire) {
return info.set_site.site_expire;
}
return '';
},
price() {
const info = this.$store.state.site.info.attributes;
if (info && info.set_site && info.set_site.site_price) {
return info.set_site.site_price;
}
return 0;
},
canWechatPay() {
if (this.forums && this.forums.paycenter) {
return this.forums.paycenter.wxpay_close;
} else {
return false;
}
}
},
mounted() {
this.inputInfo
= this.forums
&& this.forums.set_site
&& this.forums.set_site.site_introduction;
this.groupsId
= this.forums
&& this.forums.user
&& this.forums.user.groups
&& this.forums.user.groups.length > 0
&& this.forums.user.groups[0].id;
this.getPermissions();
this.reloadForums();
},
methods: {
jump2ManagePage() {
if (this.forums && this.forums.other) {
if (this.forums.other.can_edit_user_group || this.forums.other.can_edit_user_status) {
this.$router.push('/manage');
}
}
},
async reloadForums() {
try {
await this.$store.dispatch('site/getSiteInfo');
} catch (err) {
console.log('getUserInfo err', err);
}
},
handleModify() {
this.isModify = !this.isModify;
if (this.isModify) {
this.inputInfo
= this.forums
&& this.forums.set_site
&& this.forums.set_site.site_introduction;
}
},
confirmModify() {
if (this.loading) return;
const params = {
data: [
{
attributes: {
key: 'site_introduction',
value: this.inputInfo,
tag: 'default'
}
}
]
};
this.loading = true;
this.$store
.dispatch('jv/post', [{ _jv: { type: 'settings' }}, { data: params }])
.then(async() => {
try {
await this.$store.dispatch('site/getSiteInfo');
} catch (error) {
console.log(error);
}
this.isModify = false;
this.$message.success(this.$t('discuzq.msgBox.modifySuccess'));
})
.catch(e => {
this.handleError(e);
})
.finally(() => {
this.loading = false;
});
},
// 调用 用户组权限 接口
getPermissions() {
const params = {
'filter[type]': 'invite',
include: ['permission']
};
this.$store.dispatch('jv/get', ['groups', { params }]).then(res => {
// console.log(res);
const groupsId
= this.forums
&& this.forums.user
&& this.forums.user.groups
&& this.forums.user.groups.length > 0
&& this.forums.user.groups[0].id;
let list = [];
res.forEach(item => {
if (+item._jv.id === +groupsId) {
list = item.permission;
list = list.filter(item => {
return item.permission !== 'createThread';
});
}
});
this.permissionList = list.filter(item => {
return item.permission !== 'user.edit';
});
});
},
handleExpiredAt(date) {
if (date) {
return date.substr(0, 10);
}
return this.$t('site.permanent');
},
handlePermission(str) {
if (str.includes('canBeAsked.money')) {
return this.$t(`permission.canBeAsked_money`, { lowPrice: str.match(/\d+$/)[0] });
}
return this.$t(`permission.${str.replace(/\./g, '_')}`);
},
handleDays(date) {
const _date = Math.round(new Date(date) / 1000);
return timestamp2day(_date);
},
renewal() {
this.showCheckoutCounter = true;
},
/**
* 进入支付
*
* 1. 创建订单
* 2. 调用支付接口(订单号)
* 3. 调用轮询订单状态接口查看支付结果
*/
paying({ payWay, hideAvatar, rewardAmount }) {
if (payWay === 'walletPay') {
this.createOrder(hideAvatar, rewardAmount, 8, 20)
.then(() => {
this.showPasswordInput = true;
})
.finally(() => {
this.defaultLoading = false;
});
} else if (payWay === 'wxPay') {
if (!this.forums.paycenter.wxpay_close) {
return this.$message.warning(this.$t('pay.wxPayClose'));
}
this.createOrder(hideAvatar, rewardAmount, 8, 10)
.then(() => {
this.payOrder().then(
wechatQrcode => {
this.wechatQrCode = wechatQrcode;
this.wxPayActive().then(
() => {
this.getUserInfo();
console.log('支付成功');
},
() => console.log('支付失败')
);
},
() => console.log('支付失败')
);
})
.finally(() => {
this.defaultLoading = false;
});
}
this.showCheckoutCounter = false;
},
onPasswordInputCompleted(password) {
this.payOrder(password).then(
() => {
this.getUserInfo();
console.log('支付成功');
},
() => console.log('支付失败')
);
},
getUserInfo() {
const userId = this.$store.state.user.info.id;
this.$store.dispatch('user/getUserInfo', userId).then(
() => {
this.$store.commit('session/SET_USER_ID', userId);
this.loading = false;
},
e => this.$store.commit('user/SET_USER_INFO', {})
);
}
}
};
</script>
<style lang="scss" scoped>
@import "@/assets/css/variable/color.scss";
/*IFTRUE_pay*/
@import "@/assets/css/variable/color.scss";
/*FITRUE_pay*/
.site-info-container {
margin-top: 40px !important;
margin-left: 30px;
padding-right: 30px;
padding-bottom: 30px;
@media screen and (max-width: 1005px) {
margin-left: 15px;
padding-right: 15px;
padding-bottom: 20px;
}
}
.logo-content{
font-size:0;
}
.logo {
max-width: 294px;
max-height: 55px;
}
.grey-color {
color: $font-color-grey;
}
.title {
color: #6D6D6D;
}
// 重置element
.el-button--primary {
background-color: #1878f3 !important;
border-color: #1878f3 !important;
&:hover {
opacity: 0.8;
}
}
.base-font-size {
font-size: 16px;
@media screen and (max-width: 1005px) {
font-size: 14px;
}
}
.site-info {
display: flex;
justify-content: space-between;
margin-top: 40px;
.avatar {
display: flex;
align-items: center;
.right {
margin-left: 10px;
.name {
max-width: 150px;
}
}
}
.label {
color: #6d6d6d;
}
.value {
color: $font-color-grey;
font-size: 18px;
margin-top: 2px;
}
}
.site-detail {
margin-top: 30px;
padding-bottom: 27.5px;
border-bottom: 1px solid $line-color-base;
.header {
display: flex;
justify-content: space-between;
.modify {
/*IFTRUE_default*/
color: $color-blue-base;
/*FITRUE_default*/
/*IFTRUE_pay*/
color: #1878f3;
/*IFTRUE_pay*/
cursor: pointer;
outline: none;
}
}
.content {
margin-top: 16px;
color: #000;
line-height: 24px;
::v-deep.el-textarea__inner {
font-family: inherit;
}
.el-button {
margin-top: 16px;
}
&.grey-color {
color: $font-color-grey;
}
}
}
.circlemode {
margin-top: 20px;
border-bottom: 1px solid $border-color-base;
padding-bottom: 20px;
.content {
margin-top: 14px;
margin-left: 20px;
}
}
.permission {
margin-top: 20px;
.user-detail {
display: flex;
margin-top: 16px;
.avatar {
flex: 0 0 50px;
}
.user-info {
margin-left: 15px;
.role,
.join-time {
color: $font-color-grey;
}
.name{
font-weight: bold;
}
.inline {
display: inline-block;
}
.renewal {
color: #0000bf;
cursor: pointer;
}
.permission-list {
margin-top: 15px;
.item {
display: inline-block;
font-size: 12px;
color: #777777;
background-color: #f7f7f7;
padding: 6.5px 10px;
line-height: 1;
margin-right: 10px;
margin-bottom: 10px;
border-radius: 2px;
}
}
}
}
}
::v-deep .custom-dialog {
.el-dialog__header {
font-weight: bold;
.el-dialog__title {
color: #6d6d6d;
}
}
.el-dialog__body {
padding: 0;
}
.custom-input {
textarea {
background: #f4f5f6;
border: 1px solid #dcdfe6;
border-radius: 2px;
font-family: inherit;
}
}
.dialog-main {
padding: 30px 20px 45px;
}
.dialog-footer {
background: #f5f6f7;
text-align: right;
padding: 10px 20px;
}
}
</style>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/Discuz/Discuz-Q-Web.git
git@gitee.com:Discuz/Discuz-Q-Web.git
Discuz
Discuz-Q-Web
Discuz-Q-Web
master

搜索帮助