index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. //判断是否纯在登录态度
  17. if (!wx.getStorageSync('userData').token) {
  18. this.toLogin("当前未登录,是否前去登录", options.url);
  19. } else {
  20. _Http.basic({
  21. "accesstoken": "6682a82c96fb72035e6b53f32dab4d7c",
  22. "classname": "customer.usercenter.usermsg.usermsg",
  23. "method": "query_usermsg",
  24. "content": {}
  25. }).then(res => {
  26. if (res.msg != '成功') this.toLogin("当前登录状态已过期,请重新登录", options.url);
  27. })
  28. };
  29. this.setData({
  30. url: options.url
  31. })
  32. },
  33. /* 去登陆 */
  34. toLogin(content, url) {
  35. console.log(url)
  36. wx.showModal({
  37. title: "提示",
  38. content: content,
  39. success: (res) => {
  40. if (res.confirm) {
  41. getApp().globalData.liveUrl = url;
  42. wx.reLaunch({
  43. url: '/pages/login/index'
  44. })
  45. }
  46. }
  47. });
  48. },
  49. /**
  50. * 生命周期函数--监听页面初次渲染完成
  51. */
  52. onReady: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面显示
  56. */
  57. onShow: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面隐藏
  61. */
  62. onHide: function () {
  63. },
  64. /**
  65. * 生命周期函数--监听页面卸载
  66. */
  67. onUnload: function () {
  68. },
  69. /**
  70. * 页面相关事件处理函数--监听用户下拉动作
  71. */
  72. onPullDownRefresh: function () {
  73. },
  74. /**
  75. * 页面上拉触底事件的处理函数
  76. */
  77. onReachBottom: function () {
  78. },
  79. /**
  80. * 用户点击右上角分享
  81. */
  82. onShareAppMessage: function () {
  83. }
  84. })