123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <template>
- <view class="place-order">
- <custom-nav noback="noback" transparent="transparent" ref="ltm" title=" " />
- <view class="content">
- <scroll-view scroll-y :style="{ height: scrollviewHeight + 'px' }">
- <view
- :class="mode === 'list' ? 'list' : 'square'"
- v-for="item in goodsList" :key="item.id"
- @tap="tap(item.id, item.storage)"
- >
- <view class="img">
- <image :src="item.img"></image>
- </view>
- <view class="info">
- <view class="top">{{ item.name }}</view>
- <view class="mid">进货价:¥{{ item.price }}</view>
- <view class="bot">我的库存:{{ item.storage }}套</view>
- </view>
- <view class="buy">立即购买</view>
- </view>
- <view v-if="!goodsList.length" class="loading">加载中...</view>
- </scroll-view>
- </view>
- </view>
- </template>
- <script>
- import { _API_GoodList } from '@/apis/good.js'
- export default {
- data() {
- return {
- title: '订货下单',
- mode: 'square',
- goodsList: [],
- scrollviewHeight: 0
- }
- },
- mounted() { // 获取商品列表
- this.$offset('.content').then(res => this.scrollviewHeight = res.height) // 设置scrollview 高
- // uni.startPullDownRefresh()
-
- uni.navigateBack()
- setTimeout(() => uni.$emit('noopening'))
- return
- this.request()
- },
- onPullDownRefresh() {
- this.request()
- },
- methods: {
- request() {
- uni.showLoading({ mask: true })
- _API_GoodList().then(res => {
- if (res.code === 200) {
- this.goodsList = res.data.list
- } else {
- uni.toast('网络好像出了点问题,下拉刷新试试')
- }
- }).catch(() => setTimeout(() => uni.toast('网络好像出了点问题,下拉刷新试试'), 123))
- },
- navRight() { // 切换显示模式
- this.mode = this.mode === 'list' ? 'square' : 'list'
- },
- tap(id, storage) { // 查看商品详情
- if (this.$store.state.userinfo.level === '销售主管') {
- uni.toast('销售主管不能通过App下单')
- } else {
- uni.navigateTo({ url: `../good-detail/good-detail?id=${id}&storage=${storage}` })
- }
- }
- }
- }
- </script>
- <style lang="scss">
- .place-order {
- @include page();
- .content {
- .loading {
- text-align: center;
- margin-top: 567rpx;
- }
- .list {
- @include flex();
- height: 180rpx;
- background: #FFFFFF;
- margin-bottom: 10rpx;
- padding: 20rpx 30rpx;
- align-items: flex-end;
- box-sizing: border-box;
- .img {
- height: 100%;
- width: 140rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .info {
- @include flex(column);
- flex: 1;
- height: 100%;
- margin: 0 30rpx;
- justify-content: space-between;
- align-items: flex-start;
- view {
- width: 100%;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- &.top {
- font-size: 32rpx;
- }
- &.mid {
- font-size: 26rpx;
- color: $app-base-color;
- }
- &.bot {
- font-size: 26rpx;
- color: $app-sec-text-color;
- }
- }
- }
- .buy {
- @include flex();
- width: 130rpx;
- height: 48rpx;
- font-size: 26rpx;
- color: $app-base-color;
- border: 2rpx solid $app-base-color;
- }
- }
- .square {
- @include flex(column);
- float: left;
- width: 335rpx;
- height: 500rpx;
- overflow: hidden;
- margin-top: 30rpx;
- margin-left: 30rpx;
- position: relative;
- background: #FFFFFF;
- border-radius: 10rpx;
- box-shadow: 0rpx 10rpx 14rpx 2rpx rgba(168, 168, 168, 0.56);
- &:nth-child(even) {
- margin-left: 20rpx;
- }
- .img {
- width: 100%;
- height: 335rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .info {
- @include flex(column);
- flex: 1;
- width: 100%;
- padding: 20rpx;
- box-sizing: border-box;
- align-items: flex-start;
- justify-content: space-between;
- view {
- width: 100%;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- &.top {
- font-size: 32rpx;
- }
- &.mid {
- font-size: 28rpx;
- color: $app-base-color;
- }
- &.bot {
- font-size: 22rpx;
- color: $app-sec-text-color;
- }
- }
- }
- .buy {
- @include flex();
- right: 10rpx;
- bottom: 10rpx;
- width: 120rpx;
- height: 48rpx;
- color: #FFFFFF;
- font-size: 26rpx;
- position: absolute;
- border-radius: 10rpx;
- background: $app-base-color;
- }
- }
- }
- }
- </style>
|