index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // nova-tourism/components/suggest/index.js
  2. let Parse = getApp().Parse;
  3. const company = getApp().globalData.company
  4. const uid = Parse.User.current()?.id
  5. const req = require('../../../utils/request')
  6. Component({
  7. /**
  8. * 组件的属性列表
  9. */
  10. properties: {
  11. store_id:null
  12. },
  13. /**
  14. * 组件的初始数据
  15. */
  16. data: {
  17. gift: [], //望仙礼遇-商品
  18. },
  19. lifetimes: {
  20. detached: function () {},
  21. attached: async function () {
  22. setTimeout(() => {
  23. this.getGift()
  24. }, 800);
  25. },
  26. },
  27. /**
  28. * 组件的方法列表
  29. */
  30. methods: {
  31. /** 获取望仙礼遇-商品*/
  32. async getGift() {
  33. let {
  34. store_id
  35. } = this.properties
  36. console.log(store_id)
  37. let sql = `SELECT good."objectId",good."name",good."price",good."image"
  38. FROM "ShopGoods" good
  39. WHERE good."company" = '${company}'
  40. AND good."isDeleted" IS NOT TRUE
  41. AND good."status" IS TRUE
  42. AND good."shopStore"='${store_id}'
  43. ORDER BY COALESCE(good."isHome", FALSE) DESC,
  44. CASE WHEN good."top"= 0 THEN 1 ELSE 0 END,
  45. good."top" ASC,good."createdAt"
  46. LIMIT 4`
  47. let gift = await req.customSQL(sql) || []
  48. console.log(gift)
  49. this.setData({
  50. gift
  51. })
  52. },
  53. /** 跳转*/
  54. tourl(e) {
  55. const url = e.currentTarget.dataset.url
  56. wx.navigateTo({
  57. url: `${url}` //目标页面的路径
  58. });
  59. },
  60. }
  61. })