personInfo.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. const app = getApp();
  2. const request = require('../../utils/request.js');
  3. const tools = require('../../utils/tools.js');
  4. import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast';
  5. Page({
  6. data: {
  7. logs: [],
  8. sf: ''
  9. },
  10. goMydevice() {
  11. wx.navigateTo({
  12. url: '/pages/hardwareDetails/hardwareDetails',
  13. })
  14. },
  15. goinfo() {
  16. wx.navigateTo({
  17. url: '/pages/info/info',
  18. })
  19. },
  20. async unbindOpenid() {
  21. let options = {
  22. url: 'resource/miniapp/user/unbindOpenid',
  23. data: {
  24. type: app.globalData.type,
  25. openId: app.globalData.openid
  26. },
  27. method: 'post'
  28. }
  29. let res = await request.query(options);
  30. console.log(res)
  31. if (res.data.code === 200) {
  32. wx.removeStorageSync('openid')
  33. wx.navigateTo({
  34. url: '/pages/login/login',
  35. })
  36. } else {
  37. Toast.fail(res.data.msg);
  38. }
  39. },
  40. async exitLogin() {
  41. wx.showModal({
  42. showCancel: true,
  43. content: "是否确认退出",
  44. success: (res) => {
  45. if (res.confirm) {
  46. this.unbindOpenid();
  47. }
  48. }
  49. })
  50. },
  51. bind() {
  52. wx.scanCode({
  53. success: (res) => {
  54. console.log(res.result, '我成功的参数')
  55. wx.navigateTo({
  56. url: '/pages/hardwareBind/hardwareBind?code=' + res.result,
  57. })
  58. },
  59. fail: (res) => {
  60. console.log(res)
  61. }
  62. })
  63. // wx.navigateTo({
  64. // url: '/pages/hardwareBind/hardwareBind',
  65. // })
  66. },
  67. onShow: function () {
  68. if(!wx.getStorageSync('userId')){
  69. wx.showModal({
  70. title: '提示',
  71. content: '请扫描二维码进入小程序',
  72. showCancel: false,
  73. success: (res) => {
  74. if (res.confirm) {
  75. wx.navigateTo({
  76. url: '/pages/login/login',
  77. })
  78. }
  79. }
  80. })
  81. return false;
  82. }
  83. tools.isLogin().then((res) => {
  84. console.log(app.globalData.type)
  85. this.setData({
  86. sf: app.globalData.type === 'jhr' ? '监护人' : app.globalData.type === 'jhdx' ? '监护对象' : ''
  87. })
  88. }, (error) => {
  89. console.log(error);
  90. })
  91. }
  92. })