s-coupon-get.vue,detail-tabbar.vue,详情加入购物车,其他模块优化

pull/26/head
落日晚风 2023-12-11 17:42:50 +08:00
parent c5b1f3ac93
commit ef26268c8e
17 changed files with 1836 additions and 1767 deletions

View File

@ -148,11 +148,20 @@
}); });
if (res.code === 0) { if (res.code === 0) {
// //
let obj2 = {
2: '折扣',
1: '满减'
}
let obj = { let obj = {
1: '可用', 1: '可用',
2: '已用', 2: '已用',
3: '过期' 3: '过期'
} }
let obj3 = {
1: '已领取',
2: '已使用',
3: '已过期'
}
res.data.list = res.data.list.map(item => { res.data.list = res.data.list.map(item => {
return { return {
...item, ...item,
@ -160,7 +169,8 @@
amount: (item.discountPrice / 100).toFixed(2), amount: (item.discountPrice / 100).toFixed(2),
use_start_time: sheep.$helper.timeFormat(item.validStartTime, 'yyyy-mm-dd hh:MM:ss'), use_start_time: sheep.$helper.timeFormat(item.validStartTime, 'yyyy-mm-dd hh:MM:ss'),
use_end_time: sheep.$helper.timeFormat(item.validEndTime, 'yyyy-mm-dd hh:MM:ss'), use_end_time: sheep.$helper.timeFormat(item.validEndTime, 'yyyy-mm-dd hh:MM:ss'),
status_text: obj[item.status] status_text: obj[item.status],
type_text: obj2[item.discountType]
} }
}); });
if (page >= 2) { if (page >= 2) {

View File

@ -1,171 +1,165 @@
<template> <template>
<su-fixed bottom placeholder bg="bg-white"> <su-fixed bottom placeholder bg="bg-white">
<view class="ui-tabbar-box"> <view class="ui-tabbar-box">
<view class="ui-tabbar ss-flex ss-col-center ss-row-between"> <view class="ui-tabbar ss-flex ss-col-center ss-row-between">
<view <view v-if="collectIcon" class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center"
v-if="collectIcon" @tap="onFavorite">
class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center" <block v-if="modelValue.favorite">
@tap="onFavorite" <image class="item-icon" :src="sheep.$url.static('/static/img/shop/goods/collect_1.gif')"
> mode="aspectFit"></image>
<block v-if="modelValue.favorite"> <view class="item-title">已收藏</view>
<image </block>
class="item-icon" <block v-else>
:src="sheep.$url.static('/static/img/shop/goods/collect_1.gif')" <image class="item-icon" :src="sheep.$url.static('/static/img/shop/goods/collect_0.png')"
mode="aspectFit" mode="aspectFit"></image>
></image> <view class="item-title">收藏</view>
<view class="item-title">已收藏</view> </block>
</block> </view>
<block v-else> <view v-if="serviceIcon" class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center"
<image @tap="onChat">
class="item-icon" <image class="item-icon" :src="sheep.$url.static('/static/img/shop/goods/message.png')"
:src="sheep.$url.static('/static/img/shop/goods/collect_0.png')" mode="aspectFit"></image>
mode="aspectFit" <view class="item-title">客服</view>
></image> </view>
<view class="item-title">收藏</view> <view v-if="shareIcon" class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center"
</block> @tap="showShareModal">
</view> <image class="item-icon" :src="sheep.$url.static('/static/img/shop/goods/share.png')"
<view mode="aspectFit"></image>
v-if="serviceIcon" <view class="item-title">分享</view>
class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center" </view>
@tap="onChat" <slot></slot>
> </view>
<image </view>
class="item-icon" </su-fixed>
:src="sheep.$url.static('/static/img/shop/goods/message.png')"
mode="aspectFit"
></image>
<view class="item-title">客服</view>
</view>
<view
v-if="shareIcon"
class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center"
@tap="showShareModal"
>
<image
class="item-icon"
:src="sheep.$url.static('/static/img/shop/goods/share.png')"
mode="aspectFit"
></image>
<view class="item-title">分享</view>
</view>
<slot></slot>
</view>
</view>
</su-fixed>
</template> </template>
<script setup> <script setup>
/** /**
* *
* 底部导航 * 底部导航
* *
* @property {String} bg - 背景颜色Class * @property {String} bg - 背景颜色Class
* @property {String} ui - 自定义样式Class * @property {String} ui - 自定义样式Class
* @property {Boolean} noFixed - 是否定位 * @property {Boolean} noFixed - 是否定位
* @property {Boolean} topRadius - 上圆角 * @property {Boolean} topRadius - 上圆角
* *
* *
*/ */
import { computed, reactive } from 'vue'; import {
import sheep from '@/sheep'; computed,
import { showShareModal } from '@/sheep/hooks/useModal'; reactive
} from 'vue';
import sheep from '@/sheep';
import {
showShareModal
} from '@/sheep/hooks/useModal';
// //
const state = reactive({}); const state = reactive({});
// //
const props = defineProps({ const props = defineProps({
modelValue: { modelValue: {
type: Object, type: Object,
default() {}, default () {},
}, },
bg: { bg: {
type: String, type: String,
default: 'bg-white', default: 'bg-white',
}, },
bgStyles: { bgStyles: {
type: Object, type: Object,
default() {}, default () {},
}, },
ui: { ui: {
type: String, type: String,
default: '', default: '',
}, },
noFixed: { noFixed: {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
topRadius: { topRadius: {
type: Number, type: Number,
default: 0, default: 0,
}, },
collectIcon: { collectIcon: {
type: Boolean, type: Boolean,
default: true, default: true,
}, },
serviceIcon: { serviceIcon: {
type: Boolean, type: Boolean,
default: true, default: true,
}, },
shareIcon: { shareIcon: {
type: Boolean, type: Boolean,
default: true, default: true,
}, },
}); });
const elStyles = computed(() => { const elStyles = computed(() => {
return { return {
'border-top-left-radius': props.topRadius + 'rpx', 'border-top-left-radius': props.topRadius + 'rpx',
'border-top-right-radius': props.topRadius + 'rpx', 'border-top-right-radius': props.topRadius + 'rpx',
overflow: 'hidden', overflow: 'hidden',
}; };
}); });
const tabbarheight = (e) => { const tabbarheight = (e) => {
uni.setStorageSync('tabbar', e); uni.setStorageSync('tabbar', e);
}; };
async function onFavorite() { async function onFavorite() {
const { error } = await sheep.$api.user.favorite.do(props.modelValue.id); // const { error } = await sheep.$api.user.favorite.do(props.modelValue.id);
if (error === 0) { // if (error === 0) {
if (props.modelValue.favorite) { // if (props.modelValue.favorite) {
props.modelValue.favorite = 0; // props.modelValue.favorite = 0;
} else { // } else {
props.modelValue.favorite = 1; // props.modelValue.favorite = 1;
} // }
} // }
} let data;
if (props.modelValue.favorite) {
data = await sheep.$api.user.favorite.dos(props.modelValue.id);
} else {
data = await sheep.$api.user.favorite.do(props.modelValue.id);
}
if (data.data) {
props.modelValue.favorite = !props.modelValue.favorite;
}
}
const onChat = () => { const onChat = () => {
sheep.$router.go('/pages/chat/index', { sheep.$router.go('/pages/chat/index', {
id: props.modelValue.id, id: props.modelValue.id,
}); });
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.ui-tabbar-box { .ui-tabbar-box {
box-shadow: 0px -6px 10px 0px rgba(51, 51, 51, 0.2); box-shadow: 0px -6px 10px 0px rgba(51, 51, 51, 0.2);
} }
.ui-tabbar {
display: flex;
height: 50px;
background: #fff;
.detail-tabbar-item { .ui-tabbar {
width: 100rpx; display: flex;
height: 50px;
background: #fff;
.item-icon { .detail-tabbar-item {
width: 40rpx; width: 100rpx;
height: 40rpx;
}
.item-title { .item-icon {
font-size: 20rpx; width: 40rpx;
font-weight: 500; height: 40rpx;
line-height: 20rpx; }
margin-top: 12rpx;
} .item-title {
} font-size: 20rpx;
} font-weight: 500;
</style> line-height: 20rpx;
margin-top: 12rpx;
}
}
}
</style>

View File

@ -13,7 +13,7 @@
<view class="detail-swiper-selector"> <view class="detail-swiper-selector">
<!-- 商品轮播图 --> <!-- 商品轮播图 -->
<su-swiper class="ss-m-b-14" isPreview :list="formatGoodsSwiper(state.goodsInfo.sliderPicUrls)" <su-swiper class="ss-m-b-14" isPreview :list="formatGoodsSwiper(state.goodsInfo.sliderPicUrls)"
dotStyle="tag" imageMode="widthFix" dotCur="bg-mask-40" :seizeHeight="750" /> 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">
@ -31,16 +31,17 @@
</view> </view>
</view> </view>
<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">
<!-- 满减送/限时折扣活动的提示 TODO 芋艿promos 未写 --> <!-- 满减送/限时折扣活动的提示 TODO 芋艿promos 未写 -->
<div class="tag-content"> <div class="tag-content">
<view class="tag-box ss-flex"> <view class="tag-box ss-flex">
<view class="tag ss-m-r-10" v-for="promos in state.goodsInfo.promos" :key="promos.id" @tap="onActivity"> <view class="tag ss-m-r-10" v-for="promos in state.goodsInfo.promos"
:key="promos.id" @tap="onActivity">
{{ promos.title }} {{ promos.title }}
</view> </view>
</view> </view>
</div> </div>
<!-- 优惠劵 --> <!-- 优惠劵 -->
<view class="get-coupon-box ss-flex ss-col-center ss-m-l-20" @tap="state.showModel = true" <view class="get-coupon-box ss-flex ss-col-center ss-m-l-20" @tap="state.showModel = true"
v-if="state.couponInfo.length"> v-if="state.couponInfo.length">
<view class="discounts-title ss-m-r-8">领券</view> <view class="discounts-title ss-m-r-8">领券</view>
@ -54,15 +55,15 @@
<!-- 功能卡片 --> <!-- 功能卡片 -->
<view class="detail-cell-card detail-card ss-flex-col"> <view class="detail-cell-card detail-card ss-flex-col">
<detail-cell-sku v-model="state.selectedSku.goods_sku_text" :sku="state.selectedSku" <detail-cell-sku v-model="state.selectedSku.goods_sku_text" :sku="state.selectedSku"
@tap="state.showSelectSku = true" /> @tap="state.showSelectSku = true" />
<!-- TODO 芋艿可能暂时不考虑使用 --> <!-- TODO 芋艿可能暂时不考虑使用 -->
<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 :goodsInfo="state.goodsInfo" :show="state.showSelectSku" @addCart="onAddCart" <s-select-sku :goodsInfo="state.goodsInfo" :show="state.showSelectSku" @addCart="onAddCart"
@buy="onBuy" @change="onSkuChange" @close="state.showSelectSku = false" /> @buy="onBuy" @change="onSkuChange" @close="state.showSelectSku = false" />
</view> </view>
<!-- 评价 --> <!-- 评价 -->
@ -88,25 +89,35 @@
</view> </view>
</detail-tabbar> </detail-tabbar>
<!-- 优惠劵弹窗 --> <!-- 优惠劵弹窗 -->
<s-coupon-get v-model="state.couponInfo" :show="state.showModel" @close="state.showModel = false" <s-coupon-get v-model="state.couponInfo" :show="state.showModel" @close="state.showModel = false"
@get="onGet" /> @get="onGet" />
<!-- 满减送/限时折扣活动弹窗 --> <!-- 满减送/限时折扣活动弹窗 -->
<s-activity-pop v-model="state.activityInfo" :show="state.showActivityModel" <s-activity-pop v-model="state.activityInfo" :show="state.showActivityModel"
@close="state.showActivityModel = false" /> @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 CouponApi from '@/sheep/api/promotion/coupon'; import CouponApi from '@/sheep/api/promotion/coupon';
import ActivityApi from '@/sheep/api/promotion/activity'; import ActivityApi from '@/sheep/api/promotion/activity';
import { formatSales, formatGoodsSwiper, fen2yuan, } from '@/sheep/hooks/useGoods'; import {
formatSales,
formatGoodsSwiper,
fen2yuan,
} 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';
@ -116,7 +127,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';
onPageScroll(() => {}); onPageScroll(() => {});
@ -130,7 +143,7 @@
couponInfo: [], // Coupon couponInfo: [], // Coupon
showActivityModel: false, // / Activity showActivityModel: false, // / Activity
activityInfo: [], // / Activity activityInfo: [], // / Activity
activityList: [], // // Activity activityList: [], // // Activity
}); });
// //
@ -140,6 +153,7 @@
// TODO // TODO
function onAddCart(e) { function onAddCart(e) {
console.log(e, '加入购物车');
sheep.$store('cart').add(e); sheep.$store('cart').add(e);
} }
@ -166,10 +180,10 @@
// TODO // TODO
async function onGet(id) { async function onGet(id) {
const { const {
error, code,
msg msg
} = await sheep.$api.coupon.get(id); } = await sheep.$api.coupon.get(id);
if (error === 0) { if (code === 0) {
uni.showToast({ uni.showToast({
title: msg, title: msg,
}); });
@ -179,7 +193,7 @@
} }
} }
// TODO // TODO
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({
@ -207,32 +221,75 @@
} }
state.goodsId = options.id; state.goodsId = options.id;
// 1. // 1.
sheep.$api.goods.detail(state.goodsId).then((res) => { sheep.$api.goods.detail(state.goodsId).then(async (res) => {
// //
if (res.code !== 0 || !res.data) { if (res.code !== 0 || !res.data) {
state.goodsInfo = null; state.goodsInfo = null;
return; return;
} }
// //
state.skeletonLoading = false; state.skeletonLoading = false;
state.goodsInfo = res.data; //
let dasa = await sheep.$api.goods.exits(options.id);
res.data.favorite = dasa.data;
state.goodsInfo = res.data;
console.log(state.goodsInfo, '商品信息');
//
// 2.
CouponApi.getCouponTemplateList({
price: state.goodsInfo.price,
spuIds: [state.goodsInfo.id],
skuIds: state.goodsInfo.skus.map(item => item.id),
//
categoryIds: [52]
}).then((res) => {
console.log(res, '优惠券信息进行对接')
if (res.code !== 0) {
return;
}
//
let obj2 = {
2: '折扣',
1: '满减'
}
let obj = {
1: '可用',
2: '已用',
3: '过期'
}
let obj3 = {
1: '已领取',
2: '已使用',
3: '已过期'
}
res.data = res.data.map(item => {
return {
...item,
enough: (item.usePrice / 100).toFixed(2),
amount: (item.discountPrice / 100).toFixed(2),
use_start_time: sheep.$helper.timeFormat(item
.validStartTime,
'yyyy-mm-dd hh:MM:ss'),
use_end_time: sheep.$helper.timeFormat(item.validEndTime,
'yyyy-mm-dd hh:MM:ss'),
status_text: obj[item.status],
type_text: obj2[item.discountType],
get_status_text: obj3[item.status],
type_text: obj2[item.discountType]
}
});
state.couponInfo = res.data;
});
});
// return;
// 3.
ActivityApi.getActivityListBySpuId(state.goodsId).then((res) => {
if (res.code !== 0) {
return;
}
state.activityList = res.data;
}); });
// 2.
CouponApi.getCouponTemplateList(state.goodsId,2, 10).then((res) => {
if (res.code !== 0) {
return;
}
state.couponInfo = res.data;
});
// 3.
ActivityApi.getActivityListBySpuId(state.goodsId).then((res) => {
if (res.code !== 0) {
return;
}
state.activityList = res.data;
});
}); });
</script> </script>

