index.vue 3.9 KB

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