发布商品

This commit is contained in:
zmj 2024-04-23 08:45:17 +08:00
parent 12acca43be
commit 9802fda53a
9 changed files with 763 additions and 364 deletions

View File

@ -26,7 +26,7 @@
<!--#endif--> <!--#endif-->
<!--#ifdef APP-PLUS--> <!--#ifdef APP-PLUS-->
<img src="https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/3/video_bg.png" <img src="https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/3/video_bg.png"
style=" width:150rpx"></img> style=" width:140rpx"></img>
<!--#endif--> <!--#endif-->
<image src="@/static/images/gban.png" mode="widthFix"></image> <image src="@/static/images/gban.png" mode="widthFix"></image>
</view> </view>
@ -39,9 +39,11 @@
</view> </view>
<view class="" style="position: relative;" v-else> <view class="" style="position: relative;" v-else>
<view class="jiao" @click="formData.imageList.splice(index,1)"> <view class="jiao" @click="formData.imageList.splice(index,1)">
<image src="@/static/images/gban.png" mode="widthFix"></image> <image src="@/static/images/gban.png" mode="widthFix">
</image>
</view> </view>
<u--image :src="item" :fade="true" duration="450" width='140rpx' height='140rpx'></u--image> <u--image @click="preViewImg(item,index)" :src="item" :fade="true" duration="450"
width='140rpx' height='140rpx'></u--image>
</view> </view>
</view> </view>
<view class='uploadimg' @click="show=true"> <view class='uploadimg' @click="show=true">
@ -206,8 +208,7 @@
"volume": "", "volume": "",
"extension_one": "", "extension_one": "",
"extension_two": "", "extension_two": "",
open: true, "is_use": 0,
spec_type: ""
}], }],
"cate_name": "", "cate_name": "",
"unit_name": "", "unit_name": "",
@ -217,7 +218,10 @@
], ],
"mer_cate_name": "", "mer_cate_name": "",
"spec_type": "0", "spec_type": "0",
"attr": [], attr: [{
detail: [],
value: ""
}, ],
"specifica": "", "specifica": "",
"delivery_way": [ "delivery_way": [
@ -239,7 +243,16 @@
"title": "", "title": "",
"image": [] "image": []
}, },
"stock": "" "stock": "",
product_attribute: {
address: "",
leval: "",
pack: "",
attr: [{
label: "",
value: ''
}]
}
}, },
showPouple: false, showPouple: false,
fileList6: [], fileList6: [],
@ -299,8 +312,10 @@
// //
handleChooseImage() { handleChooseImage() {
let that = this; let that = this;
that.$util.uploadImageOne('upload/image', function(res) { that.$util.uploadImages({
console.log(that.formData) count: 6,
url: 'upload/image'
}, function(res) {
that.formData.imageList.push(res.data.path); that.formData.imageList.push(res.data.path);
}); });
}, },
@ -309,6 +324,7 @@
let that = this let that = this
uni.chooseVideo({ uni.chooseVideo({
sourceType: ['camera', 'album'], sourceType: ['camera', 'album'],
limit: 6,
success: res => { success: res => {
uni.showLoading({ uni.showLoading({
title: '正在上传中。。。' title: '正在上传中。。。'
@ -377,7 +393,7 @@
}, },
goDetail() { goDetail() {
uni.navigateTo({ uni.redirectTo({
url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${this.mer_id}&&formData=${JSON.stringify(this.formData)}&&showSet=${false}` url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${this.mer_id}&&formData=${JSON.stringify(this.formData)}&&showSet=${false}`
}) })
}, },
@ -386,6 +402,22 @@
url url
}) })
}, },
preViewImg(url, index) {
let that = this
uni.previewImage({
urls: [url],
// longPressActions: {
// itemList: ['', '', ''],
// success: function(data) {
// console.log('' + (data.tapIndex + 1) + ',' + (data.index + 1) + '');
// },
// fail: function(err) {
// console.log(err.errMsg);
// }
// }
});
},
async submit() { async submit() {
let data = uni.$u.deepClone(this.formData) let data = uni.$u.deepClone(this.formData)
data.image = data.imageList[0] data.image = data.imageList[0]
@ -411,7 +443,6 @@
.catch(rej => { .catch(rej => {
// Toast(rej); // Toast(rej);
}); });
console.log(this.formData)
} }
}, },
onLoad(option) { onLoad(option) {

View File

@ -139,33 +139,50 @@
</u-form-item> </u-form-item>
<view class="" v-if="showSet"> <view class="" v-if="showSet">
<view class="" v-for="(item,index) in formData.attrValue.filter(item=> !item.is_use)"> <view class="" v-for="(item,index) in formData.attrValue.filter(item=> item.is_use==0)">
<u-form-item :label="item.spec_type" label-width="350rpx" prop="userInfo.name" ref="item1" <view class="" v-if='formData.attrValue.filter(item=> item.is_use==0).length==1'>
labelPosition="left" border-bottom> <u-line color="#CECECE" style="margin-bottom: 30rpx;"></u-line>
<view class="" style="display: flex;justify-content: space-around;">
<view class=""
style="display: flex;justify-content: space-around;flex: 1;border-right: 1px solid #CECECE;">
<text>零售价格</text>
<text>5000/</text>
</view>
<view class="" style="display: flex;justify-content: space-around;flex: 1;">
<text>商品库存</text>
<text>5000</text>
</view>
<view class="" style="display: flex;justify-content: space-between;width: 100%">
<view style="width: 250rpx;" v-if='!item.spec_type'>
</view>
<view style="font-size: 28rpx;color:#777777 ;">
零售价
</view>
<view style="font-size: 28rpx;color:#777777 ;">
{{item.price}}/{{item.unit_name}}
</view>
</view> </view>
</u-form-item> </view>
<u-form-item label=" " label-width="350rpx" prop="userInfo.name" ref="item1" <view class="" v-else>
labelPosition="left" border-bottom v-if='isWholeSale'> <u-form-item :label="formData.attr[index].value" label-width="350rpx" prop="userInfo.name"
<view class="" style="display: flex;justify-content: space-between;width: 100%"> ref="item1" labelPosition="left" border-bottom>
<view style="font-size: 28rpx;color:#777777 ;"> <view class="" style="display: flex;justify-content: space-between;width: 100%">
批发价 <view style="width: 250rpx;" v-if='!formData.attr[index].value'>
</view>
<view style="font-size: 28rpx;color:#777777 ;">
零售价
</view>
<view style="font-size: 28rpx;color:#777777 ;">
{{item.price}}/{{item.unit_name}}
</view>
</view> </view>
<view style="font-size: 28rpx;color:#777777 ;"> </u-form-item>
{{item.wholesale_price}}/{{item.wholesale_unit_name}} <u-form-item label=" " label-width="350rpx" prop="userInfo.name" ref="item1"
labelPosition="left" border-bottom v-if='isWholeSale'>
<view class="" style="display: flex;justify-content: space-between;width: 100%">
<view style="font-size: 28rpx;color:#777777 ;">
批发价
</view>
<view style="font-size: 28rpx;color:#777777 ;">
{{item.wholesale_price}}/{{item.wholesale_unit_name}}
</view>
</view> </view>
</view> </u-form-item>
</u-form-item> </view>
</view> </view>
</view> </view>
@ -308,7 +325,7 @@
"volume": "", "volume": "",
"extension_one": "", "extension_one": "",
"extension_two": "", "extension_two": "",
"open": true, "is_use": 0,
"spec_type": "" "spec_type": ""
}], }],
"cate_name": "", "cate_name": "",
@ -317,7 +334,10 @@
"mer_cate_id": [], "mer_cate_id": [],
"mer_cate_name": "", "mer_cate_name": "",
"spec_type": "0", "spec_type": "0",
"attr": [], attr: [{
detail: [],
value: ""
}, ],
"specifica": "", "specifica": "",
"delivery_way": [], "delivery_way": [],
"delivery_free": "", "delivery_free": "",
@ -429,15 +449,15 @@
} }
}, },
// //
handleChooseImage() { handleChooseImage() {
let that = this; let that = this;
that.$util.uploadImageOne('upload/image', function(res) { that.$util.uploadImages({
if (that.isDetail) { count: 6,
that.formData.content.image.push(res.data.path); url: 'upload/image'
} else { }, function(res) {
that.formData.imageList.push(res.data.path); that.formData.imageList.push(res.data.path);
}
}); });
}, },
// //
@ -579,41 +599,37 @@
.catch(rej => { .catch(rej => {
// Toast(rej); // Toast(rej);
}) })
},
initFormData(option) {
this.delivery_way = this.$store.state.app.userInfo?.mer_info.delivery_way.split(',')
this.isWholeSale = this.$store.state.app.userInfo?.mer_info?.wholesale == 2;
this.mer_id = option.mer_id
if (option.formData) {
this.formData = JSON.parse(option.formData)
}
} }
}, },
onLoad(option) { onLoad(option) {
this.delivery_way = this.$store.state.app.userInfo?.mer_info.delivery_way.split(',') this.initFormData(option)
this.isWholeSale = this.$store.state.app.userInfo?.mer_info?.wholesale == 2;
this.mer_id = option.mer_id
this.showSet = option.showSet ? JSON.parse(option.showSet) : this.showSet this.showSet = option.showSet ? JSON.parse(option.showSet) : this.showSet
if (option.typeData) {
this.formData.cate_name = JSON.parse(option.typeData).label
this.formData.cate_id = JSON.parse(option.typeData).value
}
if (option.formData) {
let data = JSON.parse(option.formData)
for (let key in data) {
this.formData[key] = data[key]
}
}
let that = this let that = this
this.isSet2() this.isSet2()
if (option.product_id) { if (option.product_id) {
that.formData.product_id = option.product_id that.formData.product_id = option.product_id
this.mode = 'edit' this.mode = 'edit'
this.showSet = true
productDetail(option.mer_id, option.product_id).then(res => { productDetail(option.mer_id, option.product_id).then(res => {
this.formData = res.data this.formData = res.data
//
this.formData.product_attribute = JSON.parse(this.formData.product_attribute) this.formData.product_attribute = JSON.parse(this.formData.product_attribute)
this.formData.cate_name = this.formData.storeCategory.cate_name this.formData.cate_name = this.formData.storeCategory.cate_name
this.formData.cate_id = this.formData.storeCategory.store_category_id this.formData.cate_id = this.formData.storeCategory.store_category_id
this.formData.imageList = this.formData.image_list this.formData.imageList = this.formData.image_list
}) })
} }
console.log(this.formData)
// console.log(this.isSet(this.formData.attrValue)) // console.log(this.isSet(this.formData.attrValue))
}, },
onBackPress: function(e) { onBackPress: function(e) {

View File

@ -76,7 +76,7 @@
<view class="Positioning " style="color: #989898;margin-bottom: 30rpx;"> <view class="Positioning " style="color: #989898;margin-bottom: 30rpx;">
<view class="" style="display: flex;" @click="confirm"> <view class="" style="display: flex;" @click="confirm">
<u-icon name="map" style='margin-right: 8rpx;'></u-icon> <u-icon name="map" style='margin-right: 8rpx;'></u-icon>
<text>{{address.province}}{{address.city}}{{address.district}}</text> <text>{{(address.province+address.city+address.district )||errMag}} </text>
</view> </view>
<view class="" @click="getLocation"> <view class="" @click="getLocation">
刷新定位 刷新定位
@ -103,7 +103,6 @@
请选择 请选择
</view> </view>
<view class="position-content"> <view class="position-content">
<view class="position-li" :class="{act:address[wacthType()]==item.name}" <view class="position-li" :class="{act:address[wacthType()]==item.name}"
v-for="item in positionList" @click="chosePosition(item)"> v-for="item in positionList" @click="chosePosition(item)">
<text> <text>
@ -184,7 +183,7 @@
data() { data() {
return { return {
errMag: "",
provinceList: [], provinceList: [],
cityList: [], cityList: [],
districtList: [], districtList: [],
@ -303,22 +302,30 @@
}).then(res => { }).then(res => {
this.cityList = res.data this.cityList = res.data
this.positionList = this.cityList this.positionList = this.cityList
this.cityList.forEach(item => {
if (this.address.city == item.name) {
this.address.city_code = item.code
}
})
}) })
}, },
choseArea() { choseArea() {
this.positionType = 2; this.positionType = 2;
console.log(this.address)
getArea({ getArea({
city_code: this.address.city_code city_code: this.address.city_code
}).then(res => { }).then(res => {
this.areaList = res.data this.areaList = res.data
this.positionList = this.areaList this.positionList = this.areaList
}) })
}, },
getLocation() { getLocation() {
let that = this let that = this
uni.getLocation({ uni.getLocation({
type: 'gcj02', type: 'wgs84',
success: function(res) { success: function(res) {
console.log(res, 'res')
getGeocoder({ getGeocoder({
lat: res.latitude, lat: res.latitude,
long: res.longitude long: res.longitude
@ -331,6 +338,7 @@
} }
}) })
}).catch(err => { }).catch(err => {
console.log("获取位置失败")
uni.showToast({ uni.showToast({
title: err, title: err,
icon: 'none' icon: 'none'
@ -338,13 +346,16 @@
}) })
},
fail: function(err) {
that.errMag = "获取位置失败,请手动先择"
console.log('sad', err)
} }
}); });
}, },
submit() { submit() {
let that = this let that = this
console.log(this.mer_id) uni.reLaunch({
uni.navigateTo({
url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${that.mer_id}&&formData=${JSON.stringify(that.formData) }` url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${that.mer_id}&&formData=${JSON.stringify(that.formData) }`
}) })
@ -354,6 +365,7 @@
onLoad(option) { onLoad(option) {
getProvince().then(res => { getProvince().then(res => {
this.provinceList = res.data this.provinceList = res.data
this.positionList = res.data
}) })
this.formData = JSON.parse(option.formData) this.formData = JSON.parse(option.formData)
if (option.mer_id) { if (option.mer_id) {

View File

@ -1,14 +1,15 @@
<template> <template>
<view class="content"> <view class="content">
<view class=""> <view class="">
<u-button icon="plus" text="新增规格" @click="attrValue.push({is_use:true}),attr.push({value:'',detail: [],})" <u-button icon="plus" text="新增规格"
@click="formData.attrValue.push({is_use:true}),formData.attr.push({value:'',detail: [],})"
class="custom-style" iconColor='#38BE41'></u-button> class="custom-style" iconColor='#38BE41'></u-button>
</view> </view>
<view class="card" v-for="(item,index) in attrValue"> <view class="card" v-for="(item,index) in attrValue">
<view class="card-head card-li"> <view class="card-head card-li">
<text style="font-size: 32rpx;font-family: PingFangFamily;">规格{{index+1}}</text> <text style="font-size: 32rpx;font-family: PingFangFamily;">规格{{index+1}}</text>
<view class="" style="width: 300rpx;"> <view class="" style="width: 300rpx;">
<u--input placeholder="请输入规格名称" inputAlign='right' v-model="attr[index].value"></u--input> <u--input placeholder="请输入规格名称" inputAlign='right' v-model="formData.attr[index].value"></u--input>
</view> </view>
</view> </view>
<u-line direction="row" style="margin: 30rpx 0;" color="#ECECEC"></u-line> <u-line direction="row" style="margin: 30rpx 0;" color="#ECECEC"></u-line>
@ -51,7 +52,8 @@
</view> </view>
<u-line direction="row" style="margin: 25rpx 0;" color="#ECECEC"></u-line> <u-line direction="row" style="margin: 25rpx 0;" color="#ECECEC"></u-line>
<view class="card-li"> <view class="card-li">
<view style="display: flex;color: #777777;" @click="attrValue.splice(index,1)"> <view style="display: flex;color: #777777;"
@click="attrValue.splice(index,1),formData.attr.splice(index,1)">
<u-icon name="trash" style='margin-right: 8rpx;'></u-icon> <u-icon name="trash" style='margin-right: 8rpx;'></u-icon>
</view> </view>
<view class="" style="display: flex;align-items: center;"> <view class="" style="display: flex;align-items: center;">
@ -67,6 +69,9 @@
</template> </template>
<script> <script>
import {
formatDate
} from '../../../libs/uniApi'
export default { export default {
data() { data() {
return { return {
@ -75,62 +80,62 @@
text: "", text: "",
value: "", value: "",
formData: {}, formData: {},
attr: [{ "attrValue": [{
detail: [], "price": "",
value: "" "unit_name": "",
}, ], "wholesale_unit_name": "",
attrValue: [{ "wholesale_price": "",
spec_type: "", "cost": "",
"stock": "",
"ot_price": "",
"procure_price": "",
"bar_code": "",
"weight": "",
"volume": "",
"extension_one": "",
"extension_two": "",
"is_use": 0,
"spec_type": ""
}],
"price": "",
"unit_name": "",
"wholesale_unit_name": "",
"wholesale_price": '',
"cost": "",
"stock": "",
"ot_price": "",
"procure_price": "",
"bar_code": "",
"weight": "",
"volume": "",
"extension_one": "",
"extension_two": "",
is_use: true
},
],
} }
}, },
methods: { methods: {
submit() { submit() {
this.attrValue.forEach(item => {
item.is_use ? item.is_use = 0 : item.is_use = 1
})
this.formData.attrValue = this.attrValue this.formData.attrValue = this.attrValue
this.formData.attr = this.attr this.formData.attrValue.forEach(item => {
item.is_use = item.is_use ? '0' : '1'
})
let that = this let that = this
uni.navigateTo({ uni.reLaunch({
url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${that.mer_id}&&formData=${JSON.stringify(that.formData) }&&showSet=${true}` url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${that.mer_id}&&formData=${JSON.stringify(that.formData) }&&showSet=${true}`
}) })
},
initFomrData(option) {
if (option.mer_id) {
this.mer_id = option.mer_id
}
if (option.formData) {
this.formData = JSON.parse(option.formData)
}
} }
}, },
onLoad(option) { onLoad(option) {
this.isWholeSale = this.$store.state.app.userInfo?.mer_info?.wholesale == 2; this.isWholeSale = this.$store.state.app.userInfo?.mer_info?.wholesale == 2;
if (option.formData) { this.initFomrData(option)
this.formData = JSON.parse(option.formData) this.attrValue = this.formData.attrValue
this.attrValue = this.formData.attrValue this.attrValue.forEach(item => {
this.attr = this.formData.attr item.is_use = !Boolean(Number(item.is_use))
})
this.attrValue.forEach(item => { if (this.formData.attr.length == 0) {
item.is_use = !Boolean(item.is_use) this.formData.attr.push({
value: '',
detail: [],
}) })
} }
if (option.mer_id) { console.log(this.formData)
this.mer_id = option.mer_id console.log(this.attrValue)
}
console.log(this.mer_id, 'meridd')
} }
} }

View File

@ -68,37 +68,39 @@
}) })
}, },
navgo() { navgo() {
uni.navigateTo({ uni.redirectTo({
url: `/pages/product/addGoodDetail/goodsType?mer_id=${this.mer_id}&&type=${this.type}` url: `/pages/product/addGoodDetail/goodsType?mer_id=${this.mer_id}&&type=${this.type}&&formData=${JSON.stringify(this.formData)}`
}) })
}, },
hdChose(item) { hdChose(item) {
this.formData.cate_name = item.label.includes('--') ? item.label
.split('--')[1] : item.label;
this.formData.cate_id = item.value
categorySearchHistory(this.mer_id, this.$store.state.app.userInfo.uid, { categorySearchHistory(this.mer_id, this.$store.state.app.userInfo.uid, {
cate_id: item.value cate_id: item.value
}) })
uni.redirectTo({ uni.redirectTo({
url: `/pages/product/addGood/addGood?mer_id=${this.mer_id}&&data=${JSON.stringify(item)}&&formData=${JSON.stringify(this.formData)}` url: `/pages/product/addGood/addGood?mer_id=${this.mer_id}&&formData=${JSON.stringify(this.formData)}`
}) })
},
initFormData(option) {
this.mer_id = option.mer_id
if (option.type) {
this.type = 'simple'
}
this.formData = JSON.parse(option.formData)
} }
}, },
onLoad(option) { onLoad(option) {
this.mer_id = option.mer_id this.initFormData(option)
if (option.type) {
this.type = 'simple'
}
this.formData = JSON.parse(option.formData)
if (option.formData) {}
categoryHotcate( categoryHotcate(
option.mer_id, option.mer_id,
this.$store.state.app.userInfo.uid this.$store.state.app.userInfo.uid
).then(res => { ).then(res => {
this.hotList = res.data.hot_cate.map(item => ({ this.hotList = res.data.hot_cate.map(item => ({
label: item.cate_name, label: item.cate_name,
value: item.store_category_id value: item.store_category_id
}))
})
)
this.typeList = res.data.active_cate.map(item => ({ this.typeList = res.data.active_cate.map(item => ({
label: item.cate_name, label: item.cate_name,
value: item.store_category_id value: item.store_category_id

View File

@ -5,10 +5,10 @@
<text style="margin-left: 48rpx;color: #20B128;">生鲜--水果阿萨</text> <text style="margin-left: 48rpx;color: #20B128;">生鲜--水果阿萨</text>
</view> --> </view> -->
<view class="content"> <view class="content">
<view class="lines" :style="{top:(actIndex*82)+30+'rpx'}" /> <view class="lines" :style="{top:(actIndex*40)+16+'px'}" />
<view class="left"> <view class="left">
<view class="left-li" v-for="(item,index) in leftList" :class="actIndex==index?'act-li':''" <view class="left-li" v-for="(item,index) in leftList" :class="actIndex==index?'act-li':''"
@click="hdClcik(index)"> @click="hdClick(index)">
{{item.label}} {{item.label}}
</view> </view>
</view> </view>
@ -16,8 +16,8 @@
<u-line direction="col" color="#ECECEC"></u-line> <u-line direction="col" color="#ECECEC"></u-line>
</view> </view>
<view class="right"> <view class="right">
<u-search :showAction="true" v-model="keyword" actionText="搜索" :animation="true" <u-search :showAction="true" v-model="keyword" actionText="搜索" :animation="true" @search='hdSearch'
@search='hdSearch'></u-search> @custom='hdSearch'> </u-search>
<view style="margin: 30rpx 0;font-size: 28rpx; color: #989898;"> <view style="margin: 30rpx 0;font-size: 28rpx; color: #989898;">
可能在找 可能在找
</view> </view>
@ -38,6 +38,9 @@
</template> </template>
<script> <script>
import {
formatDate
} from '../../../libs/uniApi';
import { import {
categoryList, categoryList,
categorySearch categorySearch
@ -57,19 +60,23 @@
}, },
methods: { methods: {
hdClcik(index) { hdClick(index) {
this.actIndex = index this.actIndex = index
this.rightList = this.leftList[index].children this.rightList = this.leftList[index].children
}, },
choseType(item) { choseType(item) {
this.formData.cate_name = item.label.includes('--') ? item.label
.split('--')[1] : item.label;
this.formData.cate_id = item.value
if (this.type == 'detail') { if (this.type == 'detail') {
uni.navigateTo({ uni.redirectTo({
url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${this.mer_id}&&typeData=${JSON.stringify(item)}&&formData=${JSON.stringify(this.formData)} ` url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${this.mer_id}&&formData=${JSON.stringify(this.formData)} `
}) })
} else { } else {
uni.navigateTo({ uni.redirectTo({
url: `/pages/product/addGood/addGood?mer_id=${this.mer_id}&&data=${JSON.stringify(item)}&&formData=${JSON.stringify(this.formData)}` url: `/pages/product/addGood/addGood?mer_id=${this.mer_id}&&formData=${JSON.stringify(this.formData)}`
}) })
} }
@ -79,23 +86,19 @@
keyword: this.keyword keyword: this.keyword
}).then(res => { }).then(res => {
this.rightList = res.data this.rightList = res.data
console.log(res)
}) })
// categorySearch(this.mer_id) { },
initFormData(option) {
// } this.mer_id = option.mer_id
if (option.type) {
this.type = 'simple'
}
this.formData = JSON.parse(option.formData)
} }
}, },
onLoad(option) { onLoad(option) {
this.mer_id = option.mer_id this.initFormData(option)
if (option.type) {
this.type = 'simple'
}
if (option.formData) {
this.formData = JSON.parse(option.formData)
}
categoryList(option.mer_id).then((res) => { categoryList(option.mer_id).then((res) => {
this.leftList = res.data this.leftList = res.data
this.rightList = res.data[0].children this.rightList = res.data[0].children
@ -112,14 +115,14 @@
.content { .content {
display: flex; display: flex;
box-sizing: border-box; box-sizing: border-box;
padding: 30rpx; padding: 15px;
background-color: white; background-color: white;
min-height: 100vh; min-height: 100vh;
position: relative; position: relative;
font-family: PingFangRegular; font-family: PingFangRegular;
.lines { .lines {
height: 38rpx; height: 16px;
border-radius: 5px; border-radius: 5px;
width: 3px; width: 3px;
background-color: #40AE36; background-color: #40AE36;
@ -140,7 +143,8 @@
text-align: center; text-align: center;
font-size: 32rpx; font-size: 32rpx;
color: #444444; color: #444444;
height: 82rpx; height: 40px;
/* border-top: 1px solid red; */
} }
.act-li { .act-li {
@ -153,6 +157,8 @@
position: fixed; position: fixed;
width: 530rpx; width: 530rpx;
left: 220rpx; left: 220rpx;
min-height: 100vh;
overflow-y: auto;
.right-content { .right-content {
display: flex; display: flex;

View File

@ -58,8 +58,48 @@
<view class="wrapper" style="background-color: #F1F1F1;"> <view class="wrapper" style="background-color: #F1F1F1;">
<view class='product_list' v-if="productList && productList.length > 0"> <view class='product_list' v-if="productList && productList.length > 0">
<view v-for="(item,index) in productList" :key="index" style="position: relative;width: 100%;"> <view v-for="(item,index) in productList" :key="index" class="card">
<view class='item' @click="yinc"> <view class="card-top">
<view class="" style="width: 196rpx;height: 196rpx;position: relative;margin-right: 20rpx;">
<u--image :src="item.image" width='196rpx' height='196rpx' duration="450"></u--image>
<view class="preview" @click="preViewImg(item.image)">
点击预览
</view>
</view>
<view class="card-head-right">
<view class="" style="font-size: 32rpx;">
{{item.store_name}}
<view class="" style="margin-top: 10rpx;font-size: 24rpx;color: #989898;">
库存 96
</view>
</view>
<view class="" style="color: #FC452F;font-size: 24rpx;">
<text style="font-size: 22rpx;"></text><text>10.00</text><text
style="color: #828282;">/</text>
</view>
</view>
</view>
<view class="" style="padding: 20rpx;">
<u-line color="#CECECE" style="margin: 30rpx 0 28rpx 0"></u-line>
</view>
<view class=""
style="display: flex;justify-content: space-between;font-size: 28rpx;font-size: 28rpx;">
<view class="" style="border-right: 1px solid #CECECE;flex: 1;text-align: center;">
修改库存
</view>
<view class="" style="border-right: 1px solid #CECECE;flex: 1;text-align: center;">
下架
</view>
<view class="" style="flex: 1;text-align: center;">
编辑商品
</view>
</view>
<view class="card-footer">
</view>
<!-- <view class='item' @click="yinc">
<view class='image'> <view class='image'>
<image :src='item.image'></image> <image :src='item.image'></image>
<text v-if="item.spec_type == 1" class="spec">多规格</text> <text v-if="item.spec_type == 1" class="spec">多规格</text>
@ -72,7 +112,6 @@
</view> </view>
<view class="sales"> <view class="sales">
<text class="num">库存: {{item.stock}}</text> <text class="num">库存: {{item.stock}}</text>
<!-- <text class="num">销量: {{item.sales}}</text> -->
</view> </view>
<view class="stock_type" v-if="mer_info.type_code=='TypeSupplyChain'"> <view class="stock_type" v-if="mer_info.type_code=='TypeSupplyChain'">
<view class="type_btn" v-for="lable in lableList" :key="lable.product_label_id" <view class="type_btn" v-for="lable in lableList" :key="lable.product_label_id"
@ -94,31 +133,7 @@
</view> </view>
</view> </view>
<view style="position: absolute; top: 10px; right: 10px;">
<!-- 插件无需手动引入直接使用即可 -->
<!-- 里面···可以改为任意东西图片也可以 -->
<!-- 参数$event不可修改否则取不到点击事件详情 -->
<!-- <rudon-rowMenuDotDotDot :localdata="options"
@change="menuAction($event, item.attrValue,item)">
. . .
</rudon-rowMenuDotDotDot> -->
<view class=""
style='font-size: 30rpx;text-align: right;position: absolute; top: 0px; right: 10px;z-index: 999;"'
@click="menuActiona(item,index)">
<image src="@/static/images/dian.png" mode="aspectFill" style="width: 30rpx;height: 30rpx;
margin-top: 40rpx;"></image>
</view>
<view class="muau-header" v-if='index==num'
style="position: absolute; top: 60rpx; right: 0px;">
<view class="muau" v-for='(kk,i) in options'
@click='menuAction(kk, item.attrValue,item,index)'>
<view class="">
{{kk.text}}
</view>
</view>
</view>
</view>
<view class="operation acea-row row-between-wrapper"> <view class="operation acea-row row-between-wrapper">
<view class="acea-row row-middle"> <view class="acea-row row-middle">
<view class="" class="bnt" @click="Fline(item)" style="width:150rpx"> <view class="" class="bnt" @click="Fline(item)" style="width:150rpx">
@ -132,11 +147,12 @@
</view> </view>
<view @click="editGoods(item)" class="bnt">编辑45</view> <view @click="editGoods(item)" class="bnt">编辑45</view>
</view> </view>
</view> </view> -->
</view> </view>
</view> </view>
<u-empty v-else text="暂无商品~" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png"> <u-empty v-else text="暂无商品~" mode="data" style="min-height: 80vh;"
icon="http://cdn.uviewui.com/uview/empty/data.png">
</u-empty> </u-empty>
</view> </view>
<Loading :loaded="loaded" :loading="loading"></Loading> <Loading :loaded="loaded" :loading="loading"></Loading>
@ -149,7 +165,7 @@
<view class="footer-li"> <view class="footer-li">
扫码入库 扫码入库
</view> </view>
<view class="footer-li"> <view class="footer-li act">
发布商品 发布商品
</view> </view>
@ -331,6 +347,22 @@
}, },
methods: { methods: {
preViewImg(url) {
let that = this
uni.previewImage({
urls: [url],
// longPressActions: {
// itemList: ['', '', ''],
// success: function(data) {
// console.log('' + (data.tapIndex + 1) + ',' + (data.index + 1) + '');
// },
// fail: function(err) {
// console.log(err.errMsg);
// }
// }
});
},
// //
getCategoryList() { getCategoryList() {
getCategoryListLevel({ getCategoryListLevel({
@ -830,6 +862,54 @@
background-color: #F5F5F5; background-color: #F5F5F5;
} }
.card {
width: 718rpx;
height: 410rpx;
box-sizing: border-box;
border-radius: 16rpx;
background-color: #fff;
margin-top: 20rpx;
position: relative;
.preview {
width: 196rpx;
height: 50rpx;
position: absolute;
bottom: 0;
background: rgba(0, 0, 0, 0.2);
color: white;
text-align: center;
font-size: 24rpx;
line-height: 50rpx;
}
.card-top {
display: flex;
padding: 20rpx;
.card-head-right {
height: 196rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
}
// flex-wrap:;
// flex-direction: column;
// justify-content: sp;
}
.card-footer {
width: 713rpx;
height: 74rpx;
border-radius: 0 0 16rpx 16rpx;
background-color: #FFF1EC;
position: absolute;
bottom: 0;
}
}
.longTab { .longTab {
display: flex; display: flex;
width: 100%; width: 100%;
@ -1383,7 +1463,17 @@
align-items: center; align-items: center;
.footer-li { .footer-li {
border: 1px solid black; border: 1px solid #989898;
font-size: 32rpx;
padding: 14rpx 27rpx;
border-radius: 40rpx;
}
.act {
border: none;
background-color: #32BB3B;
color: white;
} }
} }
</style> </style>

View File

@ -1,189 +1,348 @@
<template> <template>
<view class=""> <view class="content">
<view class="table"> <view class="head">
<u-sticky custom-nav-height="0" bgColor="#fff"> <view class="" style="width: 210rpx;height: 210rpx;position: relative;">
<view class="line th"> <u--image :src="short.attrValue[0].image||short.image||defualtImg" width='210rpx' height='210rpx'
<view class="td img">图片</view> duration="450"></u--image>
<view class="td sku">规格</view> <view class="preview" @click="preViewImg(short.attrValue[0].image||short.image||defualtImg)">
<view class="td stock">库存</view> 点击预览
</view> </view>
</u-sticky> </view>
<view class="line tr" v-for="(item,index) in short.attrValue" :key="index">
<view class="td img"> <view class="right">
<image :src="item.image||short.image||defualtImg"></image> <view class="">
</view> <view class="" style="font-size: 32rpx;color: #444444;">
<view class="td sku"> 打扫房间好看
<block v-if="item.sku"> </view>
<view v-for="name in item.sku.split(',')">{{name}}</view> <view class="" style="font-size: 24rpx;color: #989898;margin-top: 10rpx;">
</block> 库存 100
<view v-else>{{short.store_name}}</view> </view>
</view> </view>
<view class="td stock"> <view class="" style="color: #FC452F;font-size: 24rpx;">
<input type="number" v-model="item.stock" /> <text style="font-size: 22rpx;"></text><text>10.00</text><text style="color: #828282;">/</text>
</view> </view>
</view> </view>
</view> </view>
<view style="height: 150rpx;"></view> <view class="attr">
<view class="btn-view"> <view class="attr-tit">
<button class="btn" @click="show=true">确认修改</button> 这是大苏打
</view> </view>
<u-modal :show="show" :closeOnClickOverlay="true" title="提示" content="确定更新库存吗" showCancelButton @confirm="onUpdate" @cancel="show=false"></u-modal> <u-line color="#CECECE" style="margin: 30rpx 0 28rpx 0"></u-line>
</view> <view class="" style="display: flex;justify-content: space-between;font-size: 32rpx;">
<view class="">
商品库存
</view>
<view class="" style="display: flex;align-items: center;color: #FC452F;">
<u--input border="surround" color='#FC452F' inputAlign='right' style='padding: 0;'
v-model="test"></u--input>
</view>
</view>
</view>
<view class="attr">
<view class="attr-tit">
这是大苏打
</view>
<u-line color="#CECECE" style="margin: 30rpx 0 28rpx 0"></u-line>
<view class="" style="display: flex;justify-content: space-between;font-size: 32rpx;">
<view class="">
商品库存
</view>
<view class="" style="display: flex;align-items: center;color: #FC452F;">
<u--input border="surround" color='#FC452F' inputAlign='right' style='padding: 0;'
v-model="test"></u--input>
</view>
</view>
</view>
<view class="table">
<u-sticky custom-nav-height="0" bgColor="#fff">
<view class="line th">
<view class="td img">图片</view>
<view class="td sku">规格</view>
<view class="td stock">库存</view>
</view>
</u-sticky>
<view class="line tr" v-for="(item,index) in short.attrValue" :key="index">
<view class="td img">
<image :src="item.image||short.image||defualtImg"></image>
</view>
<view class="td sku">
<block v-if="item.sku">
<view v-for="name in item.sku.split(',')">{{name}}</view>
</block>
<view v-else>{{short.store_name}}</view>
</view>
<view class="td stock">
<input type="number" v-model="item.stock" />
</view>
</view>
</view>
<view style="height: 150rpx;"></view>
<!-- <view class="btn-view">
<button class="btn" @click="show=true">确认修改</button>
</view> -->
<view class="submit-btn">
<u-button type="primary" shape="circle" text="确认修改" @click="show=true"></u-button>
</view>
<u-modal :show="show" :closeOnClickOverlay="true" title="提示" content="确定更新库存吗" showCancelButton
@confirm="onUpdate" @cancel="show=false"></u-modal>
</view>
</template> </template>
<script> <script>
import { import {
getProductDetail, getProductDetail,
} from '@/api/store.js'; } from '@/api/store.js';
import { import {
productDetail, productDetail,
productUpdateFree productUpdateFree
} from "@/api/product.js" } from "@/api/product.js"
import { Toast } from '../../../libs/uniApi'; import {
export default { Toast
data() { } from '../../../libs/uniApi';
return { export default {
show: false, data() {
defualtImg: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230130/00ebcfdf75684f5494c0193075055d1.png', return {
mer_id: '', test: '20',
short: { show: false,
product_id: '' defualtImg: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230130/00ebcfdf75684f5494c0193075055d1.png',
} mer_id: '',
} short: {
}, product_id: ''
onLoad(options) { }
this.short.product_id = options.product_id; }
let userInfo = this.$store.state.app.userInfo; },
if(typeof userInfo == 'string')userInfo = JSON.parse(userInfo); onLoad(options) {
this.mer_id = userInfo.service.mer_id; this.short.product_id = options.product_id;
this.initInfo(); let userInfo = this.$store.state.app.userInfo;
}, if (typeof userInfo == 'string') userInfo = JSON.parse(userInfo);
onShow() {}, this.mer_id = userInfo.service.mer_id;
methods: { this.initInfo();
initInfo() { },
productDetail(this.mer_id, this.short.product_id).then((res) => { onShow() {},
this.short = res.data; methods: {
console.log({...res.data}); preViewImg(url) {
}) let that = this
}, uni.previewImage({
onUpdate(){ urls: [url],
let obj = { // longPressActions: {
"attr": this.short.attr, // itemList: ['', '', ''],
"attrValue": this.short.attrValue, // success: function(data) {
"mer_cate_id": this.short.merCateId||[], // console.log('' + (data.tapIndex + 1) + ',' + (data.index + 1) + '');
"spec_type": this.short.spec_type, // },
"is_stock": 1 // fail: function(err) {
}; // console.log(err.errMsg);
// return console.log({...obj},this.short.product_id); // }
productUpdateFree(this.short.product_id, obj).then(res => { // }
this.show = false; });
this.$nextTick(()=>{
Toast('更新成功'); },
}) initInfo() {
uni.navigateBack({ productDetail(this.mer_id, this.short.product_id).then((res) => {
success:()=> { this.short = res.data;
let stock = 0; console.log({
this.short.attrValue.forEach(item=>{ ...res.data
stock = stock + parseInt(item.stock); });
}) })
uni.$emit('updateStock', { },
product_id: this.short.product_id, onUpdate() {
stock: stock let obj = {
}) "attr": this.short.attr,
} "attrValue": this.short.attrValue,
}) "mer_cate_id": this.short.merCateId || [],
}).catch(err => { "spec_type": this.short.spec_type,
this.show = false; "is_stock": 1
this.$util.Tips({ };
title: err // return console.log({...obj},this.short.product_id);
}) productUpdateFree(this.short.product_id, obj).then(res => {
}) this.show = false;
} this.$nextTick(() => {
}, Toast('更新成功');
onPullDownRefresh() { })
uni.stopPullDownRefresh() uni.navigateBack({
} success: () => {
} let stock = 0;
this.short.attrValue.forEach(item => {
stock = stock + parseInt(item.stock);
})
uni.$emit('updateStock', {
product_id: this.short.product_id,
stock: stock
})
}
})
}).catch(err => {
this.show = false;
this.$util.Tips({
title: err
})
})
}
},
onPullDownRefresh() {
uni.stopPullDownRefresh()
}
}
</script> </script>
<style lang="scss"> <style lang="scss">
.table{ .content {
background-color: #fff; padding: 20rpx 16rpx;
border-top: 1rpx solid rgba(0,0,0,0.1); background-color: #F1F1F1;
border-left: 1rpx solid rgba(0,0,0,0.1); min-height: 100vh;
border-right: 1rpx solid rgba(0,0,0,0.1);
font-size: 28rpx;
.line{
display: flex;
border-bottom: 1rpx solid rgba(0,0,0,0.1);
.img{
// width:140rpx;
width: 200rpx;
}
.sku{
flex: 1;
border-left: 1rpx solid rgba(0,0,0,0.1);
border-right: 1rpx solid rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
align-items: center;
}
.stock{
width: 200rpx;
input{
width: 100%;
height: 100%;
text-align: center;
color: #F84221;
}
}
}
.th{
height: 70rpx;
line-height: 70rpx;
text-align: center;
font-size: 32rpx;
font-weight: bold;
}
.tr{
min-height: 140rpx;
.td{
display: flex;
justify-content: center;
align-items: center;
}
.img{
image{
width: 120rpx;
height: 120rpx;
}
}
.sku{
padding: 16rpx 16rpx;
}
}
}
.btn-view{
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 130rpx;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
border-top: 1rpx solid rgba(0,0,0,0.1);
.btn{ .head {
background: linear-gradient(180deg, #FF6D20 0%, #F84221 100%); background-color: #fff;
// background-color: #FF6D20; display: flex;
height: 100rpx; padding: 20rpx;
line-height: 100rpx; border-radius: 16rpx;
width: 694rpx;
text-align: center; .right {
border-radius: 100rpx; margin-left: 20rpx;
color: #fff; display: flex;
} flex-direction: column;
} justify-content: space-between;
}
}
.attr {
width: 690rpx;
margin: 22rpx auto;
box-sizing: border-box;
background-color: white;
padding: 30rpx;
border-radius: 16rpx;
box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(0, 0, 0, 0.16);
.attr-tit {
margin-left: 16rpx;
font-size: 32rpx;
position: relative;
}
.attr-tit::after {
content: '';
position: absolute;
width: 8rpx;
height: 32rpx;
background-color: #40AE36;
border-radius: 4rpx;
left: -16rpx;
top: 10rpx;
}
}
}
.preview {
width: 210rpx;
height: 50rpx;
position: absolute;
bottom: 0;
background: rgba(0, 0, 0, 0.2);
color: white;
text-align: center;
font-size: 24rpx;
line-height: 50rpx;
}
.submit-btn {
position: fixed;
bottom: 50rpx;
width: 670rpx;
}
// old
.table {
background-color: #fff;
border-top: 1rpx solid rgba(0, 0, 0, 0.1);
border-left: 1rpx solid rgba(0, 0, 0, 0.1);
border-right: 1rpx solid rgba(0, 0, 0, 0.1);
font-size: 28rpx;
.line {
display: flex;
border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
.img {
// width:140rpx;
width: 200rpx;
}
.sku {
flex: 1;
border-left: 1rpx solid rgba(0, 0, 0, 0.1);
border-right: 1rpx solid rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
align-items: center;
}
.stock {
width: 200rpx;
input {
width: 100%;
height: 100%;
text-align: center;
color: #F84221;
}
}
}
.th {
height: 70rpx;
line-height: 70rpx;
text-align: center;
font-size: 32rpx;
font-weight: bold;
}
.tr {
min-height: 140rpx;
.td {
display: flex;
justify-content: center;
align-items: center;
}
.img {
image {
width: 120rpx;
height: 120rpx;
}
}
.sku {
padding: 16rpx 16rpx;
}
}
}
.btn-view {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 130rpx;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
border-top: 1rpx solid rgba(0, 0, 0, 0.1);
.btn {
background: linear-gradient(180deg, #FF6D20 0%, #F84221 100%);
// background-color: #FF6D20;
height: 100rpx;
line-height: 100rpx;
width: 694rpx;
text-align: center;
border-radius: 100rpx;
color: #fff;
}
}
</style> </style>

View File

@ -590,14 +590,14 @@ export default {
*/ */
uploadImageOne: function(opt, successCallback, errorCallback) { uploadImageOne: function(opt, successCallback, errorCallback) {
let that = this; let that = this;
let obj = {}; let obj = {};
if (typeof opt === 'string') { if (typeof opt === 'string') {
let url = opt; let url = opt;
opt = {}; opt = {};
opt.url = url; opt.url = url;
}else { } else {
opt.crop ? obj.crop = opt.crop : null; opt.crop ? obj.crop = opt.crop : null;
} }
let count = opt.count || 1, let count = opt.count || 1,
sizeType = opt.sizeType || ['compressed'], sizeType = opt.sizeType || ['compressed'],
sourceType = opt.sourceType || ['album', 'camera'], sourceType = opt.sourceType || ['album', 'camera'],
@ -609,9 +609,9 @@ export default {
count: count, //最多可以选择的图片总数 count: count, //最多可以选择的图片总数
sizeType: sizeType, // 可以指定是原图还是压缩图,默认二者都有 sizeType: sizeType, // 可以指定是原图还是压缩图,默认二者都有
sourceType: sourceType, // 可以指定来源是相册还是相机,默认二者都有 sourceType: sourceType, // 可以指定来源是相册还是相机,默认二者都有
...obj, ...obj,
success: function(res) { success: function(res) {
console.log(res); console.log(res);
//启动上传等待中... //启动上传等待中...
uni.showLoading({ uni.showLoading({
title: '图片上传中', title: '图片上传中',
@ -657,6 +657,84 @@ export default {
} }
}) })
}, },
/*
* 多上传
* @param object opt
* @param callable successCallback 成功执行方法 data
* @param callable errorCallback 失败执行方法
*/
uploadImages: function(opt, successCallback, errorCallback) {
let that = this;
let obj = {};
if (typeof opt === 'string') {
let url = opt;
opt = {};
opt.url = url;
} else {
opt.crop ? obj.crop = opt.crop : null;
}
let count = opt.count || 1,
sizeType = opt.sizeType || ['compressed'],
sourceType = opt.sourceType || ['album', 'camera'],
is_load = opt.is_load || true,
uploadUrl = opt.url || '',
inputName = opt.name || 'field';
uni.chooseImage({
count: count, //最多可以选择的图片总数
sizeType: sizeType, // 可以指定是原图还是压缩图,默认二者都有
sourceType: sourceType, // 可以指定来源是相册还是相机,默认二者都有
...obj,
success: function(res) {
console.log(res.tempFilePaths);
//启动上传等待中...
uni.showLoading({
title: '图片上传中',
});
res.tempFilePaths.forEach((item, index) => {
uni.uploadFile({
url: HTTP_REQUEST_URL + '/api/' + uploadUrl + '/' + inputName,
filePath: item,
name: inputName,
formData: {
'filename': inputName
},
header: {
// #ifdef MP
"Content-Type": "multipart/form-data",
// #endif
[TOKENNAME]: 'Bearer ' + store.state.app.token
},
success: function(res) {
uni.hideLoading();
if (res.statusCode == 403) {
that.Tips({
title: res.data
});
} else {
let data = res.data ? JSON.parse(res.data) : {};
if (data.status == 200) {
successCallback && successCallback(data)
} else {
errorCallback && errorCallback(data);
that.Tips({
title: data.message
});
}
}
},
fail: function(res) {
uni.hideLoading();
that.Tips({
title: '上传图片失败'
});
}
})
})
}
})
},
/** /**
* 小程序头像获取上传 * 小程序头像获取上传
* @param uploadUrl 上传接口地址 * @param uploadUrl 上传接口地址