| | |
| | | <template> |
| | | <view class="page-collect"> |
| | | <view class="search-container m-t-12 flex"> |
| | | <view class="flex1 input"> |
| | | <u-input placeholder="请输入花名" v-model="query.name"> |
| | | <template slot="suffix"> |
| | | <uni-icons color="#20613D" type="search" size="24" @tap="refreshList"></uni-icons> |
| | | </template> |
| | | </u-input> |
| | | </view> |
| | | </view> |
| | | <view class="component-filter-container"> |
| | | <view class="flex1" @click.stop="order_show=true"> |
| | | {{ this.query.columnStr || '排序' }} |
| | | <image src="../../../static/common/icon-arrow-down.png" class="icon-arrow-down"></image> |
| | | </view> |
| | | <view class="flex1" @click.stop="level_show=true"> |
| | | {{ this.query.levelStr || '级别' }} |
| | | <image src="../../../static/common/icon-arrow-down.png" class="icon-arrow-down" |
| | | ></image> |
| | | </view> |
| | | </view> |
| | | |
| | | <u-picker :show="level_show" @confirm="select_level" keyName="label" :columns="level_columns" |
| | | @cancel="level_show=false"></u-picker> |
| | | <u-picker :show="order_show" @confirm="select_order" keyName="label" :columns="order_columns" |
| | | @cancel="order_show=false"></u-picker> |
| | | |
| | | <view class="trade-list-container"> |
| | | <view class="trade-info-container" v-for="(dto,index) of list" :key="index"> |
| | | <view class="title"> |
| | | <view class="level m-r-15">{{ dto.levelStr || '-' }}级</view> |
| | | <view class=""> |
| | | {{ dto.name || '-' }} |
| | | </view> |
| | | </view> |
| | | <view class="desc m-t-12"> |
| | | <view class="m-r-15">已售:{{ dto.sales || 0 }}</view> |
| | | <view class="m-r-15">剩余:{{ dto.stock || 0 }}</view> |
| | | <view class=" ">{{ dto.unit || '-' }}支/扎</view> |
| | | </view> |
| | | <view class="flex m-t-12"> |
| | | <view class="price m-r-a"> |
| | | <span class="num">{{ dto.price || '-' }}</span> |
| | | 元/扎 |
| | | </view> |
| | | <view class="m-l-a m-r-15"> |
| | | <image src="../../../static/common/icon-kf.png" class="icon-kf m-l-15 img100"></image> |
| | | |
| | | </view> |
| | | <view class="m-r-0 gwc" @click="submitShopping(dto)"> |
| | | + 购物车 |
| | | </view> |
| | | </view> |
| | | </view> |
| | | |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | async onPullDownRefresh() { |
| | | await this.refreshList() |
| | | uni.stopPullDownRefresh() |
| | | }, |
| | | data() { |
| | | return { |
| | | query: { |
| | | name: '', |
| | | levelStr: '', |
| | | level: '', |
| | | column: '', |
| | | columnStr: '', |
| | | }, |
| | | level_show: false, |
| | | level_columns: [[]], |
| | | export default { |
| | | async onPullDownRefresh() { |
| | | await this.refreshList() |
| | | uni.stopPullDownRefresh() |
| | | }, |
| | | data() { |
| | | return { |
| | | query: { |
| | | name: '', |
| | | levelStr: '', |
| | | level: '', |
| | | column: '', |
| | | columnStr: '', |
| | | }, |
| | | level_show: false, |
| | | level_columns: [ |
| | | [] |
| | | ], |
| | | |
| | | order_show: false, |
| | | order_columns: [[]] |
| | | } |
| | | }, |
| | | onLoad() { |
| | | this.listApi = '/api/collect/list' |
| | | this.getList() |
| | | order_show: false, |
| | | order_columns: [ |
| | | [] |
| | | ] |
| | | } |
| | | }, |
| | | onLoad() { |
| | | this.listApi = '/api/collect/list' |
| | | this.getList() |
| | | |
| | | this.$http.request('get', '/api/code/value', { |
| | | params: { |
| | | type: 'FLOWER_LEVEL' |
| | | } |
| | | }).then(res => { |
| | | var data = res.data |
| | | this.level_columns = [data || []] |
| | | this.columns_levels[0].unshift({ |
| | | label: '全部', |
| | | value: '' |
| | | }) |
| | | }) |
| | | this.$http.request('get', '/api/code/value', { |
| | | params: { |
| | | type: 'FLOWER_LEVEL' |
| | | } |
| | | }).then(res => { |
| | | var data = res.data |
| | | this.level_columns = [data || []] |
| | | this.level_columns[0].unshift({ |
| | | label: '全部', |
| | | value: '' |
| | | }) |
| | | }) |
| | | |
| | | this.$http.request('get', '/api/code/value', { |
| | | params: { |
| | | type: 'FLOWER_ORDER_BY' |
| | | } |
| | | }).then(res => { |
| | | var data = res.data |
| | | this.order_columns = [data || []] |
| | | this.order_columns[0].unshift({ |
| | | label: '默认', |
| | | value: '' |
| | | }) |
| | | }) |
| | | }, |
| | | methods: { |
| | | select_level(e) { |
| | | this.level_show = false |
| | | this.query.levelStr = e.value[0].label |
| | | this.query.level = e.value[0].value |
| | | this.refreshList() |
| | | this.$http.request('get', '/api/code/value', { |
| | | params: { |
| | | type: 'FLOWER_ORDER_BY' |
| | | } |
| | | }).then(res => { |
| | | var data = res.data |
| | | this.order_columns = [data || []] |
| | | this.order_columns[0].unshift({ |
| | | label: '默认', |
| | | value: '' |
| | | }) |
| | | }) |
| | | }, |
| | | methods: { |
| | | async clearCollect() { |
| | | await this.$message.confirm('是否清空已失效的商品') |
| | | this.$message.showLoading() |
| | | const { |
| | | code |
| | | } = await this.$http.request('post', '/api/collect/clear', { |
| | | data: { |
| | | |
| | | }, |
| | | select_order(e) { |
| | | this.order_show = false |
| | | this.query.columnStr = e.value[0].label |
| | | this.query.column = e.value[0].value |
| | | this.refreshList() |
| | | } |
| | | }) |
| | | this.$message.hideLoading() |
| | | if (code === 0) { |
| | | this.refreshList() |
| | | } |
| | | }, |
| | | async delCollect(item) { |
| | | await this.$message.confirm('是否取消收藏') |
| | | this.$message.showLoading() |
| | | const { |
| | | code |
| | | } = await this.$http.request('get', '/api/collect/delete', { |
| | | params: { |
| | | flowerId: item.id |
| | | } |
| | | }) |
| | | this.$message.hideLoading() |
| | | if (code === 0) { |
| | | this.refreshList() |
| | | } |
| | | }, |
| | | toDetail(item) { |
| | | if (item.status == 'UP') { |
| | | |
| | | }, |
| | | } |
| | | } |
| | | } else { |
| | | this.$message.showToast('商品已下架,无法查看详情') |
| | | return |
| | | } |
| | | uni.navigateTo({ |
| | | url: `/sub_pages/customer/trade/detail?id=${item.id}` |
| | | }) |
| | | }, |
| | | async submitShopping(dto) { |
| | | //提交到购物车中 |
| | | // this.$message.showLoading() |
| | | // this.$message.hideLoading() |
| | | const { |
| | | code, |
| | | data |
| | | } = await this.$store.dispatch('submitShopping', dto); |
| | | if (code == 0) { |
| | | dto.shopnum = data || 0 |
| | | this.$forceUpdate() |
| | | } |
| | | }, |
| | | select_level(e) { |
| | | this.level_show = false |
| | | this.query.levelStr = e.value[0].label |
| | | this.query.level = e.value[0].value |
| | | this.refreshList() |
| | | |
| | | }, |
| | | select_order(e) { |
| | | this.order_show = false |
| | | this.query.columnStr = e.value[0].label |
| | | this.query.column = e.value[0].value |
| | | this.refreshList() |
| | | |
| | | }, |
| | | async updateItemNum(item) { |
| | | const res = await this.$message.confirm('', { |
| | | editable: true, |
| | | title: '请输入想要购买的数量' |
| | | }) |
| | | if (res.content && res.confirm) { |
| | | // 发送请求 |
| | | var t = parseInt(res.content) |
| | | if (isNaN(t) || t < 0) { |
| | | this.$message.showToast('数目需要大于等于0') |
| | | |
| | | } else { |
| | | if (!item.stock || t > item.stock) { |
| | | this.$message.showToast('库存不足无法修改') |
| | | return |
| | | } |
| | | this.addnum(item, (t - item.shopnum)) |
| | | |
| | | } |
| | | } else { |
| | | |
| | | } |
| | | }, |
| | | async addnum(item, addnum) { |
| | | if (!this.currentInfo.id) { |
| | | await this.$message.confirm('请前往登录') |
| | | uni.navigateTo({ |
| | | url: '/pages/user/supplier-user' |
| | | }) |
| | | return |
| | | } |
| | | if (!item.shopnum) { |
| | | item.shopnum = 0 |
| | | } |
| | | if (!item.stock) { |
| | | item.stock = 0 |
| | | } |
| | | if (addnum > 0 & item.shopnum + addnum > item.stock) { |
| | | this.$message.showToast('库存不足,无法修改') |
| | | return |
| | | } |
| | | if (item.shopnum + addnum >= 0) { |
| | | |
| | | } else { |
| | | return |
| | | } |
| | | this.$message.showLoading() |
| | | const { |
| | | code |
| | | } = await this.$http.request('post', '/api/customer/flower/cart/change-num', { |
| | | data: { |
| | | id: item.id, |
| | | num: addnum |
| | | } |
| | | }) |
| | | this.$message.hideLoading() |
| | | if (code === 0) { |
| | | item.shopnum += addnum |
| | | this.$forceUpdate() |
| | | } |
| | | }, |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <template> |
| | | <view class="page-collect " style="background: #E1F0E7;"> |
| | | <view style="padding-bottom: 0rpx;" class="p20"> |
| | | <view class="search-container flex"> |
| | | <view class="flex1 input flex"> |
| | | <u-input placeholder="请输入花名" v-model="query.name"> |
| | | <template slot="suffix"> |
| | | <uni-icons color="#20613D" type="search" size="24" @click="refreshList"></uni-icons> |
| | | </template> |
| | | </u-input> |
| | | <!-- <view class="desc-gray text-center m-l-10"> |
| | | 一键清空失效商品 |
| | | </view> --> |
| | | </view> |
| | | </view> |
| | | <view class="component-filter-container p10"> |
| | | <!-- @click.stop="order_show=true" --> |
| | | <view class="flex1" @click.stop="$refs.popup_column.open()"> |
| | | 排序{{ query.columnStr&&('-'+query.columnStr) || '' }} |
| | | <image src="../../../static/common/icon-arrow-down.png" class="icon-arrow-down"></image> |
| | | </view> |
| | | <!-- @click.stop="level_show=true" --> |
| | | <view class="flex1" @click.stop="$refs.popup_level.open()"> |
| | | {{ query.levelStr || '级别' }} |
| | | <image src="../../../static/common/icon-arrow-down.png" class="icon-arrow-down"></image> |
| | | </view> |
| | | <view class="flex1 desc-gray" @click.stop="clearCollect"> |
| | | 一键清空已失效 |
| | | </view> |
| | | </view> |
| | | </view> |
| | | |
| | | <no-data v-if="!list||list.length===0" style="width: 100%;"></no-data> |
| | | |
| | | |
| | | <u-picker :show="level_show" @confirm="select_level" keyName="label" :columns="level_columns" |
| | | @cancel="level_show=false"></u-picker> |
| | | <u-picker :show="order_show" @confirm="select_order" keyName="label" :columns="order_columns" |
| | | @cancel="order_show=false"></u-picker> |
| | | |
| | | <view class="trade-list-container"> |
| | | <view class="trade-info-container flex" :class="[dto.status!=='UP'?'OFF':'']" v-for="(dto,index) of list" |
| | | :key="index"> |
| | | <image class="img img100 br-4 m-r-10" :class="[!dto.stock?'component-stock-zero':'']" |
| | | :src="dto.url||dto.cover" @click.stop="toDetail(dto)"></image> |
| | | <view class="flex1"> |
| | | <view class="flex" @click.stop="toDetail(dto)"> |
| | | <view class="title"> |
| | | <span class="m-r-5" style="display: inline-block;" |
| | | v-if="dto.categoryStr">{{dto.categoryStr||''}}</span> |
| | | <span v-if="dto.levelStr" class="m-r-5" |
| | | style="display: inline-block;">{{ dto.levelStr || '' }}</span> |
| | | {{ dto.name || '-' }} |
| | | </view> |
| | | <view class="price m-l-a m-r-0"> |
| | | ¥{{ dto.price || '-' }}/扎 |
| | | </view> |
| | | </view> |
| | | <view class="flex"> |
| | | <view class="desc p-t-12 flex" @click.stop="toDetail(dto)"> |
| | | <view class="m-r-15">剩余:{{ dto.stock || 0 }}</view> |
| | | <view class="m-r-15">颜色:{{ dto.color || '-' }}</view> |
| | | </view> |
| | | <view class="button-icons flex m-l-a m-r-0 m-t-20" v-if="dto.status=='UP'"> |
| | | <view class="m-r-0 gwc" @click.stop="submitShopping(dto)" v-if="!dto.shopnum"> |
| | | + 购物车 |
| | | </view> |
| | | <view class="m-r-0 flex" v-if="dto.shopnum"> |
| | | <uni-icons v-if="dto.shopnum&&dto.shopnum>=1" type="minus" size="32" |
| | | @click.stop="addnum(dto,-1)"></uni-icons> |
| | | <view class="curnums" @click.stop="updateItemNum(dto)" |
| | | v-if="dto.shopnum&&dto.shopnum>=1"> |
| | | {{ dto.shopnum }} |
| | | </view> |
| | | <uni-icons v-if="!dto.shopnum||dto.shopnum<=99" type="plus-filled" size="32" |
| | | @click.stop="addnum(dto,1)"></uni-icons> |
| | | </view> |
| | | <view class=" m-l-15 m-r-0 button" @click.stop="delCollect(dto)"> |
| | | 取消收藏 |
| | | </view> |
| | | |
| | | </view> |
| | | </view> |
| | | </view> |
| | | |
| | | </view> |
| | | |
| | | </view> |
| | | |
| | | |
| | | <uni-popup ref="popup_level" type="bottom"> |
| | | <view class="component-popup_input_all"> |
| | | <view class="text-center m-b-40" style="font-size: 48rpx;font-weight: 600;">点击选择不同级别</view> |
| | | <view v-for="(item,i) in level_columns" :key="i" class="m-t-20"> |
| | | <view class="m-t-12 flex value-items"> |
| | | <view class="value-item" @click="()=>{ |
| | | if(each.value!==query.value){ |
| | | query.level = each.value |
| | | query.levelStr = each.label |
| | | refreshList() |
| | | $refs.popup_level.close() |
| | | } |
| | | }" :class="[query.level==each.value?'cur':'']" v-for="(each, j) in item" :key="j"> |
| | | {{ each.label || '-' }} |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <view class="button-space"></view> |
| | | <view> |
| | | <view class="button-green" @click="$refs.popup_level.close()">关闭 |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </uni-popup> |
| | | <uni-popup ref="popup_column" type="bottom"> |
| | | <view class="component-popup_input_all"> |
| | | <view class="text-center m-b-40" style="font-size: 48rpx;font-weight: 600;">点击选择不同排序</view> |
| | | <view v-for="(item,i) in order_columns" :key="i" class="m-t-20"> |
| | | <view class="m-t-12 flex value-items"> |
| | | <view class="value-item" @click="()=>{ |
| | | if(each.value!==query.value){ |
| | | query.column = each.value |
| | | query.columnStr = each.label |
| | | refreshList() |
| | | $refs.popup_column.close() |
| | | } |
| | | }" :class="[query.column==each.value?'cur':'']" v-for="(each, j) in item" :key="j"> |
| | | {{ each.label || '-' }} |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <view class="button-space"></view> |
| | | <view> |
| | | <view class="button-green" @click="$refs.popup_column.close()">关闭 |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </uni-popup> |
| | | |
| | | </view> |
| | | </template> |
| | | |
| | | <style lang="scss" scoped> |
| | | .page-collect { |
| | | .search-container { |
| | | display: flex; |
| | | margin: 12rpx 0rpx 20rpx 0rpx; |
| | | position: relative; |
| | | z-index: 1; |
| | | .page-collect { |
| | | min-height: 99vh; |
| | | |
| | | .input { |
| | | background-color: #fff !important; |
| | | border-radius: 8rpx; |
| | | } |
| | | .search-container { |
| | | display: flex; |
| | | margin: 12rpx 0rpx 20rpx 0rpx; |
| | | position: relative; |
| | | z-index: 1; |
| | | |
| | | .button { |
| | | min-width: 120rpx; |
| | | max-width: 120rpx; |
| | | margin-left: auto; |
| | | margin-right: 0rpx; |
| | | text-align: right; |
| | | line-height: 70rpx !important; |
| | | } |
| | | } |
| | | } |
| | | .input { |
| | | background-color: #fff !important; |
| | | border-radius: 8rpx; |
| | | } |
| | | |
| | | </style> |
| | | .button { |
| | | min-width: 120rpx; |
| | | max-width: 120rpx; |
| | | margin-left: auto; |
| | | margin-right: 0rpx; |
| | | text-align: right; |
| | | line-height: 70rpx !important; |
| | | } |
| | | } |
| | | |
| | | .trade-list-container { |
| | | min-height: calc(100vh - 300rpx); |
| | | overflow-y: scroll; |
| | | border-top-right-radius: 40rpx; |
| | | border-top-left-radius: 40rpx; |
| | | padding: 20rpx; |
| | | |
| | | } |
| | | |
| | | .trade-info-container.OFF { |
| | | .title { |
| | | color: #666; |
| | | |
| | | } |
| | | } |
| | | |
| | | .trade-info-container { |
| | | background-color: #fff; |
| | | border-radius: 40rpx; |
| | | margin-bottom: 20rpx; |
| | | padding: 20rpx; |
| | | |
| | | |
| | | .img { |
| | | width: 124rpx; |
| | | height: 124rpx; |
| | | } |
| | | |
| | | .title { |
| | | font-weight: 600; |
| | | font-size: 28rpx; |
| | | |
| | | color: #000; |
| | | line-height: 40rpx; |
| | | |
| | | .level { |
| | | color: #20613D; |
| | | } |
| | | } |
| | | |
| | | .price { |
| | | font-weight: 400; |
| | | font-size: 28rpx; |
| | | color: #CF0000; |
| | | line-height: 40rpx; |
| | | } |
| | | |
| | | .desc { |
| | | font-weight: 400; |
| | | font-size: 24rpx; |
| | | color: #666666; |
| | | line-height: 34rpx; |
| | | } |
| | | |
| | | |
| | | .button-icons { |
| | | //position: absolute; |
| | | //z-index: 10; |
| | | line-height: 40rpx; |
| | | |
| | | .curnums { |
| | | padding-left: 20rpx; |
| | | padding-right: 20rpx; |
| | | } |
| | | } |
| | | |
| | | .gwc { |
| | | width: 168rpx; |
| | | height: 48rpx; |
| | | border-radius: 30rpx; |
| | | border: 2rpx solid #20613D; |
| | | font-size: 24rpx; |
| | | color: #20613D; |
| | | line-height: 48rpx; |
| | | text-align: center; |
| | | } |
| | | |
| | | .button { |
| | | width: 168rpx; |
| | | height: 48rpx; |
| | | border-radius: 30rpx; |
| | | border: 2rpx solid #333; |
| | | font-size: 24rpx; |
| | | color: #333; |
| | | line-height: 48rpx; |
| | | text-align: center; |
| | | } |
| | | } |
| | | |
| | | } |
| | | </style> |