index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // nova-tourism/pages/my/merchant/good/good-list/index.js
  2. let Parse = getApp().Parse;
  3. const company = getApp().globalData.company
  4. const uid = Parse.User.current()?.id
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. goodList:[]
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad(options) {
  16. },
  17. async refersh(){
  18. let merchant = wx.getStorageSync('merchant')
  19. if (!merchant) {
  20. wx.showToast({
  21. title: '商户有误',
  22. icon: 'error'
  23. })
  24. setTimeout(() => {
  25. wx.reLaunch({
  26. url: `/nova-tourism/pages/index/index`
  27. })
  28. }, 1000);
  29. return
  30. }
  31. this.getGoods()
  32. },
  33. /**获取商品 */
  34. async getGoods() {
  35. let {goodList}=this.data
  36. let store = wx.getStorageSync('store')
  37. let query = new Parse.Query('ShopGoods')
  38. query.equalTo('company', company)
  39. query.notEqualTo('isDeleted', true)
  40. query.equalTo('shopStore',store?.objectId)
  41. query.ascending('top')
  42. query.limit(15)
  43. query.skip(goodList?.length||0)
  44. let d = await query.find()
  45. let list = d?.map(item=>item.toJSON())
  46. console.log(list)
  47. this.setData({
  48. goodList:[...goodList,...(list||[])]
  49. })
  50. },
  51. /** 跳转*/
  52. tourl(e) {
  53. const url = e.currentTarget.dataset.url
  54. wx.navigateTo({
  55. url: `${url}` // 目标页面的路径
  56. });
  57. },
  58. /**
  59. * 生命周期函数--监听页面初次渲染完成
  60. */
  61. onReady() {
  62. },
  63. /**
  64. * 生命周期函数--监听页面显示
  65. */
  66. onShow() {
  67. this.refersh()
  68. },
  69. /**
  70. * 生命周期函数--监听页面隐藏
  71. */
  72. onHide() {
  73. },
  74. /**
  75. * 生命周期函数--监听页面卸载
  76. */
  77. onUnload() {
  78. },
  79. /**
  80. * 页面相关事件处理函数--监听用户下拉动作
  81. */
  82. onPullDownRefresh() {
  83. },
  84. /**
  85. * 页面上拉触底事件的处理函数
  86. */
  87. onReachBottom() {
  88. this.getGoods()
  89. },
  90. /**
  91. * 用户点击右上角分享
  92. */
  93. onShareAppMessage() {
  94. }
  95. })