我的全部订单,待发货-待评价-评价晒单 优惠券列表

pull/23/head
落日晚风 2023-12-06 17:56:46 +08:00
parent 648b1a6351
commit 16a4fd21b1
9 changed files with 892 additions and 780 deletions

View File

@ -1,242 +1,261 @@
<!-- 优惠券中心 --> <!-- 优惠券中心 -->
<template> <template>
<s-layout title="优惠券" :bgStyle="{ color: '#f2f2f2' }"> <s-layout title="优惠券" :bgStyle="{ color: '#f2f2f2' }">
<su-sticky bgColor="#fff"> <su-sticky bgColor="#fff">
<su-tabs <su-tabs :list="tabMaps" :scrollable="false" @change="onTabsChange" :current="state.currentTab"></su-tabs>
:list="tabMaps" </su-sticky>
:scrollable="false" <s-empty v-if="state.pagination.total === 0" icon="/static/coupon-empty.png" text="暂无优惠券"></s-empty>
@change="onTabsChange" <template v-if="state.currentTab == '0'">
:current="state.currentTab" <view v-for="item in state.pagination.list" :key="item.id">
></su-tabs> <s-coupon-list :data="item">
</su-sticky> <!-- @tap="
<s-empty sheep.$router.go('/pages/coupon/detail', {
v-if="state.pagination.total === 0" id: item.id,
icon="/static/coupon-empty.png" })
text="暂无优惠券" " -->
></s-empty> <template #default>
<template v-if="state.currentTab == '0'"> <button class="ss-reset-button card-btn ss-flex ss-row-center ss-col-center"
<view v-for="item in state.pagination.data" :key="item.id"> :class="item.get_status != 'can_get' ? 'border-btn' : ''" @click.stop="getBuy(item.id)"
<s-coupon-list :disabled="item.get_status != 'can_get'">
:data="item" <!-- {{ item.status_text }} -->
@tap=" {{item.status_text|| '立即使用' }}
sheep.$router.go('/pages/coupon/detail', { </button>
id: item.id, </template>
}) </s-coupon-list>
" </view>
> </template>
<template #default> <template v-else>
<button <view v-for="item in state.pagination.list" :key="item.id">
class="ss-reset-button card-btn ss-flex ss-row-center ss-col-center" <s-coupon-list :data="item" type="user">
:class="item.get_status != 'can_get' ? 'border-btn' : ''" <!-- @tap="
@click.stop="getBuy(item.id)" sheep.$router.go('/pages/coupon/detail', {
:disabled="item.get_status != 'can_get'" id: item.id,
> })
{{ item.get_status_text }} " -->
</button> <template #default>
</template> <button class="ss-reset-button card-btn ss-flex ss-row-center ss-col-center" :class="
</s-coupon-list>
</view>
</template>
<template v-else>
<view v-for="item in state.pagination.data" :key="item.id">
<s-coupon-list
:data="item"
type="user"
@tap="
sheep.$router.go('/pages/coupon/detail', {
id: item.coupon_id,
user_coupon_id: item.id,
})
"
>
<template #default>
<button
class="ss-reset-button card-btn ss-flex ss-row-center ss-col-center"
:class="
item.status == 'can_get' || item.status == 'can_use' item.status == 'can_get' || item.status == 'can_use'
? '' ? ''
: item.status == 'used' || item.status == 'expired' : item.status == 'used' || item.status == 'expired'
? 'disabled-btn' ? 'disabled-btn'
: 'border-btn' : 'border-btn'
" " :disabled="item.status != 'can_get' && item.status != 'can_use'" @click.stop="
:disabled="item.status != 'can_get' && item.status != 'can_use'"
@click.stop="
sheep.$router.go('/pages/coupon/detail', { sheep.$router.go('/pages/coupon/detail', {
id: item.coupon_id, id: item.coupon_id,
user_coupon_id: item.id, user_coupon_id: item.id,
}) })
" ">
> <!-- {{ item.status_text }} -->
{{ item.status_text }} {{item.status_text|| '立即使用' }}
</button> </button>
</template> </template>
</s-coupon-list> </s-coupon-list>
</view> </view>
</template> </template>
<uni-load-more <!-- <uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多', contentdown: '上拉加载更多',
}" }" @tap="loadmore" /> -->
@tap="loadmore" </s-layout>
/>
</s-layout>
</template> </template>
<script setup> <script setup>
import sheep from '@/sheep'; import sheep from '@/sheep';
import { onLoad, onReachBottom } from '@dcloudio/uni-app'; import {
import { computed, reactive } from 'vue'; onLoad,
import _ from 'lodash'; onReachBottom
} from '@dcloudio/uni-app';
import {
computed,
reactive
} from 'vue';
import _ from 'lodash';
const pagination = { const pagination = {
data: [], data: [],
current_page: 1, current_page: 1,
total: 1, total: 1,
last_page: 1, last_page: 1,
}; };
// //
const state = reactive({ const state = reactive({
currentTab: 0, currentTab: 0,
pagination: { pagination: {
data: [], data: [],
current_page: 1, current_page: 1,
total: 1, total: 1,
last_page: 1, last_page: 1,
}, },
loadStatus: '', loadStatus: '',
type: '', type: '1',
}); });
const tabMaps = [ const tabMaps = [
{ // {
name: '领券中心', // name: '',
value: 'all', // value: 'all',
}, // },
{ {
name: '已领取', name: '已领取',
value: 'geted', value: '1',
}, },
{ {
name: '已使用', name: '已使用',
value: 'used', value: '2',
}, },
{ {
name: '已失效', name: '已失效',
value: 'expired', value: '3',
}, },
]; ];
function onTabsChange(e) {
state.pagination = pagination
state.currentTab = e.index;
state.type = e.value;
if (state.currentTab == 0) {
getData();
} else {
getCoupon();
}
}
async function getData(page = 1, list_rows = 5) {
state.loadStatus = 'loading';
const res = await sheep.$api.coupon.list({ list_rows, page });
if (res.error === 0) {
let couponlist = _.concat(state.pagination.data, res.data.data);
state.pagination = {
...res.data,
data: couponlist,
};
if (state.pagination.current_page < state.pagination.last_page) {
state.loadStatus = 'more';
} else {
state.loadStatus = 'noMore';
}
}
}
async function getCoupon(page = 1, list_rows = 5) { function onTabsChange(e) {
state.loadStatus = 'loading'; state.pagination = pagination
let res = await sheep.$api.coupon.userCoupon({ state.currentTab = e.index;
type: state.type, state.type = e.value;
list_rows, // if (state.currentTab == 0) {
page, // getData();
}); // } else {
if (res.error === 0) { getCoupon();
if (page >= 2) { // }
let couponlist = _.concat(state.pagination.data, res.data.data); }
state.pagination = { async function getData(page = 1, list_rows = 5) {
...res.data, state.loadStatus = 'loading';
data: couponlist, const res = await sheep.$api.coupon.list({
}; list_rows,
} else { page
state.pagination = res.data; });
} if (res.error === 0) {
if (state.pagination.current_page < state.pagination.last_page) { let couponlist = _.concat(state.pagination.data, res.data.data);
state.loadStatus = 'more'; state.pagination = {
} else { ...res.data,
state.loadStatus = 'noMore'; data: couponlist,
} };
} if (state.pagination.current_page < state.pagination.last_page) {
} state.loadStatus = 'more';
async function getBuy(id) { } else {
const { error, msg } = await sheep.$api.coupon.get(id); state.loadStatus = 'noMore';
if (error === 0) { }
uni.showToast({ }
title: msg, }
});
setTimeout(() => {
state.pagination = pagination
getData();
}, 1000);
}
}
// async function getCoupon(page = 1, list_rows = 5) {
function loadmore() { state.loadStatus = 'loading';
if (state.loadStatus !== 'noMore') { let res = await sheep.$api.coupon.userCoupon({
if (state.currentTab == 0) { status: state.type,
getData(state.pagination.current_page + 1); pageSize: list_rows,
} else { pageNo: page
getCoupon(state.pagination.current_page + 1); });
} if (res.code === 0) {
} //
} let obj = {
onLoad((Option) => { 1: '可用',
if (Option.type === 'all' || !Option.type) { 2: '已用',
getData(); 3: '过期'
} else { }
state.type = Option.type; res.data.list = res.data.list.map(item => {
Option.type === 'geted' return {
? (state.currentTab = 1) ...item,
: Option.type === 'used' enough: (item.usePrice / 100).toFixed(2),
? (state.currentTab = 2) amount: (item.discountPrice / 100).toFixed(2),
: (state.currentTab = 3); use_start_time: sheep.$helper.timeFormat(item.validStartTime, 'yyyy-mm-dd hh:MM:ss'),
getCoupon(); use_end_time: sheep.$helper.timeFormat(item.validEndTime, 'yyyy-mm-dd hh:MM:ss'),
} status_text: obj[item.status]
}); }
onReachBottom(() => { });
loadmore(); if (page >= 2) {
}); let couponlist = _.concat(state.pagination.data, res.data.list);
state.pagination = {
...res.data,
data: couponlist,
};
console.log(state.pagination, '拿到的优惠券数据');
} else {
state.pagination = res.data;
console.log(state.pagination, '拿到的优惠券数据');
}
// if (state.pagination.current_page < state.pagination.last_page) {
// state.loadStatus = 'more';
// } else {
// state.loadStatus = 'noMore';
// }
}
}
async function getBuy(id) {
const {
error,
msg
} = await sheep.$api.coupon.get(id);
if (error === 0) {
uni.showToast({
title: msg,
});
setTimeout(() => {
state.pagination = pagination
getData();
}, 1000);
}
}
//
function loadmore() {
if (state.loadStatus !== 'noMore') {
if (state.currentTab == 0) {
getData(state.pagination.current_page + 1);
} else {
getCoupon(state.pagination.current_page + 1);
}
}
}
onLoad((Option) => {
// if (Option.type === 'all' || !Option.type) {
// getData();
// } else {
// state.type = Option.type;
// Option.type === 'geted' ?
// () :
// Option.type === 'used' ?
// (state.currentTab = 1 && state.type = 2) :
// (state.currentTab = 2 && state.type = 3);
if (Option.type == 'geted') {
state.currentTab = 0
state.type = 1
} else if (Option.type == 'used') {
state.currentTab = 1
state.type = 2
} else {
state.currentTab = 2
state.type = 3
}
getCoupon();
// }
});
onReachBottom(() => {
loadmore();
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.card-btn { .card-btn {
// width: 144rpx; // width: 144rpx;
padding: 0 16rpx; padding: 0 16rpx;
height: 50rpx; height: 50rpx;
border-radius: 40rpx; border-radius: 40rpx;
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: #ffffff; color: #ffffff;
font-size: 24rpx; font-size: 24rpx;
font-weight: 400; font-weight: 400;
} }
.border-btn {
background: linear-gradient(90deg, var(--ui-BG-Main-opacity-4), var(--ui-BG-Main-light)); .border-btn {
color: #fff !important; background: linear-gradient(90deg, var(--ui-BG-Main-opacity-4), var(--ui-BG-Main-light));
} color: #fff !important;
.disabled-btn { }
background: #cccccc;
background-color: #cccccc !important; .disabled-btn {
color: #fff !important; background: #cccccc;
} background-color: #cccccc !important;
</style> color: #fff !important;
}
</style>

View File

@ -1,157 +1,209 @@
<!-- 评价 --> <!-- 评价 -->
<template> <template>
<s-layout title="评价"> <s-layout title="评价">
<view> <view>
<view v-for="(item, index) in state.orderInfo.items" :key="item.id"> <view v-for="(item, index) in state.orderInfo.items" :key="item.id">
<view v-if="item.btns.includes('comment')"> <view v-if="item.btns.includes('comment')">
<view class="commont-from-wrap"> <view class="commont-from-wrap">
<!-- 评价商品 --> <!-- 评价商品 -->
<s-goods-item <s-goods-item :img="item.goods_image" :title="item.goods_title" :skuText="item.goods_sku_text"
:img="item.goods_image" :price="item.goods_price" :num="item.goods_num"></s-goods-item>
:title="item.goods_title" </view>
:skuText="item.goods_sku_text"
:price="item.goods_price"
:num="item.goods_num"
></s-goods-item>
</view>
<view class="form-item"> <view class="form-item">
<!-- 评分 --> <!-- 评分 -->
<view class="star-box ss-flex ss-col-center"> <view class="star-box ss-flex ss-col-center">
<view class="star-title ss-m-r-40"> <view class="star-title ss-m-r-40">
{{ rateMap[state.commentList[index].level] }} <!-- {{ rateMap[state.commentList[index].level] }} -->
</view> 商品质量
<uni-rate v-model="state.commentList[index].level" /> </view>
</view> <uni-rate v-model="state.commentList[index].level" />
<!-- 评价 --> </view>
<view class="area-box"> <view class="star-box ss-flex ss-col-center">
<uni-easyinput <view class="star-title ss-m-r-40">
:inputBorder="false" <!-- {{ rateMap[state.commentList[index].level] }} -->
type="textarea" 服务态度
maxlength="120" </view>
autoHeight <uni-rate v-model="state.commentList[index].level2" />
v-model="state.commentList[index].content" </view>
placeholder="宝贝满足你的期待吗?说说你的使用心得,分享给想买的他们吧~" <!-- 评价 -->
></uni-easyinput> <view class="area-box">
<uni-easyinput :inputBorder="false" type="textarea" maxlength="120" autoHeight
v-model="state.commentList[index].content"
placeholder="宝贝满足你的期待吗?说说你的使用心得,分享给想买的他们吧~"></uni-easyinput>
<view class="img-box"> <view class="img-box">
<s-uploader <s-uploader v-model:url="state.commentList[index].images" fileMediatype="image"
v-model:url="state.commentList[index].images" limit="9" mode="grid" :imageStyles="{ width: '168rpx', height: '168rpx' }" />
fileMediatype="image" </view>
limit="9" </view>
mode="grid" </view>
:imageStyles="{ width: '168rpx', height: '168rpx' }" </view>
/> </view>
</view> </view>
</view>
</view>
</view>
</view>
</view>
<su-fixed bottom placeholder> <su-fixed bottom placeholder>
<view class="foot_box ss-flex ss-row-center ss-col-center"> <view class="foot_box ss-flex ss-row-center ss-col-center">
<button class="ss-reset-button post-btn ui-BG-Main-Gradient ui-Shadow-Main" @tap="onSubmit"> <button class="ss-reset-button post-btn ui-BG-Main-Gradient ui-Shadow-Main" @tap="onSubmit">
发布 发布
</button> </button>
</view> </view>
</su-fixed> </su-fixed>
</s-layout> </s-layout>
</template> </template>
<script setup> <script setup>
import sheep from '@/sheep'; import sheep from '@/sheep';
import { onLoad } from '@dcloudio/uni-app'; import {
import { computed, reactive } from 'vue'; onLoad
} from '@dcloudio/uni-app';
import {
computed,
reactive
} from 'vue';
const state = reactive({ const state = reactive({
orderInfo: {}, orderInfo: {},
commentList: [], commentList: [],
}); orderId: null
});
const rateMap = { const rateMap = {
1: '糟糕', 1: '糟糕',
2: '差评', 2: '差评',
3: '一般', 3: '一般',
4: '良好', 4: '良好',
5: '好评', 5: '好评',
}; };
async function onSubmit() { async function onSubmit() {
const { error } = await sheep.$api.order.comment(state.orderInfo.id, { //
comments: state.commentList, // console.log(state.orderInfo);
}); // return;
if (error === 0) { let obj = {
sheep.$router.back(); anonymous: false,
} benefitScores: state.commentList[0].level2,
} content: state.commentList[0].content,
descriptionScores: state.commentList[0].level,
orderItemId: state.commentList[0].item_id,
picUrls: 'https://t7.baidu.com/it/u=2531125946,3055766435&fm=193&f=GIF'
}
const {
code
} = await sheep.$api.order.comment(obj);
if (code === 0) {
sheep.$router.back();
}
}
onLoad(async (options) => { onLoad(async (options) => {
let id = ''; let id = '';
if (options.orderSN) { if (options.orderSN) {
id = options.orderSN; id = options.orderSN;
} }
if (options.id) { if (options.id) {
id = options.id; id = options.id;
} }
if (options.orderId) {
state.orderId = options.orderId
}
const { data, error } = await sheep.$api.order.detail(id); const res = await sheep.$api.order.detail(id);
if (error === 0) { if (res.code === 0) {
if (data.btns.includes('comment')) { let obj = {
state.orderInfo = data; 10: ['待发货', '等待买家付款', ["apply_refund"]],
state.orderInfo.items.forEach((item) => { 30: ['待评价', '等待买家评价', ["express", "comment"]]
if (item.btns.includes('comment')) { }
state.commentList.push({
item_id: item.id, res.data.status_text = obj[res.data.status][0];
level: 5, res.data.status_desc = obj[res.data.status][1];
content: '', res.data.btns = obj[res.data.status][2];
images: [], res.data.address = {
}); province_name: res.data.receiverAreaName.split(' ')[0],
} district_name: res.data.receiverAreaName.split(' ')[2],
}); city_name: res.data.receiverAreaName.split(' ')[1],
return; address: res.data.receiverDetailAddress,
} consignee: res.data.receiverName,
} mobile: res.data.receiverMobile,
sheep.$helper.toast('无待评价订单'); }
}); res.data.pay_fee = res.data.payPrice / 100
res.data.create_time = sheep.$helper.timeFormat(res.data.createTime, 'yyyy-mm-dd hh:MM:ss')
res.data.order_sn = res.data.no
res.data.id = res.data.id
res.data.goods_amount = res.data.totalPrice / 100
res.data.dispatch_amount = res.data.deliveryPrice / 100
res.data.pay_types_text = res.data.payChannelName.split(',')
res.data.items = res.data.items.map(ite => {
return {
...ite,
btns: obj[res.data.status][2],
goods_title: ite.spuName,
goods_num: ite.count,
goods_price: ite.price / 100,
goods_image: ite.picUrl,
goods_sku_text: ite.properties.reduce((it0, it1) => it0 + it1.valueName + ' ', '')
}
})
if (res.data.btns.includes('comment')) {
state.orderInfo = res.data;
state.orderInfo.items.forEach((item) => {
if (item.btns.includes('comment')) {
state.commentList.push({
item_id: item.id,
level: 5,
content: '',
images: [],
});
}
});
console.log(state.orderInfo.items, '循环')
return;
}
}
sheep.$helper.toast('无待评价订单');
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
// //
.goods-card { .goods-card {
margin: 10rpx 0; margin: 10rpx 0;
padding: 20rpx; padding: 20rpx;
background: #fff; background: #fff;
} }
// //
.form-item { .form-item {
background: #fff; background: #fff;
.star-box {
height: 100rpx;
padding: 0 25rpx;
}
.star-title {
font-weight: 600;
}
}
.area-box {
width: 690rpx;
min-height: 306rpx;
background: rgba(249, 250, 251, 1);
border-radius: 20rpx;
padding: 28rpx;
margin: auto;
.img-box { .star-box {
margin-top: 20rpx; height: 100rpx;
} padding: 0 25rpx;
} }
.post-btn {
width: 690rpx; .star-title {
line-height: 80rpx; font-weight: 600;
border-radius: 40rpx; }
color: rgba(#fff, 0.9); }
margin-bottom: 20rpx;
} .area-box {
</style> width: 690rpx;
min-height: 306rpx;
background: rgba(249, 250, 251, 1);
border-radius: 20rpx;
padding: 28rpx;
margin: auto;
.img-box {
margin-top: 20rpx;
}
}
.post-btn {
width: 690rpx;
line-height: 80rpx;
border-radius: 40rpx;
color: rgba(#fff, 0.9);
margin-bottom: 20rpx;
}
</style>

View File

@ -200,7 +200,7 @@
<button class="ss-reset-button cancel-btn" v-if="state.orderInfo.btns?.includes('confirm')" <button class="ss-reset-button cancel-btn" v-if="state.orderInfo.btns?.includes('confirm')"
@tap="onConfirm(state.orderInfo.id)">确认收货</button> @tap="onConfirm(state.orderInfo.id)">确认收货</button>
<button class="ss-reset-button cancel-btn" v-if="state.orderInfo.btns?.includes('comment')" <button class="ss-reset-button cancel-btn" v-if="state.orderInfo.btns?.includes('comment')"
@tap="onComment(state.orderInfo.order_sn)">评价晒单</button> @tap="onComment(state.orderInfo.id,state.orderInfo)">评价晒单</button>
<button v-if="state.orderInfo.btns?.includes('invoice')" class="ss-reset-button cancel-btn" <button v-if="state.orderInfo.btns?.includes('invoice')" class="ss-reset-button cancel-btn"
@tap.stop="onOrderInvoice(state.orderInfo.invoice?.id)"> @tap.stop="onOrderInvoice(state.orderInfo.invoice?.id)">
查看发票 查看发票
@ -389,12 +389,15 @@
} }
// //
function onComment(orderSN) { function onComment(orderSN, orderId) {
console.log(orderId);
// return;
uni.$once('SELECT_INVOICE', (e) => { uni.$once('SELECT_INVOICE', (e) => {
state.invoiceInfo = e.invoiceInfo; state.invoiceInfo = e.invoiceInfo;
}); });
sheep.$router.go('/pages/goods/comment/add', { sheep.$router.go('/pages/goods/comment/add', {
orderSN, orderSN,
orderId
}); });
} }
async function getOrderDetail(id) { async function getOrderDetail(id) {
@ -410,7 +413,8 @@
console.log(res, '我的订单详情数据'); console.log(res, '我的订单详情数据');
if (res.code === 0) { if (res.code === 0) {
let obj = { let obj = {
10: ['待发货', '等待买家付款', ["apply_refund"]] 10: ['待发货', '等待买家付款', ["apply_refund"]],
30: ['待评价', '等待买家评价', ["express", "comment"]]
} }
res.data.status_text = obj[res.data.status][0]; res.data.status_text = obj[res.data.status][0];
res.data.status_desc = obj[res.data.status][1]; res.data.status_desc = obj[res.data.status][1];

View File

@ -20,7 +20,7 @@
<su-sticky> <su-sticky>
<!-- 统计 --> <!-- 统计 -->
<view class="filter-box ss-p-x-30 ss-flex ss-col-center ss-row-between"> <view class="filter-box ss-p-x-30 ss-flex ss-col-center ss-row-between">
<!-- <uni-datetime-picker v-model="state.data" type="daterange" @change="onChangeTime" :end="state.today"> <!-- <uni-datetime-picker v-model="state.data" type="daterange" @change="onChangeTime" :end="state.today">
<button class="ss-reset-button date-btn"> <button class="ss-reset-button date-btn">
<text>{{ dateFilterText }}</text> <text>{{ dateFilterText }}</text>
<text class="cicon-drop-down ss-seldate-icon"></text> <text class="cicon-drop-down ss-seldate-icon"></text>
@ -28,9 +28,9 @@
</uni-datetime-picker> --> </uni-datetime-picker> -->
<view class="total-box"> <view class="total-box">
<!-- state.pagination.income.toFixed(2) --> <!-- state.pagination.income.toFixed(2) -->
<view class="ss-m-b-10">总收入{{ }}</view> <!-- <view class="ss-m-b-10">总收入{{ }}</view>
<view>总支出{{ }}</view> <view>总支出{{ }}</view> -->
<!-- (-state.pagination.expense).toFixed(2) --> <!-- (-state.pagination.expense).toFixed(2) -->
</view> </view>
</view> </view>
@ -45,7 +45,8 @@
<!-- <text class="title ss-line-1">{{ item.event_text }}{{ item.memo ? '-' + item.memo : '' }}</text> --> <!-- <text class="title ss-line-1">{{ item.event_text }}{{ item.memo ? '-' + item.memo : '' }}</text> -->
<text class="title ss-line-1">{{ item.title }}</text> <text class="title ss-line-1">{{ item.title }}</text>
<view class="money"> <view class="money">
<text v-if="(item.amount >= 0||item.price>=0)" class="add">+{{ item.amount||item.price }}</text> <text v-if="(item.amount >= 0||item.price>=0)"
class="add">+{{ item.amount||item.price }}</text>
<text v-else class="minus">{{ item.price }}</text> <text v-else class="minus">{{ item.price }}</text>
</view> </view>
</view> </view>
@ -133,7 +134,7 @@
income: res.data.income, income: res.data.income,
expense: res.data.expense, expense: res.data.expense,
}; };
console.log('交易数据',state.pagination) console.log('交易数据', state.pagination)
if (state.pagination.current_page < state.pagination.last_page) { if (state.pagination.current_page < state.pagination.last_page) {
state.loadStatus = 'more'; state.loadStatus = 'more';
} else { } else {

View File

@ -1,38 +1,45 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default { export default {
// 我的拼团 // 我的拼团
list: (params) => list: (params) =>
request({ request({
url: 'coupon', url: 'coupon',
method: 'GET', method: 'GET',
params, params,
custom: { custom: {
showLoading: false, showLoading: false,
}, },
}), }),
userCoupon: (params) => userCoupon: (params) =>
request({ request2({
url: 'user/coupon', url: 'promotion/coupon/page',
method: 'GET', method: 'GET',
params, params,
}), }),
detail: (id, user_coupon_id) => // userCoupon: (params) =>
request({ // request({
url: 'coupon/' + id, // url: 'user/coupon',
method: 'GET', // method: 'GET',
params: { // params,
user_coupon_id, // }),
}, detail: (id, user_coupon_id) =>
}), request({
get: (id) => url: 'coupon/' + id,
request({ method: 'GET',
url: 'coupon/get/' + id, params: {
method: 'POST', user_coupon_id,
}), },
listByGoods: (id) => }),
request({ get: (id) =>
url: 'coupon/listByGoods/' + id, request({
method: 'GET', url: 'coupon/get/' + id,
}), method: 'POST',
}; }),
listByGoods: (id) =>
request({
url: 'coupon/listByGoods/' + id,
method: 'GET',
}),
};

View File

@ -107,12 +107,18 @@ export default {
method: 'PUT', method: 'PUT',
}), }),
// 评价订单 // 评价订单
comment: (id, data) => comment: (data) =>
request({ request2({
url: 'order/order/comment/' + id, url: 'trade/order/item/create-comment',
method: 'POST', method: 'POST',
data, data,
}), }),
// comment: (id, data) =>
// request({
// url: 'order/order/comment/' + id,
// method: 'POST',
// data,
// }),
// 申请退款 // 申请退款
applyRefund: (id) => applyRefund: (id) =>
request({ request({

View File

@ -1,80 +1,78 @@
<template> <template>
<view class="ss-coupon-menu-wrap ss-flex ss-col-center"> <view class="ss-coupon-menu-wrap ss-flex ss-col-center">
<view <view class="menu-item ss-flex-col ss-row-center ss-col-center" v-for="item in props.list" :key="item.title"
class="menu-item ss-flex-col ss-row-center ss-col-center" @tap="sheep.$router.go(item.path, { type: item.type })"
v-for="item in props.list" :class="item.type === 'all' ? 'menu-wallet' : 'ss-flex-1'">
:key="item.title" <image class="item-icon" :src="sheep.$url.static(item.icon)" mode="aspectFit"></image>
@tap="sheep.$router.go(item.path, { type: item.type })" <view class="menu-title ss-m-t-28">{{ item.title }}</view>
:class="item.type === 'all' ? 'menu-wallet' : 'ss-flex-1'" </view>
> </view>
<image class="item-icon" :src="sheep.$url.static(item.icon)" mode="aspectFit"></image>
<view class="menu-title ss-m-t-28">{{ item.title }}</view>
</view>
</view>
</template> </template>
<script setup> <script setup>
/** /**
* 装修组件 - 优惠券菜单 * 装修组件 - 优惠券菜单
*/ */
import sheep from '@/sheep'; import sheep from '@/sheep';
// //
const props = defineProps({ const props = defineProps({
list: { list: {
type: Array, type: Array,
default() { default () {
return [ return [{
{ title: '已领取',
title: '已领取', value: '0',
value: '0', icon: '/static/img/shop/order/nouse_coupon.png',
icon: '/static/img/shop/order/nouse_coupon.png', path: '/pages/coupon/list',
path: '/pages/coupon/list', type: 'geted',
type: 'geted', },
}, {
{ title: '已使用',
title: '已使用', value: '0',
value: '0', icon: '/static/img/shop/order/useend_coupon.png',
icon: '/static/img/shop/order/useend_coupon.png', path: '/pages/coupon/list',
path: '/pages/coupon/list', type: 'used',
type: 'used', },
}, {
{ title: '已失效',
title: '已失效', value: '0',
value: '0', icon: '/static/img/shop/order/out_coupon.png',
icon: '/static/img/shop/order/out_coupon.png', path: '/pages/coupon/list',
path: '/pages/coupon/list', type: 'expired',
type: 'expired', },
}, // {
{ // title: '',
title: '领券中心', // value: '0',
value: '0', // icon: '/static/img/shop/order/all_coupon.png',
icon: '/static/img/shop/order/all_coupon.png', // path: '/pages/coupon/list',
path: '/pages/coupon/list', // type: 'all',
type: 'all', // },
}, ];
]; },
}, },
}, });
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.ss-coupon-menu-wrap { .ss-coupon-menu-wrap {
.menu-item { .menu-item {
height: 160rpx; height: 160rpx;
.menu-title {
font-size: 24rpx; .menu-title {
line-height: 24rpx; font-size: 24rpx;
color: #333333; line-height: 24rpx;
} color: #333333;
.item-icon { }
width: 44rpx;
height: 44rpx; .item-icon {
} width: 44rpx;
} height: 44rpx;
.menu-wallet { }
width: 144rpx; }
}
} .menu-wallet {
</style> width: 144rpx;
}
}
</style>

View File

@ -1,192 +1,195 @@
<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="tag ss-flex ss-row-center"
:class=" :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 <view class="value-text ss-flex-1 ss-m-r-10" :class="
class="value-text ss-flex-1 ss-m-r-10"
:class="
data.status == 'expired' || data.status == 'used' ? 'disabled-color' : 'info-color' data.status == 'expired' || data.status == 'used' ? 'disabled-color' : 'info-color'
" ">{{ data.name }}</view>
>{{ data.name }}</view <view>
> <view class="ss-flex ss-col-bottom" :class="
<view>
<view
class="ss-flex ss-col-bottom"
:class="
data.status != 'expired' && data.status != 'used' ? 'price-text' : 'disabled-color' data.status != 'expired' && data.status != 'used' ? 'price-text' : 'disabled-color'
" ">
> <view class="value-reduce ss-m-b-10" v-if="data.type === 'reduce'"></view>
<view class="value-reduce ss-m-b-10" v-if="data.type === 'reduce'"></view> <view class="value-price">{{ data.amount }}</view>
<view class="value-price">{{ data.amount }}</view> <view class="value-discount ss-m-b-10 ss-m-l-4" v-if="data.type === 'discount'"></view>
<view class="value-discount ss-m-b-10 ss-m-l-4" v-if="data.type === 'discount'" </view>
></view </view>
> </view>
</view> <view class="ss-flex ss-row-between ss-m-t-16">
</view> <view class="sellby-text" :class="
</view>
<view class="ss-flex ss-row-between ss-m-t-16">
<view
class="sellby-text"
:class="
data.status == 'expired' || data.status == 'used' data.status == 'expired' || data.status == 'used'
? 'disabled-color' ? 'disabled-color'
: 'subtitle-color' : 'subtitle-color'
" ">
> {{'有效期:' + data.use_start_time.substring(0, 11) }}
{{ {{ data.use_end_time.substring(0, 11) }}
<!-- {{
type === 'user' type === 'user'
? '有效期:' + data.use_start_time.substring(0, 11) ? '有效期:' + data.use_start_time.substring(0, 11)
: '领取时间:' + data.get_start_time.substring(0, 11) : '领取时间:' + data.get_start_time.substring(0, 11)
}} }}
{{ {{
type === 'user' type === 'user'
? data.use_end_time.substring(0, 11) ? data.use_end_time.substring(0, 11)
: data.get_end_time.substring(0, 11) : data.get_end_time.substring(0, 11)
}} }} -->
</view> </view>
<view <view class="value-enough" :class="
class="value-enough"
:class="
data.status == 'expired' || data.status == 'used' data.status == 'expired' || data.status == 'used'
? 'disabled-color' ? 'disabled-color'
: 'subtitle-color' : 'subtitle-color'
" ">{{ data.enough }}可用</view>
>{{ data.enough }}可用</view </view>
> </view>
</view> </view>
</view>
</view>
<view class="desc ss-flex ss-row-between"> <view class="desc ss-flex ss-row-between">
<view> <view>
<view class="desc-title"> <view class="desc-title">
{{ data.description }} {{ data.description }}
</view> </view>
<view> <view>
<slot name="reason"> <slot name="reason">
</slot> </slot>
</view> </view>
</view> </view>
<view> <view>
<slot></slot> <slot></slot>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { reactive } from 'vue'; import {
import sheep from '@/sheep'; reactive
const state = reactive({ } from 'vue';
stateMap: { import sheep from '@/sheep';
0: '立即领取', const state = reactive({
1: '去使用', stateMap: {
}, 0: '立即领取',
}); 1: '去使用',
// },
const props = defineProps({ });
data: { //
type: Object, const props = defineProps({
default: {}, data: {
}, type: Object,
disabled: { default: {},
type: Boolean, },
default: false, disabled: {
}, type: Boolean,
type: { default: false,
type: String, },
default: 'coupon', type: {
}, type: String,
}); default: 'coupon',
},
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.info-bg-color { .info-bg-color {
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));
} }
.disabled-bg-color {
background: #999;
}
.info-color {
color: #333;
}
.subtitle-color {
color: #666;
}
.disabled-color {
color: #999;
}
.content {
width: 100%;
background: #fff;
border-radius: 20rpx 20rpx 0 0;
-webkit-mask: radial-gradient(circle at 12rpx 100%, #0000 12rpx, red 0) -12rpx;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.04);
.tag { .disabled-bg-color {
width: 100rpx; background: #999;
}
color: #fff; .info-color {
height: 40rpx; color: #333;
font-size: 24rpx; }
border-radius: 20rpx 0 20rpx 0;
} .subtitle-color {
.title { color: #666;
padding-bottom: 22rpx; }
border-bottom: 2rpx dashed #d3d3d3;
.value-text { .disabled-color {
font-size: 32rpx; color: #999;
font-weight: 600; }
}
.sellby-text { .content {
font-size: 24rpx; width: 100%;
font-weight: 400; background: #fff;
} border-radius: 20rpx 20rpx 0 0;
.value-price { -webkit-mask: radial-gradient(circle at 12rpx 100%, #0000 12rpx, red 0) -12rpx;
font-size: 64rpx; box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.04);
font-weight: 500;
line-height: normal; .tag {
font-family: OPPOSANS; width: 100rpx;
}
.value-reduce { color: #fff;
line-height: normal; height: 40rpx;
font-size: 32rpx; font-size: 24rpx;
} border-radius: 20rpx 0 20rpx 0;
.value-discount { }
line-height: normal;
font-size: 28rpx; .title {
} padding-bottom: 22rpx;
.value-enough { border-bottom: 2rpx dashed #d3d3d3;
font-size: 24rpx;
font-weight: 400; .value-text {
font-family: OPPOSANS; font-size: 32rpx;
} font-weight: 600;
} }
}
.desc { .sellby-text {
width: 100%; font-size: 24rpx;
background: #fff; font-weight: 400;
-webkit-mask: radial-gradient(circle at 12rpx 0%, #0000 12rpx, red 0) -12rpx; }
box-shadow: rgba(#000, 0.1);
box-sizing: border-box; .value-price {
padding: 24rpx 30rpx; font-size: 64rpx;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.04); font-weight: 500;
border-radius: 0 0 20rpx 20rpx; line-height: normal;
.desc-title { font-family: OPPOSANS;
font-size: 24rpx; }
color: #999;
font-weight: 400; .value-reduce {
} line-height: normal;
} font-size: 32rpx;
.price-text { }
color: #ff0000;
} .value-discount {
</style> line-height: normal;
font-size: 28rpx;
}
.value-enough {
font-size: 24rpx;
font-weight: 400;
font-family: OPPOSANS;
}
}
}
.desc {
width: 100%;
background: #fff;
-webkit-mask: radial-gradient(circle at 12rpx 0%, #0000 12rpx, red 0) -12rpx;
box-shadow: rgba(#000, 0.1);
box-sizing: border-box;
padding: 24rpx 30rpx;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.04);
border-radius: 0 0 20rpx 20rpx;
.desc-title {
font-size: 24rpx;
color: #999;
font-weight: 400;
}
}
.price-text {
color: #ff0000;
}
</style>

View File

@ -1,168 +1,190 @@
import { defineStore } from 'pinia'; import {
defineStore
} from 'pinia';
import userApi from '@/sheep/api/user'; import userApi from '@/sheep/api/user';
import commissionApi from '@/sheep/api/commission'; import commissionApi from '@/sheep/api/commission';
import $share from '@/sheep/platform/share'; import $share from '@/sheep/platform/share';
import { isEmpty, cloneDeep, clone } from 'lodash'; import {
isEmpty,
cloneDeep,
clone
} from 'lodash';
import cart from './cart'; import cart from './cart';
import app from './app'; import app from './app';
import { showAuthModal } from '@/sheep/hooks/useModal'; import {
showAuthModal
} from '@/sheep/hooks/useModal';
// 默认用户信息 // 默认用户信息
const defaultUserInfo = { const defaultUserInfo = {
avatar: '', // 头像 avatar: '', // 头像
nickname: '', // 昵称 nickname: '', // 昵称
gender: 0, // 性别 gender: 0, // 性别
mobile: '', // 手机号 mobile: '', // 手机号
money: '--', // 余额 money: '--', // 余额
commission: '--', // 佣金 commission: '--', // 佣金
score: '--', // 积分 score: '--', // 积分
verification: {}, // 认证字段 verification: {}, // 认证字段
}; };
// 默认订单、优惠券等其他资产信息 // 默认订单、优惠券等其他资产信息
const defaultNumData = { const defaultNumData = {
coupons_num: '--', coupons_num: '--',
order_num: { order_num: {
aftersale: 0, aftersale: 0,
nocomment: 0, nocomment: 0,
noget: 0, noget: 0,
nosend: 0, nosend: 0,
unpaid: 0, unpaid: 0,
}, },
}; };
const user = defineStore({ const user = defineStore({
id: 'user', id: 'user',
state: () => ({ state: () => ({
userInfo: clone(defaultUserInfo), // 用户信息 userInfo: clone(defaultUserInfo), // 用户信息
isLogin: !!uni.getStorageSync('token'), // 登录状态 isLogin: !!uni.getStorageSync('token'), // 登录状态
numData: cloneDeep(defaultNumData), // 用户其他数据 numData: cloneDeep(defaultNumData), // 用户其他数据
agentInfo: {}, // 分销商信息 agentInfo: {}, // 分销商信息
lastUpdateTime: 0, // 上次更新时间 lastUpdateTime: 0, // 上次更新时间
}), }),
actions: { actions: {
// 获取个人信息 // 获取个人信息
async getInfo() { async getInfo() {
const { code, data } = await userApi.profile(); const {
// 为了兼容 获取用户余额 可能还会用到其他参数 code,
const { code:code2, data:data2 } = await userApi.balance(); data
if (code !== 0||code2!=0) return; } = await userApi.profile();
data.money=data2.balance/100; // 为了兼容 获取用户余额 可能还会用到其他参数
this.userInfo = data; // 优惠券数量,积分数量 应该在这里
const {
code: code2,
data: data2
} = await userApi.balance();
if (code !== 0 || code2 != 0) return;
data.money = data2.balance / 100;
this.userInfo = data;
console.log(data2, '信息')
return Promise.resolve(data);
},
return Promise.resolve(data); // 获取分销商信息
}, async getAgentInfo() {
const res = await commissionApi.agent();
if (res.error === 0) {
this.agentInfo = res.data;
}
return Promise.resolve(res);
},
// 获取分销商信息 // 获取订单、优惠券等其他资产信息
async getAgentInfo() { async getNumData() {
const res = await commissionApi.agent(); const {
if (res.error === 0) { code,
this.agentInfo = res.data; data
} } = await userApi.data();
return Promise.resolve(res); const data2 = await userApi.data2();
}, if (code === 0 && data2.code === 0) {
console.log('订单数据', data);
this.numData = {
order_num: {
noget: data.deliveredCount,
unpaid: data.unpaidCount,
nocomment: data.uncommentedCount,
aftersale: data2.data
}
};
}
},
// 获取订单、优惠券等其他资产信息 // 添加分享记录
async getNumData() { async addShareLog(params) {
const { code, data } = await userApi.data(); const {
const data2 = await userApi.data2(); error
if (code === 0&&data2.code===0) { } = await userApi.addShareLog(params);
console.log('订单数据',data); if (error === 0) uni.removeStorageSync('shareLog');
this.numData = {order_num:{ },
noget:data.deliveredCount,
unpaid:data.unpaidCount,
nocomment:data.uncommentedCount,
aftersale:data2.data
}};
}
},
// 添加分享记录 // 设置token
async addShareLog(params) { setToken(token = '') {
const { error } = await userApi.addShareLog(params); if (token === '') {
if (error === 0) uni.removeStorageSync('shareLog'); this.isLogin = false;
}, uni.removeStorageSync('token');
} else {
this.isLogin = true;
uni.setStorageSync('token', token);
this.loginAfter();
}
return this.isLogin;
},
// 设置token // 更新用户相关信息 (手动限流 5秒之内不刷新)
setToken(token = '') { async updateUserData() {
if (token === '') { if (!this.isLogin) {
this.isLogin = false; this.resetUserData();
uni.removeStorageSync('token'); return;
} else { }
this.isLogin = true; const nowTime = new Date().getTime();
uni.setStorageSync('token', token); if (this.lastUpdateTime + 5000 > nowTime) return;
this.loginAfter(); await this.getInfo();
} this.getNumData();
return this.isLogin; this.lastUpdateTime = nowTime;
}, return this.userInfo;
},
// 更新用户相关信息 (手动限流 5秒之内不刷新) // 重置用户默认数据
async updateUserData() { resetUserData() {
if (!this.isLogin) { this.setToken();
this.resetUserData(); this.userInfo = clone(defaultUserInfo);
return; this.numData = cloneDeep(defaultNumData);
} this.agentInfo = {};
const nowTime = new Date().getTime(); cart().emptyList();
if (this.lastUpdateTime + 5000 > nowTime) return; },
await this.getInfo();
this.getNumData();
this.lastUpdateTime = nowTime;
return this.userInfo;
},
// 重置用户默认数据 // 登录后
resetUserData() { async loginAfter() {
this.setToken(); await this.updateUserData();
this.userInfo = clone(defaultUserInfo); cart().getList();
this.numData = cloneDeep(defaultNumData); // 登录后设置全局分享参数
this.agentInfo = {}; $share.getShareInfo();
cart().emptyList(); // 提醒绑定手机号
}, if (app().platform.bind_mobile && !this.userInfo.verification?.mobile) {
showAuthModal('changeMobile');
}
// 登录后 // 添加分享记录
async loginAfter() { const shareLog = uni.getStorageSync('shareLog');
await this.updateUserData(); if (!isEmpty(shareLog)) {
cart().getList(); this.addShareLog({
// 登录后设置全局分享参数 ...shareLog,
$share.getShareInfo(); });
// 提醒绑定手机号 }
if (app().platform.bind_mobile && !this.userInfo.verification?.mobile) { },
showAuthModal('changeMobile');
}
// 添加分享记录 // 登出
const shareLog = uni.getStorageSync('shareLog'); async logout(force = false) {
if (!isEmpty(shareLog)) { if (!force) {
this.addShareLog({ const {
...shareLog, error
}); } = await userApi.logout();
} if (error === 0) {
}, this.resetUserData();
}
}
if (force) {
this.resetUserData();
}
// 登出 return !this.isLogin;
async logout(force = false) { },
if (!force) { },
const { error } = await userApi.logout(); persist: {
if (error === 0) { enabled: true,
this.resetUserData(); strategies: [{
} key: 'user-store',
} }, ],
if (force) { },
this.resetUserData();
}
return !this.isLogin;
},
},
persist: {
enabled: true,
strategies: [
{
key: 'user-store',
},
],
},
}); });
export default user; export default user;