prompt.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. let userInfo = await app.getWxUserInfo()
  15. console.log(userInfo);
  16. if (userInfo){
  17. this.setData({
  18. userInfo: userInfo,
  19. hasUserInfo: true,
  20. hasMobile: userInfo.mobile ? true : false
  21. })
  22. }
  23. },
  24. /**
  25. * 生命周期函数--监听页面初次渲染完成
  26. */
  27. onReady: function () {
  28. },
  29. /**
  30. * 生命周期函数--监听页面显示
  31. */
  32. onShow: function () {
  33. },
  34. /**
  35. * 生命周期函数--监听页面隐藏
  36. */
  37. onHide: function () {
  38. },
  39. /**
  40. * 生命周期函数--监听页面卸载
  41. */
  42. onUnload: function () {
  43. },
  44. /**
  45. * 页面相关事件处理函数--监听用户下拉动作
  46. */
  47. onPullDownRefresh: function () {
  48. },
  49. /**
  50. * 页面上拉触底事件的处理函数
  51. */
  52. onReachBottom: function () {
  53. },
  54. /**
  55. * 用户点击右上角分享
  56. */
  57. onShareAppMessage: function () {
  58. },
  59. getInfo : async function(e){
  60. const _self = this
  61. let userInfo = e.detail.userInfo
  62. console.log(userInfo)
  63. userInfo['encryptedData'] = e.detail.encryptedData
  64. userInfo['iv'] = e.detail.iv
  65. let info = await app.wxLogin(userInfo);
  66. let hasMobile = false;
  67. if (info.mobile){
  68. hasMobile = true
  69. }
  70. _self.setData({
  71. hasUserInfo: true,
  72. userInfo: info,
  73. hasMobile: hasMobile,
  74. })
  75. console.log(2222)
  76. }
  77. })