index.js 1.4 KB

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