|
@@ -5,9 +5,6 @@
|
|
|
bgColor="#ffffff" @confirm="search" class="search-bar" />
|
|
|
</view>
|
|
|
<scroll-view class="goods-box" scroll-y="true" @scrolltolower="handleLoadMore()">
|
|
|
- <view style="padding-top: 20px;background-color: transparent;" v-if="!goodsList.length">
|
|
|
- <u-divider color="#909399" border-color="#909399" bg-color="transparent">没有更多了</u-divider>
|
|
|
- </view>
|
|
|
<view class="goods-row" v-for="(item, index) in goodsList" :key="index" @click="goToGoodDetails(item)">
|
|
|
<image class="goods-img" :src="item.imgPath" mode="aspectFill"></image>
|
|
|
<view class="goods-info">
|
|
@@ -22,7 +19,7 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="goods-cart">
|
|
|
- <view class="cart-button" v-if="goodType == 1 || goodType == 3" @click.stop="addCart(item)">
|
|
|
+ <view class="cart-button" v-if="goodType == 1 || goodType == 3 || goodType == 5" @click.stop="addCart(item)">
|
|
|
<view class="iconfont icongouwuche"></view>
|
|
|
</view>
|
|
|
<view class="more-button" v-else>
|
|
@@ -30,6 +27,9 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <view style="padding-top: 20px;background-color: transparent;" v-if="isOver">
|
|
|
+ <u-divider color="#909399" border-color="#909399" bg-color="transparent">没有更多了</u-divider>
|
|
|
+ </view>
|
|
|
</scroll-view>
|
|
|
<u-modal v-model="modalShow" content="是否将该商品添加至购物车" @confirm="submitAddCart()" :async-close="true"
|
|
|
:show-cancel-button="true"></u-modal>
|
|
@@ -60,6 +60,9 @@
|
|
|
});
|
|
|
this.getGoodsList()
|
|
|
},
|
|
|
+ onShow() {
|
|
|
+ this.getGoodsList()
|
|
|
+ },
|
|
|
onReady() {
|
|
|
if (this.goodName) {
|
|
|
this.$refs.searchBar.show = true
|
|
@@ -89,28 +92,46 @@
|
|
|
},
|
|
|
// 获取商品
|
|
|
getGoodsList(type) {
|
|
|
- NET.request(API.getGoodsByType, {
|
|
|
- name: this.goodName,
|
|
|
- productType: this.goodType,
|
|
|
- pageIndex: this.pageIndex,
|
|
|
- pageSize: 10,
|
|
|
- }, 'POST').then(res => {
|
|
|
- if (type == 'refresh') {
|
|
|
- uni.stopPullDownRefresh();
|
|
|
- }
|
|
|
- this.isOver = res.data.list.length != 10
|
|
|
- this.goodsList = this.goodsList.concat(res.data.list)
|
|
|
- }).catch(error => {
|
|
|
- this.$refs.uTips.show({
|
|
|
- title: '获取商品列表失败',
|
|
|
- type: 'warning',
|
|
|
+ if (this.goodType == 5) {
|
|
|
+ NET.request(API.getPreferentialGoods+'/' + this.pageIndex+'/10', {
|
|
|
+ name: this.goodName
|
|
|
+ }, 'GET').then(res => {
|
|
|
+ if (type == 'refresh') {
|
|
|
+ uni.stopPullDownRefresh();
|
|
|
+ }
|
|
|
+ this.isOver = res.data.list.length != 10
|
|
|
+ this.goodsList = this.goodsList.concat(res.data.list)
|
|
|
+ }).catch(error => {
|
|
|
+ this.$refs.uTips.show({
|
|
|
+ title: '获取今日特惠商品列表失败',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
})
|
|
|
- })
|
|
|
+ } else {
|
|
|
+ NET.request(API.getGoodsByType, {
|
|
|
+ name: this.goodName,
|
|
|
+ productType: this.goodType,
|
|
|
+ pageIndex: this.pageIndex,
|
|
|
+ pageSize: 10,
|
|
|
+ }, 'POST').then(res => {
|
|
|
+ if (type == 'refresh') {
|
|
|
+ uni.stopPullDownRefresh();
|
|
|
+ }
|
|
|
+ this.isOver = res.data.list.length != 10
|
|
|
+ this.goodsList = this.goodsList.concat(res.data.list)
|
|
|
+ }).catch(error => {
|
|
|
+ this.$refs.uTips.show({
|
|
|
+ title: '获取商品列表失败',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
// 添加购物车
|
|
|
addCart(item) {
|
|
|
+ debugger
|
|
|
this.goodItem = {
|
|
|
- productId: item.id,
|
|
|
+ productId: this.goodType == 5 ? item.productId : item.id,
|
|
|
productName: item.productName,
|
|
|
imgUrl: item.imgPath,
|
|
|
bizPrice: item.bizPrice,
|
|
@@ -139,6 +160,9 @@
|
|
|
},
|
|
|
// 跳转商品详情
|
|
|
goToGoodDetails(item) {
|
|
|
+ if (this.goodType == 5) {
|
|
|
+ item.id = item.productId
|
|
|
+ }
|
|
|
uni.navigateTo({
|
|
|
url: '/pagesGood/goodDetails?goodId=' + item.id
|
|
|
});
|
|
@@ -149,6 +173,8 @@
|
|
|
|
|
|
<style>
|
|
|
page {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
background-color: #f7f7f7;
|
|
|
}
|
|
|
</style>
|