index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view>
  3. <uni-card>
  4. <!-- <uni-list-item title="操作手册" showExtraIcon="true" :extra-icon="list" showArrow
  5. to="/pages/my/updatePwd" /> -->
  6. <!-- <uni-list-item title="活体激活" showExtraIcon="true" :extra-icon="cameraExtraIcon" showArrow to="/pages/living/check" /> -->
  7. <uni-list-item title="修改密码" showExtraIcon="true" :extra-icon="extraIcon" showArrow
  8. to="/pages/my/updatePwd" />
  9. <view @click="goOut">
  10. <uni-list-item title="退出登录" showExtraIcon="true" :extra-icon="goOutExtraIcon" showArrow />
  11. </view>
  12. </uni-card>
  13. </view>
  14. </template>
  15. <script>
  16. import {
  17. getUser,
  18. getOpenid,
  19. setOpenid
  20. } from '@/common/auth.js'
  21. import {
  22. UpdatePwd,
  23. unbind,
  24. logout
  25. } from '@/api/my.js'
  26. export default {
  27. data() {
  28. return {
  29. list: {
  30. color: '#4a4a4a',
  31. size: '18',
  32. type: 'list'
  33. },
  34. cameraExtraIcon: {
  35. color: '#4a4a4a',
  36. size: '18',
  37. type: 'camera-filled'
  38. },
  39. extraIcon: {
  40. color: '#4a4a4a',
  41. size: '18',
  42. type: 'gear-filled'
  43. },
  44. goOutExtraIcon: {
  45. color: '#4a4a4a',
  46. size: '18',
  47. type: 'close'
  48. }
  49. }
  50. },
  51. methods: {
  52. goOut() {
  53. uni.showModal({
  54. title: '提示',
  55. content: '是否退出登录',
  56. cancelText: '取消',
  57. confirmText: '确定',
  58. success: function(response) {
  59. if (response.confirm) {
  60. uni.showLoading({
  61. title: '正在退出中...',
  62. mask: true,
  63. })
  64. const user = getUser()
  65. const {
  66. accountType
  67. } = user
  68. if (accountType === '0') {
  69. unbind().then(res => {
  70. console.log(res);
  71. logout().then(resp => {
  72. let openId = getOpenid();
  73. uni.clearStorageSync()
  74. setOpenid(openId)
  75. uni.hideLoading()
  76. uni.showToast({
  77. icon: 'none',
  78. title: '退出成功'
  79. })
  80. setTimeout(function() {
  81. let url = window.location.href;
  82. //页面授权之后退出再清空openId登录code不刷新问题
  83. if (url.indexOf("?") !== -1 && url.indexOf(
  84. "code") !== -1) {
  85. const urlWithoutQuery = url.split('?')[0];
  86. console.log(urlWithoutQuery,'<---------urlWithoutQuery')
  87. window.location.href = urlWithoutQuery
  88. } else {
  89. uni.reLaunch({
  90. url: '/pages/login/index'
  91. })
  92. }
  93. }, 1000)
  94. })
  95. })
  96. } else {
  97. logout().then(resp => {
  98. let openId = getOpenid();
  99. uni.clearStorageSync()
  100. setOpenid(openId)
  101. uni.hideLoading()
  102. uni.showToast({
  103. icon: 'none',
  104. title: '退出成功'
  105. })
  106. setTimeout(function() {
  107. let url = window.location.href;
  108. //页面授权之后退出再清空openId登录code不刷新问题
  109. if (url.indexOf("?") !== -1 && url.indexOf("code") !==
  110. -1) {
  111. const urlWithoutQuery = url.split('?')[0];
  112. console.log(urlWithoutQuery,'<---------urlWithoutQuery')
  113. window.location.href = urlWithoutQuery
  114. } else {
  115. uni.reLaunch({
  116. url: '/pages/login/index'
  117. })
  118. }
  119. }, 1000)
  120. })
  121. }
  122. }
  123. }
  124. })
  125. }
  126. }
  127. }
  128. </script>
  129. <style>
  130. </style>