Merge branch 'main' into prod

This commit is contained in:
weipengfei 2023-11-04 17:47:13 +08:00
commit 233a0748a2
6 changed files with 273 additions and 68 deletions

View File

@ -16,6 +16,14 @@ export function microProductAdd(data) {
return request.post('micro/product_add', data);
}
/**
* 添加商品库审核
*
*/
export function microProductEdit(data) {
return request.post('micro/eadt_product', data);
}
/**
* 获取收款二维码
* @returns {*}

View File

@ -47,7 +47,7 @@
</view>
<view class="pos-order-goods" v-for="(val, key) in item.refundProduct" :key="key"
@click="toRefundDetail(item)">
<view class="goods acea-row row-between-wrapper">
<view v-if="val.product" class="goods acea-row row-between-wrapper">
<view class="picTxt acea-row row-between-wrapper">
<view class="pictrue">
<image :src="val.product.cart_info.product.image" />

View File

@ -13,7 +13,7 @@
<text>{{merchant_Data.unpaid_margin}}</text>
</view>
<view class="item">
<text>缴纳店铺账户</text>
<text>缴纳押金账户</text>
<text>{{merchant_Data.mer_name}}</text>
</view>
</view>

View File

@ -14,12 +14,13 @@
<view class="top">
<view class="pictrue">
<!-- <easy-loadimage mode="widthFix" :image-src="item.image"></easy-loadimage> -->
<image class="img" :src="item.image||defaultImageSRC" :lazy-load="true"></image>
<image class="img" :src="item.image||defaultImageSRC" :lazy-load="true" @click="clickImg(item, 1, 0)"></image>
<view class="swiper">
<image :src="item.slider_image[0]||defaultImageSRC" :lazy-load="true"></image>
<image :src="item.slider_image[1]||defaultImageSRC" :lazy-load="true"></image>
<image :src="item.slider_image[2]||defaultImageSRC" :lazy-load="true"></image>
<image :src="item.slider_image[0]||defaultImageSRC" :lazy-load="true" @click="clickImg(item, 2, 0)"></image>
<image :src="item.slider_image[1]||defaultImageSRC" :lazy-load="true" @click="clickImg(item, 2, 1)"></image>
<image :src="item.slider_image[2]||defaultImageSRC" :lazy-load="true" @click="clickImg(item, 2, 2)"></image>
</view>
<view v-if="item.update" class="btn" @click="updateItemImage(item)">保存修改</view>
</view>
<view class="text-info">
<view class="title">
@ -135,7 +136,7 @@
<u-popup :show="addGoodsShow" @close="searchGoodsClose" :round="18" mode="center">
<view class="search_goods_box">
<view style="text-align: center;font-weight: bold;">完善商品信息</view>
<view v-if="showPutGoodsInput.store_name" style="display: flex;align-items: center;margin-top: 16rpx;">
<view style="display: flex;align-items: center;margin-top: 16rpx;">
<view style="margin-right: 20rpx;">名称:</view>
<input style="flex: 1;" type="text" v-model="putGoods.store_name" class="putGoods" placeholder="请输入商品名称">
</view>
@ -157,7 +158,7 @@
</view>
<view class="search_goods_btn">
<view class="cancel edit_btn" @click="addGoodsclose()">取消</view>
<view class="search edit_btn" @click="addGoodsopen()">确定</view>
<view class="search edit_btn" @click="$u.throttle(addGoodsopen, 1500)">确定</view>
</view>
</view>
</u-popup>
@ -170,26 +171,34 @@
</view>
</view>
</u-popup>
<u-modal :show="showModel" title="提示" content="没有找到该商品,是否添加?"></u-modal>
<u-modal :show="showModel" title="提示" content="没有找到该商品,是否手动添加?" show-cancel-button @cancel="showModel = false" @confirm="navToAdd"></u-modal>
</view>
</template>
<script>
import {
TOKENNAME,
HTTP_REQUEST_URL
} from '@/config/app.js';
import {
productCreate
} from '@/api/product.js'
import {
microSeachBarCode,
microEadtProduct,
microProductAdd
microProductAdd,
microProductEdit
} from '@/api/store.js'
import {
seachBarCodeAPI,
micro_product_import
} from '@/api/api.js'
import {
Toast
chooseImage,
Toast,
getStorage,
navigateTo
} from '@/libs/uniApi'
export default {
data() {
@ -208,12 +217,12 @@
// src: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/saoma.png'
src: '/static/images/SMRK/bar.png'
},
// {
// name: '',
// type: 3,
// // src: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/saoma.png'
// src: '/static/images/SMRK/img.png'
// }
{
name: '非标手动入库',
type: 3,
// src: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/saoma.png'
src: '/static/images/SMRK/img.png'
}
],
shadowStyle: {
backgroundImage: "none",
@ -231,35 +240,40 @@
searchGoodsShow: false,
searchGoodsName: '',
showModel: false,
showModelCode: '',
goods: [
// {
// "id": 56,
// "store_name": "400 400g",
// "bar_code": "8998389621348",
// "manu_address": null,
// "price": "0.00",
// "stock": 9999999,
// "image": "http://lihai001.oss-cn-chengdu.aliyuncs.com/def/2023-11-02/202311021119037679.jpg",
// "slider_image": [
// "http://lihai001.oss-cn-chengdu.aliyuncs.com/def/2023-11-02/202311021119037679.jpg"
// ],
// "spec": null,
// "trademark": null,
// "manu_name": null,
// "note": null
// "id": 35,
// "store_name": "DT1515015024",
// "bar_code": "6903244675314",
// "manu_address": "",
// "price": "0.00",
// "stock": 9999999,
// "image": "https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230130/00ebcfdf75684f5494c0193075055d1.png",
// "slider_image": [],
// "spec": "1",
// "trademark": "",
// "manu_name": null,
// "note": ""
// },
],
putGoods: {
putGoods: { //
id: '',
price: '',
stock: '',
store_name: '',
images: [],
},
uploadImgInfo:{ //
id: '',
type: 1,
index: 0
},
uploadImgIdList: new Map(),//,
showPutGoodsInput: {
spec: false,
trademark: false,
store_name: false
},
item: [],
addGoodsShow: false,
@ -273,9 +287,15 @@
},
methods: {
addGoods(item) {
if(this.isNullImage(item.image)||
( this.isNullImage(item.slider_image[0]) && this.isNullImage(item.slider_image[1]) && this.isNullImage(item.slider_image[2]) )){
return Toast('请先上传商品图片后再加入店铺');
}
if(item.update) return Toast('请保存修改后再添加');
this.putGoods.id = item.id;
this.putGoods.price = '';
this.putGoods.stock = '';
this.putGoods.store_name = item.store_name;
Object.keys(this.showPutGoodsInput).forEach((key)=>{
if(item[key]==null||item[key]==undefined||item[key]==''){
this.showPutGoodsInput[key] = true;
@ -290,10 +310,135 @@
this.addGoodsShow = true
this.item = item
},
isNullImage(src){
let flag = false;
if(src==this.defaultImageSRC||!src)flag =true;
return flag;
},
clickImg(data, type, index){
if(!data.update&&!this.uploadImgIdList.get(data.id)){
let arr = [];
if(this.isNullImage(data.image))arr.push(-1);
if(this.isNullImage(data.slider_image[0]))arr.push(0);
if(this.isNullImage(data.slider_image[1]))arr.push(1);
if(this.isNullImage(data.slider_image[2]))arr.push(2);
this.uploadImgIdList.set(data.id, arr)
}
let obj = this.uploadImgIdList.get(data.id) || [];
if(type==1&&!obj.includes(-1)) return ;
if(type==2&&!obj.includes(index)) return ;
this.uploadImgInfo.id = data.id;
this.uploadImgInfo.type = type;
this.uploadImgInfo.index = index;
if(data.image==this.defaultImageSRC||(type==2&&this.isNullImage(data.slider_image[index]))){
this.chooseImg()
}else if(data.update){
this.chooseImg()
}
},
chooseImg(){
let that = this;
uni.chooseImage({
count: 1,
sizeType: ['original'],
crop:{
width: 1024,
height: 1024,
resize: false
},
success: (res) => {
let tempFilePaths = res.tempFilePaths[0]
//#ifdef APP-PLUS
if (uni.getSystemInfoSync().platform == 'ios') {
that.doUpload(tempFilePaths)
} else {
let size = res.tempFiles[0].size / 1024
if (size >= 1) {
uni.compressImage({
src: tempFilePaths,
quality: 80, // jpg
success: res => {
that.doUpload(res.tempFilePath)
},
fail: err => {
that.doUpload(tempFilePaths)
}
})
} else {
that.doUpload(tempFilePaths)
}
}
//#endif
//#ifndef APP-PLUS
that.doUpload(tempFilePaths)
//#endif
}
})
},
doUpload(rsp) {
let that = this
uni.showLoading({
title: '上传中',
mask: true
})
uni.uploadFile({
url: HTTP_REQUEST_URL + '/api/upload/image/field',
filePath: rsp,
name: 'field',
header: {
// #ifdef MP
"Content-Type": "multipart/form-data",
// #endif
[TOKENNAME]: 'Bearer ' + that.$store.state.app.token
},
success: (uploadFileRes) => {
let imgData = JSON.parse(uploadFileRes.data)
if(this.uploadImgInfo.type==1){
this.goods.forEach(item=>{
if(item.id==this.uploadImgInfo.id){
item.image = imgData.data.path;
item.update = true;
}
})
this.putGoods.image = imgData.data.path;
}else if(this.uploadImgInfo.type==2){
this.goods = this.goods.map(item=>{
if(item.id==this.uploadImgInfo.id){
item.slider_image[this.uploadImgInfo.index] = imgData.data.path;
item.update = true;
}
return item;
})
this.putGoods.slider_image[this.uploadImgInfo.index] = imgData.data.path;
}
},
complete(res) {
let data = JSON.parse(res.data)
that.$util.Tips({
title: data.message
});
}
});
},
//
updateItemImage(item){
microProductEdit({
id: item.id,
image: item.image,
slider_image: item.slider_image.join(',')
}).then((res)=>{
this.goods = this.goods.map(e=>{
if(e.id==item.id)e.update = false;
return e;
})
Toast('更新成功')
}).catch(err=>{
Toast(err||'更新失败')
})
},
//
addGoodsopen() {
async addGoodsopen() {
let good = this.goods.find(item=>item.id==this.putGoods.id);
// console.log(good);
if (this.putGoods.id&&good) {
//
let auditFlag = false;
@ -317,7 +462,7 @@
this.addGoodsShow = false;
} else {
Toast(e.message)
this.addGoodsShow = false
this.addGoodsShow = false;
}
}).catch(err => {
Toast(err || '导入出错');
@ -408,8 +553,9 @@
this.scanCode();
this.pageType = 1;
}else {
this.photograph();
this.pageType = 2;
// this.photograph();
// this.pageType = 2;
this.jumpAddGoods();
}
},
//
@ -425,15 +571,27 @@
},
})
},
isStartsWith6Or06(str) {
const regex = /^(6|06)/;
return regex.test(str);
},
async seachBarCode(code) {
if(code.length<12){
return Toast('条形码长度不正确, 请重试!')
}
this.showModelCode = code;
console.log('扫码的值', code);
if(!this.isStartsWith6Or06(code)) {
Toast('暂不支持进口商品!');
this.$u.sleep(1200).then(()=>{
this.showModel = true;
})
return ;
}
uni.showLoading({
title: '加载中',
mask: true
})
console.log('扫码的值', code);
await seachBarCodeAPI({
code: code,
mer_id: this.mer_id
@ -448,9 +606,7 @@
});
} else {
if (res.data.list.length < 1) {
uni.navigateTo({
url: `/pages/product/addGoods/index?mer_id=${this.mer_id}&code=${code}`
})
this.showModel = true;
return
}
this.goods = JSON.parse(JSON.stringify(res.data.list));
@ -461,7 +617,10 @@
}
}).catch((err) => {
console.log('错误', err);
Toast('加载出错')
Toast(err);
this.$u.sleep(1200).then(()=>{
this.showModel = true;
})
})
},
@ -478,7 +637,34 @@
console.log(res.tempFilePaths[0]);
}
})
}
},
navToAdd(){
let url;
if(this.showModelCode) url = `/pages/product/addGoods/index?mer_id=${this.mer_id}&code=${this.showModelCode}`;
else url = `/pages/product/addGoods/index?mer_id=${this.mer_id}`;
uni.navigateTo({
url:url,
success:()=> {
this.showModel = false;
}
})
},
//
jumpAddGoods() {
const data = getStorage('addGoodsFormData');
if (data && data.product_id) {
let waitDeleteData = ['addGoodsFormData', 'singleSpecification', 'attrValue', 'modifyPriceData',
'addGoodsSecoundData', 'goodsDis', 'editGoodsDetils'];
waitDeleteData.forEach(item => {
if (getStorage(item)) {
removeStorage(item);
}
})
}
navigateTo(1, '/pages/product/addGoods/index', {
mer_id: this.mer_id
});
},
},
onPullDownRefresh() {
uni.stopPullDownRefresh()
@ -521,8 +707,8 @@
}
.select_item {
// width: 220.84rpx;
width: 336rpx;
width: 220.84rpx;
// width: 336rpx;
height: 189.47rpx;
border-radius: 8px;
background-color: #eee;
@ -1053,6 +1239,18 @@
height: 60rpx;
}
}
.btn{
font-size: 24rpx;
margin: 0 auto;
margin-top: 10rpx;
width: 120rpx;
height: 40rpx;
background-color: #419aff;
color: #fff;
line-height: 40rpx;
text-align: center;
border-radius: 40rpx;
}
}
.text-info {

View File

@ -41,6 +41,11 @@
<image src="@/static/images/guanbi.png" class="guanbi" @click="close"></image>
</u-popup>
</view>
<commodityComponent v-if="showCommodity" :key="showCommodity" :showCommodity="showCommodity" :resetKey="secoundModel" :product_id="product_id" :merId="merId"
:code="code" @lastStep="lastStep">
</commodityComponent>
<view class="popup_group">
<view class="popup_group_item" @click="selectPlatform">
@ -165,10 +170,6 @@
</view> -->
</view>
<commodityComponent v-if="showCommodity" :key="showCommodity" :showCommodity="showCommodity" :resetKey="secoundModel" :product_id="product_id" :merId="merId"
:code="code" @lastStep="lastStep">
</commodityComponent>
<view class="popup_group">
<!-- <view class="popup_group_item" @click="showMoreInfo=!showMoreInfo">
<view class="popup_group_item_label">更多信息</view>

View File

@ -9,11 +9,11 @@
<block>
<swiper-item :class="{ active: 0 == swiperCur }">
<view class="slide-navigator">
<view class="item" hover-class='none' @click="jumpAddGoods">
<!-- <view class="item" hover-class='none' @click="jumpAddGoods">
<image mode='widthFix' class="image" src="../static/images/product_add.png">
</image>
<text class="text">添加商品</text>
</view>
</view> -->
<navigator class="item"
:url="`/pages/product/goodsOnSale/index?mer_id=${mer_id}&type=1`"
hover-class='none'>
@ -21,7 +21,7 @@
</image>
<text class="text">在售商品</text>
</navigator>
<navigator class="item"
<!-- <navigator class="item"
:url="`/pages/product/goodsOnSale/index?mer_id=${mer_id}&type=3`"
hover-class='none'>
<image mode='widthFix' class="image" src="../static/images/product_out.png">
@ -34,7 +34,7 @@
<image mode='widthFix' class="image" src="../static/images/product_recycle.png">
</image>
<text class="text">回收站</text>
</navigator>
</navigator> -->
<navigator class="item"
:url="`/pages/product/storeClassification/index?mer_id=${mer_id}`"
hover-class='none'>
@ -42,11 +42,6 @@
</image>
<text class="text">店铺分类</text>
</navigator>
</view>
</swiper-item>
<swiper-item :class="{ active: 1 == swiperCur }">
<view class="slide-navigator">
<!-- 隐藏暂时不需要 -->
<navigator class="item"
:url="`/pages/product/addGoods/freightTemplate?mer_id=${mer_id}`"
hover-class='none'>
@ -54,13 +49,6 @@
</image>
<text class="text">运费模板</text>
</navigator>
<navigator class="item"
:url="`/pages/product/addGoods/mulSpecification?mer_id=${mer_id}`"
hover-class='none'>
<image mode='widthFix' class="image"
src="../static/images/product_specification.png"></image>
<text class="text">规格模板</text>
</navigator>
<navigator class="item"
:url="`/pages/users/online_warehousing/index?mer_id=${mer_id}&product_id=${data.product_id}&unique=${data.unique}&type=${mer_info.type_code}`"
hover-class='none'>
@ -69,6 +57,17 @@
</navigator>
</view>
</swiper-item>
<!-- <swiper-item :class="{ active: 1 == swiperCur }">
<view class="slide-navigator">
<navigator class="item"
:url="`/pages/product/addGoods/mulSpecification?mer_id=${mer_id}`"
hover-class='none'>
<image mode='widthFix' class="image"
src="../static/images/product_specification.png"></image>
<text class="text">规格模板</text>
</navigator>
</view>
</swiper-item> -->
</block>
</swiper>
</div>
@ -482,8 +481,7 @@
const data = getStorage('addGoodsFormData');
if (data && data.product_id) {
let waitDeleteData = ['addGoodsFormData', 'singleSpecification', 'attrValue', 'modifyPriceData',
'addGoodsSecoundData', 'goodsDis', 'editGoodsDetils'
];
'addGoodsSecoundData', 'goodsDis', 'editGoodsDetils'];
waitDeleteData.forEach(item => {
if (getStorage(item)) {
removeStorage(item);