wip: 4.0
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-05-16 14:27:57 +08:00
parent b09c1d9537
commit 8f3b158032
72 changed files with 3931 additions and 2161 deletions

View File

@@ -1,3 +1,3 @@
export default definePageConfig({
navigationBarTitleText: "我的账户",
navigationBarTitleText: '账户明细',
});

View File

@@ -1,30 +1,31 @@
<script lang="ts" setup>
import { computed, ref } from "vue";
import Taro from "@tarojs/taro";
import * as dayjs from "dayjs";
import { getIntegralDetail, getBeanDetail, getGiftRecord } from "@/api/user";
import {computed, ref} from 'vue';
import Taro from '@tarojs/taro';
import * as dayjs from 'dayjs';
import {getIntegralDetail, getBeanDetail, getGiftRecord} from '@/api/user';
import {TriangleDown} from '@nutui/icons-vue-taro';
const tabValue = ref(1);
const tabsList = ref([
{
title: "兑换明细",
title: '兑换明细',
value: 1,
},
{
title: "赠送明细",
title: '赠送明细',
value: 3,
},
{
title: "豆子明细",
title: '豆子明细',
value: 2,
},
{
title: "活动赠送",
title: '活动赠送',
value: 4,
},
{
title: "聚合积分",
title: '聚合积分',
value: 5,
},
]);
@@ -33,11 +34,11 @@ const computerType = computed(() => {
return (val: number) => {
switch (val) {
case 5:
return "注册赠送";
return '注册赠送';
case 6:
return "签到赠送";
return '签到赠送';
case 7:
return "系统赠送";
return '系统赠送';
}
};
});
@@ -64,8 +65,12 @@ const data = ref<DataType[]>([]);
const userInfo = ref<any>({});
Taro.useLoad(() => {
pickerVal.value = [
dayjs().format('YYYY-MM-DD'),
dayjs().format('YYYY-MM-DD'),
];
getList();
userInfo.value = Taro.getStorageSync("userInfo");
userInfo.value = Taro.getStorageSync('userInfo');
});
const page = ref({
@@ -86,12 +91,14 @@ const getList = async () => {
PageNum: page.value.PageNum,
PageSize: page.value.PageSize,
Type: tabValue.value,
TimeStart: pickerVal.value[0],
TimeEnd: pickerVal.value[1],
};
if (tabValue.value === 1 || tabValue.value === 3 || tabValue.value === 5) {
res = await getBeanDetail(newData);
} else if (tabValue.value === 2) {
// delete data.value.Type;
Reflect.deleteProperty(data.value, "Type");
Reflect.deleteProperty(data.value, 'Type');
res = await getIntegralDetail(newData);
} else if (tabValue.value === 4) {
res = await getGiftRecord(newData);
@@ -101,41 +108,64 @@ const getList = async () => {
} catch (error) {
Taro.showToast({
title: error.msg,
icon: "none",
icon: 'none',
});
}
};
const pickerRef = ref();
const showPicker = ref(false);
const pickerVal = ref<Array<string>>([]);
const openPicker = () => {
showPicker.value = true;
pickerRef.value.scrollToDate(dayjs().format('YYYY-MM-DD'));
};
const choose = e => {
pickerVal.value = [e[0][3], e[1][3]];
getList();
};
const closePicker = () => {
showPicker.value = false;
};
</script>
<template>
<view>
<view class="card">
<view class="info">
<view class="left">
<view>
<view class="num">豆子: {{ userInfo.data?.pulse }}</view>
</view>
<view>
<view class="num">积分: {{ userInfo.data?.integral }}</view>
</view>
</view>
<view class="tabs-box">
<view
class="item"
v-for="(item, idx) in tabsList"
:key="idx"
@click="tabChange(item.value)"
:style="{
backgroundColor: item.value === tabValue ? '#ff0000' : '#F0F0F0',
color: item.value === tabValue ? '#fff' : '#333',
}">
<view>{{ item.title }}</view>
</view>
</view>
<scroll-view scroll-x>
<view class="tabs-box">
<view
v-for="item in tabsList"
:key="item.value"
@click="tabChange(item.value)"
>
<view class="text">{{ item.title }}</view>
<view
class="line"
:class="{ lineColor: item.value === tabValue }"
></view>
</view>
</view>
</scroll-view>
<view
@click="openPicker"
class="pt-[20px] pb-[20px] pl-[25px] text-[30px] text-[#333] flex items-center">
<text>时间筛选</text>
<TriangleDown size="20px" color="#333" />
</view>
<nut-calendar
ref="pickerRef"
type="range"
title="时间筛选"
v-model:visible="showPicker"
:default-value="pickerVal"
start-date="2023-01-01"
end-date="2070-01-01"
@close="closePicker"
@choose="choose">
</nut-calendar>
<view v-if="data.length > 0">
<view v-if="tabValue === 1">
@@ -143,7 +173,7 @@ const getList = async () => {
<view class="left">
<view>订单号: {{ item.oid }}</view>
<text class="jf">{{
dayjs(item.add_time).format("YYYY/MM/DD mm:ss")
dayjs(item.add_time).format('YYYY/MM/DD mm:ss')
}}</text>
</view>
<view class="right">
@@ -205,11 +235,11 @@ const getList = async () => {
</view>
</view>
<nut-pagination
class="mt-3"
v-model="page.PageNum"
:total-items="page.ItemCount"
:items-per-page="page.PageSize"
@change="pageChange"
/>
@change="pageChange" />
</view>
<nut-empty v-else description="暂无明细"></nut-empty>
</view>
@@ -222,95 +252,46 @@ const getList = async () => {
transform: translateX(-50%);
}
.card {
width: 90%;
border-radius: 20px;
background-color: #282828;
margin: 10px auto;
color: #d0a568;
padding: 20px;
.info {
.left {
height: 200px;
text-align: left;
margin-left: 50px;
display: flex;
flex-direction: column;
justify-content: center;
.num {
font-weight: bold;
margin-top: 10px;
}
}
}
}
.tabs-box {
display: flex;
flex-direction: row;
// justify-content: space-evenly;
align-items: center;
height: auto;
background-color: #fff;
padding: 0 10px;
text-align: center;
overflow-x: auto;
flex-wrap: wrap;
padding: 15px;
justify-content: space-evenly;
&::-webkit-scrollbar {
width: 0;
height: 0;
}
view {
width: 200px;
}
.text {
margin: 10px 0;
align-items: center;
font-size: large;
}
.line {
margin: 0 auto;
width: 100px;
height: 5px;
border-radius: 30px;
transition: all 0.3s ease-in-out;
}
.lineColor {
background-color: #ff0000;
.item {
padding: 10px 20px;
font-size: 23px;
border-radius: 10px;
}
}
.card-list {
margin: 10px 20px;
// margin: 10px 20px;
background-color: #fff;
display: flex;
border-radius: 10px;
padding: 20px;
justify-content: space-between;
align-items: center;
font-size: 25px;
.jf {
color: #8a8a8a;
color: #484848;
}
.left {
.text {
text-align: left;
font-weight: bolder;
// 超出一行隐藏
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
word-break: break-word;
color: #484848;
font-size: large;
}
}

View File

@@ -1,3 +1,4 @@
export default definePageConfig({
navigationBarTitleText: "我的订单",
enablePullDownRefresh: true,
});

View File

@@ -1,10 +1,10 @@
<script lang="ts" setup>
import { ref } from "vue";
import Taro from "@tarojs/taro";
import Pay from "@/components/Pay.vue";
import { getActiveOrderList, deleteActiveOrder } from "@/api/goods";
import { getOrderStatistics } from "@/api/order";
import { getUserPoint } from "@/api/admin";
import {ref} from 'vue';
import Taro from '@tarojs/taro';
import Pay from '@/components/Pay.vue';
import {getActiveOrderList, deleteActiveOrder} from '@/api/goods';
import {getOrderStatistics} from '@/api/order';
import {getUserPoint} from '@/api/admin';
const tabValue = ref(0);
@@ -12,27 +12,27 @@ const isShowPay = ref(false);
const tabsList = ref([
{
title: "全部",
title: '全部',
value: 0,
num: 0,
},
{
title: "待付款",
title: '待付款',
value: 1,
num: 0,
},
{
title: "待使用",
title: '待使用',
value: 2,
num: 0,
},
{
title: "已使用",
title: '已使用',
value: 3,
num: 0,
},
{
title: "已失效",
title: '已失效',
value: 4,
num: 0,
},
@@ -70,7 +70,7 @@ interface GoodsItem {
const orderList = ref<OrderList[]>([]);
Taro.useLoad((options) => {
Taro.useLoad(options => {
tabValue.value = Number(options.type);
});
@@ -78,6 +78,12 @@ Taro.useDidShow(() => {
getList();
});
// Taro.startPullDownRefresh({
// success: () => {
// getList();
// },
// });
const getList = async () => {
try {
const res = await getActiveOrderList({
@@ -87,10 +93,11 @@ const getList = async () => {
} catch (error) {
Taro.showToast({
title: error.msg,
icon: "none",
icon: 'none',
});
}
await getTj();
// await getTj();
// Taro.stopPullDownRefresh();
};
const tabChange = (index: number) => {
@@ -100,7 +107,7 @@ const tabChange = (index: number) => {
const openPay = async (item: OrderList) => {
isShowPay.value = true;
const user_info = Taro.getStorageSync("userInfo");
const user_info = Taro.getStorageSync('userInfo');
const data = await getUserPoint({
phone: user_info.data.phone,
bid: item.Store.bid,
@@ -114,8 +121,8 @@ const openPay = async (item: OrderList) => {
const errPay = () => {
isShowPay.value = false;
Taro.showToast({
title: "支付失败",
icon: "none",
title: '支付失败',
icon: 'none',
});
jfInfo.value = {};
getList();
@@ -123,8 +130,8 @@ const errPay = () => {
const closePay = () => {
isShowPay.value = false;
Taro.showToast({
title: "支付取消",
icon: "none",
title: '支付取消',
icon: 'none',
});
jfInfo.value = {};
getList();
@@ -137,19 +144,18 @@ const successPay = () => {
};
const toDetail = (item: any) => {
Taro.setStorageSync("item", item);
Taro.navigateTo({
url: `/pages/users/order_list_detail/index?orderId=${item.oid}`,
url: `/pages/users/order_list_detail/index?orderId=${item.joint_oid}`,
});
};
const delOrder = async (oid: string) => {
try {
await deleteActiveOrder({ oid });
await deleteActiveOrder({oid});
} catch (error) {
Taro.showToast({
title: error.msg,
icon: "none",
icon: 'none',
});
}
await getList();
@@ -179,7 +185,7 @@ const getTj = async () => {
} catch (error) {
Taro.showToast({
title: error.msg,
icon: "none",
icon: 'none',
});
}
};
@@ -187,7 +193,7 @@ const getTj = async () => {
<template>
<view>
<view class="topTips">
<!-- <view class="topTips">
<view>
<view style="font-weight: bold">订单信息</view>
<view style="font-size: 15px"
@@ -198,34 +204,50 @@ const getTj = async () => {
</view>
</view>
<image src="../static/user/order_list_top.png" />
</view>
</view> -->
<view class="tabs-box">
<view
v-for="item in tabsList"
:key="item.value"
@click="tabChange(item.value)"
>
<view class="text">{{ item.title }}</view>
<view>{{ item.num }}</view>
@click="tabChange(item.value)">
<view
class="line"
:class="{ lineColor: item.value === tabValue }"
></view>
class="text"
:style="{
color: tabValue === item.value ? '#000' : '#9C9C9C',
}"
>{{ item.title }}</view
>
<!-- <view>{{ item.num }}</view> -->
<view class="line" :class="{lineColor: item.value === tabValue}"></view>
</view>
</view>
<view v-if="orderList.length > 0">
<view class="order-card" v-for="(item, index) in orderList" :key="index">
<view
class="order-card"
v-for="(item, index) in orderList"
:key="index"
@click="toDetail(item)">
<view class="top">
<view>{{ item.add_time.slice(0, 19) }}</view>
<view style="color: red"
<view class="text-[#9C9C9C] text-[25px]">订单号{{ item.oid }}</view>
<view
:style="{
color:
item.status === 0
? '#FF850A'
: item.status === 1
? '#F83D3D'
: item.status === 2
? '#333333'
: '#9C9C9C',
}"
>{{
item.status === 0
? "待付款"
? '待付款'
: item.status === 1
? "待使用"
? '待使用'
: item.status === 2
? "已使用"
: "已失效"
? '已使用'
: '已失效'
}}
</view>
</view>
@@ -233,43 +255,50 @@ const getTj = async () => {
<view class="center" v-for="(itm, idx) in item.OrderGoods" :key="idx">
<view class="top">
<image :src="itm.Goods.cover" />
<view class="title">{{ itm.Goods?.name }}</view>
<view class="flex flex-col justify-between flex-1">
<view class="title">{{ itm.Goods?.name }}</view>
<view class="text-[#F83D3D] mt-5">
<view>{{ itm.pay_price }}</view>
<view>{{ itm.pay_integral }}积分</view>
</view>
</view>
<view class="right">
<view>{{ itm.pay_price }}</view>
<view>{{ itm.pay_integral }}积分</view>
<view>x{{ itm.number }}</view>
</view>
</view>
</view>
<view class="line"></view>
<view v-if="item.status !== 0" style="text-align: right">
<text>{{ item.count }}件商品</text>,
<!-- <view class="line"></view> -->
<view
class="flex justify-between items-center mt-2 mb-2 text-[25px]"
v-if="item.status !== 0"
style="text-align: right">
<text class="text-[#9C9C9C]">{{ item.count }}件商品</text>
<text
>实付款:{{ item.pay_type === 1 ? item.price : item.exchange }},{{
item.pay_type === 1 ? "微信支付" : "积分支付"
}}</text
>{{ item.status !== 0 ? '实' : '应' }}付款{{
item.pay_type === 1 ? '(元): ' : '(积分): '
}}{{ item.pay_type === 1 ? item.price : item.exchange }}</text
>
<view class="line"></view>
<!-- <view class="line"></view> -->
</view>
<view class="btn">
<nut-button
v-if="item.status === 0"
plain
size="small"
size="mini"
type="primary"
@click="delOrder(item.oid)"
>取消订单
</nut-button>
<nut-button
<!-- <nut-button
style="margin-left: 5px"
size="small"
size="mini"
type="primary"
@click="toDetail(item)"
>查看详情
</nut-button>
</nut-button> -->
<nut-button
style="margin-left: 5px"
size="small"
size="mini"
type="primary"
v-if="item.status === 0"
@click="openPay(item)"
@@ -286,8 +315,7 @@ const getTj = async () => {
:OrderType="2"
@errPay="errPay"
@successPay="successPay"
@closePay="closePay"
/>
@closePay="closePay" />
</view>
</template>
@@ -309,8 +337,8 @@ page {
align-items: center;
image {
width: 150px;
height: 150px;
width: 200px;
height: 200px;
}
}
@@ -319,20 +347,20 @@ page {
flex-direction: row;
justify-content: space-between;
align-items: center;
height: auto;
background-color: #fff;
padding: 0 20px;
padding: 20px 20px 0 20px;
text-align: center;
.text {
margin: 10px 20px;
// margin: 10px 20px;
align-items: center;
font-size: 25px;
}
.line {
margin: 0 auto;
margin: 10px auto;
width: 50px;
height: 5px;
height: 10px;
border-radius: 30px;
transition: all 0.3s ease-in-out;
}
@@ -370,20 +398,20 @@ page {
}
.center {
margin-bottom: 10px;
// margin-bottom: 10px;
.top {
display: flex;
justify-content: space-between;
// align-items: flex-start;
// justify-content: space-between;
align-items: flex-start;
image {
width: 150rpx;
height: 150rpx;
border-radius: 10rpx;
width: 150px;
height: 150px;
border-radius: 15px;
margin-right: 10px;
}
.title {
margin-left: 10px;
display: -webkit-box;
overflow: hidden;
-webkit-line-clamp: 2;
@@ -396,6 +424,7 @@ page {
margin-left: 10px;
font-size: 28px;
text-align: right;
color: #9c9c9c;
}
}
}

View File

@@ -1,79 +1,142 @@
<template>
<view>
<view class="p-4">
<!-- 步骤条 -->
<view class="step-bar">
<!-- <view class="step-bar">
<view
class="item"
v-for="item in statusList"
:key="item.id"
:class="{ activation: item.id === goodInfo.status }"
>
:class="{activation: item.id === goodInfo.status}">
<view class="text">{{ item.text }}</view>
<view class="dot"></view>
</view>
</view>
<view v-if="goodInfo.status === 1" class="timeBox">
</view> -->
<!-- <view v-if="goodInfo.status === 1" class="timeBox">
订单剩余{{ timeStr }}过期,请尽快核销
</view> -->
<view class="mb-3">
<view v-if="goodInfo.status === 0">
<view class="flex text-[#333333] items-center mb-1">
<view class="font-bold">订单待付款</view>
<IconFont name="rect-right" size="15" color="#333333"></IconFont>
</view>
<view class="text-[#9C9C9C] text-[20px]">订单未支付请付款</view>
</view>
<view v-if="goodInfo.status === 1">
<view class="flex text-[#333333] items-center mb-1">
<view class="font-bold">订单待使用</view>
<IconFont name="rect-right" size="15" color="#333333"></IconFont>
</view>
<view class="text-[#9C9C9C] text-[20px]"
>订单剩余<text class="text-[#FF0000]">{{ timeStr }}</text
>过期请尽快核销</view
>
</view>
<view v-if="goodInfo.status === 2">
<view class="flex text-[#333333] items-center mb-1">
<view class="font-bold">订单已使用</view>
<IconFont name="rect-right" size="15" color="#333333"></IconFont>
</view>
<view class="text-[#9C9C9C] text-[20px]">订单已核销欢迎下次光临</view>
</view>
<view v-if="goodInfo.status === 3">
<view class="flex text-[#333333] items-center mb-1">
<view class="font-bold">订单失效</view>
<IconFont name="rect-right" size="15" color="#333333"></IconFont>
</view>
<view class="text-[#9C9C9C] text-[20px]">未核销已失效</view>
</view>
</view>
<!-- 商家信息 -->
<view class="mer-info">
<view class="left">
<view>
<text>{{ goodInfo.Store?.name }}</text>
<text>{{ goodInfo.Store?.phone }}</text>
</view>
<nut-ellipsis
:rows="2"
:content="goodInfo.Store?.address"
direction="end"
></nut-ellipsis>
</view>
<image
class="w-[150px] h-[150px] rounded-lg mr-2"
:src="goodInfo.Store?.head_photo" />
<view class="right">
<view class="icon" @click="toPhone">
<Service />
<text>电话</text>
<view class="text-[#333333]">{{ goodInfo.Store?.name }}</view>
<view
class="flex mt-2 items-center text-[#999999] text-[23px] text-ellipsis line-clamp-3">
<view
style="font-size: 15px"
class="iconfont icon-dizhi text-[#C4C4C4]"></view>
<view>{{ goodInfo.Store?.address }}</view>
</view>
<view class="icon" @click="toAdder">
<Find />
<text>导航</text>
<view class="w-full flex items-center justify-between mt-1">
<view class="ml-3 text-[23px] text-[#999999]"
>距离您{{
calculateDistance(
userLocalNum.t,
userLocalNum.l,
Number(goodInfo.Store?.lat),
Number(goodInfo.Store?.lon),
)
}}
</view>
<view class="flex items-center">
<image
@tap="toPhone()"
class="w-[50px] h-[50px]"
src="http://p0.meituan.net/csc/ab0493b124a6bb858bf82a2340767c0d919.png" />
<image
@tap="toAdder()"
class="w-[50px] h-[50px] ml-2"
src="http://p1.meituan.net/csc/92ee8512c90527169b44e07fd11d250d924.png" />
</view>
</view>
</view>
</view>
<!-- 订单信息 -->
<nut-cell-group>
<nut-cell :title="`共${goodInfo.count}件商品`"></nut-cell>
<nut-cell>
<template #default>
<view class="center-box">
<view
class="top"
v-for="(item, index) in goodInfo.OrderGoods"
:key="index"
>
:key="index">
<image :src="item.Goods?.cover" />
<view class="title">{{ item.Goods?.name }} </view>
<view class="flex flex-col justify-between flex-1">
<view class="title">{{ item.Goods?.name }}</view>
<view class="text-[#F83D3D] mt-5">
<view>{{ item.pay_price }}</view>
<view>{{ item.pay_integral }}积分</view>
</view>
</view>
<view class="right">
<view>{{ item.pay_price }}</view>
<view>{{ item.pay_integral }}积分</view>
<view>x{{ item.number }}</view>
</view>
</view>
<view
class="flex justify-between items-center mt-2 mb-2 text-[25px]">
<view class="text-[#9C9C9C]">{{
`${goodInfo.count}件商品`
}}</view>
<text
>{{ goodInfo.status !== 0 ? '实' : '应' }}付款{{
goodInfo.pay_type === 1 ? '(元): ' : '(积分): '
}}{{
goodInfo.pay_type === 1 ? goodInfo.price : goodInfo.exchange
}}</text
>
</view>
</view>
</template>
</nut-cell>
</nut-cell-group>
<nut-cell-group>
<nut-cell title="订单号:" :desc="goodInfo.oid"></nut-cell>
<nut-cell
title="下单时间:"
:desc="goodInfo.add_time?.slice(0, 19)"
></nut-cell>
<nut-cell
:desc="goodInfo.add_time?.slice(0, 19)"></nut-cell>
<!-- <nut-cell
v-if="goodInfo.expires !== 0"
title="订单过期时间:"
:desc="dayjs.unix(goodInfo.expires).format('YYYY-MM-DD HH:mm:ss')"
></nut-cell>
:desc="
dayjs.unix(goodInfo.expires).format('YYYY-MM-DD HH:mm:ss')
"></nut-cell> -->
<nut-cell
title="支付状态:"
title="订单状态:"
:desc="
goodInfo.status === 0
? '待付款'
@@ -82,38 +145,36 @@
: goodInfo.status === 2
? '已使用'
: '已失效'
"
></nut-cell>
<!-- <nut-cell
:title="`商品总价(${type === '1' ? '元' : '积分'}):`"
:desc="goodInfo.number"
>
</nut-cell> -->
<nut-cell v-if="goodInfo.status !== 0">
<template #default>
<view style="text-align: right; width: 100%">
<view
>实付款({{ goodInfo.pay_type === 1 ? "微信" : "积分" }})
<nut-price
:price="
goodInfo.pay_type === 1 ? goodInfo.price : goodInfo.exchange
"
size="normal"
:need-symbol="false"
/>
</view>
</view>
</template>
</nut-cell>
"></nut-cell>
</nut-cell-group>
<view class="btn">
<!-- <nut-button
<view class="mt-[30px] m-auto">
<nut-button
v-if="goodInfo.status === 0"
shape="square"
type="primary"
block
@click="openPay()"
>继续付款</nut-button
>
<nut-button
v-if="goodInfo.status === 1"
shape="square"
type="primary"
block
@click="openCode()"
>出示核销码</nut-button
>
</view>
<!-- <view class="btn">
<nut-button
plain
v-if="goodInfo.status === 0"
size="small"
type="primary"
>取消订单
</nut-button> -->
</nut-button>
<nut-button
v-if="goodInfo.status === 0"
style="margin-left: 5px"
@@ -130,19 +191,19 @@
@click="openCode()"
>出示核销码
</nut-button>
</view>
</view> -->
<!-- 核销码弹窗 -->
<nut-popup
v-model:visible="isShowCode"
position="bottom"
:style="{ height: 'auto' }"
position="center"
style="padding: 20px; border-radius: 15px"
:maskClosable="true"
safe-area-inset-bottom
@closed="closed"
>
@click-overlay="closed"
@closed="closed">
<view class="code-box">
<view>请出示核销码核销</view>
<view>核销码</view>
<image class="qrcode" :src="url"></image>
</view>
</nut-popup>
@@ -153,58 +214,70 @@
:OrderType="2"
@errPay="errPay"
@successPay="successPay"
@closePay="closePay"
/>
@closePay="closePay" />
</view>
</template>
<script setup lang="ts">
import Taro from "@tarojs/taro";
import { Find, Service } from "@nutui/icons-vue-taro";
import { ref } from "vue";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import Pay from "@/components/Pay.vue";
import { getUserPoint } from "@/api/admin";
import Taro from '@tarojs/taro';
import {onUnmounted, ref} from 'vue';
import dayjs from 'dayjs';
import duration from 'dayjs/plugin/duration';
import Pay from '@/components/Pay.vue';
import {getUserPoint} from '@/api/admin';
import {calculateDistance} from '@/utils';
import {IconFont} from '@nutui/icons-vue-taro';
import {getActiveOrderDetail} from '@/api/goods';
dayjs.extend(duration);
const goodInfo = ref<any>({});
const statusList = ref([
{
id: 0,
text: "待付款",
},
{
id: 1,
text: "待使用",
},
{
id: 2,
text: "已使用",
},
{
id: 3,
text: "已失效",
},
]);
const userLocalNum = ref({
l: 0,
t: 0,
});
const isShowCode = ref(false);
const isShowPay = ref(false);
const jfInfo = ref<any>({});
const type = ref("");
const type = ref('');
const url = ref("");
const url = ref('');
Taro.useLoad((options) => {
const oid = ref('');
Taro.useLoad(options => {
type.value = options.type;
goodInfo.value = Taro.getStorageSync("item");
oid.value = options.orderId;
Taro.getLocation({
type: 'wgs84',
success: res => {
userLocalNum.value.l = res.longitude;
userLocalNum.value.t = res.latitude;
},
});
// goodInfo.value = Taro.getStorageSync('item');
getOrderDetail();
});
const getOrderDetail = async () => {
const res = await getActiveOrderDetail({
oid: oid.value,
});
goodInfo.value = res.data.data;
if (goodInfo.value.status === 1) {
startTime();
}
});
if (goodInfo.value.status === 2 && isShowCode.value) {
Taro.showToast({
title: '订单核销完成',
icon: 'none',
});
}
};
const toPhone = () => {
Taro.makePhoneCall({
@@ -222,23 +295,23 @@ const toAdder = () => {
const openPay = async () => {
isShowPay.value = true;
const mer_info = Taro.getStorageSync("mer_info");
const user_info = Taro.getStorageSync("userInfo");
const mer_info = Taro.getStorageSync('mer_info');
const user_info = Taro.getStorageSync('userInfo');
const data = await getUserPoint({
phone: user_info.data.phone,
bid: mer_info.bid,
});
jfInfo.value = {
jh_info: data.data,
oid: Taro.getStorageSync("item").oid,
oid: Taro.getStorageSync('item').oid,
};
};
const successPay = (val: boolean) => {
isShowPay.value = val;
Taro.showToast({
title: "支付成功",
icon: "none",
title: '支付成功',
icon: 'none',
});
Taro.navigateBack({
delta: 1,
@@ -248,33 +321,40 @@ const successPay = (val: boolean) => {
const errPay = () => {
isShowPay.value = false;
Taro.showToast({
title: "支付失败",
icon: "none",
title: '支付失败',
icon: 'none',
});
jfInfo.value = {};
};
const closePay = () => {
isShowPay.value = false;
Taro.showToast({
title: "支付取消",
icon: "none",
title: '支付取消',
icon: 'none',
});
jfInfo.value = {};
};
const t_id = ref();
const openCode = () => {
url.value = `https://api.pwmqr.com/qrcode/create?url=${goodInfo.value.oid}`;
isShowCode.value = true;
if (goodInfo.value.status === 2) return;
t_id.value = setInterval(() => {
getOrderDetail();
}, 1000);
};
const closed = () => {
isShowCode.value = false;
url.value = "";
url.value = '';
clearInterval(t_id.value);
};
let timeId: any;
const timeStr = ref("????");
const timeStr = ref('????');
const startTime = () => {
const nowTime = dayjs();
@@ -284,10 +364,10 @@ const startTime = () => {
const duration = dayjs.duration(endTime.diff(nowTime));
// 格式化剩余时间
timeStr.value = duration.format("D天H小时m分钟s秒");
timeStr.value = duration.format('D天H小时m分钟s秒');
if (goodInfo.value.expires - dayjs().unix() > 0) {
clearInterval(timeId);
clearTimeout(timeId);
timeId = setTimeout(() => {
startTime();
}, 1000);
@@ -296,6 +376,17 @@ const startTime = () => {
Taro.useUnload(() => {
clearTimeout(timeId);
clearInterval(t_id.value);
});
Taro.useDidHide(() => {
clearTimeout(timeId);
clearInterval(t_id.value);
});
onUnmounted(() => {
clearTimeout(timeId);
clearInterval(t_id.value);
});
</script>
@@ -349,7 +440,7 @@ page {
position: relative;
&::before {
content: "";
content: '';
width: 15px;
height: 15px;
border-radius: 50%;
@@ -365,43 +456,20 @@ page {
.mer-info {
background-color: white;
padding: 20px 30px;
padding: 15px;
margin-top: 10px;
width: 100%;
box-sizing: border-box;
display: flex;
justify-content: space-between;
justify-content: space-betweenhh;
align-items: center;
.left {
width: 50%;
text {
margin-right: 10px;
}
.address {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
display: -webkit-box;
-webkit-line-clamp: 1;
}
}
border-radius: 15px;
.right {
color: #858585;
text-align: center;
display: flex;
flex-direction: column;
height: 120px;
justify-content: space-between;
.icon {
display: flex;
align-items: center;
//margin-bottom: 20px;
}
width: 70%;
}
}
@@ -435,6 +503,7 @@ page {
width: 150px;
height: 150px;
border-radius: 10rpx;
margin-right: 10px;
}
.title {
@@ -466,4 +535,8 @@ page {
width: 300px;
height: 300px;
}
.nut-button {
border-radius: 20px;
}
</style>

View File

@@ -21,7 +21,8 @@ page {
.tabs {
display: flex;
justify-content: space-between;
margin: 20px 30px;
padding: 20px;
background-color: #ffffff;
.item {
display: flex;
@@ -71,8 +72,8 @@ page {
margin: 20px;
image {
width: 195px;
height: 195px;
width: 150px;
height: 150px;
border-radius: 12px;
}

View File

@@ -17,21 +17,18 @@
class="item"
v-for="item in tabs"
:key="item.value"
@click="changeTabs(item.value)"
>
@click="changeTabs(item.value)">
<text>{{ item.text }}</text>
<view
class="line"
:class="tabsIndex == item.value ? 'active' : ''"
></view>
:class="tabsIndex == item.value ? 'active' : ''"></view>
</view>
</view>
<view v-if="listData.length > 0">
<view
class="card"
v-for="(item, index) in (listData as any[])"
:key="index"
>
:key="index">
<view class="header">
<view>
<text>台号: {{ item.seat }}</text>
@@ -50,11 +47,12 @@
<view
class="goods-list"
v-for="(itm, idx) in item.OrderGoods"
:key="idx"
>
:key="idx">
<image :src="itm.Goods.cover"></image>
<view class="center">
<nut-ellipsis direction="end" :content="itm.Goods.name"></nut-ellipsis>
<nut-ellipsis
direction="end"
:content="itm.Goods.name"></nut-ellipsis>
<!-- <view class="title">{{ itm.Goods.name }}</view> -->
</view>
<view class="num">
@@ -76,29 +74,29 @@
</template>
<script setup lang="ts">
import { ref } from "vue";
import Taro from "@tarojs/taro";
import { getUserAfterOrderList } from "../../../api/user";
import {ref} from 'vue';
import Taro from '@tarojs/taro';
import {getUserAfterOrderList} from '../../../api/user';
const tabsIndex = ref(0);
const listData = ref([]);
const listData = ref<any[]>([]);
const tabs = ref([
{
text: "全部",
text: '全部',
value: 0,
},
{
text: "未付款",
text: '未付款',
value: 1,
},
{
text: "挂帐中",
text: '挂帐中',
value: 3,
},
{
text: "已收款",
text: '已收款',
value: 2,
},
]);
@@ -112,48 +110,66 @@ const changeTabs = (index: number) => {
get_list();
};
const pageOpt = ref({
page: 1,
total: 0,
});
const get_list = async () => {
Taro.showLoading({
title: "加载中",
title: '加载中',
});
const user_info = await Taro.getStorageSync("userInfo");
const { data: res } = await getUserAfterOrderList({
const user_info = await Taro.getStorageSync('userInfo');
const {data: res} = await getUserAfterOrderList({
phone: user_info.data.phone,
status: tabsIndex.value,
PageNum: pageOpt.value.page,
PageSize: 10,
});
listData.value = res.data || [];
listData.value.push(...res.data);
pageOpt.value.total = res.total || 0;
Taro.hideLoading();
};
const get_color = (status: number) => {
switch (status) {
case 0:
return "#FD0100";
return '#FD0100';
case 1:
return "#03A113";
return '#03A113';
case 2:
return "#FFA938";
return '#FFA938';
}
};
const get_status_text = (status: number) => {
switch (status) {
case 0:
return "未付款";
return '未付款';
case 1:
return "已付款";
return '已付款';
case 2:
return "挂帐中";
return '挂帐中';
}
};
const to_page = (item) => {
const to_page = item => {
Taro.navigateTo({
url: `/pages/users/pending_order/pending_order_detail/index?bid=${item.bid}&oid=${item.oid}`,
});
};
Taro.useReachBottom(() => {
if (pageOpt.value.total === listData.value.length)
return Taro.showToast({
title: '没有更多数据了',
icon: 'none',
});
pageOpt.value.page++;
get_list();
});
</script>
<style lang="scss">
@import "./index.scss";
@import './index.scss';
</style>

View File

@@ -1,12 +1,37 @@
<script lang="ts" setup>
import Taro from "@tarojs/taro";
import Taro from '@tarojs/taro';
const toPage = (url: string) => {
if (url === "1") return Taro.showToast({ title: "暂未开放", icon: "none" });
if (url === '1') return Taro.showToast({title: '暂未开放', icon: 'none'});
Taro.navigateTo({
url: url,
});
};
const logOut = () => {
Taro.showModal({
title: '提示',
content: '确定退出登录吗?',
success: function (res) {
if (res.confirm) {
Taro.removeStorageSync('token');
Taro.removeStorageSync('userInfo');
Taro.removeStorageSync('mer_type');
Taro.reLaunch({
url: '/pages/index/index',
});
} else if (res.cancel) {
console.log('用户点击取消');
}
},
});
};
const clickText = (type: number, text: string) => {
Taro.navigateTo({
url: `/pages/users/user_agreement/index?type=${type}&name=${text}`,
});
};
</script>
<template>
@@ -15,13 +40,24 @@ const toPage = (url: string) => {
<nut-cell
title="个人信息"
is-link
@click="toPage('/pages/users/user_setting/index')"
></nut-cell>
<!-- <nut-cell title="关于我们" is-link @click="toPage('1')"></nut-cell>
<nut-cell title="资质证明" is-link @click="toPage('1')"></nut-cell>
<nut-cell title="协议规则" is-link @click="toPage('1')"></nut-cell>
<nut-cell title="隐私设置" is-link @click="toPage('1')"></nut-cell> -->
@click="toPage('/pages/users/user_setting/index')"></nut-cell>
<nut-cell title="服务协议" is-link @click="clickText(1, '用户协议')"></nut-cell>
<nut-cell title="隐私政策协议" is-link @click="clickText(2, '隐私政策')"></nut-cell>
<nut-cell
title="平台积分使用规则"
is-link
@click="clickText(3, '积分使用规则')"></nut-cell>
</nut-cell-group>
<view class="w-[90%] m-auto">
<nut-button
block
type="primary"
shape="square"
style="border-radius: 10px"
@click="logOut"
>退出登录</nut-button
>
</view>
</view>
</template>

View File

@@ -1,45 +1,25 @@
<script lang="ts" setup>
import Taro from "@tarojs/taro";
import { ref } from "vue";
import { editPersonalInfo } from "@/api/user";
import { View } from "@tarojs/components";
import { BASE_URL } from "@/utils/request";
import Taro from '@tarojs/taro';
import {ref} from 'vue';
import {editPersonalInfo} from '@/api/user';
import {BASE_URL} from '@/utils/request';
// const toPage = (e: string) => {};
const userInfo = ref<any>({});
Taro.useLoad(() => {
const { data: data } = Taro.getStorageSync("userInfo");
const {data: data} = Taro.getStorageSync('userInfo');
userInfo.value = data;
});
const logOut = () => {
Taro.showModal({
title: "提示",
content: "确定退出登录吗?",
success: function (res) {
if (res.confirm) {
Taro.removeStorageSync("token");
Taro.removeStorageSync("userInfo");
Taro.removeStorageSync("mer_type");
Taro.reLaunch({
url: "/pages/index/index",
});
} else if (res.cancel) {
console.log("用户点击取消");
}
},
});
};
const chooseavatar = (e: any) => {
Taro.uploadFile({
url: `${BASE_URL}/upload`,
filePath: e.detail.avatarUrl,
name: "file",
name: 'file',
header: {
token: Taro.getStorageSync("token"),
token: Taro.getStorageSync('token'),
},
success: function (res) {
const data = JSON.parse(res.data);
@@ -53,65 +33,48 @@ const subUser = async () => {
const reg = /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/;
if (!reg.test(userInfo.value.phone))
return Taro.showToast({
title: "请输入正确的手机号码",
icon: "none",
title: '请输入正确的手机号码',
icon: 'none',
});
const res = await editPersonalInfo(userInfo.value);
Taro.showToast({
title: res.msg,
icon: "none",
icon: 'none',
});
Taro.switchTab({
url: "/pages/user/index",
url: '/pages/user/index',
});
} catch (error) {
Taro.showToast({
title: error.msg,
icon: "none",
icon: 'none',
});
}
};
// const getUserInfo = async () => {
// try {
// const res = await getPersonalInfo();
// userInfo.value = res.data.data;
// } catch (error) {
// Taro.showToast({
// title: error.msg,
// icon: "none",
// });
// }
// };
</script>
<template>
<view class="app">
<view class="user-card">
<view>管理我的账号</view>
<!-- {{ userInfo }} -->
<view class="avatar-card">
<view class="left">
<nut-button open-type="chooseAvatar" @chooseavatar="chooseavatar">
<nut-cell-group>
<nut-cell title="头像">
<template v-slot:link>
<nut-button
style="border: none; height: auto; padding: 0"
open-type="chooseAvatar"
@chooseavatar="chooseavatar">
<nut-avatar size="large">
<img style="border-radius: 50%" :src="userInfo.avatarUrl" />
</nut-avatar>
</nut-button>
<view class="name">{{ userInfo.nickName }}</view>
</view>
</view>
</view>
<nut-cell-group>
<!-- :desc="userInfo.nickName" -->
</nut-button> </template
></nut-cell>
<nut-cell title="昵称">
<template v-slot:link>
<nut-input
type="nickname"
v-model="userInfo.nickName"
:border="false"
input-align="right"
placeholder="请输入昵称"
/> </template
placeholder="请输入昵称" /> </template
></nut-cell>
<nut-cell title="手机号码">
<template v-slot:link>
@@ -119,27 +82,30 @@ const subUser = async () => {
v-model="userInfo.phone"
:border="false"
input-align="right"
disabled
/>
disabled />
</template>
</nut-cell>
<nut-cell title="登录密码">
<!-- <nut-cell title="登录密码">
<template v-slot:link>
<nut-input
v-model="userInfo.password"
:border="false"
input-align="right"
placeholder="修改登录密码"
/>
placeholder="修改登录密码" />
</template>
</nut-cell>
<nut-cell title="注销账号" desc="账号注销后不能恢复" is-link> </nut-cell>
</nut-cell> -->
<nut-cell title="交易密码" desc="创建/修改交易密码" is-link> </nut-cell>
<!-- <nut-cell title="注销账号" desc="账号注销后不能恢复" is-link> </nut-cell> -->
</nut-cell-group>
<view class="btn">
<nut-button block @click="subUser">保存信息</nut-button>
</view>
<view class="btn">
<nut-button block type="primary" @click="logOut">退出登录</nut-button>
<nut-button
shape="square"
style="border-radius: 10px"
type="primary"
block
@click="subUser"
>保存信息</nut-button
>
</view>
</view>
</template>