index.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // pages/interview-reg/index.js
  2. import { webViewUrl } from '../../config/config'
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. show: false,
  9. options: {},
  10. url: "",
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad(options) {
  16. this.setData({
  17. options: Object.fromEntries([decodeURIComponent(options.scene).split('=')]),
  18. });
  19. },
  20. /**
  21. * 生命周期函数--监听页面初次渲染完成
  22. */
  23. onReady() { },
  24. /**
  25. * 生命周期函数--监听页面显示
  26. */
  27. onShow() {
  28. if (wx.getStorageSync("user_id") && wx.getStorageSync("user_token") && wx.getStorageSync("member_id")) {
  29. const options = this.data.options;
  30. if (options.url) {
  31. const data = Object.assign({}, options)
  32. data.phone = wx.getStorageSync('phone')
  33. data.memberId = wx.getStorageSync('member_id')
  34. data.t = new Date().getTime()
  35. data.shortUrl = data.url
  36. delete data.url
  37. this.setData({
  38. show: true,
  39. url: webViewUrl + '/#/index' + '?' + Object.keys(data).map(value => [value, data[value]]).map(val => val.join('=')).join('&'),
  40. });
  41. }
  42. } else {
  43. wx.showModal({
  44. title: '提示',
  45. content: '你还未登录,请先登录小程序',
  46. showCancel: false,
  47. success: res => {
  48. if (res.confirm) {
  49. wx.navigateTo({
  50. url: '/pages/login/login',
  51. })
  52. }
  53. }
  54. })
  55. }
  56. },
  57. /**
  58. * 生命周期函数--监听页面隐藏
  59. */
  60. onHide() { },
  61. /**
  62. * 生命周期函数--监听页面卸载
  63. */
  64. onUnload() { },
  65. /**
  66. * 页面相关事件处理函数--监听用户下拉动作
  67. */
  68. onPullDownRefresh() { },
  69. /**
  70. * 页面上拉触底事件的处理函数
  71. */
  72. onReachBottom() { },
  73. /**
  74. * 用户点击右上角分享
  75. */
  76. onShareAppMessage() { },
  77. });