index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. list: {
  5. type: Array
  6. },
  7. hidePrice: {
  8. type: Number
  9. }
  10. },
  11. options: {
  12. addGlobalClass: true
  13. },
  14. methods: {
  15. toDetail(e) {
  16. const {
  17. item
  18. } = e.currentTarget.dataset;
  19. wx.navigateTo({
  20. url: `/packageA/market/detail?params=${JSON.stringify({
  21. sa_itemgroupid:item.sa_itemgroupid,
  22. sa_brandid:item.sa_brandid
  23. })}`,
  24. })
  25. },
  26. buyMore(e) {
  27. const item = e.currentTarget.dataset.item.item[0];
  28. const item1 = e.currentTarget.dataset.item;
  29. wx.showModal({
  30. title: '提示',
  31. content: `是否确定将“${item.itemname}”加入到购物车`,
  32. complete: (res) => {
  33. if (res.confirm) _Http.basic({
  34. "id": 20220924095102,
  35. "content": {
  36. sa_brandid: item1.sa_brandid,
  37. "itemid": item.itemid, //货品id
  38. "qty": item.orderminqty, //数量
  39. itemno: item.itemno, //货品编号
  40. tradefield: item1.tradefield,
  41. width: item.width,
  42. length: item.length
  43. },
  44. }).then(res => {
  45. console.log("加入购物车", res)
  46. wx.showToast({
  47. title: res.msg == '成功' ? '加入成功' : res.msg,
  48. icon: "none"
  49. });
  50. if (res.msg == '成功') getApp().globalData.getCollectCount().then(badge => this.setData({
  51. badge
  52. }))
  53. })
  54. }
  55. })
  56. },
  57. }
  58. })