index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import {
  2. imgServerUrl
  3. } from '../../config/config.js'
  4. import {
  5. showToast
  6. } from '../../utils/tips.js'
  7. var app = getApp()
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. imgServerUrl: imgServerUrl,
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function(options) {
  19. },
  20. toclear() {
  21. wx.showModal({
  22. title: '清除缓存',
  23. content: '是否清除所有缓存内容',
  24. success(res) {
  25. if (res.confirm) {
  26. try {
  27. wx.clearStorage({
  28. success: function(res) {
  29. wx.clearStorageSync()
  30. app.globalData.userId = '';
  31. app.globalData.userToken = '';
  32. app.globalData.memberId = '';
  33. app.globalData.userInfo = null;
  34. showToast('清除成功')
  35. }
  36. })
  37. } catch (e) {
  38. // Do something when catch error
  39. }
  40. } else if (res.cancel) {
  41. console.log('用户点击取消')
  42. }
  43. }
  44. })
  45. },
  46. toabout() {
  47. wx.navigateTo({
  48. url: '../about/index',
  49. })
  50. },
  51. login_out() {
  52. wx.showModal({
  53. title: '提示',
  54. content: '确定退出登录吗?',
  55. success: function(res) {
  56. if (res.confirm) {
  57. //清除登录缓存
  58. wx.removeStorageSync("user_id");
  59. wx.removeStorageSync("member_id");
  60. wx.removeStorageSync("user_token");
  61. wx.removeStorageSync("userInfo");
  62. app.globalData.userId = '';
  63. app.globalData.userToken = '';
  64. app.globalData.memberId = '';
  65. app.globalData.userInfo = null;
  66. showToast('退出成功');
  67. setTimeout(function () {
  68. wx.navigateBack();
  69. }, 500)
  70. } else if (res.cancel) {
  71. }
  72. }
  73. })
  74. }
  75. })