index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view class="page">
  3. <uni-list>
  4. <uni-list-item title="登录密码修改" :show-arrow="true" :show-badge="true" @click="goPath('../set/password')" />
  5. <uni-list-item :title="'清除缓存'+' '+currentSize" :show-arrow="true" :show-badge="true" @click="clearTmp" />
  6. <uni-list-item title="清空所有聊天记录" :show-arrow="true" :show-badge="true" @click="clearAll" />
  7. <!-- <uni-list-item title="切换语言" :show-arrow="true" :show-badge="true" @click="goPath('../set/password')" /> -->
  8. <uni-list-item title="聊天字体" :show-arrow="true" :show-badge="true" @click="goPath('../set/font_size')" />
  9. <uni-list-item title="一键转发" :show-arrow="true" :show-badge="true"
  10. @click="goPath('/pages/push/create_group')" />
  11. <!-- <uni-list-item title="更新介绍" :show-arrow="true" :show-badge="true" @click="goPath('../set/password')" />-->
  12. </uni-list>
  13. <!-- <uni-list>
  14. <uni-list-item title="关于我们" :show-arrow="true" :show-badge="true"
  15. @click="goPath('/pages/user_info/system')" />
  16. </uni-list> -->
  17. </uni-list>
  18. <view class="uni-padding-wrap uni-common-mt login_out">
  19. <button type="primary" class="but-view" @tap="loginOut">退出登录</button>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import uniList from '../../components/uni-ui/uni-list/uni-list.vue';
  25. import uniListItem from '../../components/uni-ui/uni-list-item/uni-list-item.vue';
  26. import _action from '../../common/_action';
  27. import _mixins from '@/common/_mixins';
  28. import _hook from '../../common/_hook';
  29. import _data from '../../common/_data';
  30. export default {
  31. components: {
  32. uniList,
  33. uniListItem
  34. },
  35. data() {
  36. return {
  37. my_data: {},
  38. currentSize: ''
  39. }
  40. },
  41. onShow() {
  42. _hook.routeTabBarHook();
  43. let _this = this;
  44. /** 监听新的个人数据 */
  45. uni.$on('data_user_info', function(data) {
  46. _this.my_data = data;
  47. });
  48. this.getStorage();
  49. },
  50. onLoad() {
  51. let _this = this;
  52. _this.my_data = _data.data('user_info');
  53. },
  54. onUnload() {
  55. uni.$off('data_user_info');
  56. },
  57. computed: {
  58. },
  59. methods: {
  60. // 查看缓存
  61. getStorage() {
  62. try {
  63. const res = uni.getStorageInfoSync();
  64. console.log(res.keys);
  65. console.log(res.currentSize);
  66. console.log(res.limitSize);
  67. // this.currentSize = res.currentSize + 'kb';
  68. } catch (e) {
  69. // error
  70. }
  71. },
  72. // 清除缓存
  73. clearTmp() {
  74. uni.showModal({
  75. title: '提示',
  76. content: '确定要清除吗?',
  77. confirmText: '确认',
  78. cancelText: '取消',
  79. confirmColor: 'red',
  80. cancelColor: '#353535',
  81. success: function(res) {
  82. if (res.confirm) {
  83. uni.showLoading({
  84. title: '清除中',
  85. mask: true
  86. });
  87. try {
  88. // todo保留token,client_id
  89. let token = _data.localData('token');
  90. let client_id = _data.localData('client_id');
  91. let deviceId = _data.localData('deviceId');
  92. uni.clearStorageSync();
  93. uni.hideLoading();
  94. _data.localData('token', token);
  95. _data.localData('client_id', client_id);
  96. _data.localData('deviceId', deviceId);
  97. uni.showToast({
  98. title: '清除完毕',
  99. icon: 'none'
  100. });
  101. } catch (e) {
  102. // error
  103. uni.hideLoading()
  104. uni.showToast({
  105. title: '清除失败',
  106. icon: 'none'
  107. });
  108. }
  109. }
  110. },
  111. })
  112. },
  113. // 清空所有聊天记录
  114. clearAll() {
  115. let _this = this;
  116. uni.showModal({
  117. title: '重要提示',
  118. content: '确定要清空所有聊天记录吗?',
  119. confirmText: '确认',
  120. cancelText: '取消',
  121. confirmColor: 'red',
  122. cancelColor: '#353535',
  123. success: function(res) {
  124. if (res.confirm) {
  125. _this.$httpSend({
  126. path: '/im/remove/del_all',
  127. success: function(data) {
  128. uni.showToast({
  129. icon: 'none',
  130. title: '清除成功'
  131. })
  132. _data.localData('chat_list', []);
  133. uni.$on('data_chat_list', []);
  134. }
  135. })
  136. }
  137. }
  138. })
  139. },
  140. loginOut() {
  141. /** 跳转到登陆界面 */
  142. _action.checkFail();
  143. // #ifdef APP-PLUS
  144. // IM 登出
  145. // uni.$TUIKit.logout();
  146. // 登出 原生插件
  147. // uni.$TUICalling.logout(res => {});
  148. // #endif
  149. uni.reLaunch({
  150. url: '/pages/in/login'
  151. });
  152. },
  153. goPath(path) {
  154. if (path) {
  155. uni.navigateTo({
  156. url: path
  157. });
  158. }
  159. },
  160. },
  161. watch: {
  162. },
  163. }
  164. </script>
  165. <style>
  166. .login_out {
  167. margin-top: 100upx;
  168. }
  169. .phto {
  170. width: 130upx;
  171. height: 130upx;
  172. margin-left: 30upx;
  173. margin-right: 30upx;
  174. }
  175. .my_padding {
  176. padding-bottom: 25px;
  177. }
  178. .but-view {
  179. border-radius: 40upx;
  180. height: 80upx;
  181. text-align: center;
  182. line-height: 80upx;
  183. font-size: 16px;
  184. ;
  185. }
  186. .my_padding:before {
  187. background-color: white;
  188. }
  189. .uni-list {
  190. margin-bottom: 30upx;
  191. }
  192. </style>