index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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">用户名</text>
  13. <text class="user-phone">15785829632</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('primaryColor')}" @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. getUserInfo().then(res => {
  55. if(res.status == 200){
  56. this.userInfoData = res.data
  57. }else{
  58. this.userInfoData = null
  59. }
  60. })
  61. },
  62. // 打开对应的页面
  63. toPage(index){
  64. let pageUrl=[
  65. '/pages/login/userAuthYs?fromPage=usercenter',
  66. '/pages/userCenter/changePwd'
  67. ]
  68. uni.navigateTo({
  69. url: pageUrl[index]
  70. })
  71. },
  72. // 退出登录确认弹框
  73. quitOutSys() {
  74. const _this = this;
  75. clzConfirm({
  76. title: '提示',
  77. content: '确定退出登录?',
  78. success: function(res) {
  79. if (res.confirm || res.index == 0) {
  80. _this.quitSys();
  81. }
  82. }
  83. });
  84. },
  85. // 退出登录,返回登录页
  86. quitSys() {
  87. logout().then(res => {
  88. console.log(res);
  89. if (res.status == 200) {
  90. // this.$store.commit("$closeWebsocket")
  91. this.$store.state.vuex_token = '';
  92. this.$store.state.vuex_userData = '';
  93. uni.setStorageSync('setStatusIndexFunc', 0);
  94. setTimeout(function() {
  95. uni.reLaunch({
  96. url: '/pages/login/login'
  97. });
  98. }, 500);
  99. }
  100. });
  101. },
  102. // 获取最新版本信息
  103. getVersion() {
  104. let version = getApp().globalData.version
  105. console.log(version)
  106. getSysVersion({versionType:version.platform=='android'?'ANDROID':'IOS'}).then(ret => {
  107. console.log(JSON.stringify(ret))
  108. if(ret.status == 200){
  109. console.log(ret.data)
  110. this.$store.state.vuex_versionInfo = ret.data
  111. //进行版本型号的比对 以及下载更新请求
  112. checkVersionToLoadUpdate(ret.data, 1, market);
  113. }
  114. })
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss">
  120. .user-content{
  121. width: 100%;
  122. .user-head{
  123. display: flex;
  124. align-items: center;
  125. padding: 80rpx 35rpx;
  126. .user-photo{
  127. flex-shrink: 0;
  128. margin-right: 5rpx;
  129. }
  130. .user-info{
  131. flex-grow: 1;
  132. padding: 0 20rpx;
  133. color: #FFFFFF;
  134. .user-name{
  135. display: block;
  136. font-size: 36rpx;
  137. margin-bottom: 10rpx;
  138. }
  139. .user-phone{
  140. display: block;
  141. font-size: 28rpx;
  142. }
  143. }
  144. }
  145. .user-list{
  146. border-radius: 15upx;
  147. margin: 20upx;
  148. overflow: hidden;
  149. box-shadow: 0upx 3upx 6upx #eee;
  150. }
  151. .user-btn{
  152. padding: 85rpx 200rpx;
  153. }
  154. }
  155. </style>