index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. list: {
  5. type: Array
  6. },
  7. userrole: {
  8. type: String
  9. }
  10. },
  11. options: {
  12. addGlobalClass: true
  13. },
  14. methods: {
  15. showTips() {
  16. wx.showToast({
  17. title: '请选择领域添加',
  18. icon: "none"
  19. })
  20. },
  21. addToCart(e) {
  22. let {
  23. item
  24. } = e.currentTarget.dataset;
  25. _Http.basic({
  26. "id": 20220924095102,
  27. "content": {
  28. "sa_brandid": item.brand[0].sa_brandid, //品牌id
  29. "itemid": item.itemid, //货品id
  30. "qty": item.orderminqty, //数量
  31. "itemno": item.itemno, //货品编号
  32. tradefield: item.tradefield[e.detail.value || 0].tradefield || ''
  33. },
  34. }).then(res => {
  35. console.log("加入购物车", res)
  36. if (res.msg != '成功') return wx.showToast({
  37. title: res.msg,
  38. icon: "none"
  39. });
  40. _Http.basic({
  41. "id": 20220927093202,
  42. "content": {}
  43. }, false).then(res => {
  44. console.log("购物车数量", res)
  45. getApp().globalData.num = res.data.num;
  46. if (this.data.userrole == '经销商') getCurrentPages()[getCurrentPages().length - 1].selectComponent("#Float").setNum(res.data.num)
  47. setTimeout(() => {
  48. wx.showToast({
  49. title: '加入成功',
  50. icon: "none",
  51. icon: "none"
  52. });
  53. }, 200);
  54. });
  55. })
  56. }
  57. }
  58. })