enter-navigator.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view class="container">
  3. <view class="robot">
  4. <image src="../../static/nav_robot.png" mode="aspectFit"></image>
  5. </view>
  6. <view class="titleText">SmartAssistant</view>
  7. <view class="navigatorContent">
  8. <view class="navigator_box" v-for="(item, index) in dataList" :key="index" @click="clickToItem(item, index)">
  9. <text class="navigator_box_selected" v-if="currenIndex == index" >
  10. {{ item.t }}
  11. </text>
  12. <view class="navigator_box_selected_line" v-if="currenIndex == index"></view>
  13. <text class="navigator_box_normal" v-else>{{ item.t }}</text>
  14. </view>
  15. </view>
  16. <view class="userState_login" v-if="is_login == false">
  17. <view class="user_regist" @click="clickToRegist">注册</view>
  18. <view class="user_login" @click="clickToLogin">登录</view>
  19. </view>
  20. <view class="userState_logout userState_login" v-else @click="clickToLogout">退出登录</view>
  21. </view>
  22. </template>
  23. <script>
  24. import { nextTick } from "vue"
  25. export default {
  26. data() {
  27. return {
  28. dataList: [{'t': '首页'},{'t': 'AI聊天'},{'t': 'AI画图'}],
  29. currenIndex: this.selectedIndex,
  30. is_login: false
  31. }
  32. },
  33. props: {
  34. selectedIndex: {
  35. type: Number,
  36. default: 0
  37. }
  38. },
  39. watch: {
  40. selectedIndex: {
  41. handler(newVal) {
  42. this.currenIndex = newVal
  43. },
  44. immediate: true
  45. },
  46. },
  47. mounted() {
  48. this.is_login = this.tools.is_login()
  49. this.$emit('clickToIndex', this.currenIndex)
  50. let self = this
  51. uni.$on(this.config.notification.login_state_changed, function() {
  52. self.is_login = self.tools.is_login()
  53. })
  54. },
  55. onUnload() {
  56. uni.$off(this.config.notification.login_state_changed)
  57. },
  58. methods:{
  59. clickToItem(item, index) {
  60. if(this.currenIndex === index) {
  61. return
  62. }
  63. this.$emit('clickToIndex', index)
  64. },
  65. clickToRegist() {
  66. uni.showToast({
  67. icon:'none',
  68. title:'暂时无法注册',
  69. duration:2000
  70. })
  71. },
  72. clickToLogin() {
  73. if(this.tools.is_login()) {
  74. console.log('已登录了')
  75. return
  76. }
  77. uni.navigateTo({
  78. url:'/pages/login/login'
  79. })
  80. },
  81. clickToLogout() {
  82. let self = this
  83. uni.showModal({
  84. content:'是否退出登录?',
  85. success: function(res) {
  86. if(res.confirm) {
  87. self.tools.request_logout(self, (success)=>{
  88. if(success === true) {
  89. uni.showToast({
  90. title:'已退出登录',
  91. duration:2000
  92. })
  93. }
  94. })
  95. }
  96. }
  97. })
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss">
  103. .container{
  104. position: fixed;
  105. z-index: 100;
  106. width: 100%;
  107. height: 60px;
  108. top: 0%;
  109. left: 0;
  110. background: linear-gradient(to right, #303373, #C9A391);
  111. display: flex;
  112. box-sizing: border-box;
  113. align-items: center;
  114. .robot{
  115. flex-shrink: 0;
  116. width: 4%; // 48px;
  117. height: 90%; // 48px;
  118. margin-left: 2%; // 15px;
  119. image{
  120. width: 100%;
  121. height: 100%;
  122. }
  123. }
  124. .titleText{
  125. display: flex;
  126. margin-left: 1%; //10px;
  127. font-size: 3vw; // 30px
  128. font-weight: 500;
  129. color: #ffffff;
  130. }
  131. .navigatorContent{
  132. display: flex;
  133. flex-direction: row;
  134. height: 100%;
  135. align-items: center;
  136. .navigator_box{
  137. position: relative;
  138. display: flex;
  139. margin-left: 3vw; //30px;
  140. // width: 80px;
  141. // height: 67px;
  142. justify-content: center;
  143. align-items: center;
  144. font-size: 2.5vw; //20px;
  145. .navigator_box_normal{
  146. color: #ffffff;
  147. }
  148. .navigator_box_selected{
  149. color: #B34FFF;
  150. background: linear-gradient(90deg, #24BF74 10%, #FAEE07 90%);
  151. -webkit-background-clip: text;
  152. -webkit-text-fill-color: transparent;
  153. }
  154. .navigator_box_selected_line {
  155. position: absolute;
  156. bottom: -0.3vw;
  157. width: 100%;
  158. height: 1.5px;
  159. background: linear-gradient(90deg, #24BF74 10%, #FAEE07 90%);
  160. }
  161. }
  162. }
  163. .userState_login{
  164. position: absolute;
  165. display: flex;
  166. box-sizing: border-box;
  167. width: 20%;
  168. height: 100%;
  169. top: 0px;
  170. right: 15px;
  171. align-items: center;
  172. .user_regist{
  173. display: flex;
  174. width: 47%; //65px;
  175. height: 50%; //28px;
  176. border-radius: 5vw; //28px;
  177. font-size: 1.5vw; //16px;
  178. color: #878787;
  179. background-color: #ffffff;
  180. justify-content: center;
  181. align-items: center;
  182. }
  183. .user_login{
  184. display: flex;
  185. width: 47%; //65px;
  186. height: 50%; //28px;
  187. border-radius: 5vw; //28px;
  188. // border-radius: 28px;
  189. font-size: 1.5vw; //16px;
  190. color: #ffffff;
  191. background-color: #4C9CF1;
  192. justify-content: center;
  193. align-items: center;
  194. margin-left: 6%; //15px;
  195. }
  196. }
  197. .userState_logout{
  198. // width: 145px;
  199. color: #ffffff;
  200. font-size: 2vw; //18px;
  201. justify-content: center;
  202. }
  203. }
  204. </style>