Merge branch 'main' into prod
This commit is contained in:
commit
f89ac2d177
|
@ -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 {*}
|
||||
|
|
|
@ -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>
|
||||
|
@ -176,19 +177,25 @@
|
|||
</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 {
|
||||
chooseImage,
|
||||
Toast
|
||||
} from '@/libs/uniApi'
|
||||
export default {
|
||||
|
@ -233,33 +240,37 @@
|
|||
showModel: false,
|
||||
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": "DT15150(箱装)心相印茶语丝享系列150抽24包装三层塑装纸面巾(电商)",
|
||||
// "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 +284,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 +307,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 +459,7 @@
|
|||
this.addGoodsShow = false;
|
||||
} else {
|
||||
Toast(e.message)
|
||||
this.addGoodsShow = false
|
||||
this.addGoodsShow = false;
|
||||
}
|
||||
}).catch(err => {
|
||||
Toast(err || '导入出错');
|
||||
|
@ -1053,6 +1195,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 {
|
||||
|
|
Loading…
Reference in New Issue