<template> <view> <view class="product_detail"> <image src="../../../static/news.jpg" mode="widthFix" class="pic"></image> <view class="box"> <view class="title">{{ item.goodsName }}</view> <view class="price">¥ {{ item.price }}</view> <view class="clear"></view> <u-divider text="规格参数"></u-divider> <view class="item"> <text class="desc">净重:</text> <text>{{ item.netWeight }}</text> </view> <view class="item"> <text class="desc">毛重:</text> <text>{{ item.grossWeight }}</text> </view> <view class="item"> <text class="desc">计量单位:</text> <text>{{ item.goodsUnits }}</text> </view> <view class="item"> <text class="desc">商户:</text> <text>{{ item.merchantName }}</text> </view> <view class="item"> <text class="desc">互市区:</text> <text>{{ item.tradeAreaName }}</text> </view> <view class="item"> <text class="desc">发布时间:</text> <text>{{ item.createTime }}</text> </view> <u-divider text="商品介绍"></u-divider> <view class="contents" v-if="item.description">{{ item.description }}</view> <view class="contents">暂无关于该商品的介绍</view> </view> </view> <view class="mfooter" v-if="user.userType == 2"> <view class="flex"> <view class="f"> <button class="save btn" @click="addCar()">加入购物车</button> </view> <view class="f"> <button class="btn" @click="buy()">立即购买</button> </view> </view> </view> </view> </template> <script> export default { data() { return { user: this.getUser(), item: {} }; }, onLoad(e) { if (e.id) { this.http.request({ url: '/level-one-server/TbGoodsTransit/getById?id=' + e.id, success: res => { this.item = res.data.data; } }); } }, methods: { //加入购物车 addCar() { let params = { buyUserId: this.user.id, enterpriseId: this.item.merchantId, shopId: this.item.shopId, tradeAreaId: this.item.tradeAreaId, saleGoodsInfoId: this.item.id, goodsImg: this.item.goodsImg, goodsName: this.item.goodsName, publishGoodsId: this.item.id }; this.http.request({ url: '/level-one-server/app/TbGoodsCart/addGoodsInShopCart', data: params, method: 'POST', contentType: 'application/json; charset=utf-8', success: res => { uni.showToast({ title: '添加成功' }); } }); }, // 立即购买 buy() { uni.showModal({ title: '提示', content: '确定购买?', success: res => { if (res.confirm) { this.http.request({ url: '/level-one-server/app/TbGoodsTransit/purchaseLevelOntGoodsTransit', data: { goodsTransitId: this.item.id }, method: 'POST', contentType: 'application/json; charset=utf-8', success: res => { uni.redirectTo({ url: '/pages/market/one/leader/success' }); } }); } } }); } } }; </script> <style lang="scss"> page { background-color: $pg; } .btn { width: 100%; border-radius: 5px; } </style>