NavBar.vue 8.7 KB

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