1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- const _Http = getApp().globalData.http;
- Component({
- properties: {
- list: {
- type: Array
- },
- userrole: {
- type: String
- }
- },
- options: {
- addGlobalClass: true
- },
- lifetimes: {
- attached: function () {
- getApp().globalData.Language.getLanguagePackage(this)
- this.setData({
- siteid: wx.getStorageSync('userMsg').siteid
- })
- }
- },
- methods: {
- showTips() {
- getApp().globalData.Language.showToast('请选择领域添加')
- },
- addToCart(e) {
- let {
- item
- } = e.currentTarget.dataset;
- _Http.basic({
- "id": 20220924095102,
- "content": {
- "sa_brandid": item.brand[0].sa_brandid, //品牌id
- "itemid": item.itemid, //货品id
- "qty": item.orderminqty, //数量
- "itemno": item.itemno, //货品编号
- tradefield: item.tradefield[e.detail.value || 0].tradefield || ''
- },
- }).then(res => {
- console.log("加入购物车", res)
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- _Http.basic({
- "id": 20220927093202,
- "content": {}
- }, false).then(res => {
- console.log("购物车数量", res)
- getApp().globalData.num = res.data.num;
- if (this.data.userrole == '经销商') getCurrentPages()[getCurrentPages().length - 1].selectComponent("#Float").setNum(res.data.num)
- setTimeout(() => {
- wx.showToast({
- title: getApp().globalData.Language.getMapText('加入成功'),
- icon: "none",
- icon: "none"
- });
- }, 200);
- });
- })
- }
- }
- })
|