123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- <template>
- <view class="page">
- <u-navbar
- v-if="pageStatus != 'platform'"
- title="商品详情"
- @rightClick="rightClick"
- :autoBack="true"
- >
- </u-navbar>
- <u-navbar
- v-if="pageStatus == 'platform'"
- title="true"
- @rightClick="rightClick"
- :autoBack="true"
- >
- <view slot="center" class="u-top">
- <view
- :class="{ 'goods-Detail': goodsOrDetail == 1 }"
- @click="switchTab(1)"
- >商品</view
- >
- <view
- :class="{ 'goods-Detail': goodsOrDetail == 2 }"
- @click="switchTab(2)"
- >详情</view
- >
- </view>
- </u-navbar>
- <!-- v-if="pageStatus != 'platform'" -->
- <view v-if="!downOrGrounding && pageStatus != 'platform'">
- <view class="top-fail" v-if="commodityDetail.final_status != 'unreview'">
- <image
- src="../../static/mine/332.png"
- class="fail-icon"
- mode=""
- ></image>
- <text v-if="commodityDetail.final_status == 'refuse'"
- >涉及敏感文字,您发布的商品审核未通过</text
- >
- <text v-else-if="!downOrGrounding"
- >该商品已下架,如有需要请重新上架</text
- >
- </view>
- <view class="fail" v-if="commodityDetail.final_status == 'unreview'">
- <image
- src="../../static/mine/333.png"
- class="fail-icon"
- mode=""
- ></image>
- <text>商品还在审核中,请耐心等待</text>
- </view>
- </view>
- <image class="goods-img" :src="commodityDetail.image" mode=""></image>
- <view class="title-price" style="">
- <view class="price" v-if="commodityDetail.discount_price">
- <text style="font-size: 20rpx">折扣价</text>
- <text style="font-size: 18rpx">¥</text>
- <text style="font-size: 36rpx; font-weight: 600">{{
- commodityDetail.discount_price.split(".")[0]
- }}</text
- >.
- <text style="font-size: 18rpx">{{
- commodityDetail.discount_price.split(".")[1]
- }}</text>
- <text
- style="
- font-size: 24rpx;
- color: #ccc;
- text-decoration-line: line-through;
- "
- >
- ¥{{ commodityDetail.price }}
- </text>
- </view>
- <view class="goods-title">
- {{ commodityDetail.name_cn }}
- </view>
- </view>
- <view class="goods-detail" id="product-detail"> 商品详情 </view>
- <view class="detail">
- <view class="u-content">
- <u-parse :content="commodityDetail.detail_cn"></u-parse>
- </view>
- </view>
- <view
- class="footer"
- v-if="
- (!downOrGrounding || pageStatus == 'platform') &&
- commodityDetail.final_status != 'unreview'
- "
- >
- <!-- <button class="btn">编辑商品</button> -->
- <button
- class="btn"
- v-if="pageStatus == 'platform'"
- @click="groundingProduct"
- >
- 上架商品
- </button>
- <button class="btn" v-else @click="groundingCommodity">上架商品</button>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- goodsId: 0,
- pageStatus: "", //判断商品是什么商品,平台库或其他
- commodityDetail: {}, //商品详情
- goodsOrDetail: 1,
- scrollTop: 0,
- };
- },
- onLoad(options) {
- this.goodsId = options.goodsId;
- this.pageStatus = options.pageStatus;
- if (options.pageStatus == "platform" || options.pageStatus == "supply") {
- this.getGoodsDetail();
- } else {
- this.getGoodsManageDetail();
- }
- },
- onPageScroll(e) {
- this.scrollTop = e.scrollTop;
- },
- computed: {
- downOrGrounding() {
- if (this.commodityDetail.status == "down") {
- return false;
- } else {
- if (this.commodityDetail.merchant_goods == "down") {
- return false;
- } else {
- return true;
- }
- }
- },
- },
- methods: {
- rightClick() {},
- //获取平台库商品详情
- getGoodsDetail() {
- uni.$u.http
- .get(`/api/goods/platform_goods_details/${this.goodsId}`)
- .then((res) => {
- this.commodityDetail = res;
- });
- },
- switchTab(num) {
- this.goodsOrDetail = num;
- if (num == 1) {
- //返回顶部
- uni.pageScrollTo({
- scrollTop: 0, // 滚动到页面的目标位置 这个是滚动到顶部, 0
- duration: 300, // 滚动动画的时长
- });
- } else {
- uni
- .createSelectorQuery()
- .select("#product-detail")
- .boundingClientRect((data) => {
- //目标位置的节点:类class或者id
- uni
- .createSelectorQuery()
- .select(".page")
- .boundingClientRect((res) => {
- //最外层盒子的节点:类class或者id
- uni.pageScrollTo({
- duration: 100, //过渡时间
- scrollTop: data.top - res.top, //到达距离顶部的top值
- //scrollTop:data.top - res.top,//如果置顶
- });
- })
- .exec();
- })
- .exec();
- }
- },
- //获取商品管理商品详情
- getGoodsManageDetail() {
- uni.$u.http.get(`/api/goods/detail/${this.goodsId}`).then((res) => {
- this.commodityDetail = res;
- });
- },
- //上架平台库商品
- groundingProduct() {
- uni.$u.http
- .post(`/api/goods/elencazione`, {
- goods_id: this.commodityDetail.id,
- })
- .then((res) => {
- this.getGoodsDetail();
- uni.showToast({
- title: "已上架",
- icon: "none",
- });
- });
- },
- //上架商品
- groundingCommodity() {
- if (this.commodityDetail.status == "down") {
- uni.showToast({
- title: "商品已下架,无法上架",
- icon: "none",
- });
- return;
- }
- uni.$u.http
- .post(`/api/goods/elencazione`, {
- goods_id: this.commodityDetail.merchant_goods_id,
- })
- .then((res) => {
- if (this.pageStatus == "platform") {
- this.getGoodsDetail();
- } else {
- this.getGoodsManageDetail();
- }
- uni.showToast({
- title: "已上架",
- icon: "none",
- });
- });
- },
- },
- mounted() {
- // uni.setNavigationBarTitle({
- // title: "商品详情",
- // });
- },
- };
- </script>
- <style lang="scss" scoped>
- .page {
- //background-color: #fff;
- padding-bottom: 150rpx;
- margin-top: 174rpx;
- .u-top {
- display: flex;
- width: 200rpx;
- justify-content: space-between;
- .goods-Detail {
- color: #f83224;
- }
- }
- .top-fail {
- height: 60rpx;
- background-color: #fff1ee;
- padding-left: 24rpx;
- display: flex;
- align-items: center;
- font-size: 24rpx;
- color: #333;
- .fail-icon {
- width: 32rpx;
- height: 32rpx;
- margin-right: 10rpx;
- }
- }
- .fail {
- height: 60rpx;
- background-color: #fff1d7;
- padding-left: 24rpx;
- display: flex;
- align-items: center;
- font-size: 24rpx;
- color: #333;
- .fail-icon {
- width: 32rpx;
- height: 32rpx;
- margin-right: 10rpx;
- }
- }
- .goods-img {
- width: 100%;
- height: 750rpx;
- }
- .title-price {
- background-color: #fff;
- width: 96%;
- margin: 0 auto;
- border-radius: 16rpx;
- padding-bottom: 36rpx;
- margin-top: 20rpx;
- padding-top: 10rpx;
- }
- .price {
- color: #f83224;
- margin-top: 6rpx;
- padding-left: 40rpx;
- font-weight: 600;
- }
- .goods-title {
- padding: 0 40rpx;
- font-size: 32rpx;
- margin-top: 20rpx;
- }
- .goods-detail {
- font-size: 28rpx;
- padding-left: 40rpx;
- background-color: #fff;
- width: 90%;
- margin: 0 auto;
- margin-top: 40rpx;
- border-radius: 16rpx 16rpx 0 0;
- padding-top: 30rpx;
- }
- .detail {
- padding: 24rpx 20rpx;
- background-color: #fff;
- width: 90%;
- margin: 0 auto;
- border-radius: 0 0 16rpx 16rpx;
- .detail-img {
- width: 100%;
- }
- }
- .footer {
- position: fixed;
- bottom: 0;
- width: 100%;
- padding-bottom: 84rpx;
- padding-top: 20rpx;
- background-color: #fff;
- .btn {
- border-radius: 52rpx;
- background-color: #f83224;
- color: #fff;
- border: none;
- padding: 0;
- margin: 0;
- width: 94%;
- font-size: 30rpx;
- margin: 0 auto;
- }
- }
- }
- </style>
|