NavBar.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <!--
  2. * @Description:
  3. * @Author: 欧阳承珺
  4. * @LastEditors: 欧阳承珺
  5. * @Date: 2022-10-17 15:19:11
  6. * @LastEditTime: 2022-11-16 17:06:45
  7. -->
  8. <template>
  9. <div class="h-80px flex relative z-3 justify-between px-[10%] border-b-1 border-b-[#f0f0f0] border-b-solid">
  10. <div class="flex items-center ml-16px">
  11. <a href="/" title="17PDF Reader阅读器支持文件扫描和文件格式转换">
  12. <img src="http://cn-file.17pdf.com/website/index/logo_pdf_top.png"></img>
  13. </a>
  14. </div>
  15. <div class="flex justify-between">
  16. <div class="text-[#666] flex">
  17. <NuxtLink to="/converter" active-class="menu-active" class="inline-block mx-0 mt-28px md-35px hover:text-[#E93636] hover:opacity-70">格式转换</NuxtLink>
  18. <NuxtLink to="/pricing" active-class="menu-active" class="inline-block mt-28px mr-0 md-0 ml-35px hover:text-[#E93636] hover:opacity-70">订阅服务</NuxtLink>
  19. <NuxtLink to="/sdk" active-class="menu-active" class="inline-block mt-28px mr-0 md-0 ml-35px hover:text-[#E93636] hover:opacity-70">SDK介绍</NuxtLink>
  20. <NuxtLink to="/pdf-reader/download" active-class="menu-active" class="inline-block mt-28px mr-100px md-0 ml-35px hover:text-[#E93636] hover:opacity-70">下载</NuxtLink>
  21. </div>
  22. <div v-if="!!token">
  23. <client-only>
  24. <el-popover
  25. ref="popover"
  26. v-model="popover"
  27. placement="bottom"
  28. trigger="hover"
  29. :close-delay="800"
  30. >
  31. <div>
  32. <div class="px-24px pt-24px min-w-300px">
  33. <div class="flex pb-22px cursor-pointer" style="border-bottom: 1px solid #f0f0f0;">
  34. <a href="/members/me/expenses">
  35. <img v-if="userInfo?.subscriberType === 1" class="w-64px rounded-1/2" src="http://user-file.17pdf.com/avatars/2020/11/16/0577b907be980556bdafa23fb0be0732-jpg.jpg" >
  36. <img v-else class="w-64px rounded-1/2" src="http://user-file.17pdf.com/avatars/2018/01/02/f183029426a996325853fa244e7df661-jpg.jpg" >
  37. </a>
  38. <div class="pl-20px">
  39. <p class="mt-15px mb-10px text-[#333]">{{userInfo?.name}}</p>
  40. <p class="text-[#999]">{{userInfo?.email || userInfo?.phone}}</p>
  41. </div>
  42. </div>
  43. <div class="flex py-14px mt-20px justify-between">
  44. <div>
  45. <p v-if="userInfo?.subscriberType === 1" class="text-18px text-[#333] leading-24px">17会员</p>
  46. <p v-else class="text-18px text-[#333] leading-24px">免费用户</p>
  47. <p v-if="userInfo?.subscriberType === 1" class="text-12px text-[#999] leading-17px">剩余<span class="text-bg-$btn-color-primary">{{userInfo?.day}}</span>天到期</p>
  48. <p v-else class="text-12px text-[#999] leading-17px">订阅会员免费格式转换</p>
  49. </div>
  50. <button class="btn-renew" @click="$router.push('/pricing')">
  51. {{userInfo?.subscriberType === 1 ? '续费' : '订阅会员'}}
  52. </button>
  53. </div>
  54. <div class="flex py-14px my-8px justify-between" style="border-bottom: 1px solid #f0f0f0;">
  55. <div>
  56. <p class="text-18px text-[#333] leading-24px"><span class="text-500 text-bg-$btn-color-primary text-22px leading-18px tracking-1px">{{userInfo?.points}}</span><span class="text-14px text-[rgba(0,0,0,0.8)] leading-18px">/{{userInfo?.totalPoints}}</span></p>
  57. <p class="text-12px text-[#999] leading-17px">转换券</p>
  58. </div>
  59. <button class="btn-recharge" @click="handlerOpenLogin('ticket')">充值</button>
  60. </div>
  61. <div class="w-full h-64px leading-64px text-[#666] cursor-pointer hover:text-bg-$btn-color-primary" style="border-bottom: 1px solid #f0f0f0;" @click="handlerOpenLogin('manage')">
  62. 账号管理
  63. </div>
  64. <div class="w-full h-64px leading-64px text-[#666] cursor-pointer hover:text-bg-$btn-color-primary" @click="handlerLogout">
  65. 退出
  66. </div>
  67. </div>
  68. </div>
  69. <img slot="reference" class="w-36px h-36px rounded-full mt-23px mr-0 md-0 ml-90px cursor-pointer" :src="userInfo?.subscriberType === 1 ? 'http://user-file.17pdf.com/avatars/2020/11/16/0577b907be980556bdafa23fb0be0732-jpg.jpg' : 'http://user-file.17pdf.com/avatars/2018/01/02/f183029426a996325853fa244e7df661-jpg.jpg'" @click="$router.push('/members/me/expenses')" />
  70. </el-popover>
  71. </client-only>
  72. </div>
  73. <div v-if="!token" class="flex items-center">
  74. <button class="border-1 rounded-4px ml-9px text-$btn-color-primary border-$btn-color-primary border-solid w-70px h-42px leading-22px cursor-pointer hover:opacity-70" @click="handlerOpenLogin('login')">登录</button>
  75. <button class="bg-$btn-color-primary rounded-4px ml-25px text-[#fff] w-70px h-42px leading-22px cursor-pointer hover:bg-[#f34545]" @click="handlerOpenLogin('register')">注册</button>
  76. </div>
  77. </div>
  78. <client-only>
  79. <el-dialog
  80. :visible="visiable"
  81. :close-on-click-modal="false"
  82. :close-on-press-escape="false"
  83. :width="dialogWidth"
  84. append-to-body
  85. center
  86. :custom-class="interface === 'manage' ? 'manage-dialog': 'login-dialog'"
  87. @close="handlerCloseDialog"
  88. >
  89. <login v-show="interface === 'login'" ref="loginRef" @register="showChange" @close="handlerCloseDialog" @loginSucess="handleLoginSucess"></login>
  90. <register v-show="interface === 'register'" ref="registerRef" @login="showChange" @close="handlerCloseDialog" @loginSucess="handleLoginSucess"></register>
  91. <UserManage v-show="interface === 'manage'" ref="manageRef" @close="handlerCloseDialog"></UserManage>
  92. <BuyVip v-if="interface === 'vip'" ref="vipRef" @close="handlerCloseDialog"></BuyVip>
  93. <BuyTicket v-if="interface === 'ticket'" ref="ticketRef" @close="handlerCloseDialog"></BuyTicket>
  94. </el-dialog>
  95. </client-only>
  96. </div>
  97. </template>
  98. <script>
  99. import { mapState } from 'vuex'
  100. import { removeToken } from '~/utils/cookie';
  101. import login from '~/components/LoginBar.vue'
  102. import register from '~/components/RegisterBar.vue'
  103. import userManage from '~/components/UserManage.vue'
  104. import BuyVip from '~/components/BuyVip.vue'
  105. import BuyTicket from '~/components/BuyTicket.vue'
  106. export default {
  107. components: {
  108. login,
  109. register,
  110. userManage,
  111. BuyVip,
  112. BuyTicket
  113. },
  114. data() {
  115. return {
  116. dialogVisiable: false,
  117. popover: false,
  118. }
  119. },
  120. computed: {
  121. ...mapState([
  122. 'token',
  123. 'userInfo',
  124. 'globalLoginVisiable',
  125. 'globalInterfaceType'
  126. ]),
  127. visiable() {
  128. return this.dialogVisiable || this.globalLoginVisiable
  129. },
  130. interface() {
  131. return this.globalInterfaceType || 'login'
  132. },
  133. dialogWidth() {
  134. if(this.interface === 'vip') {
  135. return '512px'
  136. }else if(this.interface === 'ticket') {
  137. return '558px'
  138. }else {
  139. return '480px'
  140. }
  141. }
  142. },
  143. methods: {
  144. handleLoginSucess() {
  145. this.$nextTick(()=> {
  146. this.popover = true
  147. })
  148. setTimeout(() => {
  149. this.popover = false
  150. }, 2000);
  151. },
  152. handlerOpenLogin(type) {
  153. this.dialogVisiable = true
  154. this.$store.commit('SET_INTERFACE', type)
  155. },
  156. handlerCloseDialog() {
  157. this.dialogVisiable = false
  158. this.$store.commit('OPEN_LOGIN',false)
  159. this.$refs[`${this.interface}Ref`].resetInterfaceStatus()
  160. },
  161. // 切换弹窗界面
  162. showChange(type) {
  163. this.$store.commit('SET_INTERFACE', type)
  164. },
  165. handlerLogout() {
  166. localStorage.removeItem('token')
  167. localStorage.removeItem('userInfo')
  168. localStorage.removeItem('file')
  169. this.$store.commit('setUser', {})
  170. removeToken('Token')
  171. this.$store.commit('DEL_TOKEN', '')
  172. this.$router.push('/')
  173. },
  174. }
  175. }
  176. </script>
  177. <style lang="scss">
  178. .menu-active {
  179. color: #E93636;
  180. opacity: 0.7;
  181. }
  182. .login-dialog {
  183. position: relative;
  184. border-radius: 6px;
  185. box-shadow: 0 5px 15px rgb(0 0 0 / 50%)
  186. }
  187. .manage-dialog {
  188. position: relative;
  189. border-radius: 6px;
  190. box-shadow: 0 5px 15px rgb(0 0 0 / 50%);
  191. .el-dialog__body {
  192. padding: unset !important;
  193. }
  194. }
  195. .btn-renew {
  196. font-size: 14px;
  197. color: white;
  198. height: 36px;
  199. width: 82px;
  200. background: linear-gradient(128deg, #cca166, #edd3b0);
  201. box-shadow: 0px 2px 6px 0px rgb(219 184 137 / 57%);
  202. border-radius: 4px;
  203. font-weight: 500;
  204. }
  205. .btn-recharge {
  206. width: 82px;
  207. height: 36px;
  208. background-color: #FF4F4F;
  209. box-shadow: 0px 2px 6px rgb(255 79 79 / 20%);
  210. border: none;
  211. border-radius: 4px;
  212. color: #fff;
  213. font-size: 14px;
  214. outline: none;
  215. }
  216. </style>