index.vue 4.3 KB

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