prompt.js 2.2 KB

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