editSku.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. let app = getApp();
  2. Page({
  3. data: {
  4. need_data: []
  5. },
  6. goods_id: 0,
  7. onLoad: function (options) {
  8. let id = options.id || '';
  9. if(!id) {
  10. app.util.message('参数错误', '/lionfish_comshop/moduleB/supply/goodsManage', 'error');
  11. return;
  12. }
  13. this.goods_id = id;
  14. },
  15. onShow: function () {
  16. this.getData();
  17. },
  18. formSubmit: function(e) {
  19. console.log(e.detail.value)
  20. let res = e.detail.value || {};
  21. let resArr = [];
  22. Object.keys(res).forEach(k=>{
  23. if(res[k]) {
  24. let idsArr = k.split("_");
  25. let num = parseInt(res[k]);
  26. if(num!=='') {
  27. let ids = idsArr[1]+'_'+num;
  28. resArr.push(ids);
  29. }
  30. }
  31. })
  32. if(resArr.length==0) {
  33. return wx.showToast({
  34. title: '请输入修改数量',
  35. icon: 'none'
  36. })
  37. }
  38. let sku_list_str = resArr.join(',');
  39. let token = wx.getStorageSync('token');
  40. let params = {
  41. token,
  42. goods_id: this.goods_id,
  43. is_has_option: 1,
  44. sku_list_str
  45. };
  46. app.util.ProReq('supplymobile.modify_supply_goods_quantity', params).then(res=>{
  47. app.util.message(res.msg || '修改成功', 'redirect:/lionfish_comshop/moduleB/supply/goodsManage', 'error');
  48. }).catch(err=>{
  49. app.util.message(err.msg || '请求出错', '', 'error');
  50. })
  51. },
  52. getData: function() {
  53. let token = wx.getStorageSync('token');
  54. let params = {
  55. token,
  56. goods_id: this.goods_id
  57. };
  58. app.util.ProReq('supplymobile.get_supply_goods_sku', params).then(res=>{
  59. let { goods_stock_notice, need_data } = res;
  60. this.setData({ goods_stock_notice, need_data })
  61. }).catch(err=>{
  62. app.util.message(err.msg || '请求出错', 'switchTo:/lionfish_comshop/pages/user/me', 'error');
  63. })
  64. }
  65. })