index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view class="user-content">
  3. <!-- 头部 -->
  4. <view class="user-head" >
  5. <view class="user-photo">
  6. <open-data type="userAvatarUrl"></open-data>
  7. <u-image v-show="!hasLogin" src="/static/logo.png" width="100" height="100"></u-image>
  8. </view>
  9. <view class="user-info">
  10. <!-- <view v-if="hasLogin" class="user-info-item">{{userData.stationName || ''}}</view> -->
  11. <view v-if="hasLogin" class="user-info-item">hjh更合适的股份回购和股市的发挥上的飞机合计亏损幅度</view>
  12. <view v-if="hasLogin" class="user-info-item">{{userData.gatherName||''}} {{userData.gatherPhone || ''}}</view>
  13. <u-button v-else="!hasLogin" plain size="mini" shape="circle" @click="toLoginPage">立即登录</u-button>
  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" title="服务协议及隐私政策"></u-cell-item>
  20. <u-cell-item v-if="hasLogin" icon="lock" icon-size="38" :icon-style="{color:'#00aaff'}" index="1" @click="toPage" title="修改密码"></u-cell-item>
  21. </u-cell-group>
  22. </view>
  23. <view class="user-list quit">
  24. <u-cell-group>
  25. <u-cell-item v-if="hasLogin" icon="minus-circle" icon-size="40" index="3" @click="quitSys" title="退出登录"></u-cell-item>
  26. </u-cell-group>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { checkLogin, getUserInfo, logout } from '@/api/login.js'
  32. export default {
  33. data() {
  34. return {
  35. hasLogin: false,
  36. userData: {},
  37. };
  38. },
  39. onShow() {
  40. checkLogin().then(res => {
  41. this.hasLogin = res.status == 200
  42. console.log(this.hasLogin,res,'this.hasLogin')
  43. if(this.hasLogin){
  44. this.getUserInfo()
  45. }else{
  46. // uni.navigateTo({
  47. // url:"/pages/login/login"
  48. // })
  49. }
  50. })
  51. },
  52. computed: {
  53. user() {
  54. return this.userData
  55. }
  56. },
  57. onLoad() {
  58. // 开启分享
  59. uni.showShareMenu({
  60. withShareTicket: true,
  61. menus: ['shareAppMessage', 'shareTimeline']
  62. })
  63. },
  64. methods:{
  65. // 获取用户信息
  66. getUserInfo(){
  67. getUserInfo().then(res => {
  68. console.log(res,'getUserInfo')
  69. if(res.status == 200){
  70. this.$u.vuex("vuex_userData",res.data)
  71. this.userData = res.data
  72. console.log(this.userData,'-----用户信息')
  73. }
  74. })
  75. },
  76. // 打开对应的页面
  77. toPage(index){
  78. console.log(index)
  79. let pageUrl=[
  80. '/pages/agreement/agreement?fromPage=usercenter',
  81. '/pages/userCenter/changePwd',
  82. ]
  83. uni.navigateTo({
  84. url: pageUrl[index]
  85. })
  86. },
  87. // 退出登录
  88. quitSys(){
  89. let _this = this
  90. uni.showModal({
  91. title: '提示',
  92. content: '您确定要退出登录吗?',
  93. success(res) {
  94. if (res.confirm) {
  95. logout().then(res => {
  96. console.log(res,'logout')
  97. getApp().globalData.token = ''
  98. _this.$u.vuex('vuex_token','')
  99. // 关闭socket
  100. uni.reLaunch({
  101. url: '/pages/login/login'
  102. })
  103. })
  104. }
  105. }
  106. })
  107. },
  108. toLoginPage(){
  109. uni.navigateTo({
  110. url: '/pages/login/login'
  111. })
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="scss">
  117. .user-content{
  118. width: 100%;
  119. .user-head{
  120. background: #0DC55F;
  121. display: flex;
  122. align-items: center;
  123. padding: 35rpx 55rpx;
  124. .user-info{
  125. flex-grow: 1;
  126. padding: 0 20rpx;
  127. color: #FFFFFF;
  128. .user-info-item{
  129. margin: 10rpx 0;
  130. :first-child{
  131. font-size: 34upx;
  132. }
  133. }
  134. }
  135. .user-photo{
  136. width: 100rpx;
  137. height: 100rpx;
  138. border-radius: 50%;
  139. overflow: hidden;
  140. margin-right: 5rpx;
  141. }
  142. }
  143. .my-ledou{
  144. background: #FFFFFF;
  145. border-radius: 15upx;
  146. display: flex;
  147. align-items: center;
  148. justify-content: space-between;
  149. padding: 20upx;
  150. margin: 20upx;
  151. box-shadow: 0upx 3upx 6upx #eee;
  152. .user-jifen{
  153. display: flex;
  154. align-items: center;
  155. text{
  156. font-size: 40upx;
  157. font-weight: bold;
  158. color: red;
  159. }
  160. >view{
  161. &:first-child{
  162. display: flex;
  163. align-items: center;
  164. }
  165. }
  166. }
  167. }
  168. .user-list{
  169. border-radius: 15upx;
  170. margin: 20upx;
  171. overflow: hidden;
  172. box-shadow: 0upx 3upx 6upx #eee;
  173. .quit{
  174. margin-top: 20upx;
  175. }
  176. }
  177. .user-btn{
  178. padding: 85rpx 200rpx;
  179. }
  180. }
  181. </style>