index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. lifetimes: {
  15. attached: function () {
  16. getApp().globalData.Language.getLanguagePackage(this)
  17. }
  18. },
  19. methods: {
  20. showTips() {
  21. getApp().globalData.Language.showToast('请选择领域添加')
  22. },
  23. addToCart(e) {
  24. let {
  25. item
  26. } = e.currentTarget.dataset;
  27. _Http.basic({
  28. "id": 20220924095102,
  29. "content": {
  30. "sa_brandid": item.brand[0].sa_brandid, //品牌id
  31. "itemid": item.itemid, //货品id
  32. "qty": item.orderminqty, //数量
  33. "itemno": item.itemno, //货品编号
  34. tradefield: item.tradefield[e.detail.value || 0].tradefield || ''
  35. },
  36. }).then(res => {
  37. console.log("加入购物车", res)
  38. if (res.code != '1') return wx.showToast({
  39. title: res.msg,
  40. icon: "none"
  41. });
  42. _Http.basic({
  43. "id": 20220927093202,
  44. "content": {}
  45. }, false).then(res => {
  46. console.log("购物车数量", res)
  47. getApp().globalData.num = res.data.num;
  48. if (this.data.userrole == '经销商') getCurrentPages()[getCurrentPages().length - 1].selectComponent("#Float").setNum(res.data.num)
  49. setTimeout(() => {
  50. wx.showToast({
  51. title: getApp().globalData.Language.getMapText('加入成功'),
  52. icon: "none",
  53. icon: "none"
  54. });
  55. }, 200);
  56. });
  57. })
  58. }
  59. }
  60. })