prompt.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // pages/prompt/prompt.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. companyName:"测试公司"
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: async function (options) {
  14. console.log(options)
  15. this.setData({
  16. fromPage: options.page
  17. })
  18. let userInfo = await app.getWxUserInfo()
  19. console.log(userInfo);
  20. if (userInfo){
  21. this.setData({
  22. userInfo: userInfo,
  23. hasUserInfo: true,
  24. hasMobile: userInfo.mobile ? true : false
  25. })
  26. }
  27. },
  28. /**
  29. * 生命周期函数--监听页面初次渲染完成
  30. */
  31. onReady: function () {
  32. },
  33. /**
  34. * 生命周期函数--监听页面显示
  35. */
  36. onShow: function () {
  37. },
  38. /**
  39. * 生命周期函数--监听页面隐藏
  40. */
  41. onHide: function () {
  42. },
  43. /**
  44. * 生命周期函数--监听页面卸载
  45. */
  46. onUnload: function () {
  47. },
  48. /**
  49. * 页面相关事件处理函数--监听用户下拉动作
  50. */
  51. onPullDownRefresh: function () {
  52. },
  53. /**
  54. * 页面上拉触底事件的处理函数
  55. */
  56. onReachBottom: function () {
  57. },
  58. /**
  59. * 用户点击右上角分享
  60. */
  61. onShareAppMessage: function () {
  62. },
  63. getInfo : async function(e){
  64. const _self = this
  65. let userInfo = e.detail.userInfo
  66. userInfo['encryptedData'] = e.detail.encryptedData
  67. userInfo['iv'] = e.detail.iv
  68. let info = await app.wxLogin(userInfo);
  69. let hasMobile = false;
  70. if (info.mobile){
  71. hasMobile = true
  72. }
  73. _self.setData({
  74. hasUserInfo: true,
  75. userInfo: info,
  76. hasMobile: hasMobile,
  77. })
  78. if(_self.data.fromPage=="pages/personorder/personorder"){
  79. wx.switchTab({
  80. url: '/'+_self.data.fromPage,
  81. })
  82. }/* else{
  83. wx.redirectTo({
  84. url: '/'+_self.data.fromPage,
  85. })
  86. } */
  87. if(_self.data.fromPage=="pages/comments/comments"){
  88. wx.redirectTo({
  89. url: '../comments/comments?title=我的评论&commentstype=my',
  90. })
  91. }
  92. wx.redirectTo({
  93. url: '/'+_self.data.fromPage,
  94. })
  95. console.log(_self.data.fromPage)
  96. }
  97. })