index.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <el-button v-bind="$attrs" @click="handleClick"><slot /></el-button>
  3. </template>
  4. <script>
  5. export default {
  6. name: 'PermissionButton',
  7. data() {
  8. return {
  9. hasPermission: true
  10. }
  11. },
  12. methods: {
  13. handleClick($event) {
  14. const { freeUseFlag, vipStatus } = this.$store.getters.vipInfo
  15. // (已过期 or 非会员) and 非试用期
  16. this.hasPermission = !((vipStatus === 0 || vipStatus === 3) && freeUseFlag === 0)
  17. if (this.hasPermission) {
  18. this.$emit('click', $event)
  19. } else {
  20. this.$confirm('对不起,您的会员账号已到期,请尽快续费,以免影响正常使用!', '提示', {
  21. confirmButtonText: '开通会员',
  22. cancelButtonText: '取消'
  23. })
  24. .then(() => {
  25. // jumpAction()
  26. // console.log('开通会员')
  27. this.$router.push('/vip/vip-open')
  28. })
  29. .catch(() => {
  30. this.$message({
  31. type: 'info',
  32. message: '已取消操作'
  33. })
  34. })
  35. }
  36. }
  37. }
  38. }
  39. </script>