View File

@ -281,7 +281,7 @@
} }
onLoad(async (options) => { onLoad(async (options) => {
console.log(options) console.log(options, '确认订单启动参数')
if (options.data) { if (options.data) {
state.orderPayload = JSON.parse(options.data); state.orderPayload = JSON.parse(options.data);
changeConsignee(); changeConsignee();

View File

@ -12,8 +12,8 @@ export default {
}, },
}), }),
append: (data) => append: (data) =>
request({ request2({
url: 'cart', url: '/app-api/trade/cart/add',
method: 'POST', method: 'POST',
custom: { custom: {
showSuccess: true, showSuccess: true,
@ -21,9 +21,22 @@ export default {
}, },
data: { data: {
...data, ...data,
type: 'inc', // type: 'inc',
}, },
}), }),
// append: (data) =>
// request({
// url: 'cart',
// method: 'POST',
// custom: {
// showSuccess: true,
// successMsg: '已添加到购物车~',
// },
// data: {
// ...data,
// type: 'inc',
// },
// }),
// 删除购物车 // 删除购物车
delete: (ids) => delete: (ids) =>
request2({ request2({

View File

@ -33,10 +33,21 @@ export default {
}, },
}), }),
get: (id) => get: (id) =>
request({ request2({
url: 'coupon/get/' + id, url: 'promotion/coupon/take',
method: 'POST', method: 'POST',
data: {
templateId: id
},
params: {
templateId: id
},
}), }),
// get: (id) =>
// request({
// url: 'coupon/get/' + id,
// method: 'POST',
// }),
listByGoods: (id) => listByGoods: (id) =>
request({ request({
url: 'coupon/listByGoods/' + id, url: 'coupon/listByGoods/' + id,

View File

@ -2,79 +2,85 @@ import request from '@/sheep/request';
import request2 from '@/sheep/request2'; import request2 from '@/sheep/request2';
export default { export default {
// 商品详情 // 商品详情
detail: (id, params = {}) => detail: (id, params = {}) =>
request2({ request({
url: 'product/spu/get-detail?id=' + id, url: '/app-api/product/spu/get-detail?id=' + id,
method: 'GET', method: 'GET',
params, params,
custom: { custom: {
showLoading: false, showLoading: false,
showError: false, showError: false,
}, },
}), }),
// 商品列表 // 商品列表
list: (params) => list: (params) =>
request2({ request({
url: 'product/spu/page', url: '/app-api/product/spu/page',
method: 'GET', method: 'GET',
params, params,
custom: { custom: {
showLoading: false, showLoading: false,
showError: false, showError: false,
}, },
}), }),
// 商品查询 // 商品查询
ids: (params = {}) => ids: (params = {}) =>
request({ request({
url: 'goods/goods/ids', url: 'goods/goods/ids',
method: 'GET', method: 'GET',
params, params,
custom: { custom: {
showLoading: false, showLoading: false,
showError: false, showError: false,
}, },
}), }),
// 商品评价列表 // 商品评价列表
comment: (id, params = {}) => comment: (id, params = {}) =>
request2({ request({
url: 'product/comment/list?spuId=' + id, url: '/app-api/product/comment/list?spuId=' + id,
method: 'GET', method: 'GET',
params, params,
custom: { custom: {
showLoading: false, showLoading: false,
showError: false, showError: false,
}, },
}), }),
// 商品评价类型 // 商品评价类型
getType: (id) => getType: (id) =>
request({ request({
url: 'goods/comment/getType/' + id, url: 'goods/comment/getType/' + id,
method: 'GET', method: 'GET',
custom: { custom: {
showLoading: false, showLoading: false,
showError: false, showError: false,
}, },
}), }),
// 活动商品查询 // 活动商品查询
// 商品查询 // 商品查询
activity: (params = {}) => activity: (params = {}) =>
request({ request({
url: 'goods/goods/activity', url: 'goods/goods/activity',
method: 'GET', method: 'GET',
params, params,
custom: { custom: {
showLoading: false, showLoading: false,
showError: false, showError: false,
}, },
}), }),
activityList: (params = {}) => activityList: (params = {}) =>
request({ request({
url: 'goods/goods/activityList', url: 'goods/goods/activityList',
method: 'GET', method: 'GET',
params, params,
}), }),
}; // 检查是否收藏商品
exits: (id) =>
request({
url: '/app-api/product/favorite/exits?spuId=' + id,
method: 'GET',
}),
};

View File

@ -65,18 +65,24 @@ export default {
// 解决 SpringMVC 接受 List<Item> 参数的问题 // 解决 SpringMVC 接受 List<Item> 参数的问题
delete data2.items delete data2.items
for (let i = 0; i < data.items.length; i++) { 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[encodeURIComponent('items[' + i + '' + '].skuId')] = data.items[i].skuId + '';
// data2['items[' + i + '' + '].cartId'] = data.items[i].cartId + ''; // data2[encodeURIComponent('items[' + i + '' + '].count')] = data.items[i].count + '';
data2['items' + `%5B${i}%5D` + '.skuId'] = data.items[i].skuId + ''; // data2[encodeURIComponent('items[' + i + '' + '].cartId')] = data.items[i].cartId + '';
data2['items' + `%5B${i}%5D` + '.count'] = data.items[i].count + '';
data2['items' + `%5B${i}%5D` + '.cartId'] = data.items[i].cartId + ''; // 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, '对比数据') console.log(data2, '手动转码的参数')
return request2({ return request2({
url: 'trade/order/settlement', url: 'trade/order/settlement',
method: 'GET', method: 'GET',
// data, // data: data2,
params: data2 params: data2
}) })
}, },

View File

@ -1,18 +1,18 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
const CommentApi = { const CommentApi = {
// 获得商品评价分页 // 获得商品评价分页
getCommentPage: (spuId, pageNo, pageSize, type) => { getCommentPage: (spuId, pageNo, pageSize, type) => {
return request({ return request({
url: '/app-api/product/comment/page', url: '/app-api/product/comment/page',
method: 'GET', method: 'GET',
params: { params: {
spuId, spuId,
pageNo, pageNo,
pageSize, pageSize,
type type
}, },
}); });
}, },
}; };
export default CommentApi; export default CommentApi;

View File

@ -1,20 +1,30 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default { export default {
// 获得优惠劵模板列表 // 获得优惠劵模板列表
getCouponTemplateListByIds: (ids) => { getCouponTemplateListByIds: (ids) => {
return request({ return request({
url: '/app-api/promotion/coupon-template/list-by-ids', url: '/app-api/promotion/coupon-template/list-by-ids',
method: 'GET', method: 'GET',
params: { ids }, params: {
}); ids
}, },
// 获得优惠劵模版列表 });
getCouponTemplateList: (spuId, productScope, count) => { },
return request({ // 获得优惠劵模版列表
url: '/app-api/promotion/coupon-template/list', getCouponTemplateList: (params) => {
method: 'GET', return request2({
params: { spuId, productScope, count }, url: `promotion/coupon/match-list?price=${params.price}&spuIds=${params.spuIds}&skuIds=${params.skuIds}&categoryIds=${params.categoryIds}`,
}); method: 'GET',
}, // params,
}; });
},
// getCouponTemplateList: (spuId, productScope, count) => {
// return request({
// url: '/app-api/promotion/coupon-template/list',
// method: 'GET',
// params: { spuId, productScope, count },
// });
// },
};

View File

@ -1,11 +1,10 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
import request2 from '@/sheep/request2';
import $platform from '@/sheep/platform'; import $platform from '@/sheep/platform';
export default { export default {
getUnused: () => getUnused: () =>
request2({ request({
url: 'promotion/coupon/get-unused-count', url: '/app-api/promotion/coupon/get-unused-count',
method: 'GET', method: 'GET',
custom: { custom: {
showLoading: false, showLoading: false,
@ -13,8 +12,8 @@ export default {
}, },
}), }),
profile: () => profile: () =>
request2({ request({
url: 'member/user/get', url: '/app-api/member/user/get',
method: 'GET', method: 'GET',
custom: { custom: {
showLoading: false, showLoading: false,
@ -22,7 +21,7 @@ export default {
}, },
}), }),
balance: () => balance: () =>
request2({ request({
url: '/app-api/pay/wallet/get', url: '/app-api/pay/wallet/get',
method: 'GET', method: 'GET',
custom: { custom: {
@ -30,28 +29,9 @@ export default {
auth: true, auth: true,
}, },
}), }),
// profile: () =>
// request({
// url: '/user/api/user/profile',
// method: 'GET',
// custom: {
// showLoading: false,
// auth: true,
// },
// }),
// update: (data) =>
// request({
// url: '/user/api/user/update',
// method: 'POST',
// custom: {
// showSuccess: true,
// auth: true,
// },
// data,
// }),
update: (data) => update: (data) =>
request2({ request({
url: 'member/user/update', url: '/app-api/member/user/update',
method: 'PUT', method: 'PUT',
custom: { custom: {
showSuccess: true, showSuccess: true,
@ -196,90 +176,48 @@ export default {
}), }),
address: { address: {
// default: () =>
// request({
// url: 'user/address/default',
// method: 'GET',
// custom: {
// showError: false,
// },
// }),
default: () => default: () =>
request2({ request({
url: 'member/address/get-default', url: '/app-api/member/address/get-default',
method: 'GET', method: 'GET',
custom: { custom: {
showError: false, showError: false,
}, },
}), }),
list: () => list: () =>
request2({ request({
url: 'member/address/list', url: '/app-api/member/address/list',
method: 'GET', method: 'GET',
custom: {}, custom: {},
}), }),
// list: () =>
// request({
// url: 'user/address',
// method: 'GET',
// custom: {},
// }),
create: (data) => create: (data) =>
request2({ request({
url: 'member/address/create', url: '/app-api/member/address/create',
method: 'POST', method: 'POST',
data, data,
custom: { custom: {
showSuccess: true, showSuccess: true,
}, },
}), }),
// create: (data) =>
// request({
// url: 'user/address',
// method: 'POST',
// data,
// custom: {
// showSuccess: true,
// },
// }),
update: (data) => update: (data) =>
request2({ request({
url: 'member/address/update', url: '/app-api/member/address/update',
method: 'PUT', method: 'PUT',
data, data,
custom: { custom: {
showSuccess: true, showSuccess: true,
}, },
}), }),
// update: (id, data) =>
// request({
// url: 'user/address/' + id,
// method: 'PUT',
// data,
// custom: {
// showSuccess: true,
// },
// }),
detail: (id) => detail: (id) =>
request2({ request({
url: 'member/address/get?id=' + id, url: '/app-api/member/address/get?id=' + id,
method: 'GET', method: 'GET',
}), }),
// detail: (id) =>
// request({
// url: 'user/address/' + id,
// method: 'GET',
// }),
delete: (id) => delete: (id) =>
request2({ request({
url: 'member/address/delete?id=' + id, url: '/app-api/member/address/delete?id=' + id,
method: 'DELETE', method: 'DELETE',
}), }),
// delete: (id) =>
// request({
// url: 'user/address/' + id,
// method: 'DELETE',
// }),
}, },
invoice: { invoice: {
list: () => list: () =>
@ -319,17 +257,29 @@ export default {
}, },
favorite: { favorite: {
list: (params) => list: (params) =>
request2({ request({
url: 'product/favorite/page', url: '/app-api/product/favorite/page',
method: 'GET', method: 'GET',
params, params,
}), }),
do: (id) => do: (id) =>
request({ request({
url: 'user/goodsLog/favorite', url: '/app-api/product/favorite/create',
method: 'POST', method: 'POST',
data: { data: {
goods_id: id, spuId: id,
},
custom: {
showSuccess: true,
auth: true,
},
}),
dos: (id) =>
request({
url: '/app-api/product/favorite/delete',
method: 'DELETE',
data: {
spuId: id,
}, },
custom: { custom: {
showSuccess: true, showSuccess: true,
@ -338,8 +288,8 @@ export default {
}), }),
// 取消收藏 // 取消收藏
cancel: (id) => cancel: (id) =>
request2({ request({
url: 'product/favorite/delete-list', url: '/app-api/product/favorite/delete-list',
method: 'DELETE', method: 'DELETE',
data: { data: {
spuIds: id.split(',').map(item => item * 1), spuIds: id.split(',').map(item => item * 1),
@ -350,18 +300,6 @@ export default {
auth: true, auth: true,
}, },
}), }),
// cancel: (id) =>
// request({
// url: 'user/goodsLog/favorite',
// method: 'POST',
// data: {
// goods_ids: id,
// },
// custom: {
// showSuccess: true,
// auth: true,
// },
// }),
}, },
view: { view: {
list: (params) => list: (params) =>
@ -383,28 +321,21 @@ export default {
}, },
wallet: { wallet: {
log: (params) => log: (params) =>
request2({ request({
// url: 'member/point/record/page', // url: 'member/point/record/page',
url: 'pay/wallet-transaction/page', url: '/app-api/pay/wallet-transaction/page',
method: 'GET', method: 'GET',
params, params,
custom: {}, custom: {},
}), }),
log2: (params) => log2: (params) =>
request2({ request({
url: 'member/point/record/page', url: '/app-api/member/point/record/page',
// url: 'pay/wallet-transaction/page', // url: 'pay/wallet-transaction/page',
method: 'GET', method: 'GET',
params, params,
custom: {}, custom: {},
}), }),
// log: (params) =>
// request({
// url: '/user/api/walletLog',
// method: 'GET',
// params,
// custom: {},
// }),
}, },
account: { account: {
info: (params) => info: (params) =>
@ -429,18 +360,9 @@ export default {
}), }),
}, },
//数量接口 //数量接口
// data: () =>
// request({
// url: 'user/user/data',
// method: 'GET',
// custom: {
// showLoading: false,
// auth: true,
// },
// }),
data: () => data: () =>
request2({ request({
url: 'trade/order/get-count', url: '/app-api/trade/order/get-count',
method: 'GET', method: 'GET',
custom: { custom: {
showLoading: false, showLoading: false,
@ -448,8 +370,8 @@ export default {
}, },
}), }),
data2: () => data2: () =>
request2({ request({
url: 'trade/after-sale/get-applying-count', url: '/app-api/trade/after-sale/get-applying-count',
method: 'GET', method: 'GET',
custom: { custom: {
showLoading: false, showLoading: false,

View File

@ -1,108 +1,104 @@
<template> <template>
<su-popup <su-popup :show="show" type="bottom" round="20" @close="emits('close')" showClose backgroundColor="#f2f2f2">
:show="show" <view class="model-box">
type="bottom" <view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠券</view>
round="20" <scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true">
@close="emits('close')" <view class="subtitle ss-m-l-20">可使用优惠券</view>
showClose <view v-for="item in state.couponInfo" :key="item.id">
backgroundColor="#f2f2f2" <s-coupon-list :data="item">
> <template #default>
<view class="model-box"> <button class="ss-reset-button card-btn ss-flex ss-row-center ss-col-center" :class="
<view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠券</view>
<scroll-view
class="model-content"
scroll-y
:scroll-with-animation="false"
:enable-back-to-top="true"
>
<view class="subtitle ss-m-l-20">可使用优惠券</view>
<view v-for="item in state.couponInfo" :key="item.id">
<s-coupon-list :data="item">
<template #default>
<button
class="ss-reset-button card-btn ss-flex ss-row-center ss-col-center"
:class="
item.get_status != 'can_get' && item.get_status != 'can_use' ? 'boder-btn' : '' item.get_status != 'can_get' && item.get_status != 'can_use' ? 'boder-btn' : ''
" " @click.stop="getBuy(item.id)">
@click.stop="getBuy(item.id)" <!-- 此处对接领取优惠券先将限制解除 -->
:disabled="item.get_status != 'can_get' && item.get_status != 'can_use'" <!-- :disabled="item.get_status != 'can_get' && item.get_status != 'can_use'" -->
> {{ item.get_status_text }}
{{ item.get_status_text }} </button>
</button> </template>
</template> </s-coupon-list>
</s-coupon-list> </view>
</view> </scroll-view>
</scroll-view> </view>
</view> </su-popup>
</su-popup>
</template> </template>
<script setup> <script setup>
import { computed, reactive } from 'vue'; import {
const props = defineProps({ computed,
modelValue: { reactive
type: Object, } from 'vue';
default() {}, const props = defineProps({
}, modelValue: {
show: { type: Object,
type: Boolean, default () {},
default: false, },
}, show: {
}); type: Boolean,
const emits = defineEmits(['get', 'close']); default: false,
const state = reactive({ },
couponInfo: computed(() => props.modelValue), });
currentValue: -1, const emits = defineEmits(['get', 'close']);
couponId: '', const state = reactive({
}); couponInfo: computed(() => props.modelValue),
const getBuy = (id) => { currentValue: -1,
emits('get', id); couponId: '',
}; });
// const getBuy = (id) => {
console.log('应该是详情页领取优惠券')
emits('get', id);
};
//
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.model-box { .model-box {
height: 60vh; height: 60vh;
.title {
font-size: 36rpx; .title {
height: 80rpx; font-size: 36rpx;
font-weight: bold; height: 80rpx;
color: #333333; font-weight: bold;
} color: #333333;
.subtitle { }
font-size: 26rpx;
font-weight: 500; .subtitle {
color: #333333; font-size: 26rpx;
} font-weight: 500;
} color: #333333;
.model-content { }
height: 54vh; }
}
.modal-footer { .model-content {
width: 100%; height: 54vh;
height: 120rpx; }
background: #fff;
} .modal-footer {
.confirm-btn { width: 100%;
width: 710rpx; height: 120rpx;
margin-left: 20rpx; background: #fff;
height: 80rpx; }
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
border-radius: 40rpx; .confirm-btn {
color: #fff; width: 710rpx;
} margin-left: 20rpx;
// height: 80rpx;
.card-btn { background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
// width: 144rpx; border-radius: 40rpx;
padding: 0 16rpx; color: #fff;
height: 50rpx; }
border-radius: 40rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient)); //
color: #ffffff; .card-btn {
font-size: 24rpx; // width: 144rpx;
font-weight: 400; padding: 0 16rpx;
} height: 50rpx;
.boder-btn { border-radius: 40rpx;
background: linear-gradient(90deg, var(--ui-BG-Main-opacity-4), var(--ui-BG-Main-light)); background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: #fff !important; color: #ffffff;
} font-size: 24rpx;
</style> font-weight: 400;
}
.boder-btn {
background: linear-gradient(90deg, var(--ui-BG-Main-opacity-4), var(--ui-BG-Main-light));
color: #fff !important;
}
</style>

View File

@ -1,13 +1,9 @@
<template> <template>
<view class="ss-m-20" :style="{ opacity: disabled ? '0.5' : '1' }"> <view class="ss-m-20" :style="{ opacity: disabled ? '0.5' : '1' }">
<view class="content"> <view class="content">
<!-- <view <view class="tag ss-flex ss-row-center" :class="
class="tag ss-flex ss-row-center"
:class="
data.status == 'expired' || data.status == 'used' ? 'disabled-bg-color' : 'info-bg-color' data.status == 'expired' || data.status == 'used' ? 'disabled-bg-color' : 'info-bg-color'
" ">{{ data.type_text }}</view>
>{{ data.type_text }}</view
> -->
<view class="title ss-m-x-30 ss-p-t-18"> <view class="title ss-m-x-30 ss-p-t-18">
<view class="ss-flex ss-row-between"> <view class="ss-flex ss-row-between">
<view class="value-text ss-flex-1 ss-m-r-10" :class=" <view class="value-text ss-flex-1 ss-m-r-10" :class="

View File

@ -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
@ -97,6 +98,7 @@ http.interceptors.request.use(
config.header['tenant-id'] = '1'; config.header['tenant-id'] = '1';
config.header['Authorization'] = 'Bearer test247'; config.header['Authorization'] = 'Bearer test247';
} }
// console.log(config, '看参数')
return config; return config;
}, },
(error) => { (error) => {

View File

@ -1,108 +1,120 @@
import { defineStore } from 'pinia'; import {
defineStore
} from 'pinia';
import cartApi from '@/sheep/api/cart'; import cartApi from '@/sheep/api/cart';
const cart = defineStore({ const cart = defineStore({
id: 'cart', id: 'cart',
state: () => ({ state: () => ({
list: [], // 购物车列表 list: [], // 购物车列表
selectedIds: [], // 已选列表 selectedIds: [], // 已选列表
isAllSelected: false, //是否全选 isAllSelected: false, //是否全选
cartSelectedTotalPrice: '0.00', // 选中项总金额 cartSelectedTotalPrice: '0.00', // 选中项总金额
}), }),
getters: { getters: {
totalPriceSelected: (state) => { totalPriceSelected: (state) => {
let price = 0; let price = 0;
if (!state.selectedIds.length) return price.toFixed(2); if (!state.selectedIds.length) return price.toFixed(2);
state.list.forEach((item) => { state.list.forEach((item) => {
price += state.selectedIds.includes(item.id) price += state.selectedIds.includes(item.id) ?
? Number(item.sku.price/100) * item.count Number(item.sku.price / 100) * item.count :
: 0; 0;
}); });
return price.toFixed(2); return price.toFixed(2);
}, },
}, },
actions: { actions: {
// 获取购物车列表 // 获取购物车列表
async getList() { async getList() {
const { data, code } = await cartApi.list(); const {
if (code === 0) { data,
this.list = data.validList; code
} } = await cartApi.list();
}, if (code === 0) {
// 添加购物车 this.list = data.validList;
async add(goodsInfo) { }
const { error } = await cartApi.append({ },
goods_id: goodsInfo.goods_id, // 添加购物车
goods_num: goodsInfo.goods_num, async add(goodsInfo) {
goods_sku_price_id: goodsInfo.id, console.log()
}); const {
if (error === 0) { code
this.getList(); } = await cartApi.append({
} // goods_id: goodsInfo.goods_id,
}, // goods_num: goodsInfo.goods_num,
// goods_sku_price_id: goodsInfo.id,
count: goodsInfo.goods_num,
skuId: goodsInfo.id,
});
if (code === 0) {
this.getList();
}
},
// 更新购物车 // 更新购物车
async update(goodsInfo) { async update(goodsInfo) {
const { error } = await cartApi.update({ const {
id: goodsInfo.goods_id, error
count: goodsInfo.goods_num, } = await cartApi.update({
goods_sku_price_id: goodsInfo.goods_sku_price_id, id: goodsInfo.goods_id,
}); count: goodsInfo.goods_num,
if (error === 0) { goods_sku_price_id: goodsInfo.goods_sku_price_id,
// this.getList(); });
} if (error === 0) {
}, // this.getList();
}
},
// 移除购物车 // 移除购物车
async delete(ids) { async delete(ids) {
if (typeof ids === 'array') { if (typeof ids === 'array') {
ids = ids.join(','); ids = ids.join(',');
} }
const { code } = await cartApi.delete(ids); const {
if (code === 0) { code
this.selectAll(false); } = await cartApi.delete(ids);
this.getList(); if (code === 0) {
} this.selectAll(false);
}, this.getList();
}
},
// 选择购物车商品 // 选择购物车商品
selectSingle(goodsId) { selectSingle(goodsId) {
if (!this.selectedIds.includes(goodsId)) { if (!this.selectedIds.includes(goodsId)) {
this.selectedIds.push(goodsId); this.selectedIds.push(goodsId);
} else { } else {
this.selectedIds.splice(this.selectedIds.indexOf(goodsId), 1); this.selectedIds.splice(this.selectedIds.indexOf(goodsId), 1);
} }
this.isAllSelected = this.selectedIds.length === this.list.length; this.isAllSelected = this.selectedIds.length === this.list.length;
}, },
// 全选 // 全选
selectAll(flag) { selectAll(flag) {
this.isAllSelected = flag; this.isAllSelected = flag;
if (!flag) { if (!flag) {
this.selectedIds = []; this.selectedIds = [];
} else { } else {
this.list.forEach((item) => { this.list.forEach((item) => {
this.selectedIds.push(item.id); this.selectedIds.push(item.id);
}); });
} }
}, },
// 清空购物车 // 清空购物车
emptyList() { emptyList() {
this.list = []; this.list = [];
this.selectedIds = []; this.selectedIds = [];
this.isAllSelected = false; this.isAllSelected = false;
this.cartSelectedTotalPrice = '0.00'; this.cartSelectedTotalPrice = '0.00';
}, },
}, },
persist: { persist: {
enabled: true, enabled: true,
strategies: [ strategies: [{
{ key: 'cart-store',
key: 'cart-store', }, ],
}, },
],
},
}); });
export default cart; export default cart;

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,6 @@
import { loadEnv } from 'vite'; import {
loadEnv
} from 'vite';
import uni from '@dcloudio/vite-plugin-uni'; import uni from '@dcloudio/vite-plugin-uni';
import path from 'path'; import path from 'path';
// import viteCompression from 'vite-plugin-compression'; // import viteCompression from 'vite-plugin-compression';
@ -31,4 +33,4 @@ export default (command, mode) => {
}, },
}, },
}; };
}; };