index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="user-content">
  3. <view class="status_bar">
  4. <!-- 这里是状态栏 -->
  5. </view>
  6. <!-- 头部 -->
  7. <view class="user-head" :style="`background:${$config('primaryColor')}`">
  8. <view class="user-photo">
  9. <u-avatar :src="userAvatarUrl" size="100" class="avatar"></u-avatar>
  10. </view>
  11. <view class="user-info">
  12. <text class="user-name">{{$store.state.vuex_userData.userNameCN}}</text>
  13. <text class="user-phone">{{$store.state.vuex_userData.username}}</text>
  14. </view>
  15. </view>
  16. <!-- 列表 -->
  17. <view class="user-list">
  18. <u-cell-group>
  19. <u-cell-item icon="file-text" icon-size="40" :icon-style="{color:'#ffaa00'}" index="0" @click="toPage(0)" title="服务协议及隐私政策"></u-cell-item>
  20. <!-- <u-cell-item icon="info-circle" icon-size="38" :icon-style="{color:'#55aa00'}" index="1" @click="toPage" title="关于我们"></u-cell-item> -->
  21. <u-cell-item icon="lock" icon-size="38" :icon-style="{color:'#00aaff'}" index="2" @click="toPage(1)" title="修改密码"></u-cell-item>
  22. </u-cell-group>
  23. </view>
  24. <!-- 退出 -->
  25. <view class="user-btn">
  26. <u-button type="success" :custom-style="{background:$config('infoColor')}" hover-class="none" @click="quitOutSys" shape="circle">退出登录</u-button>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { getUserInfo, logout } from '@/api/user.js'
  32. import { getSysVersion } from '@/api/data.js'
  33. import { checkVersionToLoadUpdate, clzConfirm } from '@/libs/tools';
  34. import market from "@/js_sdk/dc-market/market.js"
  35. export default {
  36. data() {
  37. return {
  38. userInfoData: null, // 用户信息
  39. userAvatarUrl: '' // 用户头像
  40. };
  41. },
  42. onShow() {
  43. this.getUserInfo()
  44. },
  45. onLoad() {
  46. uni.setNavigationBarColor({
  47. frontColor: '#ffffff',
  48. backgroundColor: this.$config('primaryColor')
  49. })
  50. },
  51. methods:{
  52. // 获取用户信息
  53. getUserInfo(){
  54. console.log(this.$store.state.vuex_userData)
  55. // getUserInfo().then(res => {
  56. // if(res.status == 200){
  57. // this.userInfoData = res.data
  58. // }else{
  59. // this.userInfoData = null
  60. // }
  61. // })
  62. },
  63. // 打开对应的页面
  64. toPage(index){
  65. let pageUrl=[
  66. '/pages/login/userAuthYs?fromPage=usercenter',
  67. '/pages/userCenter/changePwd'
  68. ]
  69. uni.navigateTo({
  70. url: pageUrl[index]
  71. })
  72. },
  73. // 退出登录确认弹框
  74. quitOutSys() {
  75. const _this = this;
  76. clzConfirm({
  77. title: '提示',
  78. content: '确定退出登录?',
  79. success: function(res) {
  80. if (res.confirm || res.index == 0) {
  81. _this.quitSys();
  82. }
  83. }
  84. });
  85. },
  86. // 退出登录,返回登录页
  87. quitSys() {
  88. logout().then(res => {
  89. console.log(res);
  90. if (res.status == 200) {
  91. // this.$store.commit("$closeWebsocket")
  92. this.$store.state.vuex_token = '';
  93. this.$store.state.vuex_userData = '';
  94. uni.setStorageSync('setStatusIndexFunc', 0);
  95. setTimeout(function() {
  96. uni.reLaunch({
  97. url: '/pages/login/login'
  98. });
  99. }, 500);
  100. }
  101. });
  102. },
  103. // 获取最新版本信息
  104. getVersion() {
  105. let version = getApp().globalData.version
  106. console.log(version)
  107. getSysVersion({versionType:version.platform=='android'?'ANDROID':'IOS'}).then(ret => {
  108. console.log(JSON.stringify(ret))
  109. if(ret.status == 200){
  110. console.log(ret.data)
  111. this.$store.state.vuex_versionInfo = ret.data
  112. //进行版本型号的比对 以及下载更新请求
  113. checkVersionToLoadUpdate(ret.data, 1, market);
  114. }
  115. })
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss">
  121. .user-content{
  122. width: 100%;
  123. .user-head{
  124. display: flex;
  125. align-items: center;
  126. padding: 80rpx 35rpx;
  127. .user-photo{
  128. flex-shrink: 0;
  129. margin-right: 5rpx;
  130. }
  131. .user-info{
  132. flex-grow: 1;
  133. padding: 0 20rpx;
  134. color: #FFFFFF;
  135. .user-name{
  136. display: block;
  137. font-size: 36rpx;
  138. margin-bottom: 10rpx;
  139. }
  140. .user-phone{
  141. display: block;
  142. font-size: 28rpx;
  143. }
  144. }
  145. }
  146. .user-list{
  147. border-radius: 15upx;
  148. margin: 20upx;
  149. overflow: hidden;
  150. box-shadow: 0upx 3upx 6upx #eee;
  151. }
  152. .user-btn{
  153. padding: 85rpx 200rpx;
  154. }
  155. }
  156. </style>