Commit 9f04d6cd authored by Damon's avatar Damon

feat: 选择配件交互优化

parent 2e5a6b05
...@@ -118,26 +118,26 @@ export default { ...@@ -118,26 +118,26 @@ export default {
// 总数 // 总数
num() { num() {
return this.submitList.reduce((counter, { disabled, quantity }) => !disabled ? counter += quantity : counter, 0) return this.submitList.reduce((counter, { disabled, quantity }) => !disabled ? counter += quantity : counter, 0)
}, },
loadText() { loadText() {
return { return {
loadmore: '上拉加载更多', loadmore: '上拉加载更多',
loading: '努力加载中', loading: '努力加载中',
nomore: this.pageNumber > 1 ? '没有更多了' : '未找到备件' nomore: this.pageNumber > 1 ? '没有更多了' : '未找到备件'
} }
} }
}, },
onLoad(e) { onLoad(e) {
getApp().trackPage('选择配件页') getApp().trackPage('选择配件页')
if (e) { if (e) {
if (e.type == 1) { if (e.type == 1) {
this.categaryId = e.categaryId || '' this.categaryId = e.categaryId || ''
this.type = e.type this.type = e.type
this.getBrandList(e.brandId) this.getBrandList(e.brandId)
} else if (e.type == 2) { } else if (e.type == 2) {
this.type = e.type this.type = e.type
this.getCategaryList() this.getCategaryList()
} }
} }
}, },
methods: { methods: {
...@@ -263,6 +263,7 @@ export default { ...@@ -263,6 +263,7 @@ export default {
// 加入申请 // 加入申请
apply(item, index) { apply(item, index) {
this.$set(this.lists[index], 'disabled', false) this.$set(this.lists[index], 'disabled', false)
this.$set(this.lists[index], 'quantity', 1)
// 如果购物车没有该记录,则添加 // 如果购物车没有该记录,则添加
const findIndex = this.submitList.findIndex(v => v.id === item.id) const findIndex = this.submitList.findIndex(v => v.id === item.id)
...@@ -271,7 +272,7 @@ export default { ...@@ -271,7 +272,7 @@ export default {
// 改变数量 // 改变数量
numChange(val, item, index) { numChange(val, item, index) {
this.$set(this.lists[index], 'quantity', val) this.$set(this.lists[index], 'quantity', val)
if (val === 0) this.$set(this.lists[index], 'disabled', true)
// 如果购物车有该记录,则更新 // 如果购物车有该记录,则更新
const findIndex = this.submitList.findIndex(v => v.id === item.id) const findIndex = this.submitList.findIndex(v => v.id === item.id)
this.$set(this.submitList[findIndex], 'quantity', val) this.$set(this.submitList[findIndex], 'quantity', val)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment