prompt.js 2.6 KB

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