setting.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. const app = getApp()
  2. Page({
  3. /**
  4. * 生命周期函数--监听页面显示
  5. */
  6. onShow: function () {
  7. app.isLogin()
  8. },
  9. //清空缓存
  10. clearStorage: function () {
  11. wx.showModal({
  12. content: '请确认要退出登录?',
  13. success: function (res) {
  14. if (res.confirm) {
  15. wx.clearStorage({
  16. success: function () {
  17. wx.switchTab({
  18. url: '../index/index',
  19. })
  20. },
  21. })
  22. }
  23. }
  24. })
  25. },
  26. /**
  27. * 绑定公众号帐号
  28. */
  29. pubOffice: function () {
  30. wx.showModal({
  31. content: '确定要绑定同主体公众号帐号吗?',
  32. success: function (res) {
  33. if (res.confirm) {
  34. wx.navigateTo({ url: 'startup' })
  35. }
  36. }
  37. })
  38. },
  39. /**
  40. *地址
  41. */
  42. address: function () {
  43. let that = this;
  44. //获取用户权限
  45. wx.getSetting({
  46. success(res) {
  47. if (res.authSetting['scope.address'] == false) {
  48. wx.openSetting({
  49. success: (res) => {
  50. res.authSetting = {
  51. "scope.address": true,
  52. }
  53. }
  54. })
  55. } else {
  56. wx.chooseAddress({})
  57. }
  58. }
  59. })
  60. },
  61. })