优化从购物车下单
parent
bfa440e98c
commit
4030e40ebc
17
App.vue
17
App.vue
|
|
@ -1,6 +1,12 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onLaunch, onShow, onError } from '@dcloudio/uni-app';
|
import {
|
||||||
import { ShoproInit } from './sheep';
|
onLaunch,
|
||||||
|
onShow,
|
||||||
|
onError
|
||||||
|
} from '@dcloudio/uni-app';
|
||||||
|
import {
|
||||||
|
ShoproInit
|
||||||
|
} from './sheep';
|
||||||
|
|
||||||
onLaunch(() => {
|
onLaunch(() => {
|
||||||
// 隐藏原生导航栏 使用自定义底部导航
|
// 隐藏原生导航栏 使用自定义底部导航
|
||||||
|
|
@ -18,18 +24,17 @@
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
// 获取urlSchemes参数
|
// 获取urlSchemes参数
|
||||||
const args = plus.runtime.arguments;
|
const args = plus.runtime.arguments;
|
||||||
if (args) {
|
if (args) {}
|
||||||
}
|
|
||||||
|
|
||||||
// 获取剪贴板
|
// 获取剪贴板
|
||||||
uni.getClipboardData({
|
uni.getClipboardData({
|
||||||
success: (res) => { },
|
success: (res) => {},
|
||||||
});
|
});
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
// 确认收货回调结果
|
// 确认收货回调结果
|
||||||
console.log(options,'options');
|
console.log(options, 'options');
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,26 +7,13 @@
|
||||||
<!-- 骨架屏 -->
|
<!-- 骨架屏 -->
|
||||||
<detailSkeleton v-if="state.skeletonLoading" />
|
<detailSkeleton v-if="state.skeletonLoading" />
|
||||||
<!-- 下架/售罄提醒 -->
|
<!-- 下架/售罄提醒 -->
|
||||||
<s-empty
|
<s-empty v-else-if="state.goodsInfo === null" text="商品不存在或已下架" icon="/static/soldout-empty.png" showAction
|
||||||
v-else-if="state.goodsInfo === null"
|
actionText="再逛逛" actionUrl="/pages/goods/list" />
|
||||||
text="商品不存在或已下架"
|
|
||||||
icon="/static/soldout-empty.png"
|
|
||||||
showAction
|
|
||||||
actionText="再逛逛"
|
|
||||||
actionUrl="/pages/goods/list"
|
|
||||||
/>
|
|
||||||
<block v-else>
|
<block v-else>
|
||||||
<view class="detail-swiper-selector">
|
<view class="detail-swiper-selector">
|
||||||
<!-- 商品轮播图 -->
|
<!-- 商品轮播图 -->
|
||||||
<su-swiper
|
<su-swiper class="ss-m-b-14" isPreview :list="state.goodsSwiper" dotStyle="tag" imageMode="widthFix"
|
||||||
class="ss-m-b-14"
|
dotCur="bg-mask-40" :seizeHeight="750" />
|
||||||
isPreview
|
|
||||||
:list="state.goodsSwiper"
|
|
||||||
dotStyle="tag"
|
|
||||||
imageMode="widthFix"
|
|
||||||
dotCur="bg-mask-40"
|
|
||||||
:seizeHeight="750"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 价格+标题 -->
|
<!-- 价格+标题 -->
|
||||||
<view class="title-card detail-card ss-p-y-40 ss-p-x-20">
|
<view class="title-card detail-card ss-p-y-40 ss-p-x-20">
|
||||||
|
|
@ -46,22 +33,15 @@
|
||||||
<view class="discounts-box ss-flex ss-row-between ss-m-b-28">
|
<view class="discounts-box ss-flex ss-row-between ss-m-b-28">
|
||||||
<div class="tag-content">
|
<div class="tag-content">
|
||||||
<view class="tag-box ss-flex">
|
<view class="tag-box ss-flex">
|
||||||
<view
|
<view class="tag ss-m-r-10" v-for="promos in state.goodsInfo.promos"
|
||||||
class="tag ss-m-r-10"
|
:key="promos.id" @tap="onActivity">
|
||||||
v-for="promos in state.goodsInfo.promos"
|
|
||||||
:key="promos.id"
|
|
||||||
@tap="onActivity"
|
|
||||||
>
|
|
||||||
{{ promos.title }}
|
{{ promos.title }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<view
|
<view class="get-coupon-box ss-flex ss-col-center ss-m-l-20" @tap="state.showModel = true"
|
||||||
class="get-coupon-box ss-flex ss-col-center ss-m-l-20"
|
v-if="state.couponInfo.length">
|
||||||
@tap="state.showModel = true"
|
|
||||||
v-if="state.couponInfo.length"
|
|
||||||
>
|
|
||||||
<view class="discounts-title ss-m-r-8">领券</view>
|
<view class="discounts-title ss-m-r-8">领券</view>
|
||||||
<text class="cicon-forward"></text>
|
<text class="cicon-forward"></text>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -72,24 +52,15 @@
|
||||||
|
|
||||||
<!-- 功能卡片 -->
|
<!-- 功能卡片 -->
|
||||||
<view class="detail-cell-card detail-card ss-flex-col">
|
<view class="detail-cell-card detail-card ss-flex-col">
|
||||||
<detail-cell-sku
|
<detail-cell-sku v-model="state.selectedSkuPrice.goods_sku_text" :skus="state.goodsInfo.skus"
|
||||||
v-model="state.selectedSkuPrice.goods_sku_text"
|
@tap="state.showSelectSku = true" />
|
||||||
:skus="state.goodsInfo.skus"
|
|
||||||
@tap="state.showSelectSku = true"
|
|
||||||
/>
|
|
||||||
<detail-cell-service v-if="state.goodsInfo.service" v-model="state.goodsInfo.service" />
|
<detail-cell-service v-if="state.goodsInfo.service" v-model="state.goodsInfo.service" />
|
||||||
<detail-cell-params v-if="state.goodsInfo.params" v-model="state.goodsInfo.params" />
|
<detail-cell-params v-if="state.goodsInfo.params" v-model="state.goodsInfo.params" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 规格与数量弹框 -->
|
<!-- 规格与数量弹框 -->
|
||||||
<s-select-sku
|
<s-select-sku :goodsInfo="state.goodsInfo" :show="state.showSelectSku" @addCart="onAddCart"
|
||||||
:goodsInfo="state.goodsInfo"
|
@buy="onBuy" @change="onSkuChange" @close="state.showSelectSku = false" />
|
||||||
:show="state.showSelectSku"
|
|
||||||
@addCart="onAddCart"
|
|
||||||
@buy="onBuy"
|
|
||||||
@change="onSkuChange"
|
|
||||||
@close="state.showSelectSku = false"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 评价 -->
|
<!-- 评价 -->
|
||||||
|
|
@ -98,25 +69,16 @@
|
||||||
<detail-content-card class="detail-content-selector" :content="state.goodsInfo.description" />
|
<detail-content-card class="detail-content-selector" :content="state.goodsInfo.description" />
|
||||||
|
|
||||||
<!-- 活动跳转 -->
|
<!-- 活动跳转 -->
|
||||||
<detail-activity-tip
|
<detail-activity-tip v-if="state.goodsInfo.activities" :data="state.goodsInfo"></detail-activity-tip>
|
||||||
v-if="state.goodsInfo.activities"
|
|
||||||
:data="state.goodsInfo"
|
|
||||||
></detail-activity-tip>
|
|
||||||
|
|
||||||
<!-- 详情tabbar -->
|
<!-- 详情tabbar -->
|
||||||
<detail-tabbar v-model="state.goodsInfo">
|
<detail-tabbar v-model="state.goodsInfo">
|
||||||
<!-- TODO: 缺货中 已售罄 判断 设计-->
|
<!-- TODO: 缺货中 已售罄 判断 设计-->
|
||||||
<view class="buy-box ss-flex ss-col-center ss-p-r-20" v-if="state.goodsInfo.stock > 0">
|
<view class="buy-box ss-flex ss-col-center ss-p-r-20" v-if="state.goodsInfo.stock > 0">
|
||||||
<button
|
<button class="ss-reset-button add-btn ui-Shadow-Main" @tap="state.showSelectSku = true">
|
||||||
class="ss-reset-button add-btn ui-Shadow-Main"
|
|
||||||
@tap="state.showSelectSku = true"
|
|
||||||
>
|
|
||||||
加入购物车
|
加入购物车
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button class="ss-reset-button buy-btn ui-Shadow-Main" @tap="state.showSelectSku = true">
|
||||||
class="ss-reset-button buy-btn ui-Shadow-Main"
|
|
||||||
@tap="state.showSelectSku = true"
|
|
||||||
>
|
|
||||||
立即购买
|
立即购买
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -124,27 +86,30 @@
|
||||||
<button class="ss-reset-button disabled-btn" disabled> 已售罄 </button>
|
<button class="ss-reset-button disabled-btn" disabled> 已售罄 </button>
|
||||||
</view>
|
</view>
|
||||||
</detail-tabbar>
|
</detail-tabbar>
|
||||||
<s-coupon-get
|
<s-coupon-get v-model="state.couponInfo" :show="state.showModel" @close="state.showModel = false"
|
||||||
v-model="state.couponInfo"
|
@get="onGet" />
|
||||||
:show="state.showModel"
|
<s-activity-pop v-model="state.activityInfo" :show="state.showActivityModel"
|
||||||
@close="state.showModel = false"
|
@close="state.showActivityModel = false" />
|
||||||
@get="onGet"
|
|
||||||
/>
|
|
||||||
<s-activity-pop
|
|
||||||
v-model="state.activityInfo"
|
|
||||||
:show="state.showActivityModel"
|
|
||||||
@close="state.showActivityModel = false"
|
|
||||||
/>
|
|
||||||
</block>
|
</block>
|
||||||
</s-layout>
|
</s-layout>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, computed } from 'vue';
|
import {
|
||||||
import { onLoad, onPageScroll } from '@dcloudio/uni-app';
|
reactive,
|
||||||
|
computed
|
||||||
|
} from 'vue';
|
||||||
|
import {
|
||||||
|
onLoad,
|
||||||
|
onPageScroll
|
||||||
|
} from '@dcloudio/uni-app';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import { formatSales, formatGoodsSwiper, formatPrice } from '@/sheep/hooks/useGoods';
|
import {
|
||||||
|
formatSales,
|
||||||
|
formatGoodsSwiper,
|
||||||
|
formatPrice
|
||||||
|
} from '@/sheep/hooks/useGoods';
|
||||||
import detailNavbar from './components/detail/detail-navbar.vue';
|
import detailNavbar from './components/detail/detail-navbar.vue';
|
||||||
import detailCellSku from './components/detail/detail-cell-sku.vue';
|
import detailCellSku from './components/detail/detail-cell-sku.vue';
|
||||||
import detailCellService from './components/detail/detail-cell-service.vue';
|
import detailCellService from './components/detail/detail-cell-service.vue';
|
||||||
|
|
@ -154,7 +119,9 @@
|
||||||
import detailCommentCard from './components/detail/detail-comment-card.vue';
|
import detailCommentCard from './components/detail/detail-comment-card.vue';
|
||||||
import detailContentCard from './components/detail/detail-content-card.vue';
|
import detailContentCard from './components/detail/detail-content-card.vue';
|
||||||
import detailActivityTip from './components/detail/detail-activity-tip.vue';
|
import detailActivityTip from './components/detail/detail-activity-tip.vue';
|
||||||
import { isEmpty } from 'lodash';
|
import {
|
||||||
|
isEmpty
|
||||||
|
} from 'lodash';
|
||||||
|
|
||||||
// import detailActivityTip from './components/detail/detail-activity-tip.vue';
|
// import detailActivityTip from './components/detail/detail-activity-tip.vue';
|
||||||
// import detailTab from './components/detail/detail-tab.vue';
|
// import detailTab from './components/detail/detail-tab.vue';
|
||||||
|
|
@ -190,13 +157,11 @@
|
||||||
sheep.$router.go('/pages/order/confirm', {
|
sheep.$router.go('/pages/order/confirm', {
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
order_type: 'goods',
|
order_type: 'goods',
|
||||||
goods_list: [
|
goods_list: [{
|
||||||
{
|
|
||||||
goods_id: e.goods_id,
|
goods_id: e.goods_id,
|
||||||
goods_num: e.goods_num,
|
goods_num: e.goods_num,
|
||||||
goods_sku_price_id: e.id,
|
goods_sku_price_id: e.id,
|
||||||
},
|
}, ],
|
||||||
],
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -208,7 +173,10 @@
|
||||||
|
|
||||||
//立即领取
|
//立即领取
|
||||||
async function onGet(id) {
|
async function onGet(id) {
|
||||||
const { error, msg } = await sheep.$api.coupon.get(id);
|
const {
|
||||||
|
error,
|
||||||
|
msg
|
||||||
|
} = await sheep.$api.coupon.get(id);
|
||||||
if (error === 0) {
|
if (error === 0) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: msg,
|
title: msg,
|
||||||
|
|
@ -221,8 +189,7 @@
|
||||||
|
|
||||||
const shareInfo = computed(() => {
|
const shareInfo = computed(() => {
|
||||||
if (isEmpty(state.goodsInfo)) return {};
|
if (isEmpty(state.goodsInfo)) return {};
|
||||||
return sheep.$platform.share.getShareInfo(
|
return sheep.$platform.share.getShareInfo({
|
||||||
{
|
|
||||||
title: state.goodsInfo.title,
|
title: state.goodsInfo.title,
|
||||||
image: sheep.$url.cdn(state.goodsInfo.image),
|
image: sheep.$url.cdn(state.goodsInfo.image),
|
||||||
desc: state.goodsInfo.subtitle,
|
desc: state.goodsInfo.subtitle,
|
||||||
|
|
@ -230,15 +197,13 @@
|
||||||
page: '2',
|
page: '2',
|
||||||
query: state.goodsInfo.id,
|
query: state.goodsInfo.id,
|
||||||
},
|
},
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
type: 'goods', // 商品海报
|
type: 'goods', // 商品海报
|
||||||
title: state.goodsInfo.title, // 商品标题
|
title: state.goodsInfo.title, // 商品标题
|
||||||
image: sheep.$url.cdn(state.goodsInfo.image), // 商品主图
|
image: sheep.$url.cdn(state.goodsInfo.image), // 商品主图
|
||||||
price: state.goodsInfo.price[0], // 商品价格
|
price: state.goodsInfo.price[0], // 商品价格
|
||||||
original_price: state.goodsInfo.original_price, // 商品原价
|
original_price: state.goodsInfo.original_price, // 商品原价
|
||||||
},
|
}, );
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
|
|
@ -251,15 +216,25 @@
|
||||||
state.goodsId = options.id;
|
state.goodsId = options.id;
|
||||||
// 加载商品信息
|
// 加载商品信息
|
||||||
sheep.$api.goods.detail(state.goodsId).then((res) => {
|
sheep.$api.goods.detail(state.goodsId).then((res) => {
|
||||||
console.log(res)
|
// 处理数据适配
|
||||||
|
// let arr = [];
|
||||||
|
// res.skus = res.data.skus.map(item => {
|
||||||
|
// arr = [...arr, ...item.properties];
|
||||||
|
// item.children = item.properties;
|
||||||
|
// item.goods_id = res.data.id;
|
||||||
|
// item.name = item.children[0].propertyName;
|
||||||
|
// return item;
|
||||||
|
// })
|
||||||
|
// console.log(arr, '合并');
|
||||||
|
// console.log(res.data, '替换后订单数据');
|
||||||
state.skeletonLoading = false;
|
state.skeletonLoading = false;
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
// 在此处对数据做出转换
|
// 在此处对数据做出转换
|
||||||
res.data.sales=res.data.salesCount
|
res.data.sales = res.data.salesCount
|
||||||
res.data.original_price=res.data.marketPrice/100
|
res.data.original_price = res.data.marketPrice / 100
|
||||||
res.data.subtitle=res.data.introduction
|
res.data.subtitle = res.data.introduction
|
||||||
res.data.title=res.data.name
|
res.data.title = res.data.name
|
||||||
res.data.price=[res.data.price/100]
|
res.data.price = [res.data.price / 100]
|
||||||
state.goodsInfo = res.data;
|
state.goodsInfo = res.data;
|
||||||
state.goodsSwiper = formatGoodsSwiper(state.goodsInfo.sliderPicUrls);
|
state.goodsSwiper = formatGoodsSwiper(state.goodsInfo.sliderPicUrls);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -267,7 +242,10 @@
|
||||||
state.goodsInfo = null;
|
state.goodsInfo = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const { error, data } = await sheep.$api.coupon.listByGoods(state.goodsId);
|
const {
|
||||||
|
error,
|
||||||
|
data
|
||||||
|
} = await sheep.$api.coupon.listByGoods(state.goodsId);
|
||||||
if (error === 0) {
|
if (error === 0) {
|
||||||
state.couponInfo = data;
|
state.couponInfo = data;
|
||||||
}
|
}
|
||||||
|
|
@ -323,10 +301,12 @@
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-box {
|
.tag-box {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag {
|
.tag {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
padding: 4rpx 10rpx;
|
padding: 4rpx 10rpx;
|
||||||
|
|
@ -388,6 +368,7 @@
|
||||||
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
|
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
|
||||||
color: $white;
|
color: $white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.disabled-btn {
|
.disabled-btn {
|
||||||
width: 428rpx;
|
width: 428rpx;
|
||||||
height: 72rpx;
|
height: 72rpx;
|
||||||
|
|
@ -399,9 +380,11 @@
|
||||||
|
|
||||||
.model-box {
|
.model-box {
|
||||||
height: 60vh;
|
height: 60vh;
|
||||||
|
|
||||||
.model-content {
|
.model-content {
|
||||||
height: 56vh;
|
height: 56vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<s-layout title="购物车" tabbar="/pages/index/cart" :bgStyle="{ color: '#fff' }">
|
<s-layout title="购物车" tabbar="/pages/index/cart" :bgStyle="{ color: '#fff' }">
|
||||||
<s-empty
|
<s-empty v-if="state.list.length === 0" text="购物车空空如也,快去逛逛吧~" icon="/static/cart-empty.png" />
|
||||||
v-if="state.list.length === 0"
|
|
||||||
text="购物车空空如也,快去逛逛吧~"
|
|
||||||
icon="/static/cart-empty.png"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 头部 -->
|
<!-- 头部 -->
|
||||||
<view class="cart-box ss-flex ss-flex-col ss-row-between" v-if="state.list.length">
|
<view class="cart-box ss-flex ss-flex-col ss-row-between" v-if="state.list.length">
|
||||||
|
|
@ -28,29 +24,16 @@
|
||||||
<view class="goods-box ss-r-10 ss-m-b-14" v-for="item in state.list" :key="item.id">
|
<view class="goods-box ss-r-10 ss-m-b-14" v-for="item in state.list" :key="item.id">
|
||||||
<view class="ss-flex ss-col-center">
|
<view class="ss-flex ss-col-center">
|
||||||
<label class="check-box ss-flex ss-col-center ss-p-l-10" @tap="onSelectSingle(item.id)">
|
<label class="check-box ss-flex ss-col-center ss-p-l-10" @tap="onSelectSingle(item.id)">
|
||||||
<radio
|
<radio :checked="state.selectedIds.includes(item.id)" color="var(--ui-BG-Main)"
|
||||||
:checked="state.selectedIds.includes(item.id)"
|
style="transform: scale(0.8)" @tap.stop="onSelectSingle(item.id)" />
|
||||||
color="var(--ui-BG-Main)"
|
|
||||||
style="transform: scale(0.8)"
|
|
||||||
@tap.stop="onSelectSingle(item.id)"
|
|
||||||
/>
|
|
||||||
</label>
|
</label>
|
||||||
<s-goods-item
|
<s-goods-item :title="item.spu.name" :img="item.spu.picUrl || item.goods.image"
|
||||||
:title="item.spu.name"
|
|
||||||
:img="item.spu.picUrl || item.goods.image"
|
|
||||||
:price="item.sku.price/100"
|
:price="item.sku.price/100"
|
||||||
:skuText="item.sku.properties.length>1? item.sku.properties.reduce((items2,items)=>items2.valueName+' '+items.valueName):item.sku.properties[0].valueName"
|
:skuText="item.sku.properties.length>1? item.sku.properties.reduce((items2,items)=>items2.valueName+' '+items.valueName):item.sku.properties[0].valueName"
|
||||||
priceColor="#FF3000"
|
priceColor="#FF3000" :titleWidth="400">
|
||||||
:titleWidth="400"
|
|
||||||
>
|
|
||||||
<template v-if="!state.editMode" v-slot:tool>
|
<template v-if="!state.editMode" v-slot:tool>
|
||||||
<su-number-box
|
<su-number-box :min="0" :max="item.sku.stock" :step="1" v-model="item.count"
|
||||||
:min="0"
|
@change="onNumberChange($event, item)"></su-number-box>
|
||||||
:max="item.sku.stock"
|
|
||||||
:step="1"
|
|
||||||
v-model="item.count"
|
|
||||||
@change="onNumberChange($event, item)"
|
|
||||||
></su-number-box>
|
|
||||||
</template>
|
</template>
|
||||||
</s-goods-item>
|
</s-goods-item>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -61,12 +44,8 @@
|
||||||
<view class="cart-footer ss-flex ss-col-center ss-row-between ss-p-x-30 border-bottom">
|
<view class="cart-footer ss-flex ss-col-center ss-row-between ss-p-x-30 border-bottom">
|
||||||
<view class="footer-left ss-flex ss-col-center">
|
<view class="footer-left ss-flex ss-col-center">
|
||||||
<label class="check-box ss-flex ss-col-center ss-p-r-30" @tap="onSelectAll">
|
<label class="check-box ss-flex ss-col-center ss-p-r-30" @tap="onSelectAll">
|
||||||
<radio
|
<radio :checked="state.isAllSelected" color="var(--ui-BG-Main)"
|
||||||
:checked="state.isAllSelected"
|
style="transform: scale(0.8)" @tap.stop="onSelectAll" />
|
||||||
color="var(--ui-BG-Main)"
|
|
||||||
style="transform: scale(0.8)"
|
|
||||||
@tap.stop="onSelectAll"
|
|
||||||
/>
|
|
||||||
<view class="ss-m-l-8"> 全选 </view>
|
<view class="ss-m-l-8"> 全选 </view>
|
||||||
</label>
|
</label>
|
||||||
<text>合计:</text>
|
<text>合计:</text>
|
||||||
|
|
@ -75,18 +54,12 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="footer-right">
|
<view class="footer-right">
|
||||||
<button
|
<button v-if="state.editMode" class="ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main"
|
||||||
v-if="state.editMode"
|
@tap="onDelete">
|
||||||
class="ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main"
|
|
||||||
@tap="onDelete"
|
|
||||||
>
|
|
||||||
删除
|
删除
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button v-else class="ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main"
|
||||||
v-else
|
@tap="onConfirm">
|
||||||
class="ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main"
|
|
||||||
@tap="onConfirm"
|
|
||||||
>
|
|
||||||
去结算
|
去结算
|
||||||
{{ state.selectedIds?.length ? `(${state.selectedIds.length})` : '' }}
|
{{ state.selectedIds?.length ? `(${state.selectedIds.length})` : '' }}
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -99,7 +72,11 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import { computed, reactive, unref } from 'vue';
|
import {
|
||||||
|
computed,
|
||||||
|
reactive,
|
||||||
|
unref
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
const sys_navBar = sheep.$platform.navbar;
|
const sys_navBar = sheep.$platform.navbar;
|
||||||
const cart = sheep.$store('cart');
|
const cart = sheep.$store('cart');
|
||||||
|
|
@ -124,24 +101,39 @@
|
||||||
|
|
||||||
// 结算
|
// 结算
|
||||||
function onConfirm() {
|
function onConfirm() {
|
||||||
|
let items = []
|
||||||
let goods_list = [];
|
let goods_list = [];
|
||||||
state.selectedList = state.list.filter((item) => state.selectedIds.includes(item.id));
|
state.selectedList = state.list.filter((item) => state.selectedIds.includes(item.id));
|
||||||
state.selectedList.map((item) => {
|
state.selectedList.map((item) => {
|
||||||
|
console.log(item, '便利');
|
||||||
|
// 此处前端做出修改
|
||||||
|
items.push({
|
||||||
|
skuId: item.sku.id,
|
||||||
|
count: item.count,
|
||||||
|
cartId: item.id,
|
||||||
|
})
|
||||||
goods_list.push({
|
goods_list.push({
|
||||||
goods_id: item.goods_id,
|
// goods_id: item.goods_id,
|
||||||
goods_num: item.goods_num,
|
goods_id: item.spu.id,
|
||||||
goods_sku_price_id: item.goods_sku_price_id,
|
// goods_num: item.goods_num,
|
||||||
|
goods_num: item.count,
|
||||||
|
// 商品价格id真没有
|
||||||
|
// goods_sku_price_id: item.goods_sku_price_id,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// return;
|
||||||
if (goods_list.length === 0) {
|
if (goods_list.length === 0) {
|
||||||
sheep.$helper.toast('请选择商品');
|
sheep.$helper.toast('请选择商品');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sheep.$router.go('/pages/order/confirm', {
|
sheep.$router.go('/pages/order/confirm', {
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
order_type: 'goods',
|
// order_type: 'goods',
|
||||||
goods_list,
|
// goods_list,
|
||||||
from: 'cart',
|
items,
|
||||||
|
// from: 'cart',
|
||||||
|
deliveryType: 1,
|
||||||
|
pointStatus: false,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +143,7 @@
|
||||||
cart.delete(cartItem.id);
|
cart.delete(cartItem.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(cartItem.goods_num === e) return;
|
if (cartItem.goods_num === e) return;
|
||||||
cartItem.goods_num = e;
|
cartItem.goods_num = e;
|
||||||
cart.update({
|
cart.update({
|
||||||
goods_id: cartItem.id,
|
goods_id: cartItem.id,
|
||||||
|
|
@ -199,6 +191,7 @@
|
||||||
|
|
||||||
.cart-content {
|
.cart-content {
|
||||||
margin-top: 70rpx;
|
margin-top: 70rpx;
|
||||||
|
|
||||||
.goods-box {
|
.goods-box {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,17 +22,18 @@
|
||||||
} from '@dcloudio/uni-app';
|
} from '@dcloudio/uni-app';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import $share from '@/sheep/platform/share';
|
import $share from '@/sheep/platform/share';
|
||||||
|
import index2Api from '@/sheep/api/index2'
|
||||||
// 隐藏原生tabBar
|
// 隐藏原生tabBar
|
||||||
uni.hideTabBar();
|
uni.hideTabBar();
|
||||||
|
|
||||||
const template = computed(() => sheep.$store('app').template?.home);
|
const template = computed(() => sheep.$store('app').template?.home);
|
||||||
// 在此处拦截改变一下首页轮播图 此处先写死后期复活 放到启动函数里
|
// 在此处拦截改变一下首页轮播图 此处先写死后期复活 放到启动函数里
|
||||||
(async function() {
|
(async function() {
|
||||||
console.log('原代码首页定制化数据',template)
|
console.log('原代码首页定制化数据', template)
|
||||||
let {
|
let {
|
||||||
data
|
data
|
||||||
} = await index2Api.decorate();
|
} = await index2Api.decorate();
|
||||||
console.log('首页导航配置化过高无法兼容',JSON.parse(data[1].value))
|
console.log('首页导航配置化过高无法兼容', JSON.parse(data[1].value))
|
||||||
// 改变首页底部数据 但是没有通过数组id获取商品数据接口
|
// 改变首页底部数据 但是没有通过数组id获取商品数据接口
|
||||||
// let {
|
// let {
|
||||||
// data: datas
|
// data: datas
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<s-layout title="确认订单">
|
<s-layout title="确认订单">
|
||||||
<view
|
<!-- v-if="state.orderInfo.need_address === 1" -->
|
||||||
class="bg-white address-box ss-m-b-14 ss-r-b-10"
|
<!-- 这个判断先删除 -->
|
||||||
@tap="onSelectAddress"
|
<view class="bg-white address-box ss-m-b-14 ss-r-b-10" @tap="onSelectAddress">
|
||||||
v-if="state.orderInfo.need_address === 1"
|
|
||||||
>
|
|
||||||
<s-address-item :item="state.addressInfo" :hasBorderBottom="false">
|
<s-address-item :item="state.addressInfo" :hasBorderBottom="false">
|
||||||
<view class="ss-rest-button"><text class="_icon-forward"></text></view>
|
<view class="ss-rest-button"><text class="_icon-forward"></text></view>
|
||||||
</s-address-item>
|
</s-address-item>
|
||||||
</view>
|
</view>
|
||||||
<view class="order-card-box ss-m-b-14">
|
<view class="order-card-box ss-m-b-14">
|
||||||
<s-goods-item
|
<s-goods-item v-for="item in state.orderInfo.goods_list" :key="item.goods_id"
|
||||||
v-for="item in state.orderInfo.goods_list"
|
:img="item.current_sku_price.image || item.goods.image" :title="item.goods.title"
|
||||||
:key="item.goods_id"
|
:skuText="item.current_sku_price?.goods_sku_text" :price="item.current_sku_price.price"
|
||||||
:img="item.current_sku_price.image || item.goods.image"
|
:num="item.goods_num" marginBottom="10">
|
||||||
:title="item.goods.title"
|
|
||||||
:skuText="item.current_sku_price?.goods_sku_text"
|
|
||||||
:price="item.current_sku_price.price"
|
|
||||||
:num="item.goods_num"
|
|
||||||
marginBottom="10"
|
|
||||||
>
|
|
||||||
<template #top>
|
<template #top>
|
||||||
<view class="order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white">
|
<view class="order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white">
|
||||||
<view class="item-title">配送方式</view>
|
<view class="item-title">配送方式</view>
|
||||||
|
|
@ -33,13 +25,8 @@
|
||||||
<view class="order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white ss-r-10">
|
<view class="order-item ss-flex ss-col-center ss-row-between ss-p-x-20 bg-white ss-r-10">
|
||||||
<view class="item-title">订单备注</view>
|
<view class="item-title">订单备注</view>
|
||||||
<view class="ss-flex ss-col-center">
|
<view class="ss-flex ss-col-center">
|
||||||
<uni-easyinput
|
<uni-easyinput maxlength="20" placeholder="建议留言前先与商家沟通" v-model="state.orderPayload.remark"
|
||||||
maxlength="20"
|
:inputBorder="false" :clearable="false"></uni-easyinput>
|
||||||
placeholder="建议留言前先与商家沟通"
|
|
||||||
v-model="state.orderPayload.remark"
|
|
||||||
:inputBorder="false"
|
|
||||||
:clearable="false"
|
|
||||||
></uni-easyinput>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -52,16 +39,11 @@
|
||||||
<text class="item-value ss-m-r-24">¥{{ state.orderInfo.goods_amount }}</text>
|
<text class="item-value ss-m-r-24">¥{{ state.orderInfo.goods_amount }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view class="order-item ss-flex ss-col-center ss-row-between"
|
||||||
class="order-item ss-flex ss-col-center ss-row-between"
|
v-if="state.orderPayload.order_type === 'score'">
|
||||||
v-if="state.orderPayload.order_type === 'score'"
|
|
||||||
>
|
|
||||||
<view class="item-title">扣除积分</view>
|
<view class="item-title">扣除积分</view>
|
||||||
<view class="ss-flex ss-col-center">
|
<view class="ss-flex ss-col-center">
|
||||||
<image
|
<image :src="sheep.$url.static('/static/img/shop/goods/score1.svg')" class="score-img"></image>
|
||||||
:src="sheep.$url.static('/static/img/shop/goods/score1.svg')"
|
|
||||||
class="score-img"
|
|
||||||
></image>
|
|
||||||
<text class="item-value ss-m-r-24">{{ state.orderInfo.score_amount }}</text>
|
<text class="item-value ss-m-r-24">{{ state.orderInfo.score_amount }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -71,34 +53,25 @@
|
||||||
<text class="item-value ss-m-r-24">+¥{{ state.orderInfo.dispatch_amount }}</text>
|
<text class="item-value ss-m-r-24">+¥{{ state.orderInfo.dispatch_amount }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view class="order-item ss-flex ss-col-center ss-row-between"
|
||||||
class="order-item ss-flex ss-col-center ss-row-between"
|
v-if="state.orderPayload.order_type != 'score'">
|
||||||
v-if="state.orderPayload.order_type != 'score'"
|
|
||||||
>
|
|
||||||
<!-- <view v-if="state.orderInfo.coupon_discount_fee > 0" class="order-item ss-flex ss-col-center ss-row-between"> -->
|
<!-- <view v-if="state.orderInfo.coupon_discount_fee > 0" class="order-item ss-flex ss-col-center ss-row-between"> -->
|
||||||
<view class="item-title">优惠券</view>
|
<view class="item-title">优惠券</view>
|
||||||
<view class="ss-flex ss-col-center" @tap="state.showCoupon = true">
|
<view class="ss-flex ss-col-center" @tap="state.showCoupon = true">
|
||||||
<text class="item-value text-red" v-if="state.orderPayload.coupon_id"
|
<text class="item-value text-red"
|
||||||
>-¥{{ state.orderInfo.coupon_discount_fee }}</text
|
v-if="state.orderPayload.coupon_id">-¥{{ state.orderInfo.coupon_discount_fee }}</text>
|
||||||
>
|
<text class="item-value"
|
||||||
<text
|
:class="state.couponInfo.can_use?.length > 0 ? 'text-red' : 'text-disabled'" v-else>{{
|
||||||
class="item-value"
|
|
||||||
:class="state.couponInfo.can_use?.length > 0 ? 'text-red' : 'text-disabled'"
|
|
||||||
v-else
|
|
||||||
>{{
|
|
||||||
state.couponInfo.can_use?.length > 0
|
state.couponInfo.can_use?.length > 0
|
||||||
? state.couponInfo.can_use?.length + '张可用'
|
? state.couponInfo.can_use?.length + '张可用'
|
||||||
: '暂无可用优惠券'
|
: '暂无可用优惠券'
|
||||||
}}</text
|
}}</text>
|
||||||
>
|
|
||||||
|
|
||||||
<text class="_icon-forward item-icon"></text>
|
<text class="_icon-forward item-icon"></text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view class="order-item ss-flex ss-col-center ss-row-between"
|
||||||
class="order-item ss-flex ss-col-center ss-row-between"
|
v-if="state.orderInfo.promo_infos?.length">
|
||||||
v-if="state.orderInfo.promo_infos?.length"
|
|
||||||
>
|
|
||||||
<!-- <view v-if="state.orderInfo.promo_discount_fee > 0" class="order-item ss-flex ss-col-center ss-row-between"> -->
|
<!-- <view v-if="state.orderInfo.promo_discount_fee > 0" class="order-item ss-flex ss-col-center ss-row-between"> -->
|
||||||
<view class="item-title">活动优惠</view>
|
<view class="item-title">活动优惠</view>
|
||||||
<view class="ss-flex ss-col-center" @tap="state.showDiscount = true">
|
<view class="ss-flex ss-col-center" @tap="state.showDiscount = true">
|
||||||
|
|
@ -113,10 +86,7 @@
|
||||||
<view class="total-num text-red"> ¥{{ state.orderInfo.pay_fee }} </view>
|
<view class="total-num text-red"> ¥{{ state.orderInfo.pay_fee }} </view>
|
||||||
<view class="ss-flex" v-if="state.orderPayload.order_type === 'score'">
|
<view class="ss-flex" v-if="state.orderPayload.order_type === 'score'">
|
||||||
<view class="total-num ss-font-30 text-red ss-m-l-4"> + </view>
|
<view class="total-num ss-font-30 text-red ss-m-l-4"> + </view>
|
||||||
<image
|
<image :src="sheep.$url.static('/static/img/shop/goods/score1.svg')" class="score-img"></image>
|
||||||
:src="sheep.$url.static('/static/img/shop/goods/score1.svg')"
|
|
||||||
class="score-img"
|
|
||||||
></image>
|
|
||||||
<view class="total-num ss-font-30 text-red">{{ state.orderInfo.score_amount }}</view>
|
<view class="total-num ss-font-30 text-red">{{ state.orderInfo.score_amount }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -132,18 +102,10 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 选择优惠券弹框 -->
|
<!-- 选择优惠券弹框 -->
|
||||||
<s-coupon-select
|
<s-coupon-select v-model="state.couponInfo" :show="state.showCoupon" @confirm="onSelectCoupon"
|
||||||
v-model="state.couponInfo"
|
@close="state.showCoupon = false" />
|
||||||
:show="state.showCoupon"
|
|
||||||
@confirm="onSelectCoupon"
|
|
||||||
@close="state.showCoupon = false"
|
|
||||||
/>
|
|
||||||
<!-- 满额折扣弹框 -->
|
<!-- 满额折扣弹框 -->
|
||||||
<s-discount-list
|
<s-discount-list v-model="state.orderInfo" :show="state.showDiscount" @close="state.showDiscount = false" />
|
||||||
v-model="state.orderInfo"
|
|
||||||
:show="state.showDiscount"
|
|
||||||
@close="state.showDiscount = false"
|
|
||||||
/>
|
|
||||||
<!-- 底部 -->
|
<!-- 底部 -->
|
||||||
<su-fixed bottom :opacity="false" bg="bg-white" placeholder :noFixed="false" :index="200">
|
<su-fixed bottom :opacity="false" bg="bg-white" placeholder :noFixed="false" :index="200">
|
||||||
<view class="footer-box border-top ss-flex ss-row-between ss-p-x-20 ss-col-center">
|
<view class="footer-box border-top ss-flex ss-row-between ss-p-x-20 ss-col-center">
|
||||||
|
|
@ -151,18 +113,12 @@
|
||||||
<view class="total-num ss-font-30 text-red"> ¥{{ state.orderInfo.pay_fee }} </view>
|
<view class="total-num ss-font-30 text-red"> ¥{{ state.orderInfo.pay_fee }} </view>
|
||||||
<view v-if="state.orderPayload.order_type === 'score'" class="ss-flex">
|
<view v-if="state.orderPayload.order_type === 'score'" class="ss-flex">
|
||||||
<view class="total-num ss-font-30 text-red ss-m-l-4">+</view>
|
<view class="total-num ss-font-30 text-red ss-m-l-4">+</view>
|
||||||
<image
|
<image :src="sheep.$url.static('/static/img/shop/goods/score1.svg')" class="score-img"></image>
|
||||||
:src="sheep.$url.static('/static/img/shop/goods/score1.svg')"
|
|
||||||
class="score-img"
|
|
||||||
></image>
|
|
||||||
<view class="total-num ss-font-30 text-red">{{ state.orderInfo.score_amount }}</view>
|
<view class="total-num ss-font-30 text-red">{{ state.orderInfo.score_amount }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<button
|
<button class="ss-reset-button ui-BG-Main-Gradient ss-r-40 submit-btn ui-Shadow-Main" @tap="onConfirm">
|
||||||
class="ss-reset-button ui-BG-Main-Gradient ss-r-40 submit-btn ui-Shadow-Main"
|
|
||||||
@tap="onConfirm"
|
|
||||||
>
|
|
||||||
{{ exchangeNow ? '立即兑换' : '提交订单' }}
|
{{ exchangeNow ? '立即兑换' : '提交订单' }}
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -171,10 +127,19 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, computed } from 'vue';
|
import {
|
||||||
import { onLoad, onPageScroll, onShow } from '@dcloudio/uni-app';
|
reactive,
|
||||||
|
computed
|
||||||
|
} from 'vue';
|
||||||
|
import {
|
||||||
|
onLoad,
|
||||||
|
onPageScroll,
|
||||||
|
onShow
|
||||||
|
} from '@dcloudio/uni-app';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import { isEmpty } from 'lodash';
|
import {
|
||||||
|
isEmpty
|
||||||
|
} from 'lodash';
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
orderPayload: {},
|
orderPayload: {},
|
||||||
|
|
@ -203,8 +168,13 @@
|
||||||
// 更改收货人地址&计算订单信息
|
// 更改收货人地址&计算订单信息
|
||||||
async function changeConsignee(addressInfo = {}) {
|
async function changeConsignee(addressInfo = {}) {
|
||||||
if (isEmpty(addressInfo)) {
|
if (isEmpty(addressInfo)) {
|
||||||
const { error, data } = await sheep.$api.user.address.default();
|
const {
|
||||||
if (error === 0 && !isEmpty(data)) {
|
code,
|
||||||
|
data
|
||||||
|
} = await sheep.$api.user.address.default();
|
||||||
|
console.log(data, '默认收货地址');
|
||||||
|
if (code === 0 && !isEmpty(data)) {
|
||||||
|
console.log('执行赋值')
|
||||||
addressInfo = data;
|
addressInfo = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -243,7 +213,7 @@
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '确定使用积分立即兑换?',
|
content: '确定使用积分立即兑换?',
|
||||||
cancelText: '再想想',
|
cancelText: '再想想',
|
||||||
success: async function (res) {
|
success: async function(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
submitOrder();
|
submitOrder();
|
||||||
}
|
}
|
||||||
|
|
@ -256,7 +226,10 @@
|
||||||
|
|
||||||
// 创建订单&跳转
|
// 创建订单&跳转
|
||||||
async function submitOrder() {
|
async function submitOrder() {
|
||||||
const { error, data } = await sheep.$api.order.create(state.orderPayload);
|
const {
|
||||||
|
error,
|
||||||
|
data
|
||||||
|
} = await sheep.$api.order.create(state.orderPayload);
|
||||||
if (error === 0) {
|
if (error === 0) {
|
||||||
// 更新购物车列表
|
// 更新购物车列表
|
||||||
if (state.orderPayload.from === 'cart') {
|
if (state.orderPayload.from === 'cart') {
|
||||||
|
|
@ -276,7 +249,17 @@
|
||||||
|
|
||||||
// 检查库存&计算订单价格
|
// 检查库存&计算订单价格
|
||||||
async function getOrderInfo() {
|
async function getOrderInfo() {
|
||||||
let { error, data } = await sheep.$api.order.calc(state.orderPayload);
|
console.log(state.orderPayload, '计算价格传参')
|
||||||
|
// let {code, data} = await sheep.$api.order.calc(state.orderPayload);
|
||||||
|
// let data = await sheep.$api.order.calc(state.orderPayload);
|
||||||
|
console.log(state.orderPayload.items)
|
||||||
|
let data = await sheep.$api.order.calc({
|
||||||
|
deliveryType: 1,
|
||||||
|
pointStatus: false,
|
||||||
|
items: state.orderPayload.items
|
||||||
|
});
|
||||||
|
console.log(data, '修改后的获取订单详细数据')
|
||||||
|
return;
|
||||||
if (error === 0) {
|
if (error === 0) {
|
||||||
state.totalNumber = 0;
|
state.totalNumber = 0;
|
||||||
state.orderInfo = data;
|
state.orderInfo = data;
|
||||||
|
|
@ -288,13 +271,17 @@
|
||||||
|
|
||||||
// 获取可用优惠券
|
// 获取可用优惠券
|
||||||
async function getCoupons() {
|
async function getCoupons() {
|
||||||
const { error, data } = await sheep.$api.order.coupons(state.orderPayload);
|
const {
|
||||||
|
error,
|
||||||
|
data
|
||||||
|
} = await sheep.$api.order.coupons(state.orderPayload);
|
||||||
if (error === 0) {
|
if (error === 0) {
|
||||||
state.couponInfo = data;
|
state.couponInfo = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
|
console.log(options)
|
||||||
if (options.data) {
|
if (options.data) {
|
||||||
state.orderPayload = JSON.parse(options.data);
|
state.orderPayload = JSON.parse(options.data);
|
||||||
changeConsignee();
|
changeConsignee();
|
||||||
|
|
@ -325,17 +312,20 @@
|
||||||
margin-top: 4rpx;
|
margin-top: 4rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.uni-easyinput__content {
|
.uni-easyinput__content {
|
||||||
display: flex !important;
|
display: flex !important;
|
||||||
align-items: center !important;
|
align-items: center !important;
|
||||||
justify-content: right !important;
|
justify-content: right !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.score-img {
|
.score-img {
|
||||||
width: 36rpx;
|
width: 36rpx;
|
||||||
height: 36rpx;
|
height: 36rpx;
|
||||||
margin: 0 4rpx;
|
margin: 0 4rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.order-item {
|
.order-item {
|
||||||
height: 80rpx;
|
height: 80rpx;
|
||||||
|
|
||||||
|
|
@ -349,6 +339,7 @@
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-family: OPPOSANS;
|
font-family: OPPOSANS;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-disabled {
|
.text-disabled {
|
||||||
color: #bbbbbb;
|
color: #bbbbbb;
|
||||||
}
|
}
|
||||||
|
|
@ -399,19 +390,23 @@
|
||||||
color: $dark-9;
|
color: $dark-9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtitle {
|
.subtitle {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #999999;
|
color: #999999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cicon-checkbox {
|
.cicon-checkbox {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
color: var(--ui-BG-Main);
|
color: var(--ui-BG-Main);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cicon-box {
|
.cicon-box {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
color: #999999;
|
color: #999999;
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,42 @@
|
||||||
<template>
|
<template>
|
||||||
<s-layout title="收货地址" :bgStyle="{ color: '#FFF' }">
|
<s-layout title="收货地址" :bgStyle="{ color: '#FFF' }">
|
||||||
<view v-if="state.list.length">
|
<view v-if="state.list.length">
|
||||||
<s-address-item
|
<s-address-item hasBorderBottom v-for="item in state.list" :key="item.id" :item="item"
|
||||||
hasBorderBottom
|
@tap="onSelect(item)">
|
||||||
v-for="item in state.list"
|
|
||||||
:key="item.id"
|
|
||||||
:item="item"
|
|
||||||
@tap="onSelect(item)"
|
|
||||||
>
|
|
||||||
</s-address-item>
|
</s-address-item>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<su-fixed bottom placeholder>
|
<su-fixed bottom placeholder>
|
||||||
<view class="footer-box ss-flex ss-row-between ss-p-20">
|
<view class="footer-box ss-flex ss-row-between ss-p-20">
|
||||||
<!-- 微信小程序和微信H5 -->
|
<!-- 微信小程序和微信H5 -->
|
||||||
<button
|
<button v-if="['WechatMiniProgram', 'WechatOfficialAccount'].includes(sheep.$platform.name)"
|
||||||
v-if="['WechatMiniProgram', 'WechatOfficialAccount'].includes(sheep.$platform.name)"
|
|
||||||
@tap="importWechatAddress"
|
@tap="importWechatAddress"
|
||||||
class="border ss-reset-button sync-wxaddress ss-m-20 ss-flex ss-row-center ss-col-center"
|
class="border ss-reset-button sync-wxaddress ss-m-20 ss-flex ss-row-center ss-col-center">
|
||||||
>
|
|
||||||
<text class="cicon-weixin ss-p-r-10" style="color: #09bb07; font-size: 40rpx"></text>
|
<text class="cicon-weixin ss-p-r-10" style="color: #09bb07; font-size: 40rpx"></text>
|
||||||
导入微信地址
|
导入微信地址
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button class="add-btn ss-reset-button ui-Shadow-Main"
|
||||||
class="add-btn ss-reset-button ui-Shadow-Main"
|
@tap="sheep.$router.go('/pages/user/address/edit')">
|
||||||
@tap="sheep.$router.go('/pages/user/address/edit')"
|
|
||||||
>
|
|
||||||
新增收货地址
|
新增收货地址
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
</su-fixed>
|
</su-fixed>
|
||||||
<s-empty
|
<s-empty v-if="state.list.length === 0 && !state.loading" text="暂无收货地址" icon="/static/data-empty.png" />
|
||||||
v-if="state.list.length === 0 && !state.loading"
|
|
||||||
text="暂无收货地址"
|
|
||||||
icon="/static/data-empty.png"
|
|
||||||
/>
|
|
||||||
</s-layout>
|
</s-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, onBeforeMount } from 'vue';
|
import {
|
||||||
import { onShow } from '@dcloudio/uni-app';
|
reactive,
|
||||||
|
onBeforeMount
|
||||||
|
} from 'vue';
|
||||||
|
import {
|
||||||
|
onShow
|
||||||
|
} from '@dcloudio/uni-app';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import { isEmpty } from 'lodash';
|
import {
|
||||||
|
isEmpty
|
||||||
|
} from 'lodash';
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
list: [],
|
list: [],
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import request2 from '@/sheep/request2';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// 订单详情
|
// 订单详情
|
||||||
detail: (id,params) =>
|
detail: (id, params) =>
|
||||||
request({
|
request({
|
||||||
url: 'order/order/' + id,
|
url: 'order/order/' + id,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
|
@ -24,9 +24,9 @@ export default {
|
||||||
showLoading: false,
|
showLoading: false,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
itemDetail: (id,itemId) =>
|
itemDetail: (id, itemId) =>
|
||||||
request({
|
request({
|
||||||
url: 'order/order/itemDetail/'+ id + '/' + itemId,
|
url: 'order/order/itemDetail/' + id + '/' + itemId,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
custom: {
|
custom: {
|
||||||
showLoading: false,
|
showLoading: false,
|
||||||
|
|
@ -52,12 +52,34 @@ export default {
|
||||||
// },
|
// },
|
||||||
// }),
|
// }),
|
||||||
// 计算订单信息
|
// 计算订单信息
|
||||||
calc: (data) =>
|
calc: (data) => {
|
||||||
request({
|
const data2 = {
|
||||||
url: 'order/order/calc',
|
...data,
|
||||||
method: 'POST',
|
}
|
||||||
data,
|
// 解决 SpringMVC 接受 List<Item> 参数的问题
|
||||||
}),
|
delete data2.items
|
||||||
|
for (let i = 0; i < data.items.length; i++) {
|
||||||
|
data2['items[' + i + '' + '].skuId'] = data.items[i].skuId + '';
|
||||||
|
data2['items[' + i + '' + '].count'] = data.items[i].count + '';
|
||||||
|
data2['items[' + i + '' + '].cartId'] = data.items[i].cartId + '';
|
||||||
|
// data2['items' + `%5B${i}%5D` + '.skuId'] = data.items[i].skuId + '';
|
||||||
|
// data2['items' + `%5B${i}%5D` + '.count'] = data.items[i].count + '';
|
||||||
|
// data2['items' + `%5B${i}%5D` + '.cartId'] = data.items[i].cartId + '';
|
||||||
|
}
|
||||||
|
console.log(data2, '对比数据')
|
||||||
|
return request2({
|
||||||
|
url: 'trade/order/settlement',
|
||||||
|
method: 'GET',
|
||||||
|
// data,
|
||||||
|
params: data2
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// calc: (data) =>
|
||||||
|
// request({
|
||||||
|
// url: 'order/order/calc',
|
||||||
|
// method: 'POST',
|
||||||
|
// data,
|
||||||
|
// }),
|
||||||
// 创建订单
|
// 创建订单
|
||||||
create: (data) =>
|
create: (data) =>
|
||||||
request({
|
request({
|
||||||
|
|
|
||||||
|
|
@ -187,9 +187,17 @@ export default {
|
||||||
}),
|
}),
|
||||||
|
|
||||||
address: {
|
address: {
|
||||||
|
// default: () =>
|
||||||
|
// request({
|
||||||
|
// url: 'user/address/default',
|
||||||
|
// method: 'GET',
|
||||||
|
// custom: {
|
||||||
|
// showError: false,
|
||||||
|
// },
|
||||||
|
// }),
|
||||||
default: () =>
|
default: () =>
|
||||||
request({
|
request2({
|
||||||
url: 'user/address/default',
|
url: 'member/address/get-default',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
custom: {
|
custom: {
|
||||||
showError: false,
|
showError: false,
|
||||||
|
|
@ -225,7 +233,7 @@ export default {
|
||||||
// showSuccess: true,
|
// showSuccess: true,
|
||||||
// },
|
// },
|
||||||
// }),
|
// }),
|
||||||
update: ( data) =>
|
update: (data) =>
|
||||||
request2({
|
request2({
|
||||||
url: 'member/address/update',
|
url: 'member/address/update',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
|
|
@ -325,7 +333,7 @@ export default {
|
||||||
url: 'product/favorite/delete-list',
|
url: 'product/favorite/delete-list',
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
data: {
|
data: {
|
||||||
spuIds: id.split(',').map(item=>item*1),
|
spuIds: id.split(',').map(item => item * 1),
|
||||||
// spuIds: id.split(',').join(','),
|
// spuIds: id.split(',').join(','),
|
||||||
},
|
},
|
||||||
custom: {
|
custom: {
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,8 @@
|
||||||
<view class="ss-modal-box bg-white ss-flex-col">
|
<view class="ss-modal-box bg-white ss-flex-col">
|
||||||
<view class="modal-header ss-flex ss-col-center">
|
<view class="modal-header ss-flex ss-col-center">
|
||||||
<view class="header-left ss-m-r-30">
|
<view class="header-left ss-m-r-30">
|
||||||
<image
|
<image class="sku-image" :src="sheep.$url.cdn(state.selectedSkuPrice.image || goodsInfo.image)"
|
||||||
class="sku-image"
|
mode="aspectFill"></image>
|
||||||
:src="sheep.$url.cdn(state.selectedSkuPrice.image || goodsInfo.image)"
|
|
||||||
mode="aspectFill"
|
|
||||||
></image>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="header-right ss-flex-col ss-row-between ss-flex-1">
|
<view class="header-right ss-flex-col ss-row-between ss-flex-1">
|
||||||
<view class="goods-title ss-line-2">{{ goodsInfo.title }}</view>
|
<view class="goods-title ss-line-2">{{ goodsInfo.title }}</view>
|
||||||
|
|
@ -18,16 +15,10 @@
|
||||||
{{ goodsPrice.price }}
|
{{ goodsPrice.price }}
|
||||||
</view>
|
</view>
|
||||||
<view class="ss-flex">
|
<view class="ss-flex">
|
||||||
<view
|
<view v-if="goodsPrice.price > 0 && goodsPrice.score > 0" class="score-text ss-m-l-4">+
|
||||||
v-if="goodsPrice.price > 0 && goodsPrice.score > 0"
|
|
||||||
class="score-text ss-m-l-4"
|
|
||||||
>+
|
|
||||||
</view>
|
</view>
|
||||||
<image
|
<image v-if="goodsPrice.score > 0"
|
||||||
v-if="goodsPrice.score > 0"
|
:src="sheep.$url.static('/static/img/shop/goods/score1.svg')" class="score-img">
|
||||||
:src="sheep.$url.static('/static/img/shop/goods/score1.svg')"
|
|
||||||
class="score-img"
|
|
||||||
>
|
|
||||||
</image>
|
</image>
|
||||||
<view v-if="goodsPrice.score > 0" class="score-text">
|
<view v-if="goodsPrice.score > 0" class="score-text">
|
||||||
{{ goodsPrice.score }}
|
{{ goodsPrice.score }}
|
||||||
|
|
@ -50,48 +41,31 @@
|
||||||
<view class="sku-item ss-m-b-20" v-for="sku1 in goodsInfo.skus" :key="sku1.id">
|
<view class="sku-item ss-m-b-20" v-for="sku1 in goodsInfo.skus" :key="sku1.id">
|
||||||
<view class="label-text ss-m-b-20">{{ sku1.name }}</view>
|
<view class="label-text ss-m-b-20">{{ sku1.name }}</view>
|
||||||
<view class="ss-flex ss-col-center ss-flex-wrap">
|
<view class="ss-flex ss-col-center ss-flex-wrap">
|
||||||
<button
|
<button class="ss-reset-button spec-btn" v-for="sku2 in sku1.children" :class="[
|
||||||
class="ss-reset-button spec-btn"
|
|
||||||
v-for="sku2 in sku1.children"
|
|
||||||
:class="[
|
|
||||||
{
|
{
|
||||||
'ui-BG-Main-Gradient': state.currentSkuArray[sku2.parent_id] == sku2.id,
|
'ui-BG-Main-Gradient': state.currentSkuArray[sku2.parent_id] == sku2.id,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'disabled-btn': sku2.disabled == true,
|
'disabled-btn': sku2.disabled == true,
|
||||||
},
|
},
|
||||||
]"
|
]" :key="sku2.id" :disabled="sku2.disabled == true" @tap="onSelectSku(sku2.parent_id, sku2.id)">
|
||||||
:key="sku2.id"
|
|
||||||
:disabled="sku2.disabled == true"
|
|
||||||
@tap="onSelectSku(sku2.parent_id, sku2.id)"
|
|
||||||
>
|
|
||||||
{{ sku2.name }}
|
{{ sku2.name }}
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="buy-num-box ss-flex ss-col-center ss-row-between ss-m-b-40">
|
<view class="buy-num-box ss-flex ss-col-center ss-row-between ss-m-b-40">
|
||||||
<view class="label-text">购买数量</view>
|
<view class="label-text">购买数量</view>
|
||||||
<su-number-box
|
<su-number-box :min="1" :max="state.selectedSkuPrice.stock" :step="1"
|
||||||
:min="1"
|
v-model="state.selectedSkuPrice.goods_num" @change="onNumberChange($event)"></su-number-box>
|
||||||
:max="state.selectedSkuPrice.stock"
|
|
||||||
:step="1"
|
|
||||||
v-model="state.selectedSkuPrice.goods_num"
|
|
||||||
@change="onNumberChange($event)"
|
|
||||||
></su-number-box>
|
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
<view class="modal-footer border-top">
|
<view class="modal-footer border-top">
|
||||||
<view
|
<view class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center" v-if="isScore">
|
||||||
class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center"
|
|
||||||
v-if="isScore"
|
|
||||||
>
|
|
||||||
<button class="ss-reset-button score-btn ui-Shadow-Main" @tap="onBuy">立即兑换</button>
|
<button class="ss-reset-button score-btn ui-Shadow-Main" @tap="onBuy">立即兑换</button>
|
||||||
</view>
|
</view>
|
||||||
<view class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center" v-else>
|
<view class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center" v-else>
|
||||||
<button class="ss-reset-button add-btn ui-Shadow-Main" @tap="onAddCart"
|
<button class="ss-reset-button add-btn ui-Shadow-Main" @tap="onAddCart">加入购物车</button>
|
||||||
>加入购物车</button
|
|
||||||
>
|
|
||||||
<button class="ss-reset-button buy-btn ui-Shadow-Main" @tap="onBuy">立即购买</button>
|
<button class="ss-reset-button buy-btn ui-Shadow-Main" @tap="onBuy">立即购买</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -100,16 +74,25 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, reactive, watch } from 'vue';
|
import {
|
||||||
|
computed,
|
||||||
|
reactive,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import { formatStock, formatPrice } from '@/sheep/hooks/useGoods';
|
import {
|
||||||
import { isEmpty } from 'lodash';
|
formatStock,
|
||||||
|
formatPrice
|
||||||
|
} from '@/sheep/hooks/useGoods';
|
||||||
|
import {
|
||||||
|
isEmpty
|
||||||
|
} from 'lodash';
|
||||||
|
|
||||||
const emits = defineEmits(['change', 'addCart', 'buy', 'close']);
|
const emits = defineEmits(['change', 'addCart', 'buy', 'close']);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
goodsInfo: {
|
goodsInfo: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default() {},
|
default () {},
|
||||||
},
|
},
|
||||||
show: {
|
show: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|
@ -153,8 +136,7 @@
|
||||||
() => state.selectedSkuPrice,
|
() => state.selectedSkuPrice,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
emits('change', newVal);
|
emits('change', newVal);
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
immediate: true, // 立即执行
|
immediate: true, // 立即执行
|
||||||
deep: true, // 深度监听
|
deep: true, // 深度监听
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Request from 'luch-request';
|
import Request from 'luch-request';
|
||||||
import { baseUrl, apiPath } from '@/sheep/config';
|
import {
|
||||||
|
baseUrl,
|
||||||
|
apiPath
|
||||||
|
} from '@/sheep/config';
|
||||||
import $store from '@/sheep/store';
|
import $store from '@/sheep/store';
|
||||||
import $platform from '@/sheep/platform';
|
import $platform from '@/sheep/platform';
|
||||||
import { showAuthModal } from '@/sheep/hooks/useModal';
|
import {
|
||||||
|
showAuthModal
|
||||||
|
} from '@/sheep/hooks/useModal';
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
// 显示操作成功消息 默认不显示
|
// 显示操作成功消息 默认不显示
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,8 @@ const http = new Request({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
header: {
|
header: {
|
||||||
Accept: 'text/json',
|
Accept: 'text/json',
|
||||||
'Content-Type': 'application/json;charset=UTF-8',
|
'Content-Type': 'application/json',
|
||||||
|
// ;charset=UTF-8
|
||||||
platform: $platform.name,
|
platform: $platform.name,
|
||||||
},
|
},
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue