index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import {
  2. ApiModel
  3. } from "../../utils/api";
  4. const _Http = new ApiModel();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. url: {},
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. const url = decodeURIComponent(options.url);
  17. //判断是否存在登录态
  18. if (!wx.getStorageSync('userData').token) {
  19. getApp().globalData.liveUrl = url;
  20. wx.setStorageSync('liveUrl', url)
  21. wx.reLaunch({
  22. url: '/pages/login/index'
  23. })
  24. } else {
  25. _Http.basic({
  26. "accesstoken": wx.getStorageSync('userData').token,
  27. "classname": "customer.usercenter.usermsg.usermsg",
  28. "method": "query_usermsg",
  29. "content": {}
  30. }).then(res => {
  31. if (res.msg != '成功') {
  32. getApp().globalData.liveUrl = url;
  33. wx.setStorageSync('liveUrl', url)
  34. wx.reLaunch({
  35. url: '/pages/login/index'
  36. })
  37. }
  38. })
  39. };
  40. this.setData({
  41. url: url
  42. })
  43. },
  44. /**
  45. * 生命周期函数--监听页面初次渲染完成
  46. */
  47. onReady: function () {
  48. },
  49. /**
  50. * 生命周期函数--监听页面显示
  51. */
  52. onShow: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面隐藏
  56. */
  57. onHide: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面卸载
  61. */
  62. onUnload: function () {
  63. },
  64. /**
  65. * 页面相关事件处理函数--监听用户下拉动作
  66. */
  67. onPullDownRefresh: function () {
  68. },
  69. /**
  70. * 页面上拉触底事件的处理函数
  71. */
  72. onReachBottom: function () {
  73. },
  74. /**
  75. * 用户点击右上角分享
  76. */
  77. onShareAppMessage: function () {
  78. }
  79. })