Commit 91483a06 authored by Damon's avatar Damon

feat: 更多型号交互

parent 58f4c1c2
...@@ -2,7 +2,12 @@ ...@@ -2,7 +2,12 @@
<view class="u-flex content"> <view class="u-flex content">
<view class="categary" v-if="type === '2'"> <view class="categary" v-if="type === '2'">
<view class="u-flex u-col-center"> <view class="u-flex u-col-center">
<view :class="['txt', {'active': categoryId === item.categoryId }]" v-for="item in categary" :key="item.categoryId" @click="changeCategary(item)">{{item.label}}</view> <view
:class="['txt', {'active': categoryId === item.categoryId }]"
v-for="item in categary"
:key="item.categoryId"
@click="changeCategary(item)"
>{{item.label}}</view>
</view> </view>
</view> </view>
...@@ -26,7 +31,13 @@ ...@@ -26,7 +31,13 @@
class="u-flex" class="u-flex"
:scroll-into-view="scrollId" :scroll-into-view="scrollId"
> >
<view :id="`brand${item.brandId}`" :class="['label-title', { selected: item.brandId == brandId }]" v-for="(item, index) in brand" :key="index" @click="selectBrand(item, index)">{{ item.label }}</view> <view
:id="`brand${item.brandId}`"
:class="['label-title', { selected: item.brandId == brandId }]"
v-for="(item, index) in brand"
:key="index"
@click="selectBrand(item, index)"
>{{ item.label }}</view>
</scroll-view> </scroll-view>
</view> </view>
<view class="more u-flex" @click="handleClick"> <view class="more u-flex" @click="handleClick">
...@@ -37,7 +48,7 @@ ...@@ -37,7 +48,7 @@
</view> </view>
</view> </view>
<view class="model u-flex" v-if="brand.length > 0"> <view class="model u-flex" v-show="showMore !== true">
<view class="label-content u-flex"> <view class="label-content u-flex">
<scroll-view <scroll-view
style="width:100%;white-space: nowrap;" style="width:100%;white-space: nowrap;"
...@@ -45,18 +56,44 @@ ...@@ -45,18 +56,44 @@
class="u-flex" class="u-flex"
:scroll-into-view="scrollId" :scroll-into-view="scrollId"
> >
<view :id="`brand${item.brandId}`" :class="['label-title', { selected: item.brandId == brandId }]" v-for="(item, index) in brand" :key="index" @click="selectBrand(item, index)">{{ item.label }}</view> <view
:id="`brand${item.brandId}`"
:class="['label-title', { selected: item.brandId == brandId }]"
v-for="(item, index) in brand"
:key="index"
@click="selectBrand(item, index)"
>{{ item.label }}</view>
</scroll-view> </scroll-view>
</view> </view>
<view class="more u-flex" @click="handleClick"> <view class="more u-flex" @click="showMore = true">
<!-- <picker mode="selector" :value="brandIndex" range-key="label" :range="brand" @click="show = true" @change="changeBrand"> -->
<!-- <view class="more-text">更多</view> -->
<!-- </picker> -->
<u-icon class="input-icon" color="#666" name="arrow-down"></u-icon> <u-icon class="input-icon" color="#666" name="arrow-down"></u-icon>
</view> </view>
</view> </view>
<view class="allModel u-flex" v-show="showMore === true">
<view class="label-content u-flex">
<scroll-view
style="width:100%;height: 320rpx;"
scroll-y="true"
class="u-flex"
:scroll-into-view="scrollId"
>
<view
:id="`brand${item.brandId}`"
:class="['label-title', { selected: item.brandId == brandId }]"
v-for="(item, index) in brand"
:key="index"
@click="selectBrand(item, index)"
>{{ item.label }}</view>
</scroll-view>
</view>
<view class="more u-flex" @click="showMore = false">
<u-icon class="input-icon" color="#666" name="arrow-up"></u-icon>
</view>
</view>
<view class="lists"> <view class="lists">
<view class="mask" v-show="showMore === true" @click="showMore = false"></view>
<scroll-view <scroll-view
style="height:100%;" style="height:100%;"
:scroll-top="scrollTop" :scroll-top="scrollTop"
...@@ -93,56 +130,64 @@ ...@@ -93,56 +130,64 @@
</template> </template>
<script> <script>
import selectParts from '@/components/select-parts/index'
import selectParts from "@/components/select-parts/index" import submitBar from '@/components/submit-bar/index'
import submitBar from "@/components/submit-bar/index"
export default { export default {
components: { components: {
selectParts, selectParts,
submitBar submitBar,
}, },
data() { data() {
return { return {
keyword: '', keyword: '',
show: false, show: false,
showMore: false,
categary: [], categary: [],
brand: [], brand: [],
model: [],
categaryIndex: 0, categaryIndex: 0,
categoryId: '', categoryId: '',
brandIndex: 0, brandIndex: 0,
brandId: 0, brandId: 0,
scrollId: '', scrollId: '',
loadStatus: "loadmore", loadStatus: 'loadmore',
lists: [], lists: [],
submitList: [], submitList: [],
pageSize: 20, pageSize: 20,
pageNumber: 1, pageNumber: 1,
type: '1', type: '1',
}
};
}, },
computed: { computed: {
searchStyle() { searchStyle() {
return { return {
color: "#2272FF" color: '#2272FF',
}; }
}, },
// 配件数 // 配件数
partNum() { partNum() {
return this.submitList.reduce((counter, item) => !item.disabled && item.quantity > 0 ? counter += 1 : counter, 0) return this.submitList.reduce(
(counter, item) =>
!item.disabled && item.quantity > 0 ? (counter += 1) : counter,
0
)
}, },
// 总数 // 总数
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) {
...@@ -157,9 +202,9 @@ export default { ...@@ -157,9 +202,9 @@ export default {
} }
}, },
onShow() { onShow() {
let pages = getCurrentPages(); let pages = getCurrentPages()
let page = pages[pages.length - 1]; let page = pages[pages.length - 1]
let selectedItem = page.selectedItem; let selectedItem = page.selectedItem
if (selectedItem) { if (selectedItem) {
page.selectedItem = null page.selectedItem = null
this.selectBrand(selectedItem.item, selectedItem.index) this.selectBrand(selectedItem.item, selectedItem.index)
...@@ -169,11 +214,11 @@ export default { ...@@ -169,11 +214,11 @@ export default {
methods: { methods: {
// 获取品类 // 获取品类
getCategaryList() { getCategaryList() {
this.$u.api.getCategoryList().then(res => { this.$u.api.getCategoryList().then((res) => {
if (res.code === 200) { if (res.code === 200) {
const data = res.data const data = res.data
if (data.length > 0) { if (data.length > 0) {
this.categary = data.map(v => { this.categary = data.map((v) => {
v.label = v.categoryName v.label = v.categoryName
return v return v
}) })
...@@ -191,7 +236,7 @@ export default { ...@@ -191,7 +236,7 @@ export default {
}, },
// 获取品牌 // 获取品牌
getBrandList(id) { getBrandList(id) {
this.$u.api.getBrandList({categoryId: this.categoryId}).then(res => { this.$u.api.getBrandList({ categoryId: this.categoryId }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
const data = res.data const data = res.data
let item, index let item, index
...@@ -217,20 +262,20 @@ export default { ...@@ -217,20 +262,20 @@ export default {
}, },
// 获取配件列表 // 获取配件列表
getPartsList() { getPartsList() {
this.page++; this.page++
this.loadStatus = "loading"; this.loadStatus = 'loading'
const params = { const params = {
pageNumber: this.pageNumber, pageNumber: this.pageNumber,
pageSize: this.pageSize, pageSize: this.pageSize,
categoryId: this.categoryId || '', categoryId: this.categoryId || '',
brandId: this.brandId || '', brandId: this.brandId || '',
keyword: this.keyword keyword: this.keyword,
} }
this.$u.api.getPartsList(params).then(res => { this.$u.api.getPartsList(params).then((res) => {
if (res.code === 200) { if (res.code === 200) {
const data = res.data const data = res.data
if (data.length > 0) { if (data.length > 0) {
const lists = data.map(v => { const lists = data.map((v) => {
v.quantity = 0 v.quantity = 0
v.disabled = true v.disabled = true
v.max = 9999 v.max = 9999
...@@ -240,11 +285,11 @@ export default { ...@@ -240,11 +285,11 @@ export default {
}) })
this.lists = this.lists.concat(lists) this.lists = this.lists.concat(lists)
this.pageNumber++ this.pageNumber++
this.loadStatus = lists.length < this.pageSize ? "nomore" : "loadmore" this.loadStatus =
lists.length < this.pageSize ? 'nomore' : 'loadmore'
} else { } else {
this.loadStatus = "nomore" this.loadStatus = 'nomore'
} }
} }
}) })
}, },
...@@ -283,13 +328,20 @@ export default { ...@@ -283,13 +328,20 @@ export default {
}, },
// 加载更多 // 加载更多
loadMore() { loadMore() {
if (this.loadStatus !== "nomore") { if (this.loadStatus !== 'nomore') {
this.getPartsList(); this.getPartsList()
} }
}, },
// 点击更多 // 点击更多
handleClick() { handleClick() {
this.$u.route({url: 'pages/order/document-tag' + '?categoryId=' + this.categoryId + '&selectedId=' + this.brandId}) this.$u.route({
url:
'pages/order/document-tag' +
'?categoryId=' +
this.categoryId +
'&selectedId=' +
this.brandId,
})
}, },
// 加入申请 // 加入申请
apply(item, index) { apply(item, index) {
...@@ -297,7 +349,7 @@ export default { ...@@ -297,7 +349,7 @@ export default {
this.$set(this.lists[index], 'quantity', 1) 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)
if (findIndex === -1) this.submitList.push(item) if (findIndex === -1) this.submitList.push(item)
}, },
// 改变数量 // 改变数量
...@@ -305,25 +357,27 @@ export default { ...@@ -305,25 +357,27 @@ export default {
this.$set(this.lists[index], 'quantity', val) this.$set(this.lists[index], 'quantity', val)
if (val === 0) this.$set(this.lists[index], 'disabled', true) 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)
}, },
// 提交 // 提交
submit() { submit() {
const lists = this.submitList.filter(v => !v.disabled && v.quantity > 0).map(v => { const lists = this.submitList
.filter((v) => !v.disabled && v.quantity > 0)
.map((v) => {
return { return {
part_id: v.skuId, part_id: v.skuId,
name: v.name, name: v.name,
quantity: v.quantity quantity: v.quantity,
} }
}) })
let pages = getCurrentPages(); let pages = getCurrentPages()
let prevPage = pages[pages.length - 2]; //上一个页面 let prevPage = pages[pages.length - 2] //上一个页面
prevPage.$vm.updateParts(lists) prevPage.$vm.updateParts(lists)
this.$u.route({ type: 'back' }) this.$u.route({ type: 'back' })
}
}, },
}; },
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
...@@ -352,7 +406,6 @@ export default { ...@@ -352,7 +406,6 @@ export default {
.warp { .warp {
border-radius: 30rpx 30rpx 0 0; border-radius: 30rpx 30rpx 0 0;
padding: 30rpx 30rpx 0 30rpx;
width: 100%; width: 100%;
background: #fff; background: #fff;
flex-direction: column; flex-direction: column;
...@@ -361,17 +414,17 @@ export default { ...@@ -361,17 +414,17 @@ export default {
overflow: hidden; overflow: hidden;
.brand { .brand {
width: 100%; width: 100%;
padding-bottom: 20rpx; padding: 20rpx 30rpx 0rpx 30rpx;
.label-content { .label-content {
flex: 1; flex: 1;
overflow: hidden; overflow: hidden;
padding-right: 20rpx; padding-right: 20rpx;
border-right: 2rpx solid #F4F5F7; border-right: 2rpx solid #f4f5f7;
.label-title { .label-title {
color:#666; color: #666;
padding: 10rpx 0rpx; padding: 10rpx 0rpx;
margin-right: 40rpx; margin-right: 40rpx;
display:inline-block; display: inline-block;
font-size: 32rpx; font-size: 32rpx;
&.selected { &.selected {
color: #2272ff; color: #2272ff;
...@@ -385,21 +438,20 @@ export default { ...@@ -385,21 +438,20 @@ export default {
width: 100rpx; width: 100rpx;
padding-left: 20rpx; padding-left: 20rpx;
.more-text { .more-text {
color: #2272FF; color: #2272ff;
font-size: 26rpx; font-size: 26rpx;
} }
} }
} }
.model { .model {
width: 100%; width: 100%;
padding: 20rpx 0; padding: 30rpx 30rpx 0 30rpx;
.label-content { .label-content {
flex: 1; flex: 1;
overflow: hidden; overflow: hidden;
padding-right: 20rpx; padding-right: 20rpx;
border-right: 2rpx solid #F4F5F7;
.label-title { .label-title {
background: #F4F5F7; background: #f4f5f7;
color: #999; color: #999;
padding: 7rpx 30rpx; padding: 7rpx 30rpx;
margin-right: 20rpx; margin-right: 20rpx;
...@@ -408,22 +460,58 @@ export default { ...@@ -408,22 +460,58 @@ export default {
border-radius: 30rpx; border-radius: 30rpx;
&.selected { &.selected {
color: #fff; color: #fff;
background: #2272FF; background: #2272ff;
} }
} }
} }
.more { .more {
padding-left: 20rpx; padding-left: 20rpx;
.more-text { }
color: #2272FF; }
.allModel {
width: 100%;
padding: 30rpx 30rpx 0 30rpx;
flex-flow: column;
border-radius: 0 0 30rpx 30rpx;
.label-content {
flex: 1;
overflow: hidden;
width: 100%;
.label-title {
background: #f4f5f7;
color: #999;
padding: 7rpx 30rpx;
margin: 0rpx 15rpx 20rpx 0;
display: inline-block;
font-size: 26rpx; font-size: 26rpx;
border-radius: 30rpx;
&.selected {
color: #fff;
background: #2272ff;
}
} }
} }
.more {
padding: 20rpx 0;
width: 100%;
justify-content: flex-end;
}
} }
.lists { .lists {
width: 100%; width: 100%;
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
padding: 30rpx 30rpx 0 30rpx;
position: relative;
.mask {
position: absolute;
z-index: 9;
background: #00000082;
width: 100%;
left: 0;
top: 0;
bottom: 0;
}
.load-more { .load-more {
padding: 50rpx 0; padding: 50rpx 0;
} }
...@@ -431,7 +519,7 @@ export default { ...@@ -431,7 +519,7 @@ export default {
} }
.bar { .bar {
width: 100%; width: 100%;
border-top: 2rpx solid #F4F5F7; border-top: 2rpx solid #f4f5f7;
padding: 0 20rpx; padding: 0 20rpx;
background: #fff; background: #fff;
} }
......
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