prompt.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. console.log(userInfo)
  67. userInfo['encryptedData'] = e.detail.encryptedData
  68. userInfo['iv'] = e.detail.iv
  69. let info = await app.wxLogin(userInfo);
  70. let hasMobile = false;
  71. if (info.mobile){
  72. hasMobile = true
  73. }
  74. _self.setData({
  75. hasUserInfo: true,
  76. userInfo: info,
  77. hasMobile: hasMobile,
  78. })
  79. wx.switchTab({
  80. url: '/'+_self.data.fromPage,
  81. })
  82. console.log(2222)
  83. }
  84. })