init
This commit is contained in:
196
wx05cb767e6530b48f/pages/gongzuo/index.js
Normal file
196
wx05cb767e6530b48f/pages/gongzuo/index.js
Normal file
@@ -0,0 +1,196 @@
|
||||
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;
|
||||
wx.getStorage({
|
||||
key: "user_id",
|
||||
success: function(a) {
|
||||
10984 != a.data && 10003 != a.data && 10004 != a.data && 10011 != 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 = this.data.fromData;
|
||||
if (s.content = o, s.goods_price = e, s.goods_status = this.data.shangjiastatus,
|
||||
null != s.colour && null != s.category_id) {
|
||||
var i = {}, r = {};
|
||||
i.goods_id = s.goods_id, i.images = s.imageIdList, i.content = o, r.goods_no = this.data.goodsNo,
|
||||
r.goods_price = e, i.spec = r, i.colour = s.colour, i.goods_status = s.goods_status,
|
||||
i.category_id = s.category_id, console.log(i), wx.request({
|
||||
url: "https://wxminiapp.19year.cn/index.php?s=/api/goods/editGoods&wxapp_id=10001",
|
||||
header: {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
data: i,
|
||||
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
|
||||
});
|
||||
var r = {
|
||||
imageIdList: []
|
||||
};
|
||||
r.goods_price = e.goods_price, 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.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
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user