index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="mine-container" :style="'background: url('+this.imgUrl+'/index/mingbg.png) no-repeat 100% 100%;height:'+windowHeight+'px;background-position: 0 0;background-size: 100% 100%;'">
  3. <view style="position: fixed;right: 10px;z-index: 999999;top:30px" @click="changeLocale">
  4. {{ $t('login.language') }}:{{localeConfig[locale]}}<uni-icons type="gear" size="15"></uni-icons>
  5. </view>
  6. <!--顶部个人信息栏-->
  7. <view class="header-section">
  8. <view class="flex padding justify-between">
  9. <view class="flex align-center">
  10. <view v-if="!avatar" class="cu-avatar xl round bg-white">
  11. <view class="iconfont icon-people text-gray icon"></view>
  12. </view>
  13. <image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix">
  14. </image>
  15. <view v-if="!name" @click="handleToLogin" class="login-tip">
  16. {{ i18('点击登录')}}
  17. </view>
  18. <view v-if="name" @click="handleToInfo" class="user-info">
  19. <view class="u_title" style="color: #8E8E8E">
  20. {{ i18('你好')}}!
  21. </view>
  22. <view class="u_title">
  23. {{ name }}
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="menu-list">
  30. <view class="list-cell list-cell-arrow" @click="handleToEditInfo">
  31. <view class="menu-item-box">
  32. <image :src="this.imgUrl+'/index/settingicon.png'" style="width: 18px;height: 18px;margin-right:5px"></image>
  33. <view class="menu-text"> {{ i18('账户设置')}}</view>
  34. </view>
  35. </view>
  36. <view class="list-cell list-cell-arrow" @click="handleAbout">
  37. <view class="menu-item-box">
  38. <image :src="this.imgUrl+'/index/chargeicon.png'" style="width: 18px;height: 18px;margin-right:5px"></image>
  39. <view class="menu-text">{{ i18('充电记录')}}</view>
  40. </view>
  41. </view>
  42. <view class="list-cell list-cell-arrow" @click="handleToSetting">
  43. <view class="menu-item-box">
  44. <image :src="this.imgUrl+'/index/planicon.png'" style="width: 18px;height: 18px;margin-right:5px"></image>
  45. <view class="menu-text">{{ i18('预约记录')}}</view>
  46. </view>
  47. </view>
  48. </view>
  49. <u-picker @cancel="cancelLocale" :show="showLocale" keyName="label" :columns="localeList" @confirm="changeLanguage"></u-picker>
  50. </view>
  51. </template>
  52. <script>
  53. import storage from '@/utils/storage'
  54. import i18 from '@/utils/i18.js'
  55. export default {
  56. data() {
  57. return {
  58. showLocale:false,
  59. locale:"",
  60. localeList:[[{"label":"简体中文","id":"zh-Hans"},{"label":"英文","id":"en"}]],
  61. localeConfig:{"zh-Hans":"简体中文","en":"英文"},
  62. name: this.$store.state.user.name,
  63. version: getApp().globalData.config.appInfo.version,
  64. imgUrl:getApp().globalData.config.imgUrl
  65. }
  66. },
  67. computed: {
  68. avatar() {
  69. return getApp().globalData.config.imgUrl+"/index/user.png"
  70. },
  71. windowHeight() {
  72. return uni.getSystemInfoSync().windowHeight - 50
  73. }
  74. },
  75. onLoad(){
  76. this.setLocale();
  77. },
  78. onShow(){
  79. uni.setNavigationBarTitle({
  80. title: this.$t('page.mine')
  81. })
  82. },
  83. methods: {
  84. cancelLocale(){
  85. this.showLocale = false;
  86. },
  87. changeLanguage(e){
  88. this.showLocale =false;
  89. console.log(e.value[0].id)
  90. uni.setLocale(e.value[0].id);
  91. },
  92. changeLocale(){
  93. this.showLocale = true;
  94. },
  95. setLocale(){
  96. this.locale = uni.getLocale()
  97. if(this.locale == "en"){
  98. this.localeList = [[{"label":"Chinese","id":"zh-Hans"},{"label":"English","id":"en"}]];
  99. this.localeConfig={"zh-Hans":"Chinese","en":"English"};
  100. }else if(this.locale == "zh-Hans"){
  101. this.localeList = [[{"label":"简体中文","id":"zh-Hans"},{"label":"英文","id":"en"}]];
  102. this.localeConfig={"zh-Hans":"简体中文","en":"英文"};
  103. }
  104. },
  105. i18(text){
  106. return i18(text)
  107. },
  108. handleToEditInfo() {
  109. this.$tab.navigateTo('/pages/mine/pwd/index')
  110. },
  111. handleToSetting() {
  112. this.$tab.navigateTo('/pages/weitiandi/device/planrecord')
  113. },
  114. handleToLogin() {
  115. this.$tab.reLaunch('/pages/login')
  116. },
  117. handleLogout() {
  118. this.$modal.confirm('确定注销并退出系统吗?').then(() => {
  119. this.$store.dispatch('LogOut').then(() => {
  120. this.$tab.reLaunch('/pages/index')
  121. })
  122. })
  123. },
  124. handleAbout() {
  125. this.$tab.navigateTo('/pages/weitiandi/device/chargerecord')
  126. },
  127. }
  128. }
  129. </script>
  130. <style lang="scss">
  131. page {
  132. background-color: #f5f6f7;
  133. }
  134. .mine-container {
  135. width: 100%;
  136. height: 100%;
  137. .header-section {
  138. padding: 15px 15px 45px 15px;
  139. color: white;
  140. .login-tip {
  141. font-size: 18px;
  142. margin-left: 10px;
  143. }
  144. .cu-avatar {
  145. border: 2px solid #eaeaea;
  146. .icon {
  147. font-size: 40px;
  148. }
  149. }
  150. .user-info {
  151. margin-left: 15px;
  152. .u_title {
  153. font-size: 18px;
  154. line-height: 30px;
  155. color: #000000;
  156. }
  157. }
  158. }
  159. .content-section {
  160. position: relative;
  161. top: -50px;
  162. .mine-actions {
  163. margin: 15px 15px;
  164. padding: 20px 0px;
  165. border-radius: 8px;
  166. .action-item {
  167. .icon {
  168. font-size: 28px;
  169. }
  170. .text {
  171. display: block;
  172. font-size: 13px;
  173. margin: 8px 0px;
  174. }
  175. }
  176. }
  177. }
  178. }
  179. .menu-list{
  180. box-shadow: 0px 2px 24px 0px rgba(0,0,0,0.06);
  181. border-radius: 20px;
  182. }
  183. .list-cell{
  184. padding:17px 15px;
  185. }
  186. .menu-text{
  187. color:#555555
  188. }
  189. </style>