| | |
| | | arrayList:[], |
| | | checkResults: [] as any, |
| | | doccode:'', |
| | | roomid:'', |
| | | hadRelationList:[] |
| | | }, |
| | | onLoad(options) { |
| | | let doccode = options.doccode || ''; |
| | | let from = options.from || ''; |
| | | let roomid = options.roomid || ''; |
| | | this.setData({ |
| | | doccode |
| | | doccode, |
| | | roomid, |
| | | fromPage:from |
| | | }) |
| | | this.getPromotionsRelationList(); |
| | | this.getHadRelationList(); |
| | | if (from=='myStock'){ |
| | | this.getPanicBuyingListForLiveGoods(); |
| | | } |
| | | if (from=='myLive'){ |
| | | wx.setNavigationBarTitle({ |
| | | title: '选择直播商品' |
| | | }) |
| | | this.getGoodsListForImportRoom(); |
| | | } |
| | | |
| | | }, |
| | | onChange(event:any) { |
| | | console.log(event.detail); |
| | |
| | | const checkbox = this.selectComponent(`.checkboxes-${index}`); |
| | | checkbox.toggle(); |
| | | }, |
| | | async getPromotionsRelationList(){ |
| | | let doccode = this.data.doccode; |
| | | async getPanicBuyingListForLiveGoods(){ |
| | | let [error, result] = await wx.$utils.to( |
| | | wx.$http.request({ |
| | | url:`/shopping/panicBuying.do?m=getMayableRelationList`, |
| | | data:{ |
| | | doccode |
| | | url:`/shopping/panicBuyingLive/getPanicBuyingListForImportGoods.do`, |
| | | }) |
| | | ) |
| | | if (error){ |
| | | console.log(error); |
| | | return; |
| | | } |
| | | console.log(result); |
| | | this.setData({ |
| | | goodsList:result.list |
| | | }) |
| | | }, |
| | | async getGoodsListForImportRoom(){ |
| | | let [error, result] = await wx.$utils.to( |
| | | wx.$http.request({ |
| | | url:`/shopping/panicBuyingLive/getGoodsListForImportRoom.do`, |
| | | data: { |
| | | roomid:this.data.roomid |
| | | } |
| | | }) |
| | | ) |
| | |
| | | } |
| | | console.log(result); |
| | | this.setData({ |
| | | relationList: result.mayableRelationList |
| | | goodsList:result.list |
| | | }) |
| | | }, |
| | | async getHadRelationList(){ |
| | | let doccode = this.data.doccode; |
| | | async addGoods(data:any){ |
| | | let [error, result] = await wx.$utils.to( |
| | | wx.$http.request({ |
| | | url:`/shopping/panicBuying.do?m=getHadRelationList`, |
| | | data:{ |
| | | doccode |
| | | } |
| | | url:data.url, |
| | | data: data.data |
| | | }) |
| | | ) |
| | | if (error){ |
| | |
| | | return; |
| | | } |
| | | console.log(result); |
| | | this.handleRelationList(result.hadRelationList); |
| | | }, |
| | | handleRelationList(list:any[]){ |
| | | let checkResults: any[] = []; |
| | | list.forEach((item:any)=>{ |
| | | if (item.doccode){ |
| | | checkResults.push(item.doccode) |
| | | } |
| | | }) |
| | | this.setData({ |
| | | checkResults |
| | | }) |
| | | }, |
| | | async saveRelationList(){ |
| | | let docCode = this.data.doccode; |
| | | let panicBuyingDocCodes = this.data.checkResults; |
| | | let [error, result] = await wx.$utils.to( |
| | | wx.$http.request({ |
| | | url:`/shopping/panicBuying.do?m=saveRelationList`, |
| | | data:{ |
| | | docCode, |
| | | panicBuyingDocCodes |
| | | }, |
| | | method:'POST' |
| | | }) |
| | | ) |
| | | if (error){ |
| | | console.log(error); |
| | | return; |
| | | } |
| | | console.log(result); |
| | | wx.showToast({title: '保存成功'}) |
| | | wx.showToast({title: '添加成功'}) |
| | | setTimeout(()=>{ |
| | | wx.navigateBack() |
| | | },1000) |
| | | }, |
| | | onSubmitSave(){ |
| | | onSubmitForStock(){ |
| | | console.log(this.data.checkResults); |
| | | // this.saveRelationList(); |
| | | let doccode = this.data.checkResults.join(); |
| | | this.addGoods({ |
| | | url:`/shopping/panicBuyingLiveGoods.do?m=add`, |
| | | data:{ |
| | | doccode |
| | | } |
| | | }); |
| | | }, |
| | | onSubmitForLiveRoom(){ |
| | | console.log(this.data.checkResults); |
| | | let goodsid = this.data.checkResults.join(); |
| | | let roomid = this.data.roomid; |
| | | this.addGoods({ |
| | | url:`/shopping/live/addGoodsToRoom.do`, |
| | | data:{ |
| | | roomid, |
| | | goodsid |
| | | } |
| | | }); |
| | | } |
| | | }) |
| | | export {} |