index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="main">
  3. <view class="user" @click="go('/pages/user/info')">
  4. <image :src="user.avatarUrl ? user.avatarUrl : '../../static/favicon.png'" class="head"></image>
  5. <view class="con" v-if="user.id">
  6. <view class="nickName">微信用户</view>
  7. <view class="welcome">欢迎使用承揽时代</view>
  8. </view>
  9. <view class="con" v-else>
  10. <view class="nickName">你还没登录</view>
  11. <view class="welcome">欢迎使用承揽时代</view>
  12. </view>
  13. <view class="icon">&#xe62b;</view>
  14. </view>
  15. <view class="cmd">
  16. <view class="s_item" @click="go('auth')">
  17. <text class="icon ic">&#xe600;</text>
  18. <text class="title">我的认证</text>
  19. <text class="icon arrow">&#xe62b;</text>
  20. </view>
  21. <view class="s_item" @click="go('contract')">
  22. <text class="icon ic">&#xe6ed;</text>
  23. <text class="title">我的签约</text>
  24. <text class="icon arrow">&#xe62b;</text>
  25. </view>
  26. <view class="s_item" @click="go('company')">
  27. <text class="icon ic">&#xe623;</text>
  28. <text class="title">关联企业</text>
  29. <text class="icon arrow">&#xe62b;</text>
  30. </view>
  31. <view class="s_item" @click="go('packages')">
  32. <text class="icon ic">&#xe604;</text>
  33. <text class="title">我的接包</text>
  34. <text class="icon arrow">&#xe62b;</text>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. ip: this.http.ip,
  44. user: {}
  45. };
  46. },
  47. onShow() {
  48. /* this.user = {
  49. token: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjI2NTFjMmU4LTAxNzEtNDQwYS04YjA2LTcwOWI3N2ZhNGZiZCJ9.zb2gQaeHZApJkbo4LoSeZfnVVsJJ-QabY7FnsVn13Kf1KUgKeBQ82bwhzD-CqchI1dhUOQFoVh__zeJaJHFWGg'
  50. };
  51. uni.setStorageSync('user', this.user); */
  52. if (this.hasLogin()) {
  53. this.getUserInfo();
  54. }
  55. },
  56. methods: {
  57. getUserInfo() {
  58. this.http.request({
  59. url: '/app/user/info',
  60. success: (res) => {
  61. this.user = res.data.data;
  62. }
  63. });
  64. },
  65. go(url) {
  66. if (this.hasLogin()) {
  67. if (url == 'auth') {
  68. uni.navigateTo({ url: '/pages/auth/index' });
  69. }
  70. if (url == 'company' && this.user.isAuthentication === 1) {
  71. uni.navigateTo({ url: '/pages/company/index' });
  72. }
  73. if (url == 'packages' && this.user.isCompany > 0 && this.user.isContract == 1) {
  74. uni.switchTab({ url: '/pages/packages/index' });
  75. }
  76. if (url == 'contract' && this.user.isContract == 1) {
  77. this.look();
  78. }
  79. } else {
  80. uni.navigateTo({ url: '/pages/user/login' });
  81. }
  82. },
  83. //查看合同
  84. look() {
  85. uni.downloadFile({
  86. url: this.user.isContract == 0 ? this.ip + this.contract.url : this.ip + '/app/contract/look',
  87. header: { Authorization: this.getUser().token },
  88. success: (res) => {
  89. uni.openDocument({
  90. filePath: res.tempFilePath,
  91. showMenu: true,
  92. success: (res) => {}
  93. });
  94. }
  95. });
  96. },
  97. //退出登录
  98. exit(url) {
  99. uni.showModal({
  100. title: '提示',
  101. content: '确定退出登录?',
  102. success: (res) => {
  103. if (res.confirm) {
  104. this.http.request({
  105. url: this.http.urls.logout,
  106. success: (res) => {
  107. uni.removeStorageSync('user');
  108. uni.$emit('top');
  109. uni.switchTab({
  110. url: '/pages/index/index'
  111. });
  112. }
  113. });
  114. }
  115. }
  116. });
  117. }
  118. }
  119. };
  120. </script>
  121. <style lang="scss">
  122. .main {
  123. padding: 20px;
  124. }
  125. .user {
  126. overflow: hidden;
  127. image {
  128. float: left;
  129. width: 60px;
  130. height: 60px;
  131. border-radius: 50%;
  132. }
  133. .con {
  134. float: left;
  135. padding-left: 15px;
  136. .nickName {
  137. padding-top: 5px;
  138. }
  139. .welcome {
  140. font-size: 13px;
  141. padding-top: 5px;
  142. color: #989898;
  143. }
  144. }
  145. .icon {
  146. float: right;
  147. margin-top: 14px;
  148. }
  149. }
  150. .exit {
  151. width: 40%;
  152. margin-top: 20px;
  153. }
  154. </style>