发布商品

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,13 +139,28 @@
</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>
</view>
<view class="" v-else>
<u-form-item :label="formData.attr[index].value" label-width="350rpx" prop="userInfo.name"
ref="item1" labelPosition="left" border-bottom>
<view class="" style="display: flex;justify-content: space-between;width: 100%"> <view class="" style="display: flex;justify-content: space-between;width: 100%">
<view style="width: 250rpx;" v-if='!item.spec_type'> <view style="width: 250rpx;" v-if='!formData.attr[index].value'>
</view> </view>
<view style="font-size: 28rpx;color:#777777 ;"> <view style="font-size: 28rpx;color:#777777 ;">
零售价 零售价
@ -167,6 +182,8 @@
</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,17 +80,11 @@
text: "", text: "",
value: "", value: "",
formData: {}, formData: {},
attr: [{ "attrValue": [{
detail: [],
value: ""
}, ],
attrValue: [{
spec_type: "",
"price": "", "price": "",
"unit_name": "", "unit_name": "",
"wholesale_unit_name": "", "wholesale_unit_name": "",
"wholesale_price": '', "wholesale_price": "",
"cost": "", "cost": "",
"stock": "", "stock": "",
"ot_price": "", "ot_price": "",
@ -95,42 +94,48 @@
"volume": "", "volume": "",
"extension_one": "", "extension_one": "",
"extension_two": "", "extension_two": "",
is_use: true "is_use": 0,
}, "spec_type": ""
}],
],
} }
}, },
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.attr = this.formData.attr
this.attrValue.forEach(item => { this.attrValue.forEach(item => {
item.is_use = !Boolean(item.is_use) item.is_use = !Boolean(Number(item.is_use))
})
if (this.formData.attr.length == 0) {
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,26 +68,31 @@
}) })
}, },
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)}`
}) })
}
}, },
onLoad(option) { initFormData(option) {
this.mer_id = option.mer_id this.mer_id = option.mer_id
if (option.type) { if (option.type) {
this.type = 'simple' this.type = 'simple'
} }
this.formData = JSON.parse(option.formData) this.formData = JSON.parse(option.formData)
if (option.formData) {} }
},
onLoad(option) {
this.initFormData(option)
categoryHotcate( categoryHotcate(
option.mer_id, option.mer_id,
this.$store.state.app.userInfo.uid this.$store.state.app.userInfo.uid
@ -95,10 +100,7 @@
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) {
// }
}
}, },
onLoad(option) { initFormData(option) {
this.mer_id = option.mer_id this.mer_id = option.mer_id
if (option.type) { if (option.type) {
this.type = 'simple' this.type = 'simple'
} }
if (option.formData) {
this.formData = JSON.parse(option.formData) this.formData = JSON.parse(option.formData)
} }
},
onLoad(option) {
this.initFormData(option)
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,5 +1,58 @@
<template> <template>
<view class="content">
<view class="head">
<view class="" style="width: 210rpx;height: 210rpx;position: relative;">
<u--image :src="short.attrValue[0].image||short.image||defualtImg" width='210rpx' height='210rpx'
duration="450"></u--image>
<view class="preview" @click="preViewImg(short.attrValue[0].image||short.image||defualtImg)">
点击预览
</view>
</view>
<view class="right">
<view class=""> <view class="">
<view class="" style="font-size: 32rpx;color: #444444;">
打扫房间好看
</view>
<view class="" style="font-size: 24rpx;color: #989898;margin-top: 10rpx;">
库存 100
</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="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="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"> <view class="table">
<u-sticky custom-nav-height="0" bgColor="#fff"> <u-sticky custom-nav-height="0" bgColor="#fff">
<view class="line th"> <view class="line th">
@ -24,10 +77,14 @@
</view> </view>
</view> </view>
<view style="height: 150rpx;"></view> <view style="height: 150rpx;"></view>
<view class="btn-view"> <!-- <view class="btn-view">
<button class="btn" @click="show=true">确认修改</button> <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> </view>
<u-modal :show="show" :closeOnClickOverlay="true" title="提示" content="确定更新库存吗" showCancelButton @confirm="onUpdate" @cancel="show=false"></u-modal> <u-modal :show="show" :closeOnClickOverlay="true" title="提示" content="确定更新库存吗" showCancelButton
@confirm="onUpdate" @cancel="show=false"></u-modal>
</view> </view>
</template> </template>
@ -39,10 +96,13 @@
productDetail, productDetail,
productUpdateFree productUpdateFree
} from "@/api/product.js" } from "@/api/product.js"
import { Toast } from '../../../libs/uniApi'; import {
Toast
} from '../../../libs/uniApi';
export default { export default {
data() { data() {
return { return {
test: '20',
show: false, show: false,
defualtImg: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230130/00ebcfdf75684f5494c0193075055d1.png', defualtImg: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230130/00ebcfdf75684f5494c0193075055d1.png',
mer_id: '', mer_id: '',
@ -54,36 +114,54 @@ import { Toast } from '../../../libs/uniApi';
onLoad(options) { onLoad(options) {
this.short.product_id = options.product_id; this.short.product_id = options.product_id;
let userInfo = this.$store.state.app.userInfo; let userInfo = this.$store.state.app.userInfo;
if(typeof userInfo == 'string')userInfo = JSON.parse(userInfo); if (typeof userInfo == 'string') userInfo = JSON.parse(userInfo);
this.mer_id = userInfo.service.mer_id; this.mer_id = userInfo.service.mer_id;
this.initInfo(); this.initInfo();
}, },
onShow() {}, onShow() {},
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);
// }
// }
});
},
initInfo() { initInfo() {
productDetail(this.mer_id, this.short.product_id).then((res) => { productDetail(this.mer_id, this.short.product_id).then((res) => {
this.short = res.data; this.short = res.data;
console.log({...res.data}); console.log({
...res.data
});
}) })
}, },
onUpdate(){ onUpdate() {
let obj = { let obj = {
"attr": this.short.attr, "attr": this.short.attr,
"attrValue": this.short.attrValue, "attrValue": this.short.attrValue,
"mer_cate_id": this.short.merCateId||[], "mer_cate_id": this.short.merCateId || [],
"spec_type": this.short.spec_type, "spec_type": this.short.spec_type,
"is_stock": 1 "is_stock": 1
}; };
// return console.log({...obj},this.short.product_id); // return console.log({...obj},this.short.product_id);
productUpdateFree(this.short.product_id, obj).then(res => { productUpdateFree(this.short.product_id, obj).then(res => {
this.show = false; this.show = false;
this.$nextTick(()=>{ this.$nextTick(() => {
Toast('更新成功'); Toast('更新成功');
}) })
uni.navigateBack({ uni.navigateBack({
success:()=> { success: () => {
let stock = 0; let stock = 0;
this.short.attrValue.forEach(item=>{ this.short.attrValue.forEach(item => {
stock = stock + parseInt(item.stock); stock = stock + parseInt(item.stock);
}) })
uni.$emit('updateStock', { uni.$emit('updateStock', {
@ -107,30 +185,105 @@ import { Toast } from '../../../libs/uniApi';
</script> </script>
<style lang="scss"> <style lang="scss">
.table{ .content {
padding: 20rpx 16rpx;
background-color: #F1F1F1;
min-height: 100vh;
.head {
background-color: #fff; 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; display: flex;
border-bottom: 1rpx solid rgba(0,0,0,0.1); padding: 20rpx;
.img{ border-radius: 16rpx;
.right {
margin-left: 20rpx;
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:140rpx;
width: 200rpx; width: 200rpx;
} }
.sku{
.sku {
flex: 1; flex: 1;
border-left: 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); border-right: 1rpx solid rgba(0, 0, 0, 0.1);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
.stock{
.stock {
width: 200rpx; width: 200rpx;
input{
input {
width: 100%; width: 100%;
height: 100%; height: 100%;
text-align: center; text-align: center;
@ -138,32 +291,38 @@ import { Toast } from '../../../libs/uniApi';
} }
} }
} }
.th{
.th {
height: 70rpx; height: 70rpx;
line-height: 70rpx; line-height: 70rpx;
text-align: center; text-align: center;
font-size: 32rpx; font-size: 32rpx;
font-weight: bold; font-weight: bold;
} }
.tr{
.tr {
min-height: 140rpx; min-height: 140rpx;
.td{
.td {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.img{
image{ .img {
image {
width: 120rpx; width: 120rpx;
height: 120rpx; height: 120rpx;
} }
} }
.sku{
.sku {
padding: 16rpx 16rpx; padding: 16rpx 16rpx;
} }
} }
} }
.btn-view{
.btn-view {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
left: 0; left: 0;
@ -173,9 +332,9 @@ import { Toast } from '../../../libs/uniApi';
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
border-top: 1rpx solid rgba(0,0,0,0.1); border-top: 1rpx solid rgba(0, 0, 0, 0.1);
.btn{ .btn {
background: linear-gradient(180deg, #FF6D20 0%, #F84221 100%); background: linear-gradient(180deg, #FF6D20 0%, #F84221 100%);
// background-color: #FF6D20; // background-color: #FF6D20;
height: 100rpx; height: 100rpx;
@ -185,5 +344,5 @@ import { Toast } from '../../../libs/uniApi';
border-radius: 100rpx; border-radius: 100rpx;
color: #fff; color: #fff;
} }
} }
</style> </style>

View File

@ -595,7 +595,7 @@ export default {
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,
@ -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 上传接口地址