123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- <template>
- <view>
- <!-- <image src="../../static/images/role/bm.png"></image> -->
- <uni-nav-bar color="#fff" height="60" :fixed="true" left-icon="back" @clickLeft="back()" @clickRight="rightClick()"
- right-icon="list" :border="false" backgroundColor="#0081ff" title="一级市场" />
- </u-navbar>
- <u-list class="list" width="100%" @scrolltolower="scrolltolower">
- <u-list-item v-for="(item, index) in goods" :key="index">
- <view class="item-box">
- <view class="goods-item">
- <u-row>
- <u-col span="5" @click="toDetails(item.id)">
- <u--image radius="10" :showLoading="true" src="" width="250rpx" height="220rpx"></u--image>
- </u-col>
- <u-col span="7">
- <view class="t1 txt" @click="toDetails(item.id)">
- <text>{{item.goodsName}}</text>
- <!-- <text>[老板力荐]鲜活小龙虾(帮剪头去虾线)约250g/份</text> -->
- </view>
- <view class="txt">
- <text v-if="item.grossWeight">{{item.grossWeight}}吨</text>
- </view>
- <view class="txt" v-if="item.tradeAreaName">
- <u-tag style="width: 250rpx" :text="item.tradeAreaName" plain size="mini"></u-tag>
- </view>
- <view class="t4">
- <view class="price">¥{{item.price}}</view>
- <view class="car" @click="addCar(item)">
- <uni-icons type="cart" color="#fff" size="30"></uni-icons>
- </view>
- </view>
- </u-col>
- </u-row>
- </view>
- </view>
- </u-list-item>
- </u-list>
- <u-popup :show="show" mode="right" @close="close" @open="open">
- <view class="pop" style="padding: 15px;">
- <view class="item">
- <view class="title">生鲜海鲜</view>
- <view class="rows">
- <view class="row omit" v-for="(item, index) in typeList" :key="index">
- <view class="out">
- <view class="int" @click="typeClick(item)" :style="{color: item.check?'#0081FF':'#213227'}">{{item.name}}</view>
- </view>
- </view>
- <view class="clear"></view>
- </view>
- </view>
- <u-button class="custom-style" shape="circle" type="primary" size="small" text="确定"
- @click="close()"></u-button>
- </view>
- </u-popup>
- <view class="tab">
- <view class="tabBtn" @click="BtnClick(1)">
- <u-icon label="购物车" size="30" color="#ef732a" labelColor="#ef732a" name="shopping-cart"></u-icon>
- </view>
- <view class="tabBtn" @click="BtnClick(2)">
- <u-icon label="订单列表" size="30" color="#1E90FF" labelColor="#1E90FF" name="order"></u-icon>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- loadmoreStatus: 'loadmore',
- goods: [],
- active: 0,
- title: '一级市场',
- show: false,
- typeList: [],
- typeCheck: [],
- }
- },
- onLoad() {
- this.getGoodsList()
- },
- // onShow() {
- // var a = document.getElementsByClassName('uni-page-head-hd')[0]
- // a.style.display = 'none';
- // },
- methods: {
- getGoodsList() {
- this.http.request({
- url: '/level-one-server/TbGoodsTransit/getTransitList',
- success: res => {
- this.goods = res.data.data;
- // this.goods.forEach((item, index) => {
- // if (index === this.goods.length - 1) {
- // this.loadmoreStatus = 'nomore'
- // } else {
- // this.loadmoreStatus = 'loadmore'
- // }
- // })
- }
- });
- },
- // 添加购物车
- addCar(goods) {
- let user = uni.getStorageSync("info")
- let params = {
- buyUserId: user.id,
- enterpriseId: goods.merchantId,
- shopId: goods.shopId,
- tradeAreaId: goods.tradeAreaId,
- saleGoodsInfoId: goods.id,
- goodsImg: goods.goodsImg,
- goodsName: goods.goodsName,
- // buyNum: parseInt(this.num)
- }
- this.http.request({
- url: '/level-one-server/app/TbGoodsCart/addGoodsInShopCart',
- data: params,
- contentType: 'application/json; charset=utf-8',
- method: 'POST',
- success: res => {
- setTimeout(function() {
- uni.showToast({
- title: res.data.msg
- });
- }, 1000)
- }
- });
- },
- // 商品分类
- getGoodsType() {
- this.http.request({
- url: '/level-one-server/TbGoodsType/getList',
- success: res => {
- this.typeList = res.data.data
- this.typeList.map(item => {
- item.check=false
- })
- }
- });
- },
- scrolltolower() {
- this.getGoodsList()
- },
- toDetails(id) {
- this.$common.to('/pages/goodsDetails/goodsDetails?id=' + id)
- },
- back() {
- uni.switchTab({
- url: '/pages/index/index'
- });
- },
- rightClick() {
- this.show = true
- this.getGoodsType()
- },
- open() {
- // console.log('open');
- },
- close() {
- this.typeList.map(item => {
- if(item.check) this.typeCheck.push(item)
- })
- this.show = false
- },
- BtnClick(type) {
- type == 1 ? uni.navigateTo({
- url: '/pages/oneMarket/cart/cart'
- }) : uni.navigateTo({
- url: '/pages/oneMarket/order/order'
- })
- },
- typeClick(data) {
- this.typeList.map(item => {
- if(item.no == data.no) item.check=!item.check
- })
- this.$forceUpdate();
- }
- }
- }
- </script>
- <style lang="scss">
- .item {
- .title {
- padding: 5px;
- }
- .rows {
- width: 100%;
- .row {
- width: 33.33%;
- float: left;
- text-align: center;
- .out {
- padding: 6px;
- overflow: hidden;
- .int {
- padding: 5px;
- color: #213227;
- background-color: #eaf1fe;
- border-radius: 3px;
- font-size: 14px;
- overflow: hidden;
- &.active {
- color: $main-color;
- }
- }
- }
- }
- }
- }
- page {
- background-image: url(../../static/images/top-bg.png);
- background-size: 100% 400rpx;
- background-repeat: no-repeat;
- background-position: top;
- background-color: #f3f4f6;
- }
- .list {
- height: auto;
- border-radius: 10rpx;
- margin: 10rpx 20rpx 10rpx 20rpx;
- }
- .goods-item {
- margin-bottom: 8rpx;
- }
- .item-box {
- height: 230rpx;
- width: 86%;
- padding: 30rpx;
- background-color: #fff;
- border: 1rpx #FFF solid;
- margin: 10rpx 0rpx;
- border-radius: 10rpx;
- }
- .txt {
- /* height: 50rpx; */
- margin-bottom: 20rpx;
- }
- .t1 {
- font-size: 32rpx;
- font-weight: bold;
- word-wrap: break-word;
- position: relative;
- top: 1rpx;
- right: 5rpx;
- }
- .t4 {
- display: flex;
- position: relative;
- bottom: 1rpx;
- right: 5rpx;
- }
- .price {
- color: #ef732a;
- width: 400rpx;
- font-weight: bold;
- }
- .car {
- background-color: #0081ff;
- width: 80rpx;
- height: 70rpx;
- border-radius: 40rpx;
- text-align: center;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .tab {
- position: fixed;
- bottom: 1rpx;
- width: 100%;
- height: 100rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- border-top: #ffffff 1rpx solid;
- background-color: #ffffff;
- }
- .tabBtn {
- width: 35%;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- margin: 0 30rpx;
- }
- .pop {
- width: 400rpx;
- margin-top: 200rpx;
- }
- .custom-style {
- width: 300rpx;
- }
- /* .active-btn {
- width: 35%;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- color: #fff;
- background-color: #00BFFF;
- } */
- </style>
|