index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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="mine-actions grid col-4 text-center">
  34. <view class="action-item" @click="handleJiaoLiuQun">
  35. <view class="iconfont icon-friendfill text-pink icon"></view>
  36. <text class="text">交流群</text>
  37. </view>
  38. <view class="action-item" @click="handleBuilding">
  39. <view class="iconfont icon-service text-blue icon"></view>
  40. <text class="text">在线客服</text>
  41. </view>
  42. <view class="action-item" @click="handleBuilding">
  43. <view class="iconfont icon-community text-mauve icon"></view>
  44. <text class="text">反馈社区</text>
  45. </view>
  46. <view class="action-item" @click="handleBuilding">
  47. <view class="iconfont icon-dianzan text-green icon"></view>
  48. <text class="text">点赞我们</text>
  49. </view>
  50. </view> -->
  51. <!-- <view class="menu-list">
  52. <view class="list-cell list-cell-arrow" @click="handleToEditInfo">
  53. <view class="menu-item-box">
  54. <view class="iconfont icon-user menu-icon"></view>
  55. <view>编辑资料</view>
  56. </view>
  57. </view>
  58. <view class="list-cell list-cell-arrow" @click="handleHelp">
  59. <view class="menu-item-box">
  60. <view class="iconfont icon-help menu-icon"></view>
  61. <view>常见问题</view>
  62. </view>
  63. </view>
  64. <view class="list-cell list-cell-arrow" @click="handleAbout">
  65. <view class="menu-item-box">
  66. <view class="iconfont icon-aixin menu-icon"></view>
  67. <view>关于我们</view>
  68. </view>
  69. </view>
  70. <view class="list-cell list-cell-arrow" @click="handleToSetting">
  71. <view class="menu-item-box">
  72. <view class="iconfont icon-setting menu-icon"></view>
  73. <view>应用设置</view>
  74. </view>
  75. </view>
  76. </view> -->
  77. </view>
  78. <view class="btn"
  79. ><u-button
  80. v-if="isWeixin"
  81. shape="circle"
  82. type="primary"
  83. @click="showModal = true"
  84. >微信用户解绑</u-button
  85. ></view
  86. >
  87. <u-modal
  88. showCancelButton
  89. cancelText="取消"
  90. @cancel="showModal = false"
  91. @close="showModal = false"
  92. confirmText="确认"
  93. @confirm="handleUnBind"
  94. :show="showModal"
  95. :title="'提示'"
  96. :content="'解除当前微信登录用户会返回登录页重新登录'"
  97. ></u-modal>
  98. </view>
  99. </template>
  100. <script>
  101. import storage from "@/utils/storage";
  102. import { unBindWeixin } from "@/api/system/user";
  103. export default {
  104. data() {
  105. return {
  106. showModal: false,
  107. isWeixin: this.$store.state.user.isWeixin,
  108. name: this.$store.state.user.name,
  109. version: getApp().globalData.config.appInfo.version,
  110. };
  111. },
  112. computed: {
  113. avatar() {
  114. return this.$store.state.user.avatar;
  115. },
  116. windowHeight() {
  117. return uni.getSystemInfoSync().windowHeight - 50;
  118. },
  119. },
  120. methods: {
  121. //微信用户解绑
  122. async handleUnBind() {
  123. try {
  124. uni.showLoading({
  125. title: "提交中...",
  126. });
  127. let unionId = uni.getStorageSync("unionId");
  128. await unBindWeixin({ unionId: unionId });
  129. uni.showToast({
  130. title: "提交成功",
  131. //显示持续时间为 2秒
  132. duration: 2000,
  133. });
  134. this.$store.dispatch("LogOut").then((res) => {
  135. this.$tab.reLaunch("/pages/login");
  136. uni.clearStorageSync();
  137. this.$store.state.user.isWeixin = false;
  138. });
  139. } catch (error) {}
  140. },
  141. handleToInfo() {
  142. this.$tab.navigateTo("/pages/mine/info/index");
  143. },
  144. handleToEditInfo() {
  145. this.$tab.navigateTo("/pages/mine/info/edit");
  146. },
  147. handleToSetting() {
  148. this.$tab.navigateTo("/pages/mine/setting/index");
  149. },
  150. handleToLogin() {
  151. this.$tab.reLaunch("/pages/login");
  152. },
  153. handleToAvatar() {
  154. this.$tab.navigateTo("/pages/mine/avatar/index");
  155. },
  156. handleLogout() {
  157. this.$modal.confirm("确定注销并退出系统吗?").then(() => {
  158. this.$store.dispatch("LogOut").then(() => {
  159. this.$tab.reLaunch("/pages/index");
  160. });
  161. });
  162. },
  163. handleHelp() {
  164. this.$tab.navigateTo("/pages/mine/help/index");
  165. },
  166. handleAbout() {
  167. this.$tab.navigateTo("/pages/mine/about/index");
  168. },
  169. handleJiaoLiuQun() {
  170. this.$modal.showToast("QQ群:①133713780、②146013835");
  171. },
  172. handleBuilding() {
  173. this.$modal.showToast("模块建设中~");
  174. },
  175. },
  176. };
  177. </script>
  178. <style lang="scss">
  179. page {
  180. background-color: #f5f6f7;
  181. }
  182. .btn {
  183. width: 90%;
  184. margin: 30rpx auto 0;
  185. }
  186. .mine-container {
  187. width: 100%;
  188. height: 100%;
  189. .header-section {
  190. padding: 15px 15px 45px 15px;
  191. background-color: #3c96f3;
  192. color: white;
  193. .login-tip {
  194. font-size: 18px;
  195. margin-left: 10px;
  196. }
  197. .cu-avatar {
  198. border: 2px solid #eaeaea;
  199. .icon {
  200. font-size: 40px;
  201. }
  202. }
  203. .user-info {
  204. margin-left: 15px;
  205. .u_title {
  206. font-size: 18px;
  207. line-height: 30px;
  208. }
  209. }
  210. }
  211. .content-section {
  212. position: relative;
  213. top: -50px;
  214. .mine-actions {
  215. margin: 15px 15px;
  216. padding: 20px 0px;
  217. border-radius: 8px;
  218. background-color: white;
  219. .action-item {
  220. .icon {
  221. font-size: 28px;
  222. }
  223. .text {
  224. display: block;
  225. font-size: 13px;
  226. margin: 8px 0px;
  227. }
  228. }
  229. }
  230. }
  231. }
  232. </style>