common-setting.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // pages/common-setting/common-setting.js
  2. import { baseurl } from '../../config'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. version: '',
  10. cancellation: false,
  11. userAgreement: encodeURIComponent(baseurl + '/uploadfile/userAgreement.html'),
  12. privacyPolicy: encodeURIComponent(baseurl + '/uploadfile/privacyPolicy.html')
  13. },
  14. showCancellation() {
  15. this.setData({
  16. cancellation: !this.data.cancellation
  17. })
  18. },
  19. cancellation() {
  20. wx.clearStorage({
  21. success: res => {
  22. this.setData({
  23. cancellation: false
  24. })
  25. wx.$emit('is_login', false, () => {
  26. wx.navigateBack({
  27. delta: 2
  28. })
  29. })
  30. }
  31. })
  32. },
  33. logout() {
  34. wx.clearStorage({
  35. success: res => {
  36. wx.reLaunch({
  37. url: '/pages/index/index',
  38. })
  39. }
  40. })
  41. },
  42. /**
  43. * 生命周期函数--监听页面加载
  44. */
  45. onLoad: function (options) {
  46. if (wx.getAccountInfoSync) {
  47. const info = wx.getAccountInfoSync()
  48. this.setData({
  49. version: info.miniProgram.version || app.globalData.version
  50. })
  51. } else {
  52. this.setData({
  53. version: app.globalData.version
  54. })
  55. }
  56. },
  57. /**
  58. * 生命周期函数--监听页面初次渲染完成
  59. */
  60. onReady: function () {
  61. },
  62. /**
  63. * 生命周期函数--监听页面显示
  64. */
  65. onShow: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面隐藏
  69. */
  70. onHide: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面卸载
  74. */
  75. onUnload: function () {
  76. },
  77. /**
  78. * 页面相关事件处理函数--监听用户下拉动作
  79. */
  80. onPullDownRefresh: function () {
  81. },
  82. /**
  83. * 页面上拉触底事件的处理函数
  84. */
  85. onReachBottom: function () {
  86. },
  87. /**
  88. * 用户点击右上角分享
  89. */
  90. onShareAppMessage: function () {
  91. }
  92. })