enter-navigator.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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="selectContent">
  8. <view class="select_box" v-for="(item, index) in dataList" :key="index" @click="clickToItem(item, index)">
  9. {{ item }}
  10. </view>
  11. </view>
  12. <view class="userState_login" v-if="is_login == false">
  13. <view class="user_regist" @click="clickToRegist">注册</view>
  14. <view class="user_login" @click="clickToLogin">登录</view>
  15. </view>
  16. <view class="userState_logout userState_login" v-else @click="clickToLogout">退出登录</view>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. data() {
  22. return {
  23. dataList: ['首页', 'AI聊天', 'AI画图'],
  24. currenIndex: this.selectedIndex,
  25. is_login: false
  26. }
  27. },
  28. props: {
  29. selectedIndex: {
  30. type: Number,
  31. default: 0
  32. }
  33. },
  34. mounted() {
  35. this.is_login = this.tools.is_login()
  36. this.$emit('clickToIndex', this.currenIndex)
  37. let self = this
  38. uni.$on(this.config.notification.login_state_changed, function() {
  39. self.is_login = self.tools.is_login()
  40. })
  41. },
  42. onUnload() {
  43. uni.$off(this.config.notification.login_state_changed)
  44. },
  45. methods:{
  46. clickToItem(item, index) {
  47. if(this.currenIndex === index) {
  48. return
  49. }
  50. this.currenIndex = index
  51. this.$emit('clickToIndex', index)
  52. },
  53. clickToRegist() {
  54. uni.showToast({
  55. icon:'none',
  56. title:'暂时无法注册',
  57. duration:2000
  58. })
  59. },
  60. clickToLogin() {
  61. if(this.tools.is_login()) {
  62. console.log('已登录了')
  63. return
  64. }
  65. uni.navigateTo({
  66. url:'/pages/login/login'
  67. })
  68. },
  69. clickToLogout() {
  70. let self = this
  71. uni.showModal({
  72. title:'是否退出登录',
  73. success: function(res) {
  74. if(res.confirm) {
  75. self.tools.request_logout(self, (success)=>{
  76. if(success === true) {
  77. uni.showToast({
  78. title:'已退出登录',
  79. duration:2000
  80. })
  81. }
  82. })
  83. }
  84. }
  85. })
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss">
  91. .container{
  92. position: fixed;
  93. width: 100%;
  94. height: 60px;
  95. top: 0%;
  96. left: 0;
  97. background: linear-gradient(to right, #303373, #C9A391);
  98. display: flex;
  99. box-sizing: border-box;
  100. align-items: center;
  101. .robot{
  102. flex-shrink: 0;
  103. width: 48px;
  104. height: 48px;
  105. margin-left: 15px;
  106. image{
  107. width: 100%;
  108. height: 100%;
  109. }
  110. }
  111. .titleText{
  112. display: flex;
  113. margin-left: 10px;
  114. // height: 100%;
  115. font-size: 30px;
  116. font-weight: 500;
  117. color: #ffffff;
  118. }
  119. .selectContent{
  120. display: flex;
  121. flex-direction: row;
  122. height: 100%;
  123. align-items: center;
  124. .select_box{
  125. display: flex;
  126. margin-left: 40px;
  127. color: #ffffff;
  128. }
  129. }
  130. .userState_login{
  131. position: absolute;
  132. display: flex;
  133. box-sizing: border-box;
  134. height: 100%;
  135. top: 0px;
  136. right: 15px;
  137. align-items: center;
  138. .user_regist{
  139. display: flex;
  140. width: 65px;
  141. height: 28px;
  142. border-radius: 28px;
  143. font-size: 16px;
  144. color: #878787;
  145. background-color: #ffffff;
  146. justify-content: center;
  147. align-items: center;
  148. }
  149. .user_login{
  150. display: flex;
  151. width: 65px;
  152. height: 28px;
  153. border-radius: 28px;
  154. font-size: 16px;
  155. color: #ffffff;
  156. background-color: #4C9CF1;
  157. justify-content: center;
  158. align-items: center;
  159. margin-left: 15px;
  160. }
  161. }
  162. .userState_logout{
  163. width: 145px;
  164. color: #ffffff;
  165. font-size: 18px;
  166. justify-content: center;
  167. }
  168. }
  169. </style>