|
@@ -1,8 +1,240 @@
|
|
<template>
|
|
<template>
|
|
|
|
+ <view class="container">
|
|
|
|
+ <view class="search-box">
|
|
|
|
+ <uni-search-bar ref="searchBar" radius="5" placeholder="搜索" :defaultText="goodName" clearButton="auto" cancelButton="none"
|
|
|
|
+ bgColor="#ffffff" @confirm="search" class="search-bar" />
|
|
|
|
+ </view>
|
|
|
|
+ <k-scroll-view @onPullDown="handlePullDown" @onPullUp="handleLoadMore" class="goods-box">
|
|
|
|
+ <view class="goods-row" v-for="item in goodsList" @click="goToGoodDetails(item)">
|
|
|
|
+ <cover-image class="goods-img" :src="item.imgPath"></cover-image>
|
|
|
|
+ <view class="goods-info">
|
|
|
|
+ <view class="goods-name">{{item.productName}}</view>
|
|
|
|
+ <view class="goods-details">{{item.details}}</view>
|
|
|
|
+ <view class="goods-number">
|
|
|
|
+ <text class="goods-icon">¥</text>
|
|
|
|
+ <text class="goods-spec">{{item.bizPrice}}/{{item.spec}}</text>
|
|
|
|
+ <text class="goods-sales">{{item.sellCount}}人付款</text>
|
|
|
|
+ </view>
|
|
|
|
+ </view>
|
|
|
|
+ <view class="goods-cart">
|
|
|
|
+ <view class="cart-button">
|
|
|
|
+ <view class="iconfont icongouwuche"></view>
|
|
|
|
+ </view>
|
|
|
|
+ </view>
|
|
|
|
+ </view>
|
|
|
|
+ </k-scroll-view>
|
|
|
|
+ </view>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+ const NET = require('@/utils/request')
|
|
|
|
+ const API = require('@/config/api')
|
|
|
|
+ export default {
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ goodType: '',
|
|
|
|
+ pageIndex: 1,
|
|
|
|
+ isOver: false,
|
|
|
|
+ goodName: '',
|
|
|
|
+ goodsList: [],
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ onLoad(options) {
|
|
|
|
+ this.goodName = options.goodName ? options.goodName : ''
|
|
|
|
+ this.goodType = options.goodType
|
|
|
|
+ switch (this.goodType) {
|
|
|
|
+ case 0:
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ }
|
|
|
|
+ uni.setNavigationBarTitle({
|
|
|
|
+ title: this.goodType == 0 ? '商品列表' : (this.goodType == 1 ? '自助采摘' : (this.goodType == 2 ? '共享种植' : '拍卖'))
|
|
|
|
+ });
|
|
|
|
+ this.getGoodsList()
|
|
|
|
+ },
|
|
|
|
+ onReady(options) {
|
|
|
|
+ if (this.goodName) {
|
|
|
|
+ this.$refs.searchBar.show = true
|
|
|
|
+ this.$refs.searchBar.showSync = true
|
|
|
|
+ this.$refs.searchBar.searchVal = this.goodName
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ // 搜索商品
|
|
|
|
+ search(data) {
|
|
|
|
+ this.goodName = data.value
|
|
|
|
+ this.goodsList = []
|
|
|
|
+ this.pageIndex = 1
|
|
|
|
+ this.getGoodsList()
|
|
|
|
+ },
|
|
|
|
+ // 下拉刷新
|
|
|
|
+ handlePullDown(stopLoad) {
|
|
|
|
+ this.pageIndex = 1
|
|
|
|
+ this.goodsList = []
|
|
|
|
+ this.getGoodsList(stopLoad)
|
|
|
|
+ stopLoad ? stopLoad() : '';
|
|
|
|
+ },
|
|
|
|
+ // 懒加载
|
|
|
|
+ handleLoadMore(stopLoad) {
|
|
|
|
+ if (!this.isOver) {
|
|
|
|
+ this.pageIndex++
|
|
|
|
+ this.getGoodsList()
|
|
|
|
+ } else {
|
|
|
|
+ stopLoad ? stopLoad({
|
|
|
|
+ isEnd: true
|
|
|
|
+ }) : '';
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 获取商品
|
|
|
|
+ getGoodsList(stopLoad) {
|
|
|
|
+ NET.request(API.getGoodsBySort, {
|
|
|
|
+ name: this.goodName,
|
|
|
|
+ oneId: '',
|
|
|
|
+ twoId: '',
|
|
|
|
+ pageIndex: this.pageIndex,
|
|
|
|
+ pageSize: 10,
|
|
|
|
+ }, 'POST').then(res => {
|
|
|
|
+ if (res.code == 0) {
|
|
|
|
+ this.isOver = res.data.list.length != 10
|
|
|
|
+ this.goodsList = this.goodsList.concat(res.data.list)
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: "获取商品列表失败",
|
|
|
|
+ icon: "none"
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }).catch(res => {})
|
|
|
|
+ },
|
|
|
|
+ // 跳转商品详情
|
|
|
|
+ goToGoodDetails(item) {
|
|
|
|
+ uni.navigateTo({
|
|
|
|
+ url: '/pagesGood/goodDetails?goodId=' + item.productId
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ }
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
<style lang="less" scoped>
|
|
|
|
+ page {
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 100%;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .container {
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 100%;
|
|
|
|
+ background-color: #f7f7f7;
|
|
|
|
+
|
|
|
|
+ .search-box {
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 58px;
|
|
|
|
+ box-sizing: border-box;
|
|
|
|
+ padding: 2px 12px 1px 12px;
|
|
|
|
+
|
|
|
|
+ /deep/.uni-searchbar {
|
|
|
|
+ background-color: #f7f7f7;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .goods-box {
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: calc(100% - 58px) !important;
|
|
|
|
+ padding: 6px 0 0px 0;
|
|
|
|
+ box-sizing: border-box;
|
|
|
|
+ overflow-y: auto;
|
|
|
|
+
|
|
|
|
+ .goods-row {
|
|
|
|
+ width: calc(100% - 24px);
|
|
|
|
+ height: 104px;
|
|
|
|
+ padding: 11px 11px 11px 7px;
|
|
|
|
+ box-sizing: border-box;
|
|
|
|
+ margin: 4px 0 12px 12px;
|
|
|
|
+ background: #FFFFFF;
|
|
|
|
+ box-shadow: 0px 1px 5px 0px rgba(102, 102, 102, 0.43);
|
|
|
|
+ border-radius: 15px;
|
|
|
|
+
|
|
|
|
+ .goods-img {
|
|
|
|
+ width: 84px;
|
|
|
|
+ height: 84px;
|
|
|
|
+ float: left;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .goods-info {
|
|
|
|
+ width: calc(100% - 108px);
|
|
|
|
+ height: 84px;
|
|
|
|
+ float: left;
|
|
|
|
+
|
|
|
|
+ .goods-name {
|
|
|
|
+ height: 18px;
|
|
|
|
+ font-size: 15px;
|
|
|
|
+ font-family: PingFang SC;
|
|
|
|
+ color: #333333;
|
|
|
|
+ line-height: 18px;
|
|
|
|
+ white-space: nowrap;
|
|
|
|
+ text-overflow: ellipsis;
|
|
|
|
+ overflow: hidden;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .goods-details {
|
|
|
|
+ height: 28px;
|
|
|
|
+ font-size: 12px;
|
|
|
|
+ font-family: PingFang SC;
|
|
|
|
+ color: #999999;
|
|
|
|
+ line-height: 14px;
|
|
|
|
+ overflow: hidden;
|
|
|
|
+ text-overflow: ellipsis;
|
|
|
|
+ display: -webkit-box;
|
|
|
|
+ -webkit-line-clamp: 2;
|
|
|
|
+ -webkit-box-orient: vertical;
|
|
|
|
+ word-wrap: break-word;
|
|
|
|
+ margin: 4px 0 12px 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .goods-number {
|
|
|
|
+ height: 16px;
|
|
|
|
+ font-family: PingFang SC;
|
|
|
|
+ line-height: 16px;
|
|
|
|
+
|
|
|
|
+ .goods-icon {
|
|
|
|
+ font-size: 12px;
|
|
|
|
+ color: #52A63A;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .goods-spec {
|
|
|
|
+ font-size: 15px;
|
|
|
|
+ color: #52A63A;
|
|
|
|
+ margin-right: 15px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .goods-sales {
|
|
|
|
+ font-size: 12px;
|
|
|
|
+ color: #999999;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .goods-cart {
|
|
|
|
+ width: 24px;
|
|
|
|
+ height: 84px;
|
|
|
|
+ float: left;
|
|
|
|
+
|
|
|
|
+ .cart-button {
|
|
|
|
+ width: 24px;
|
|
|
|
+ height: 24px;
|
|
|
|
+ margin-top: 30px;
|
|
|
|
+ background-color: #52A63A;
|
|
|
|
+ border-radius: 50%;
|
|
|
|
+ text-align: center;
|
|
|
|
+
|
|
|
|
+ .iconfont {
|
|
|
|
+ color: #FFFFFF;
|
|
|
|
+ font-size: 18px;
|
|
|
|
+ line-height: 24px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
</style>
|
|
</style>
|