seller.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // pages/mine/wxml/seller.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. userInfo: {},
  9. hasUserInfo: false,
  10. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  11. Auctioneer: true
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. if (app.globalData.userInfo) {
  18. this.setData({
  19. userInfo: app.globalData.userInfo,
  20. hasUserInfo: true
  21. })
  22. } else if (this.data.canIUse) {
  23. // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
  24. // 所以此处加入 callback 以防止这种情况
  25. app.userInfoReadyCallback = res => {
  26. this.setData({
  27. userInfo: res.userInfo,
  28. hasUserInfo: true
  29. })
  30. }
  31. } else {
  32. // 在没有 open-type=getUserInfo 版本的兼容处理
  33. wx.getUserInfo({
  34. success: res => {
  35. app.globalData.userInfo = res.userInfo
  36. this.setData({
  37. userInfo: res.userInfo,
  38. hasUserInfo: true
  39. })
  40. }
  41. })
  42. }
  43. },
  44. /**
  45. * 生命周期函数--监听页面初次渲染完成
  46. */
  47. onReady: function () {
  48. },
  49. /**
  50. * 生命周期函数--监听页面显示
  51. */
  52. onShow: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面隐藏
  56. */
  57. onHide: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面卸载
  61. */
  62. onUnload: function () {
  63. },
  64. /**
  65. * 页面相关事件处理函数--监听用户下拉动作
  66. */
  67. onPullDownRefresh: function () {
  68. },
  69. /**
  70. * 页面上拉触底事件的处理函数
  71. */
  72. onReachBottom: function () {
  73. }
  74. })