index.vue 5.6 KB

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