index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <!-- @format -->
  2. <template>
  3. <view class="mine-container" :style="{ height: `${windowHeight}px` }">
  4. <view class="header-section">
  5. <view class="flex padding justify-between">
  6. <view class="flex align-center">
  7. <view v-if="!avatar" class="cu-avatar xl round bg-white">
  8. <view class="iconfont icon-people text-gray icon"></view>
  9. </view>
  10. <view v-if="!name" @click="handleToLogin" class="login-tip">
  11. 点击登录
  12. </view>
  13. <view v-if="name" @click="handleToInfo" class="user-info">
  14. <view class="u_title"> 用户名:{{ name }} </view>
  15. <view class="u_title"> 单 位: {{ userInfo.mechanism.name }} </view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="btn"><u-button v-if="isWeixin" shape="circle" type="primary"
  21. @click="showModal = true">微信用户解绑</u-button></view>
  22. <view class="btn"><u-button shape="circle" @click="handleOut" type="primary">退出登录</u-button></view>
  23. <u-modal showCancelButton cancelText="取消" @cancel="showModal = false" @close="showModal = false"
  24. confirmText="确认" @confirm="handleUnBind" :show="showModal" :title="'提示'"
  25. :content="'解除当前微信登录用户会返回登录页重新登录'"></u-modal>
  26. </view>
  27. </template>
  28. <script>
  29. import storage from "@/utils/storage";
  30. import {
  31. unBindWeixin
  32. } from "@/api/system/user";
  33. export default {
  34. data() {
  35. return {
  36. showModal: false,
  37. isWeixin: this.$store.state.user.isWeixin,
  38. name: this.$store.state.user.name,
  39. version: getApp().globalData.config.appInfo.version,
  40. userInfo: null,
  41. };
  42. },
  43. onLoad() {
  44. this.userInfo = JSON.parse(uni.getStorageSync("userInfo"));
  45. console.log(this.userInfo);
  46. },
  47. computed: {
  48. avatar() {
  49. return this.$store.state.user.avatar;
  50. },
  51. windowHeight() {
  52. return uni.getSystemInfoSync().windowHeight - 50;
  53. },
  54. },
  55. methods: {
  56. //退出登录
  57. handleOut() {
  58. this.$store.dispatch("LogOut").then((res) => {
  59. this.$tab.reLaunch("/pages/login");
  60. uni.clearStorageSync();
  61. });
  62. },
  63. //微信用户解绑
  64. async handleUnBind() {
  65. try {
  66. uni.showLoading({
  67. title: "提交中...",
  68. });
  69. let unionId = uni.getStorageSync("unionId");
  70. await unBindWeixin({
  71. unionId: unionId
  72. });
  73. uni.showToast({
  74. title: "提交成功",
  75. //显示持续时间为 2秒
  76. duration: 2000,
  77. });
  78. this.$store.dispatch("LogOut").then((res) => {
  79. this.$tab.reLaunch("/pages/login");
  80. uni.clearStorageSync();
  81. this.$store.state.user.isWeixin = false;
  82. });
  83. } catch (error) {}
  84. },
  85. handleToInfo() {
  86. this.$tab.navigateTo("/pages/mine/info/index");
  87. },
  88. handleToEditInfo() {
  89. this.$tab.navigateTo("/pages/mine/info/edit");
  90. },
  91. handleToSetting() {
  92. this.$tab.navigateTo("/pages/mine/setting/index");
  93. },
  94. handleToLogin() {
  95. this.$tab.reLaunch("/pages/login");
  96. },
  97. handleToAvatar() {
  98. this.$tab.navigateTo("/pages/mine/avatar/index");
  99. },
  100. handleLogout() {
  101. this.$modal.confirm("确定注销并退出系统吗?").then(() => {
  102. this.$store.dispatch("LogOut").then(() => {
  103. this.$tab.reLaunch("/pages/index");
  104. });
  105. });
  106. },
  107. handleHelp() {
  108. this.$tab.navigateTo("/pages/mine/help/index");
  109. },
  110. handleAbout() {
  111. this.$tab.navigateTo("/pages/mine/about/index");
  112. },
  113. handleJiaoLiuQun() {
  114. this.$modal.showToast("QQ群:①133713780、②146013835");
  115. },
  116. handleBuilding() {
  117. this.$modal.showToast("模块建设中~");
  118. },
  119. },
  120. };
  121. </script>
  122. <style lang="scss">
  123. page {
  124. background-color: #f5f6f7;
  125. }
  126. .btn {
  127. width: 90%;
  128. margin: 30rpx auto 0;
  129. }
  130. .mine-container {
  131. width: 100%;
  132. height: 100%;
  133. .header-section {
  134. padding: 15px 15px 45px 15px;
  135. background-color: #3c96f3;
  136. color: white;
  137. .login-tip {
  138. font-size: 18px;
  139. margin-left: 10px;
  140. }
  141. .cu-avatar {
  142. border: 2px solid #eaeaea;
  143. .icon {
  144. font-size: 40px;
  145. }
  146. }
  147. .user-info {
  148. margin-left: 15px;
  149. .u_title {
  150. font-size: 16px;
  151. line-height: 30px;
  152. }
  153. }
  154. }
  155. .content-section {
  156. position: relative;
  157. top: -50px;
  158. .mine-actions {
  159. margin: 15px 15px;
  160. padding: 20px 0px;
  161. border-radius: 8px;
  162. background-color: white;
  163. .action-item {
  164. .icon {
  165. font-size: 28px;
  166. }
  167. .text {
  168. display: block;
  169. font-size: 13px;
  170. margin: 8px 0px;
  171. }
  172. }
  173. }
  174. }
  175. }
  176. </style>