|
@@ -1,56 +1,86 @@
|
|
|
<!--
|
|
<!--
|
|
|
秒杀商品编辑页
|
|
秒杀商品编辑页
|
|
|
从秒杀配置页跳转,单选活动商品并填写秒杀价/库存/限购;通过 seckillDraft 与列表页同步。
|
|
从秒杀配置页跳转,单选活动商品并填写秒杀价/库存/限购;通过 seckillDraft 与列表页同步。
|
|
|
|
|
+ 单规格:一套表单;多规格:按规格数动态生成多套表单,保存时每规格各写一条秒杀商品(goodsId 用子规格 id)。
|
|
|
-->
|
|
-->
|
|
|
<template>
|
|
<template>
|
|
|
<view class="page-container">
|
|
<view class="page-container">
|
|
|
<view class="module-com input-line-wrap form-card">
|
|
<view class="module-com input-line-wrap form-card">
|
|
|
<tui-list-cell class="line-cell" :arrow="true" :hover="true" @click="selectGoods">
|
|
<tui-list-cell class="line-cell" :arrow="true" :hover="true" @click="selectGoods">
|
|
|
<view class="tui-title required">活动商品</view>
|
|
<view class="tui-title required">活动商品</view>
|
|
|
- <view class="tui-input picker-text" :class="{ placeholder: !goodsForm.name }">
|
|
|
|
|
- {{ goodsForm.name || '请选择活动商品' }}
|
|
|
|
|
|
|
+ <view class="tui-input picker-text" :class="{ placeholder: !goodsBase.name }">
|
|
|
|
|
+ {{ goodsBase.name || '请选择活动商品' }}
|
|
|
</view>
|
|
</view>
|
|
|
</tui-list-cell>
|
|
</tui-list-cell>
|
|
|
|
|
|
|
|
- <tui-list-cell v-if="goodsForm.cover" class="line-cell" :hover="false">
|
|
|
|
|
- <image class="preview-cover" :src="imgFullUrl(goodsForm.cover)" mode="aspectFill" />
|
|
|
|
|
|
|
+ <tui-list-cell v-if="goodsBase.cover" class="line-cell" :hover="false" :last="!specForms.length">
|
|
|
|
|
+ <image class="preview-cover" :src="imgFullUrl(goodsBase.cover)" mode="aspectFill" />
|
|
|
</tui-list-cell>
|
|
</tui-list-cell>
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 单规格一套表单;多规格按规格数动态多套,字段一致 -->
|
|
|
|
|
+ <view
|
|
|
|
|
+ v-for="(item, sIndex) in specForms"
|
|
|
|
|
+ :key="sIndex"
|
|
|
|
|
+ class="module-com input-line-wrap form-card"
|
|
|
|
|
+ >
|
|
|
|
|
+ <view v-if="isMultiSpec" class="spec-head">
|
|
|
|
|
+ <text class="spec-head-label">规格{{ sIndex + 1 }}</text>
|
|
|
|
|
+ <text class="spec-head-name">{{ item.specName || '未命名规格' }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
|
|
|
<tui-list-cell class="line-cell" :hover="false">
|
|
<tui-list-cell class="line-cell" :hover="false">
|
|
|
<view class="tui-title required">秒杀价格</view>
|
|
<view class="tui-title required">秒杀价格</view>
|
|
|
<input
|
|
<input
|
|
|
- v-model="goodsForm.price"
|
|
|
|
|
|
|
+ :value="item.price"
|
|
|
class="tui-input"
|
|
class="tui-input"
|
|
|
placeholder-class="phcolor"
|
|
placeholder-class="phcolor"
|
|
|
placeholder="请输入秒杀价格"
|
|
placeholder="请输入秒杀价格"
|
|
|
type="digit"
|
|
type="digit"
|
|
|
|
|
+ :data-index="sIndex"
|
|
|
|
|
+ data-field="price"
|
|
|
|
|
+ @input="onSpecInput"
|
|
|
/>
|
|
/>
|
|
|
</tui-list-cell>
|
|
</tui-list-cell>
|
|
|
|
|
|
|
|
<tui-list-cell class="line-cell" :hover="false">
|
|
<tui-list-cell class="line-cell" :hover="false">
|
|
|
<view class="tui-title required">秒杀库存</view>
|
|
<view class="tui-title required">秒杀库存</view>
|
|
|
<input
|
|
<input
|
|
|
- v-model="goodsForm.stock"
|
|
|
|
|
|
|
+ :value="item.stock"
|
|
|
class="tui-input"
|
|
class="tui-input"
|
|
|
placeholder-class="phcolor"
|
|
placeholder-class="phcolor"
|
|
|
- :placeholder="stockPlaceholder"
|
|
|
|
|
|
|
+ :placeholder="item.realStock > 0 ? '不超过实际库存' + item.realStock : '请输入秒杀库存'"
|
|
|
type="number"
|
|
type="number"
|
|
|
|
|
+ :data-index="sIndex"
|
|
|
|
|
+ data-field="stock"
|
|
|
|
|
+ @input="onSpecInput"
|
|
|
/>
|
|
/>
|
|
|
</tui-list-cell>
|
|
</tui-list-cell>
|
|
|
|
|
|
|
|
- <tui-list-cell class="line-cell" :hover="false" :last="true">
|
|
|
|
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
<view class="tui-title required">单人限购</view>
|
|
<view class="tui-title required">单人限购</view>
|
|
|
<input
|
|
<input
|
|
|
- v-model="goodsForm.limit"
|
|
|
|
|
|
|
+ :value="item.limit"
|
|
|
class="tui-input"
|
|
class="tui-input"
|
|
|
placeholder-class="phcolor"
|
|
placeholder-class="phcolor"
|
|
|
placeholder="请输入单人限购数量"
|
|
placeholder="请输入单人限购数量"
|
|
|
type="number"
|
|
type="number"
|
|
|
|
|
+ :data-index="sIndex"
|
|
|
|
|
+ data-field="limit"
|
|
|
|
|
+ @input="onSpecInput"
|
|
|
/>
|
|
/>
|
|
|
</tui-list-cell>
|
|
</tui-list-cell>
|
|
|
- </view>
|
|
|
|
|
|
|
|
|
|
- <view v-if="goodsForm.realStock > 0" class="tip-text">商品实际库存:{{ goodsForm.realStock }}</view>
|
|
|
|
|
|
|
+ <!-- 补上商品原价格 -->
|
|
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
|
|
+ <view class="tui-title">商品原价格</view>
|
|
|
|
|
+ <view class="tui-input real-stock-text">{{ item.originPrice > 0 ? item.originPrice : '--' }}</view>
|
|
|
|
|
+ </tui-list-cell>
|
|
|
|
|
+ <tui-list-cell class="line-cell" :hover="false" :last="true">
|
|
|
|
|
+ <view class="tui-title">商品实际库存</view>
|
|
|
|
|
+ <view class="tui-input real-stock-text">{{ item.realStock > 0 ? item.realStock : '--' }}</view>
|
|
|
|
|
+ </tui-list-cell>
|
|
|
|
|
+ </view>
|
|
|
|
|
|
|
|
<view class="bottom-bar">
|
|
<view class="bottom-bar">
|
|
|
<button class="admin-button-com big default bottom-btn" @click="cancelFn">取消</button>
|
|
<button class="admin-button-com big default bottom-btn" @click="cancelFn">取消</button>
|
|
@@ -61,19 +91,28 @@
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import TuiListCell from '@/components/plugin/list-cell'
|
|
import TuiListCell from '@/components/plugin/list-cell'
|
|
|
|
|
+import { getGoodsDetail } from '@/api/goods'
|
|
|
|
|
|
|
|
const DRAFT_KEY = 'seckillDraft'
|
|
const DRAFT_KEY = 'seckillDraft'
|
|
|
|
|
|
|
|
-const EMPTY_GOODS = () => ({
|
|
|
|
|
|
|
+/** 空的商品基础信息(名称/封面等,多规格共用) */
|
|
|
|
|
+const EMPTY_BASE = () => ({
|
|
|
|
|
+ masterGoodsId: 0,
|
|
|
|
|
+ name: '',
|
|
|
|
|
+ cover: '',
|
|
|
|
|
+ status: 1
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+/** 空的规格填写表单(单规格时只有一项) */
|
|
|
|
|
+const EMPTY_SPEC_FORM = () => ({
|
|
|
goodsId: 0,
|
|
goodsId: 0,
|
|
|
|
|
+ specName: '',
|
|
|
price: '',
|
|
price: '',
|
|
|
stock: '',
|
|
stock: '',
|
|
|
limit: '',
|
|
limit: '',
|
|
|
- status: 1,
|
|
|
|
|
- name: '',
|
|
|
|
|
- cover: '',
|
|
|
|
|
originPrice: 0,
|
|
originPrice: 0,
|
|
|
- realStock: 0
|
|
|
|
|
|
|
+ realStock: 0,
|
|
|
|
|
+ cover: ''
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -83,15 +122,10 @@ export default {
|
|
|
return {
|
|
return {
|
|
|
constant: this.$constant,
|
|
constant: this.$constant,
|
|
|
goodsIndex: -1,
|
|
goodsIndex: -1,
|
|
|
- goodsForm: EMPTY_GOODS()
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- computed: {
|
|
|
|
|
- stockPlaceholder() {
|
|
|
|
|
- if (this.goodsForm.realStock > 0) {
|
|
|
|
|
- return `不超过实际库存${this.goodsForm.realStock}`
|
|
|
|
|
- }
|
|
|
|
|
- return '请输入秒杀库存'
|
|
|
|
|
|
|
+ goodsBase: EMPTY_BASE(),
|
|
|
|
|
+ // 单规格 1 项;多规格按规格数展开
|
|
|
|
|
+ specForms: [EMPTY_SPEC_FORM()],
|
|
|
|
|
+ isMultiSpec: false
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
onLoad() {
|
|
onLoad() {
|
|
@@ -103,6 +137,7 @@ export default {
|
|
|
methods: {
|
|
methods: {
|
|
|
/**
|
|
/**
|
|
|
* 解析路由 index,从 seckillDraft 加载待编辑商品
|
|
* 解析路由 index,从 seckillDraft 加载待编辑商品
|
|
|
|
|
+ * 编辑态按单条展示(列表中每规格已是独立一条)
|
|
|
*/
|
|
*/
|
|
|
init() {
|
|
init() {
|
|
|
this.goodsIndex = parseInt(this.option && this.option.index, 10)
|
|
this.goodsIndex = parseInt(this.option && this.option.index, 10)
|
|
@@ -111,9 +146,28 @@ export default {
|
|
|
}
|
|
}
|
|
|
const draft = uni.getStorageSync(DRAFT_KEY) || {}
|
|
const draft = uni.getStorageSync(DRAFT_KEY) || {}
|
|
|
if (this.goodsIndex >= 0 && draft.goods && draft.goods[this.goodsIndex]) {
|
|
if (this.goodsIndex >= 0 && draft.goods && draft.goods[this.goodsIndex]) {
|
|
|
- this.goodsForm = { ...EMPTY_GOODS(), ...draft.goods[this.goodsIndex] }
|
|
|
|
|
|
|
+ const item = draft.goods[this.goodsIndex]
|
|
|
|
|
+ this.goodsBase = {
|
|
|
|
|
+ masterGoodsId: item.goodsId || 0,
|
|
|
|
|
+ name: item.name || '',
|
|
|
|
|
+ cover: item.cover || '',
|
|
|
|
|
+ status: item.status == 1 ? 1 : 0
|
|
|
|
|
+ }
|
|
|
|
|
+ this.isMultiSpec = false
|
|
|
|
|
+ this.specForms = [{
|
|
|
|
|
+ goodsId: item.goodsId || 0,
|
|
|
|
|
+ specName: item.specName || '',
|
|
|
|
|
+ price: item.price !== undefined && item.price !== null ? item.price : '',
|
|
|
|
|
+ stock: item.stock !== undefined && item.stock !== null ? item.stock : '',
|
|
|
|
|
+ limit: item.limit !== undefined && item.limit !== null ? item.limit : '',
|
|
|
|
|
+ originPrice: item.originPrice || 0,
|
|
|
|
|
+ realStock: item.realStock || 0,
|
|
|
|
|
+ cover: item.cover || ''
|
|
|
|
|
+ }]
|
|
|
} else {
|
|
} else {
|
|
|
- this.goodsForm = EMPTY_GOODS()
|
|
|
|
|
|
|
+ this.goodsBase = EMPTY_BASE()
|
|
|
|
|
+ this.specForms = [EMPTY_SPEC_FORM()]
|
|
|
|
|
+ this.isMultiSpec = false
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
imgFullUrl(path) {
|
|
imgFullUrl(path) {
|
|
@@ -122,70 +176,165 @@ export default {
|
|
|
const base = (this.constant.imgUrl || '').replace(/\/$/, '')
|
|
const base = (this.constant.imgUrl || '').replace(/\/$/, '')
|
|
|
return `${base}/${String(path).replace(/^\//, '')}`
|
|
return `${base}/${String(path).replace(/^\//, '')}`
|
|
|
},
|
|
},
|
|
|
- /** 跳转花束商品单选页 */
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 规格表单字段输入(小程序端 v-for 内不能直接 v-model 别名)
|
|
|
|
|
+ * 下标/字段名通过 data-index、data-field 传入,避免事件参数编译异常
|
|
|
|
|
+ */
|
|
|
|
|
+ onSpecInput(e) {
|
|
|
|
|
+ const dataset = (e && e.currentTarget && e.currentTarget.dataset) || {}
|
|
|
|
|
+ const index = parseInt(dataset.index, 10)
|
|
|
|
|
+ const field = dataset.field
|
|
|
|
|
+ const value = e && e.detail ? e.detail.value : ''
|
|
|
|
|
+ if (isNaN(index) || !field || !this.specForms[index]) return
|
|
|
|
|
+ this.$set(this.specForms[index], field, value)
|
|
|
|
|
+ },
|
|
|
|
|
+ /** 跳转花束商品单选页(列表为主商品 masterId=0) */
|
|
|
selectGoods() {
|
|
selectGoods() {
|
|
|
|
|
+ const selectedId = this.goodsBase.masterGoodsId || (this.specForms[0] && this.specForms[0].goodsId) || ''
|
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
|
- url: `/admin/goods/ad-goods-select?mode=single&selectedIds=${this.goodsForm.goodsId || ''}`
|
|
|
|
|
|
|
+ url: `/admin/goods/ad-goods-select?mode=single&selectedIds=${selectedId}`
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- /** 接收商品选择结果,填充 goodsId/name/cover/originPrice/realStock */
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 接收商品选择结果:拉详情判断是否多规格,动态生成填写表单
|
|
|
|
|
+ * 多规格时每条子规格用自己的 goodsId/库存/原价
|
|
|
|
|
+ */
|
|
|
onGoodsSelected(payload) {
|
|
onGoodsSelected(payload) {
|
|
|
const g = (payload.goodsList || [])[0]
|
|
const g = (payload.goodsList || [])[0]
|
|
|
if (!g) return
|
|
if (!g) return
|
|
|
- this.goodsForm.goodsId = g.id
|
|
|
|
|
- this.goodsForm.name = g.name || ''
|
|
|
|
|
- this.goodsForm.cover = g.cover || ''
|
|
|
|
|
- this.goodsForm.originPrice = g.price || 0
|
|
|
|
|
- this.goodsForm.realStock = parseInt(g.stock, 10) || 0
|
|
|
|
|
|
|
+ this.goodsBase.masterGoodsId = g.id
|
|
|
|
|
+ this.goodsBase.name = g.name || ''
|
|
|
|
|
+ this.goodsBase.cover = g.cover || ''
|
|
|
|
|
+ // 先用列表快照填一套单规格表单,详情返回后再按规格覆盖
|
|
|
|
|
+ this.isMultiSpec = false
|
|
|
|
|
+ this.specForms = [{
|
|
|
|
|
+ goodsId: g.id,
|
|
|
|
|
+ specName: '',
|
|
|
|
|
+ price: '',
|
|
|
|
|
+ stock: '',
|
|
|
|
|
+ limit: '',
|
|
|
|
|
+ originPrice: g.price || 0,
|
|
|
|
|
+ realStock: parseInt(g.stock, 10) || 0,
|
|
|
|
|
+ cover: g.cover || ''
|
|
|
|
|
+ }]
|
|
|
|
|
+ this.loadGoodsSpecs(g.id)
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 拉取商品详情,多规格则按 specList 展开多套表单
|
|
|
|
|
+ * @param {number} goodsId 主商品 id
|
|
|
|
|
+ */
|
|
|
|
|
+ loadGoodsSpecs(goodsId) {
|
|
|
|
|
+ if (!goodsId) return
|
|
|
|
|
+ getGoodsDetail({ id: goodsId }).then((res) => {
|
|
|
|
|
+ if (res.code !== 1 || !res.data) return
|
|
|
|
|
+ // 若用户已切换到其他商品,忽略过期回调
|
|
|
|
|
+ if (parseInt(goodsId, 10) !== parseInt(this.goodsBase.masterGoodsId, 10)) return
|
|
|
|
|
+ const data = res.data
|
|
|
|
|
+ const cover = data.shortCover || data.cover || this.goodsBase.cover || ''
|
|
|
|
|
+ this.goodsBase.name = data.name || this.goodsBase.name
|
|
|
|
|
+ this.goodsBase.cover = cover
|
|
|
|
|
+ const specList = Array.isArray(data.specList) ? data.specList : []
|
|
|
|
|
+ // 启用多规格且存在子规格:一套规格一张填写表单
|
|
|
|
|
+ if (Number(data.specEnabled) === 1 && specList.length > 0) {
|
|
|
|
|
+ this.isMultiSpec = true
|
|
|
|
|
+ this.specForms = specList.map((spec) => ({
|
|
|
|
|
+ goodsId: spec.id || 0,
|
|
|
|
|
+ specName: spec.specName || '',
|
|
|
|
|
+ price: '',
|
|
|
|
|
+ stock: '',
|
|
|
|
|
+ limit: '',
|
|
|
|
|
+ originPrice: spec.price || 0,
|
|
|
|
|
+ realStock: parseInt(spec.stock, 10) || 0,
|
|
|
|
|
+ cover: spec.shortCover || spec.cover || cover
|
|
|
|
|
+ }))
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ this.isMultiSpec = false
|
|
|
|
|
+ this.specForms = [{
|
|
|
|
|
+ goodsId: data.id || goodsId,
|
|
|
|
|
+ specName: '',
|
|
|
|
|
+ price: '',
|
|
|
|
|
+ stock: '',
|
|
|
|
|
+ limit: '',
|
|
|
|
|
+ originPrice: data.price || 0,
|
|
|
|
|
+ realStock: parseInt(data.stock, 10) || 0,
|
|
|
|
|
+ cover
|
|
|
|
|
+ }]
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
cancelFn() {
|
|
cancelFn() {
|
|
|
uni.navigateBack()
|
|
uni.navigateBack()
|
|
|
},
|
|
},
|
|
|
- /** 校验后写回 seckillDraft 并返回列表页 */
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 校验全部规格表单后写回 seckillDraft
|
|
|
|
|
+ * 多规格保存为多条(每规格 goodsId 为子商品 id,后端按该 id 校验实际库存)
|
|
|
|
|
+ */
|
|
|
saveFn() {
|
|
saveFn() {
|
|
|
- const goodsId = parseInt(this.goodsForm.goodsId, 10) || 0
|
|
|
|
|
- const price = parseFloat(this.goodsForm.price)
|
|
|
|
|
- const stock = parseInt(this.goodsForm.stock, 10)
|
|
|
|
|
- const limit = parseInt(this.goodsForm.limit, 10)
|
|
|
|
|
- if (!goodsId) {
|
|
|
|
|
|
|
+ if (!this.goodsBase.masterGoodsId && !(this.specForms[0] && this.specForms[0].goodsId)) {
|
|
|
this.$msg('请选择活动商品')
|
|
this.$msg('请选择活动商品')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if (!price || price <= 0) {
|
|
|
|
|
- this.$msg('请输入秒杀价格')
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- if (!stock || stock <= 0) {
|
|
|
|
|
- this.$msg('请输入秒杀库存')
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- if (this.goodsForm.realStock > 0 && stock > this.goodsForm.realStock) {
|
|
|
|
|
- this.$msg(`秒杀库存不能超过实际库存(${this.goodsForm.realStock})`)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- if (!limit || limit <= 0) {
|
|
|
|
|
- this.$msg('请输入单人限购')
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ const items = []
|
|
|
|
|
+ for (let i = 0; i < this.specForms.length; i++) {
|
|
|
|
|
+ const form = this.specForms[i]
|
|
|
|
|
+ const label = this.isMultiSpec
|
|
|
|
|
+ ? `规格「${form.specName || (i + 1)}」`
|
|
|
|
|
+ : ''
|
|
|
|
|
+ const goodsId = parseInt(form.goodsId, 10) || 0
|
|
|
|
|
+ const price = parseFloat(form.price)
|
|
|
|
|
+ const stock = parseInt(form.stock, 10)
|
|
|
|
|
+ const limit = parseInt(form.limit, 10)
|
|
|
|
|
+ if (!goodsId) {
|
|
|
|
|
+ this.$msg(label ? `${label}商品无效,请重新选择` : '请选择活动商品')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!price || price <= 0) {
|
|
|
|
|
+ this.$msg(label ? `请输入${label}秒杀价格` : '请输入秒杀价格')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!stock || stock <= 0) {
|
|
|
|
|
+ this.$msg(label ? `请输入${label}秒杀库存` : '请输入秒杀库存')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ // 秒杀库存不得超过该规格实际库存
|
|
|
|
|
+ if (form.realStock > 0 && stock > form.realStock) {
|
|
|
|
|
+ this.$msg(
|
|
|
|
|
+ label
|
|
|
|
|
+ ? `${label}秒杀库存不能超过实际库存(${form.realStock})`
|
|
|
|
|
+ : `秒杀库存不能超过实际库存(${form.realStock})`
|
|
|
|
|
+ )
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!limit || limit <= 0) {
|
|
|
|
|
+ this.$msg(label ? `请输入${label}单人限购` : '请输入单人限购')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ // 列表展示名带规格后缀,便于区分同商品多规格
|
|
|
|
|
+ const displayName = form.specName
|
|
|
|
|
+ ? `${this.goodsBase.name}(${form.specName})`
|
|
|
|
|
+ : this.goodsBase.name
|
|
|
|
|
+ items.push({
|
|
|
|
|
+ goodsId,
|
|
|
|
|
+ price,
|
|
|
|
|
+ stock,
|
|
|
|
|
+ limit,
|
|
|
|
|
+ status: this.goodsBase.status == 1 ? 1 : 0,
|
|
|
|
|
+ name: displayName,
|
|
|
|
|
+ cover: form.cover || this.goodsBase.cover,
|
|
|
|
|
+ originPrice: parseFloat(form.originPrice) || 0,
|
|
|
|
|
+ realStock: form.realStock || 0,
|
|
|
|
|
+ specName: form.specName || ''
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
const draft = uni.getStorageSync(DRAFT_KEY) || { goods: [] }
|
|
const draft = uni.getStorageSync(DRAFT_KEY) || { goods: [] }
|
|
|
if (!Array.isArray(draft.goods)) {
|
|
if (!Array.isArray(draft.goods)) {
|
|
|
draft.goods = []
|
|
draft.goods = []
|
|
|
}
|
|
}
|
|
|
- const item = {
|
|
|
|
|
- goodsId,
|
|
|
|
|
- price,
|
|
|
|
|
- stock,
|
|
|
|
|
- limit,
|
|
|
|
|
- status: this.goodsForm.status == 1 ? 1 : 0,
|
|
|
|
|
- name: this.goodsForm.name,
|
|
|
|
|
- cover: this.goodsForm.cover,
|
|
|
|
|
- originPrice: parseFloat(this.goodsForm.originPrice) || 0,
|
|
|
|
|
- realStock: this.goodsForm.realStock
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 编辑态:用本次结果替换原位置(多规格重选时可能 1 变 N)
|
|
|
if (this.goodsIndex >= 0) {
|
|
if (this.goodsIndex >= 0) {
|
|
|
- this.$set(draft.goods, this.goodsIndex, item)
|
|
|
|
|
|
|
+ draft.goods.splice(this.goodsIndex, 1, ...items)
|
|
|
} else {
|
|
} else {
|
|
|
- draft.goods.push(item)
|
|
|
|
|
|
|
+ draft.goods.push(...items)
|
|
|
}
|
|
}
|
|
|
draft._goodsUpdated = true
|
|
draft._goodsUpdated = true
|
|
|
uni.setStorageSync(DRAFT_KEY, draft)
|
|
uni.setStorageSync(DRAFT_KEY, draft)
|
|
@@ -230,10 +379,30 @@ export default {
|
|
|
background: #f5f5f5;
|
|
background: #f5f5f5;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-.tip-text {
|
|
|
|
|
- padding: 20upx 30upx;
|
|
|
|
|
- font-size: 24upx;
|
|
|
|
|
|
|
+.spec-head {
|
|
|
|
|
+ @include disFlex(center, flex-start);
|
|
|
|
|
+ padding: 24upx 30upx 8upx;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.spec-head-label {
|
|
|
|
|
+ flex-shrink: 0;
|
|
|
|
|
+ font-size: 26upx;
|
|
|
color: $fontColor3;
|
|
color: $fontColor3;
|
|
|
|
|
+ margin-right: 12upx;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.spec-head-name {
|
|
|
|
|
+ font-size: 28upx;
|
|
|
|
|
+ color: #333;
|
|
|
|
|
+ font-weight: 500;
|
|
|
|
|
+ overflow: hidden;
|
|
|
|
|
+ text-overflow: ellipsis;
|
|
|
|
|
+ white-space: nowrap;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.real-stock-text {
|
|
|
|
|
+ text-align: right;
|
|
|
|
|
+ color: $fontColor2;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.bottom-bar {
|
|
.bottom-bar {
|