201 lines
7.0 KiB
JavaScript
201 lines
7.0 KiB
JavaScript
require("../../@babel/runtime/helpers/Arrayincludes");
|
|
|
|
var a = getApp(), t = require("../../wxParse/wxParse.js");
|
|
|
|
Page({
|
|
data: {
|
|
imgList: [],
|
|
goodsNo: null,
|
|
fromData: null,
|
|
isShangJia: !1,
|
|
searchValue: "",
|
|
searchGoodsNoArray: [],
|
|
imageObjArray: [],
|
|
imageUrlArray: [],
|
|
cateObjArray: [],
|
|
indexCate: null,
|
|
colourObjList: [],
|
|
indexColour: null
|
|
},
|
|
bindPickerChangeCate: function(a) {
|
|
var t = this.data.fromData;
|
|
t.category_id = this.data.cateObjArray[a.detail.value].category_id, this.setData({
|
|
fromData: t,
|
|
indexCate: a.detail.value
|
|
});
|
|
},
|
|
bindPickerChangeColour: function(a) {
|
|
var t = this.data.fromData;
|
|
t.colour = this.data.colourObjList[a.detail.value].id, this.setData({
|
|
fromData: t,
|
|
indexColour: a.detail.value
|
|
});
|
|
},
|
|
onLoad: function(a) {
|
|
var t = this, o = wx.getStorageSync("values");
|
|
wx.getStorage({
|
|
key: "phone",
|
|
success: function(a) {
|
|
"" != a.data && o.includes(a.data) || wx.showModal({
|
|
title: "提示",
|
|
content: "无权访问",
|
|
success: function(a) {
|
|
a.confirm, wx.navigateBack({
|
|
delta: 1
|
|
});
|
|
}
|
|
}), t.CategoryList(), t.ColourList();
|
|
}
|
|
});
|
|
},
|
|
onShow: function() {},
|
|
bindFormSubmit: function(t) {
|
|
var o = t.detail.value.jieshao, e = t.detail.value.goods_price, s = t.detail.value.l_a, i = t.detail.value.l_b, r = t.detail.value.stock_num;
|
|
console.log(r);
|
|
var n = this.data.fromData;
|
|
if (n.content = o, n.goods_price = e, n.l_b = i, n.l_a = s, n.goods_status = this.data.shangjiastatus,
|
|
null != n.colour && null != n.category_id) {
|
|
var l = {}, d = {};
|
|
l.goods_id = n.goods_id, l.images = n.imageIdList, l.content = o, d.goods_no = this.data.goodsNo,
|
|
d.goods_price = e, d.l_b = i, d.l_a = s, d.stock_num = r, l.spec = d, l.colour = n.colour,
|
|
l.goods_status = n.goods_status, l.category_id = n.category_id, console.log(l),
|
|
wx.request({
|
|
url: "https://ltwxminiapp.19year.cn/index.php?s=/api/goods/editGoods&wxapp_id=10001",
|
|
header: {
|
|
"content-type": "application/json"
|
|
},
|
|
data: l,
|
|
method: "POST",
|
|
success: function(t) {
|
|
console.log(t.data), 1 == t.data.code ? a.showError("保存成功") : a.showError("保存失败");
|
|
}
|
|
});
|
|
} else a.showError("请选择分类与成色");
|
|
},
|
|
getSearchContent: function(t) {
|
|
var o = this, e = t.detail.value;
|
|
console.log(e), a._get("goods/likeGoodsNo", {
|
|
goods_no: e
|
|
}, function(a) {
|
|
console.log(a.data.list), o.setData({
|
|
searchGoodsNoArray: a.data.list
|
|
});
|
|
}), o.setData({
|
|
searchValue: e
|
|
});
|
|
},
|
|
clearNo: function() {
|
|
this.setData({
|
|
searchValue: "",
|
|
searchGoodsNoArray: []
|
|
});
|
|
},
|
|
xuanze: function(t) {
|
|
var o = t.currentTarget.dataset.goodsId;
|
|
if (console.log(t.currentTarget.dataset.goodsId), o.length <= 0) return a.showError("没有选中数据"),
|
|
!1;
|
|
this.setData({
|
|
searchValue: "",
|
|
searchGoodsNoArray: []
|
|
}), this.getGoodsDetail(o);
|
|
},
|
|
CategoryList: function() {
|
|
var t = this;
|
|
a._get("category/lists", {}, function(a) {
|
|
var o = a.data;
|
|
t.setData({
|
|
cateObjArray: o.list
|
|
});
|
|
});
|
|
},
|
|
ColourList: function() {
|
|
var t = this;
|
|
a._get("goods/getColourListV2", {}, function(a) {
|
|
var o = a.data;
|
|
t.setData({
|
|
colourObjList: o.data
|
|
});
|
|
});
|
|
},
|
|
onSaoMa: function() {
|
|
var t = this;
|
|
wx.scanCode({
|
|
onlyFromCamera: !0,
|
|
scanType: [ "barCode" ],
|
|
success: function(a) {
|
|
t.getGoodsDetail(a.result);
|
|
},
|
|
fail: function(t) {
|
|
a.showError(t.result + "扫码错误");
|
|
}
|
|
});
|
|
},
|
|
getGoodsDetail: function(t) {
|
|
var o = this;
|
|
a._get("goods/infos", {
|
|
goods_no: t
|
|
}, function(a) {
|
|
var e = o.initGoodsDetailData(a.data);
|
|
o.setData(e), o.setData({
|
|
goodsNo: t
|
|
});
|
|
var s = [], i = [];
|
|
e.detail.image.forEach(function(a) {
|
|
s.push(a.file_path), i.push(a);
|
|
}), o.setData({
|
|
imageUrlArray: s,
|
|
imageObjArray: i
|
|
}), console.log(e);
|
|
var r = {
|
|
imageIdList: []
|
|
};
|
|
r.goods_price = e.goods_price, r.l_a = e.l_a, r.l_b = e.l_b, r.content = o.delHtmlTag(e.detail.content),
|
|
r.goods_id = e.detail.goods_id, console.log(e.detail.category_id), o.setData({
|
|
indexCate: null
|
|
}), o.data.cateObjArray.forEach(function(a, t) {
|
|
a.category_id == e.detail.category_id && (o.setData({
|
|
indexCate: t
|
|
}), r.category_id = a.category_id);
|
|
}), console.log(e.detail.colour), o.setData({
|
|
indexColour: null
|
|
}), o.data.colourObjList.forEach(function(a, t) {
|
|
a.id == parseInt(e.detail.colour) && (o.setData({
|
|
indexColour: t
|
|
}), r.colour = a.id);
|
|
}), 10 == e.detail.goods_status.value ? (r.goods_status = 10, o.setData({
|
|
isShangJia: !0,
|
|
fromData: r,
|
|
shangjiastatus: 10
|
|
})) : (r.goods_status = 20, o.setData({
|
|
isShangJia: !1,
|
|
fromData: r,
|
|
shangjiastatus: 20
|
|
}));
|
|
});
|
|
},
|
|
initGoodsDetailData: function(a) {
|
|
return a.detail.content.length > 0 && t.wxParse("content", "html", a.detail.content, this, 0),
|
|
a.goods_sku_id = a.detail.spec[0].spec_sku_id, a.goods_price = a.detail.spec[0].goods_price,
|
|
a.l_a = a.detail.spec[0].l_a, a.l_b = a.detail.spec[0].l_b, a.line_price = a.detail.spec[0].line_price,
|
|
a.stock_num = a.detail.spec[0].stock_num, a;
|
|
},
|
|
updateImageList: function(a) {
|
|
console.log("update", a);
|
|
var t = a.detail.list.map(function(a) {
|
|
return a.image_id;
|
|
}), o = this.data.fromData;
|
|
o.imageIdList = t, console.log(), this.setData({
|
|
fromData: o
|
|
});
|
|
},
|
|
delHtmlTag: function(a) {
|
|
return a.replace(/<[^>]+>/g, "");
|
|
},
|
|
shangJiaSwitch: function(a) {
|
|
a.detail.value ? this.setData({
|
|
shangjiastatus: 10
|
|
}) : this.setData({
|
|
shangjiastatus: 20
|
|
});
|
|
}
|
|
}); |