This commit is contained in:
2024-08-22 12:53:28 +08:00
commit 1d65a849fd
360 changed files with 41757 additions and 0 deletions

View 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
});
}
});

View File

@@ -0,0 +1,6 @@
{
"navigationBarTitleText": "工作台",
"usingComponents": {
"wxDragImg": "/components/imgDrag/imgDrag"
}
}

View File

@@ -0,0 +1,76 @@
<view class="container">
<view class="cont-box b-f">
<button bindtap="onSaoMa" class="saoma">扫码</button>
</view>
<view class="dis-flex search-input-box flex-box">
<view class="search-input">
<view class="dis-flex search-box">
<view class="left">
<icon color="rgba(180,180,180,1)" size="15" type="search"></icon>
</view>
<view class="right">
<input bindinput="getSearchContent" class="input" placeholder="输入串号搜索" placeholderStyle="color:#aba9a9" type="number" value="{{searchValue}}"></input>
</view>
</view>
</view>
<view class="serch-button">
<button bindtap="clearNo" type="warn"> 清空 </button>
</view>
</view>
<view wx:for="{{searchGoodsNoArray}}" wx:key="this">
<view bindtap="xuanze" data-goods-id="{{item.goods_no}}" style="background: rgb(248, 136, 136); border: 1rpx solid white; padding:10rpx; text-align: center;">
<text style="text-align: center;">{{item.goods_no}}</text>
</view>
</view>
<view class="cont-box b-f" wx:if="{{goodsNo!==null}}">
<view class="goods-title">
<text>名称:{{detail.goods_name}}</text>
</view>
<view class="goods-title">
<text class="title f-26" style="color: red;">价 格:{{goods_price}}</text>
</view>
<view class="goods-title">
<text class="title f-26 twolist-hidden" style="color: #555;">标 题:{{detail.goods_title.length>0?detail.goods_title:' '}}</text>
</view>
<view class="goods-title">
<text class="title f-26 twolist-hidden" style="color: red;">状 态:{{detail.goods_status.text}}</text>
</view>
<wxDragImg bind:updateImageList="updateImageList" columns="{{3}}" defaultGoodsId="{{fromData.goods_id}}" defaultImgList="{{imageObjArray}}" defaultImgUrlList="{{imageUrlArray}}" gap="{{9}}" maxCount="{{9}}" previewSize="{{100}}" style="margin:5rpx;"></wxDragImg>
<form bindsubmit="bindFormSubmit">
<view class="ipt-wrap" style="display: flex;align-items: center; padding-bottom: 10rpx; border-bottom: 1px solid red; ">
<label class="f-30" for="" style="color: #555;">价格:</label>
<input name="goods_price" placeholder="请输入姓名" type="number" value="{{goods_price}}"></input>
</view>
<view class="ipt-wrap" style=" padding-bottom: 10rpx; border-bottom: 1px solid red;">
<label class="f-30" for="" style="color: #555;">商品介绍:</label>
<textarea autoHeight class="f-30" name="jieshao" placeholder="此处填写商品介绍" style=" width: auto; margin-bottom: 10rpx; line-height: 10rpx;" value="{{fromData.content}}"></textarea>
</view>
<view class="ipt-wrap" style=" padding-bottom: 10rpx; border-bottom: 1px solid red;">
<picker bindchange="bindPickerChangeCate" range="{{cateObjArray}}" rangeKey="name" value="{{indexCate}}">
<view class="f-30" style="color: #555;"> 分类:<text style="color: black;">{{cateObjArray[indexCate].name}}</text>
</view>
</picker>
</view>
<view class="ipt-wrap" style=" padding-bottom: 10rpx; border-bottom: 1px solid red;">
<picker bindchange="bindPickerChangeColour" range="{{colourObjList}}" rangeKey="name" value="{{indexColour}}">
<view class="f-30" style="color: #555;"> 成色:<text style="color: black;">{{colourObjList[indexColour].name}}</text>
</view>
</picker>
</view>
<view style="display: flex; align-items: center;justify-content: space-between; padding-bottom: 10rpx; margin-top: 10rpx; border-bottom: 1px solid red;">
<view style="display: flex; align-items: center;">
<label class="f-30" for="" style="color: #555;">是否上架:</label>
</view>
<view class="flex" style="display: flex;">
<switch bindchange="shangJiaSwitch" checked="{{isShangJia}}" class="switch"></switch>
</view>
</view>
<view class="cont-box b-f">
<button class="sub" formType="submit"> 保存 </button>
</view>
</form>
</view>
<view wx:else>
<view class="center-text">请先扫码或根据串号查询商品</view>
</view>
</view>

View File

@@ -0,0 +1,142 @@
.saoma {
align-items: center;
background-color: #f70000;
border-radius: 98rpx;
color: #fff;
display: flex;
flex-direction: row;
justify-content: center;
margin-top: 10rpx;
width: 80%;
}
.search-input-box {
background: #f7f7f7;
height: 64rpx;
margin-right: 10rpx;
width: auto;
}
.search-input {
background: #fff;
border-radius: 5px 0 0 5px;
box-sizing: border-box;
overflow: hidden;
padding-left: 10rpx;
width: 100%;
}
.search-input input {
font-size: 30rpx;
height: 64rpx;
line-height: 64rpx;
}
.serch-button {
box-sizing: border-box;
width: 20%;
}
.serch-button button {
border-radius: 0 5px 5px 0;
font-size: 28rpx;
height: 64rpx;
line-height: 64rpx;
}
.search-cate-box {
height: 70rpx;
}
.search-cate {
position: relative;
top: 30%;
}
.sub {
align-items: center;
background-color: #50f85e;
border-radius: 98rpx;
color: #fff;
display: flex;
flex-direction: row;
justify-content: center;
margin-top: 10rpx;
width: 80%;
}
.ipt-wrap {
line-height: 100rpx;
min-height: 100rpx;
}
.ipt-wrap label {
min-width: 120rpx;
}
.goods-title {
color: #333;
overflow: hidden;
padding: 0 0rpx 0 0;
}
.money-box,.money-box .num {
margin-top: 10rpx;
}
.money-box .num {
color: #ff495e;
font-size: 40rpx;
}
.money-box .del {
TEXT-DECORATION: line-through;
color: #999;
font-size: 24rpx;
margin-left: 6rpx;
}
.center-text {
align-items: center;
justify-content: center;
padding-top: 25rpx;
}
.center-text,.img_box {
display: flex;
}
.img_box {
flex-wrap: wrap;
margin: 20rpx;
width: 100%;
}
.img_item_i {
display: block;
height: 100%;
width: 100%;
}
.add_icon {
display: block;
height: 50%;
width: 50%;
}
.img_item {
border: 1px solid #c0ccda;
height: 210rpx;
margin-bottom: 2%;
margin-right: 2%;
position: relative;
width: 30%;
}
.closeImv {
height: 50rpx;
position: absolute;
right: 0rpx;
top: 0rpx;
width: 50rpx;
}