发布商品

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-->
<!--#ifdef APP-PLUS-->
<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-->
<image src="@/static/images/gban.png" mode="widthFix"></image>
</view>
@ -39,9 +39,11 @@
</view>
<view class="" style="position: relative;" v-else>
<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>
<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 class='uploadimg' @click="show=true">
@ -206,8 +208,7 @@
"volume": "",
"extension_one": "",
"extension_two": "",
open: true,
spec_type: ""
"is_use": 0,
}],
"cate_name": "",
"unit_name": "",
@ -217,7 +218,10 @@
],
"mer_cate_name": "",
"spec_type": "0",
"attr": [],
attr: [{
detail: [],
value: ""
}, ],
"specifica": "",
"delivery_way": [
@ -239,7 +243,16 @@
"title": "",
"image": []
},
"stock": ""
"stock": "",
product_attribute: {
address: "",
leval: "",
pack: "",
attr: [{
label: "",
value: ''
}]
}
},
showPouple: false,
fileList6: [],
@ -299,8 +312,10 @@
//
handleChooseImage() {
let that = this;
that.$util.uploadImageOne('upload/image', function(res) {
console.log(that.formData)
that.$util.uploadImages({
count: 6,
url: 'upload/image'
}, function(res) {
that.formData.imageList.push(res.data.path);
});
},
@ -309,6 +324,7 @@
let that = this
uni.chooseVideo({
sourceType: ['camera', 'album'],
limit: 6,
success: res => {
uni.showLoading({
title: '正在上传中。。。'
@ -377,7 +393,7 @@
},
goDetail() {
uni.navigateTo({
uni.redirectTo({
url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${this.mer_id}&&formData=${JSON.stringify(this.formData)}&&showSet=${false}`
})
},
@ -386,6 +402,22 @@
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() {
let data = uni.$u.deepClone(this.formData)
data.image = data.imageList[0]
@ -411,7 +443,6 @@
.catch(rej => {
// Toast(rej);
});
console.log(this.formData)
}
},
onLoad(option) {

View File

@ -139,13 +139,28 @@
</u-form-item>
<view class="" v-if="showSet">
<view class="" v-for="(item,index) in formData.attrValue.filter(item=> !item.is_use)">
<u-form-item :label="item.spec_type" label-width="350rpx" prop="userInfo.name" ref="item1"
labelPosition="left" border-bottom>
<view class="" v-for="(item,index) in formData.attrValue.filter(item=> item.is_use==0)">
<view class="" v-if='formData.attrValue.filter(item=> item.is_use==0).length==1'>
<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 style="width: 250rpx;" v-if='!item.spec_type'>
<view style="width: 250rpx;" v-if='!formData.attr[index].value'>
</view>
<view style="font-size: 28rpx;color:#777777 ;">
零售价
@ -167,6 +182,8 @@
</view>
</u-form-item>
</view>
</view>
</view>
@ -308,7 +325,7 @@
"volume": "",
"extension_one": "",
"extension_two": "",
"open": true,
"is_use": 0,
"spec_type": ""
}],
"cate_name": "",
@ -317,7 +334,10 @@
"mer_cate_id": [],
"mer_cate_name": "",
"spec_type": "0",
"attr": [],
attr: [{
detail: [],
value: ""
}, ],
"specifica": "",
"delivery_way": [],
"delivery_free": "",
@ -429,15 +449,15 @@
}
},
//
handleChooseImage() {
let that = this;
that.$util.uploadImageOne('upload/image', function(res) {
if (that.isDetail) {
that.formData.content.image.push(res.data.path);
} else {
that.$util.uploadImages({
count: 6,
url: 'upload/image'
}, function(res) {
that.formData.imageList.push(res.data.path);
}
});
},
//
@ -579,41 +599,37 @@
.catch(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) {
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
this.initFormData(option)
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
this.isSet2()
if (option.product_id) {
that.formData.product_id = option.product_id
this.mode = 'edit'
this.showSet = true
productDetail(option.mer_id, option.product_id).then(res => {
this.formData = res.data
//
this.formData.product_attribute = JSON.parse(this.formData.product_attribute)
this.formData.cate_name = this.formData.storeCategory.cate_name
this.formData.cate_id = this.formData.storeCategory.store_category_id
this.formData.imageList = this.formData.image_list
})
}
console.log(this.formData)
// console.log(this.isSet(this.formData.attrValue))
},
onBackPress: function(e) {

View File

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

View File

@ -1,14 +1,15 @@
<template>
<view class="content">
<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>
</view>
<view class="card" v-for="(item,index) in attrValue">
<view class="card-head card-li">
<text style="font-size: 32rpx;font-family: PingFangFamily;">规格{{index+1}}</text>
<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>
<u-line direction="row" style="margin: 30rpx 0;" color="#ECECEC"></u-line>
@ -51,7 +52,8 @@
</view>
<u-line direction="row" style="margin: 25rpx 0;" color="#ECECEC"></u-line>
<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>
</view>
<view class="" style="display: flex;align-items: center;">
@ -67,6 +69,9 @@
</template>
<script>
import {
formatDate
} from '../../../libs/uniApi'
export default {
data() {
return {
@ -75,17 +80,11 @@
text: "",
value: "",
formData: {},
attr: [{
detail: [],
value: ""
}, ],
attrValue: [{
spec_type: "",
"attrValue": [{
"price": "",
"unit_name": "",
"wholesale_unit_name": "",
"wholesale_price": '',
"wholesale_price": "",
"cost": "",
"stock": "",
"ot_price": "",
@ -95,42 +94,48 @@
"volume": "",
"extension_one": "",
"extension_two": "",
is_use: true
},
"is_use": 0,
"spec_type": ""
}],
],
}
},
methods: {
submit() {
this.attrValue.forEach(item => {
item.is_use ? item.is_use = 0 : item.is_use = 1
})
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
uni.navigateTo({
uni.reLaunch({
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) {
this.isWholeSale = this.$store.state.app.userInfo?.mer_info?.wholesale == 2;
if (option.formData) {
this.formData = JSON.parse(option.formData)
this.initFomrData(option)
this.attrValue = this.formData.attrValue
this.attr = this.formData.attr
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) {
this.mer_id = option.mer_id
}
console.log(this.mer_id, 'meridd')
console.log(this.formData)
console.log(this.attrValue)
}
}

View File

@ -68,26 +68,31 @@
})
},
navgo() {
uni.navigateTo({
url: `/pages/product/addGoodDetail/goodsType?mer_id=${this.mer_id}&&type=${this.type}`
uni.redirectTo({
url: `/pages/product/addGoodDetail/goodsType?mer_id=${this.mer_id}&&type=${this.type}&&formData=${JSON.stringify(this.formData)}`
})
},
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, {
cate_id: item.value
})
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
if (option.type) {
this.type = 'simple'
}
this.formData = JSON.parse(option.formData)
if (option.formData) {}
}
},
onLoad(option) {
this.initFormData(option)
categoryHotcate(
option.mer_id,
this.$store.state.app.userInfo.uid
@ -95,10 +100,7 @@
this.hotList = res.data.hot_cate.map(item => ({
label: item.cate_name,
value: item.store_category_id
})
)
}))
this.typeList = res.data.active_cate.map(item => ({
label: item.cate_name,
value: item.store_category_id

View File

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

View File

@ -58,8 +58,48 @@
<view class="wrapper" style="background-color: #F1F1F1;">
<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 class='item' @click="yinc">
<view v-for="(item,index) in productList" :key="index" class="card">
<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'>
<image :src='item.image'></image>
<text v-if="item.spec_type == 1" class="spec">多规格</text>
@ -72,7 +112,6 @@
</view>
<view class="sales">
<text class="num">库存: {{item.stock}}</text>
<!-- <text class="num">销量: {{item.sales}}</text> -->
</view>
<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"
@ -94,31 +133,7 @@
</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="acea-row row-middle">
<view class="" class="bnt" @click="Fline(item)" style="width:150rpx">
@ -132,11 +147,12 @@
</view>
<view @click="editGoods(item)" class="bnt">编辑45</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>
</view>
<Loading :loaded="loaded" :loading="loading"></Loading>
@ -149,7 +165,7 @@
<view class="footer-li">
扫码入库
</view>
<view class="footer-li">
<view class="footer-li act">
发布商品
</view>
@ -331,6 +347,22 @@
},
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() {
getCategoryListLevel({
@ -830,6 +862,54 @@
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 {
display: flex;
width: 100%;
@ -1383,7 +1463,17 @@
align-items: center;
.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>

View File

@ -1,5 +1,58 @@
<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="" 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">
<u-sticky custom-nav-height="0" bgColor="#fff">
<view class="line th">
@ -24,10 +77,14 @@
</view>
</view>
<view style="height: 150rpx;"></view>
<view class="btn-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>
<u-modal :show="show" :closeOnClickOverlay="true" title="提示" content="确定更新库存吗" showCancelButton
@confirm="onUpdate" @cancel="show=false"></u-modal>
</view>
</template>
@ -39,10 +96,13 @@
productDetail,
productUpdateFree
} from "@/api/product.js"
import { Toast } from '../../../libs/uniApi';
import {
Toast
} from '../../../libs/uniApi';
export default {
data() {
return {
test: '20',
show: false,
defualtImg: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230130/00ebcfdf75684f5494c0193075055d1.png',
mer_id: '',
@ -60,10 +120,28 @@ import { Toast } from '../../../libs/uniApi';
},
onShow() {},
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() {
productDetail(this.mer_id, this.short.product_id).then((res) => {
this.short = res.data;
console.log({...res.data});
console.log({
...res.data
});
})
},
onUpdate() {
@ -107,19 +185,92 @@ import { Toast } from '../../../libs/uniApi';
</script>
<style lang="scss">
.content {
padding: 20rpx 16rpx;
background-color: #F1F1F1;
min-height: 100vh;
.head {
background-color: #fff;
display: flex;
padding: 20rpx;
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: 200rpx;
}
.sku {
flex: 1;
border-left: 1rpx solid rgba(0, 0, 0, 0.1);
@ -128,8 +279,10 @@ import { Toast } from '../../../libs/uniApi';
flex-direction: column;
align-items: center;
}
.stock {
width: 200rpx;
input {
width: 100%;
height: 100%;
@ -138,6 +291,7 @@ import { Toast } from '../../../libs/uniApi';
}
}
}
.th {
height: 70rpx;
line-height: 70rpx;
@ -145,24 +299,29 @@ import { Toast } from '../../../libs/uniApi';
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;

View File

@ -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 上传接口地址