This commit is contained in:
parent
39f8eeeff6
commit
2d92c6594c
|
@ -1,5 +1,5 @@
|
|||
NODE_ENV = 'development'
|
||||
# 邮储奶茶活动
|
||||
VITE_BASE_URL = 'http://milk.test.api.cdlsxd.cn'
|
||||
VITE_BASE_URL = 'http://milk.h5.test.86698.cn'
|
||||
# 邮储音视频
|
||||
# VITE_BASE_URL = 'https://gateway.dev.cdlsxd.cn/ycav'
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
NODE_ENV = 'test'
|
||||
|
||||
# 邮储奶茶活动(测试环境)
|
||||
VITE_BASE_URL = 'http://milk.test.api.cdlsxd.cn'
|
||||
# VITE_BASE_URL = 'http://milk.h5.test.86698.cn'
|
||||
VITE_BASE_URL = ''
|
||||
VITE_YCNC_MERCH_CODE = '100310100018908'
|
||||
|
||||
|
||||
|
|
|
@ -16,16 +16,15 @@
|
|||
<body>
|
||||
<div id="app"><!--app-html--></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
<script src="./static/YT_Client_api.js"></script>
|
||||
<script>
|
||||
<!-- <script>
|
||||
document.addEventListener('touchmove', function(e) {
|
||||
e.preventDefault();
|
||||
}, {passive: false})
|
||||
</script>
|
||||
<!-- <script src="https://fastly.jsdelivr.net/npm/eruda"></script>
|
||||
</script> -->
|
||||
<script src="https://fastly.jsdelivr.net/npm/eruda"></script>
|
||||
<script>
|
||||
eruda.init()
|
||||
</script> -->
|
||||
</script>
|
||||
<script>
|
||||
// var clickCount = 0
|
||||
// var timer = null
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"type": "home",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "奶茶活动",
|
||||
"navigationBarTitleText": "奶茶专区",
|
||||
"navigationBarBackgroundColor": "#FFF"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<template>
|
||||
<wd-navbar :title="title" custom-style="background-color: transparent !important;" left-arrow></wd-navbar>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, unref, onMounted} from 'vue';
|
||||
const props = defineProps({
|
||||
title:{
|
||||
type:String,
|
||||
default:''
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
|
@ -12,7 +12,7 @@
|
|||
<view class="w-full h-full flex flex-col">
|
||||
<scroll-view scroll-y class="w-full h-full overflow-y-auto flex-1">
|
||||
<view class="container">
|
||||
<image class="banner" :src="detailObj.main_image" @click="testEvent"></image>
|
||||
<image class="banner" :src="detailObj.main_image"></image>
|
||||
<view class="detail flex flex-col flex-justify-between">
|
||||
<view class="proname">{{ detailObj.name }}</view>
|
||||
<view class="num">
|
||||
|
@ -44,11 +44,9 @@
|
|||
import { onMounted, reactive, ref, unref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { queryDetail, goPay, login } from '../../api/ycnc';
|
||||
import usePay from './hooks/usePay';
|
||||
import useCode from './hooks/useCode';
|
||||
import { getQueryString } from '../../utils/utils'
|
||||
|
||||
const id = ref('')
|
||||
const authCode = ref('');
|
||||
|
||||
const detailObj = reactive({})
|
||||
|
||||
|
@ -71,47 +69,18 @@
|
|||
}
|
||||
|
||||
const toPay = async () => {
|
||||
const token = window.localStorage.getItem('token') || '';
|
||||
if(!token){
|
||||
const code = await useCode();
|
||||
authCode.value = code
|
||||
const {token} = await login({params:{code:unref(authCode)}});
|
||||
window.localStorage.setItem('token',token);
|
||||
}
|
||||
const token = getQueryString('token') || uni.getStorageSync('token');
|
||||
uni.setStorageSync('token',token)
|
||||
const params = {
|
||||
product_id:unref(id)
|
||||
}
|
||||
goPay({params}).then(res => {
|
||||
const {order_no,notify_url,sign,plain_text} = res;
|
||||
const {payFunc} = usePay();
|
||||
payFunc({order_no,notify_url,TranAmt:detailObj.price,MerName:detailObj.brand,sign,plain_text})
|
||||
const {order_no,notify_url,sign,plain_text,pay_url} = res;
|
||||
window.location.replace(pay_url)
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
|
||||
var clickCount = 0
|
||||
var timer = null
|
||||
const testEvent = () => {
|
||||
if (clickCount < 6) {
|
||||
clickCount++
|
||||
console.log(`Clicked ${clickCount} times`)
|
||||
|
||||
// 如果是第一次点击,则开始计时
|
||||
if (clickCount === 1) {
|
||||
timer = setTimeout(() => {
|
||||
clickCount = 0 // 重置点击计数
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
// 如果点击次数达到6次,则清除计时器并重置状态
|
||||
if (clickCount >= 6) {
|
||||
clearTimeout(timer)
|
||||
clickCount = 0 // 重置点击计数
|
||||
window.location.href = 'https://22233.cn/AAALM4HwLrAfdSCx'
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
|
|
|
@ -1,145 +1,142 @@
|
|||
<route lang="json5" type="home">
|
||||
{
|
||||
{
|
||||
style: {
|
||||
navigationStyle: 'custom',
|
||||
navigationBarTitleText: '奶茶活动',
|
||||
navigationBarBackgroundColor:'#FFF',
|
||||
navigationStyle: "custom",
|
||||
navigationBarTitleText: "奶茶专区",
|
||||
navigationBarBackgroundColor: "#FFF",
|
||||
},
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
<template>
|
||||
<scroll-view scroll-y class="page-wrapper">
|
||||
<view class="nav-btn" @click="toOrder">我的订单</view>
|
||||
<!-- <view style="opacity: 0;width: 100%;height:200rpx;position:absolute;top:230rpx" @click="test"></view> -->
|
||||
<view class="wrapper flex flex-col flex-items-center box-border">
|
||||
<view v-for="(item,key) in productList" :key="key">
|
||||
<brand :products="item" :brandName="key"/>
|
||||
<view v-for="(item, key) in productList" :key="key">
|
||||
<brand :products="item" :brandName="key" />
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import brand from './components/brand';
|
||||
import { getProductList, goPay, login } from '../../api/ycnc'
|
||||
import { onMounted, ref, provide, unref } from 'vue';
|
||||
// import { getQueryString , isIOS, isAndroid } from '../../utils/utils';
|
||||
import useCode from './hooks/useCode';
|
||||
import usePay from './hooks/usePay';
|
||||
import config from './config';
|
||||
const productList = ref([]);
|
||||
const authCode = ref('');
|
||||
import brand from "./components/brand";
|
||||
import { getProductList, goPay, login } from "../../api/ycnc";
|
||||
import { onMounted, ref, provide, unref } from "vue";
|
||||
import { getQueryString, getQueryParams } from "../../utils/utils";
|
||||
import config from "./config";
|
||||
const productList = ref([]);
|
||||
|
||||
const handleBuy = (productData) => {
|
||||
pay(productData)
|
||||
}
|
||||
const handleBuy = (productData) => {
|
||||
pay(productData);
|
||||
};
|
||||
|
||||
const goDetail = (productData) => {
|
||||
const {ProductId} = productData
|
||||
const goDetail = (productData) => {
|
||||
const { ProductId } = productData;
|
||||
uni.navigateTo({
|
||||
url:`/pages/ycnc/detail?product_id=${ProductId}`
|
||||
})
|
||||
}
|
||||
|
||||
const pay = (productData) => {
|
||||
const {ProductId,voucherAmount,brandFlag} = productData
|
||||
console.log('商品数据',productData);
|
||||
const params = {
|
||||
product_id:ProductId
|
||||
}
|
||||
goPay({params}).then(res => {
|
||||
const {order_no,notify_url,sign,plain_text} = res;
|
||||
const {payFunc} = usePay();
|
||||
payFunc({order_no,notify_url,TranAmt:voucherAmount,MerName:config[brandFlag].name,sign,plain_text})
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
|
||||
provide('custom-events',{
|
||||
handleBuy,
|
||||
goDetail
|
||||
})
|
||||
|
||||
const toOrder = () => {
|
||||
uni.navigateTo({
|
||||
url:'/pages/ycnc/order'
|
||||
})
|
||||
};
|
||||
|
||||
onMounted(async ()=>{
|
||||
queryProducts();
|
||||
const token = window.localStorage.getItem('token') || '';
|
||||
if(!token){
|
||||
const code = await useCode();
|
||||
authCode.value = code
|
||||
const {token} = await login({params:{code:unref(authCode)}});
|
||||
window.localStorage.setItem('token',token);
|
||||
}
|
||||
url: `/pages/ycnc/detail?product_id=${ProductId}`,
|
||||
});
|
||||
};
|
||||
|
||||
function handleData(arg,args){
|
||||
return arg.reduce((total,current) =>{
|
||||
const flag = current.brandFlag;
|
||||
const flagData = args.filter(item => item.brandFlag === flag)
|
||||
if(Array.isArray(total[flag])){
|
||||
total[flag].push(...flagData)
|
||||
}else{
|
||||
total[flag] = [...flagData]
|
||||
}
|
||||
return total
|
||||
},{})
|
||||
}
|
||||
|
||||
//查询品牌,商品接口
|
||||
const queryProducts = () => {
|
||||
const params = {GID:'4894651'}
|
||||
getProductList({params}).then(res => {
|
||||
const {milkList,
|
||||
milkVoucherList} = res
|
||||
const sortMilkList = milkList.sort((a,b)=>{
|
||||
const orderA = config[a.brandFlag] ? config[a.brandFlag].order : Infinity;
|
||||
const orderB = config[b.brandFlag] ? config[b.brandFlag].order : Infinity;
|
||||
return orderA - orderB
|
||||
const pay = (productData) => {
|
||||
const { ProductId, voucherAmount, brandFlag } = productData;
|
||||
const params = {
|
||||
product_id: ProductId,
|
||||
};
|
||||
goPay({ params })
|
||||
.then((res) => {
|
||||
const { order_no, notify_url, sign, plain_text, pay_url } = res;
|
||||
window.location.replace(pay_url);
|
||||
})
|
||||
productList.value = handleData(sortMilkList,milkVoucherList);
|
||||
}).catch(err=>{
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
provide("custom-events", {
|
||||
handleBuy,
|
||||
goDetail,
|
||||
});
|
||||
|
||||
const toOrder = () => {
|
||||
uni.navigateTo({
|
||||
url: "/pages/ycnc/order",
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
queryProducts();
|
||||
console.log(
|
||||
"url中所有查询参数---》》》",
|
||||
getQueryParams(window.location.href)
|
||||
);
|
||||
const token = getQueryString("token");
|
||||
uni.setStorageSync("token", token);
|
||||
});
|
||||
|
||||
function handleData(arg, args) {
|
||||
return arg.reduce((total, current) => {
|
||||
const flag = current.brandFlag;
|
||||
const flagData = args.filter((item) => item.brandFlag === flag);
|
||||
if (Array.isArray(total[flag])) {
|
||||
total[flag].push(...flagData);
|
||||
} else {
|
||||
total[flag] = [...flagData];
|
||||
}
|
||||
return total;
|
||||
}, {});
|
||||
}
|
||||
|
||||
//查询品牌,商品接口
|
||||
const queryProducts = () => {
|
||||
const params = { GID: "4894651" };
|
||||
getProductList({ params })
|
||||
.then((res) => {
|
||||
const { milkList, milkVoucherList } = res;
|
||||
const sortMilkList = milkList.sort((a, b) => {
|
||||
const orderA = config[a.brandFlag]
|
||||
? config[a.brandFlag].order
|
||||
: Infinity;
|
||||
const orderB = config[b.brandFlag]
|
||||
? config[b.brandFlag].order
|
||||
: Infinity;
|
||||
return orderA - orderB;
|
||||
});
|
||||
productList.value = handleData(sortMilkList, milkVoucherList);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang='scss'>
|
||||
.page-wrapper{
|
||||
// width: 100vw;
|
||||
// height: 100vh;
|
||||
width:100%;
|
||||
<style lang="scss">
|
||||
.page-wrapper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.nav-btn{
|
||||
.nav-btn {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top:42rpx;
|
||||
top: 42rpx;
|
||||
width: 42rpx;
|
||||
height: 132rpx;
|
||||
background: #FFFFFF;
|
||||
background: #ffffff;
|
||||
border-radius: 16rpx 0rpx 0rpx 16rpx;
|
||||
font-weight: normal;
|
||||
font-size: 22rpx;
|
||||
color: #4BB8FF;
|
||||
color: #4bb8ff;
|
||||
writing-mode: vertical-lr;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.wrapper{
|
||||
width:100%;
|
||||
min-height:100vh;
|
||||
background: url('/static/ycnc/bg.png') no-repeat;
|
||||
background-size:cover;
|
||||
padding-top:730rpx;
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
background: url("/static/ycnc/bg.png") no-repeat;
|
||||
background-size: cover;
|
||||
padding-top: 730rpx;
|
||||
}
|
||||
</style>
|
|
@ -1,11 +1,11 @@
|
|||
<route lang="json5" type="page">
|
||||
{
|
||||
{
|
||||
style: {
|
||||
navigationStyle: 'custom',
|
||||
navigationBarTitleText: '我的订单',
|
||||
navigationBarBackgroundColor:'#FFF',
|
||||
navigationStyle: "custom",
|
||||
navigationBarTitleText: "我的订单",
|
||||
navigationBarBackgroundColor: "#FFF",
|
||||
},
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
<template>
|
||||
|
@ -17,8 +17,11 @@
|
|||
<!-- <view v-for="(ele,index) in list[item.state]" :key="`${ele.id}-${item.state}`">
|
||||
<OrderItem :detail="ele" @pay-event="pay" @detail-event="viewDetail" @pwd-event="viewPwd"/>
|
||||
</view> -->
|
||||
<view class="order-wrapper flex flex-col flex-items-center" v-if="Array.isArray(list) && list.length > 0">
|
||||
<view v-for="(ele,index) in list" :key="`${ele.id}-${item.state}`">
|
||||
<view
|
||||
class="order-wrapper flex flex-col flex-items-center"
|
||||
v-if="Array.isArray(list) && list.length > 0"
|
||||
>
|
||||
<view v-for="(ele, index) in list" :key="`${ele.id}-${item.state}`">
|
||||
<OrderItem
|
||||
:detail="ele"
|
||||
@pay-event="pay"
|
||||
|
@ -46,213 +49,187 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useMessage } from 'wot-design-uni'
|
||||
import OrderItem from './components/order-item';
|
||||
import usePay from './hooks/usePay';
|
||||
import { getOrderList,deleteOrder,refundOrder,queryOrderDetail } from '../../api/ycnc';
|
||||
import { onMounted, ref, unref,reactive,computed } from 'vue';
|
||||
import { tabs } from './config';
|
||||
import {deepClone} from '../../utils/utils'
|
||||
const message = useMessage()
|
||||
const pageSize = 10;
|
||||
const activeName = ref(0);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const list = ref([]);
|
||||
const replace = ref(false);
|
||||
//页码
|
||||
// const enumPage = tabs.reduce((prev,cur) => {
|
||||
// prev[cur.state] = 1
|
||||
// return prev
|
||||
// },{})
|
||||
// const page = ref(enumPage)
|
||||
// //总数
|
||||
// const enumObj = tabs.reduce((prev,cur) => {
|
||||
// prev[cur.state] = 0
|
||||
// return prev
|
||||
// },{})
|
||||
// const total = reactive(enumObj);
|
||||
//数据列表
|
||||
// const enumOrder = tabs.reduce((prev,cur) => {
|
||||
// prev[cur.state] = []
|
||||
// return prev
|
||||
// },{})
|
||||
// const list = reactive(enumOrder)
|
||||
import { useMessage } from "wot-design-uni";
|
||||
import OrderItem from "./components/order-item";
|
||||
import {
|
||||
getOrderList,
|
||||
deleteOrder,
|
||||
refundOrder,
|
||||
queryOrderDetail,
|
||||
} from "../../api/ycnc";
|
||||
import { onMounted, ref, unref, reactive, computed } from "vue";
|
||||
import { tabs } from "./config";
|
||||
import { deepClone } from "../../utils/utils";
|
||||
const message = useMessage();
|
||||
const pageSize = 10;
|
||||
const activeName = ref(0);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const list = ref([]);
|
||||
const replace = ref(false);
|
||||
|
||||
//获取订单列表
|
||||
const queryOrderList = () => {
|
||||
//获取订单列表
|
||||
const queryOrderList = () => {
|
||||
const activeTab = unref(activeName);
|
||||
const params = {
|
||||
page:unref(page),
|
||||
pageSize:pageSize,
|
||||
...(activeTab !== 0 && {state:activeTab})
|
||||
}
|
||||
getOrderList({params}).then(res => {
|
||||
const {count,data} = res
|
||||
total.value = count
|
||||
// Object.assign(list,{[activeTab]:[...list[activeTab],...data]})
|
||||
if(replace.value){
|
||||
page: unref(page),
|
||||
pageSize: pageSize,
|
||||
...(activeTab !== 0 && { state: activeTab }),
|
||||
};
|
||||
getOrderList({ params })
|
||||
.then((res) => {
|
||||
const { count, data } = res;
|
||||
total.value = count;
|
||||
if (replace.value) {
|
||||
const prevPage = page.value - 1;
|
||||
const prevList = list.value.slice(0, prevPage * pageSize);
|
||||
list.value = [...prevList,...data];
|
||||
}else{
|
||||
list.value = [...list.value,...data]
|
||||
list.value = [...prevList, ...data];
|
||||
} else {
|
||||
list.value = [...list.value, ...data];
|
||||
}
|
||||
replace.value = false
|
||||
}).catch(err => {
|
||||
total.value = 0;
|
||||
// Object.assign(list,{[activeTab]:[]})
|
||||
list.value = []
|
||||
replace.value = false;
|
||||
})
|
||||
}
|
||||
.catch((err) => {
|
||||
total.value = 0;
|
||||
list.value = [];
|
||||
});
|
||||
};
|
||||
|
||||
function handleClick({index, name}){
|
||||
function handleClick({ index, name }) {
|
||||
page.value = 1;
|
||||
total.value = 0;
|
||||
// Object.assign(list,{[name]:[]})
|
||||
list.value = [];
|
||||
activeName.value = name;
|
||||
// name代表状态值
|
||||
queryOrderList()
|
||||
queryOrderList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function pay(orderData){
|
||||
async function pay(orderData) {
|
||||
console.log(orderData);
|
||||
const {order_no,notify_url,price,brand,sign,plain_text,id} = orderData;
|
||||
// const params = {
|
||||
// order_id:id,
|
||||
// order_no: order_no
|
||||
// }
|
||||
// const res = await queryOrderDetail({params})
|
||||
// if(res.third_status === '03'){
|
||||
// uni.showToast({
|
||||
// title: '当前订单已支付成功,无需再支付~',
|
||||
// icon: 'none'
|
||||
// });
|
||||
// replace.value = true;
|
||||
// queryOrderList()
|
||||
// return
|
||||
// }
|
||||
const {payFunc} = usePay();
|
||||
payFunc({order_no,notify_url,TranAmt:price,MerName:brand,sign,plain_text})
|
||||
}
|
||||
const { order_no, notify_url, price, brand, sign, plain_text, id, pay_url } =
|
||||
orderData;
|
||||
window.location.replace(pay_url);
|
||||
}
|
||||
|
||||
function viewDetail(orderData){
|
||||
const {id,order_no} = orderData;
|
||||
function viewDetail(orderData) {
|
||||
const { id, order_no } = orderData;
|
||||
uni.navigateTo({
|
||||
url:`/pages/ycnc/orderDetail?order_id=${id}&order_no=${order_no}`
|
||||
})
|
||||
}
|
||||
url: `/pages/ycnc/orderDetail?order_id=${id}&order_no=${order_no}`,
|
||||
});
|
||||
}
|
||||
|
||||
function viewPwd(orderData){
|
||||
const {voucher_link} = orderData
|
||||
if(voucher_link){
|
||||
console.log('跳转外部链接--->',voucher_link);
|
||||
window.location.href = voucher_link
|
||||
}else{
|
||||
function viewPwd(orderData) {
|
||||
const { voucher_link } = orderData;
|
||||
if (voucher_link) {
|
||||
console.log("跳转外部链接--->", voucher_link);
|
||||
window.location.href = voucher_link;
|
||||
} else {
|
||||
console.error(`${voucher_link}无有效值`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeOrder(orderData){
|
||||
function removeOrder(orderData) {
|
||||
message
|
||||
.confirm({
|
||||
msg: '删除订单后无法恢复,确认继续吗?',
|
||||
title: '提示'
|
||||
msg: "删除订单后无法恢复,确认继续吗?",
|
||||
title: "提示",
|
||||
})
|
||||
.then(() => {
|
||||
const {id} = orderData
|
||||
const params = {order_id:id}
|
||||
deleteOrder({params}).then(res => {
|
||||
const { id } = orderData;
|
||||
const params = { order_id: id };
|
||||
deleteOrder({ params })
|
||||
.then((res) => {
|
||||
replace.value = true;
|
||||
queryOrderList()
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
queryOrderList();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
console.log('点击了取消按钮')
|
||||
})
|
||||
}
|
||||
|
||||
function refund(orderData){
|
||||
const {id} = orderData
|
||||
if(!id){
|
||||
uni.showToast({
|
||||
icon:'none',
|
||||
title: '无有效的订单id',
|
||||
console.log("点击了取消按钮");
|
||||
});
|
||||
return
|
||||
}
|
||||
const params = {order_id:id}
|
||||
refundOrder({params}).then(res => {
|
||||
}
|
||||
|
||||
function refund(orderData) {
|
||||
const { id } = orderData;
|
||||
if (!id) {
|
||||
uni.showToast({
|
||||
icon:'success',
|
||||
title: '退款成功',
|
||||
icon: "none",
|
||||
title: "无有效的订单id",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const params = { order_id: id };
|
||||
refundOrder({ params })
|
||||
.then((res) => {
|
||||
uni.showToast({
|
||||
icon: "success",
|
||||
title: "退款成功",
|
||||
});
|
||||
replace.value = true;
|
||||
queryOrderList();
|
||||
}).catch(err => {
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(()=>{
|
||||
queryOrderList()
|
||||
})
|
||||
onMounted(() => {
|
||||
queryOrderList();
|
||||
});
|
||||
|
||||
const isLastPage = computed(()=>{
|
||||
return unref(page) === Math.ceil(unref(total) / pageSize)
|
||||
})
|
||||
const isLastPage = computed(() => {
|
||||
return unref(page) === Math.ceil(unref(total) / pageSize);
|
||||
});
|
||||
|
||||
function queryNext(){
|
||||
if(unref(isLastPage)){
|
||||
console.error('已经是最后一页');
|
||||
function queryNext() {
|
||||
if (unref(isLastPage)) {
|
||||
console.error("已经是最后一页");
|
||||
return false;
|
||||
};
|
||||
page.value = page.value + 1
|
||||
queryOrderList()
|
||||
}
|
||||
page.value = page.value + 1;
|
||||
queryOrderList();
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
.page-wrapper{
|
||||
width:100%;
|
||||
<style lang="scss" scoped>
|
||||
.page-wrapper {
|
||||
width: 100%;
|
||||
// height: 100%;
|
||||
height: calc(100vh - 42rpx);
|
||||
overflow-y: auto;
|
||||
background: #FAFBFD;
|
||||
background: #fafbfd;
|
||||
box-sizing: border-box;
|
||||
padding-bottom:30rpx
|
||||
padding-bottom: 30rpx;
|
||||
}
|
||||
.order-wrapper{
|
||||
.order-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width:100%;
|
||||
width: 100%;
|
||||
}
|
||||
.no-more{
|
||||
.no-more {
|
||||
font-weight: normal;
|
||||
font-size: 18rpx;
|
||||
color: #999999;
|
||||
height:146rpx;
|
||||
height: 146rpx;
|
||||
padding: 28rpx 0;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.no-data{
|
||||
.no-data {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
.no-img{
|
||||
width:446rpx;
|
||||
.no-img {
|
||||
width: 446rpx;
|
||||
height: 446rpx;
|
||||
}
|
||||
.no-text{
|
||||
.no-text {
|
||||
font-weight: normal;
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
|
@ -263,17 +240,17 @@
|
|||
// background: #EA0000;
|
||||
// }
|
||||
:deep(.wd-tabs__line) {
|
||||
background: #EA0000;
|
||||
background: #ea0000;
|
||||
}
|
||||
:deep(.wd-tabs){
|
||||
:deep(.wd-tabs) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height:100%;
|
||||
height: 100%;
|
||||
}
|
||||
:deep(.wd-tab__body){
|
||||
height:calc(100vh - 42rpx);
|
||||
:deep(.wd-tab__body) {
|
||||
height: calc(100vh - 42rpx);
|
||||
}
|
||||
:deep(.wd-tabs__container){
|
||||
flex:1;
|
||||
:deep(.wd-tabs__container) {
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
|
@ -1,11 +1,11 @@
|
|||
<route lang="json5" type="page">
|
||||
{
|
||||
{
|
||||
style: {
|
||||
navigationStyle: 'custom',
|
||||
navigationBarTitleText: '订单详情',
|
||||
navigationBarBackgroundColor:'#FFF',
|
||||
navigationStyle: "custom",
|
||||
navigationBarTitleText: "订单详情",
|
||||
navigationBarBackgroundColor: "#FFF",
|
||||
},
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
<template>
|
||||
|
@ -16,9 +16,14 @@
|
|||
<view class="content flex">
|
||||
<image class="pro-img" :src="orderDetail.main_image" />
|
||||
<view class="flex flex-1 flex-col">
|
||||
<view class="flex flex-justify-between name" style="margin-bottom:12rpx">
|
||||
<view
|
||||
class="flex flex-justify-between name"
|
||||
style="margin-bottom: 12rpx"
|
||||
>
|
||||
<view class="text-over">{{ orderDetail.product_name }}</view>
|
||||
<view class="amount"><text>¥</text>{{ orderDetail.price }}<text>元</text></view>
|
||||
<view class="amount"
|
||||
><text>¥</text>{{ orderDetail.price }}<text>元</text></view
|
||||
>
|
||||
</view>
|
||||
<view class="flex flex-justify-between num">
|
||||
<view>数量</view>
|
||||
|
@ -29,172 +34,177 @@
|
|||
</view>
|
||||
<view class="order-info">
|
||||
<view class="info-item">订单编号:{{ orderDetail.order_no }}</view>
|
||||
<view class="info-item" v-if="!!orderDetail.exchange_time && ![9].includes(orderDetail.state)">支付时间:{{
|
||||
orderDetail.exchange_time }}</view>
|
||||
<view
|
||||
class="info-item"
|
||||
v-if="!!orderDetail.exchange_time && ![9].includes(orderDetail.state)"
|
||||
>支付时间:{{ orderDetail.exchange_time }}</view
|
||||
>
|
||||
<view class="info-item">下单时间:{{ orderDetail.create_time }}</view>
|
||||
<view class="info-item" style="margin-bottom: 24rpx;">订单金额:{{ orderDetail.price }}</view>
|
||||
<view class="info-item" style="margin-bottom: 24rpx"
|
||||
>订单金额:{{ orderDetail.price }}</view
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
<view class="btns" v-if="pageType === 1">
|
||||
<view class="btn pwd" @click="viewPwd(orderDetail)"
|
||||
v-if="[3].includes(orderDetail.state) && orderDetail.voucher_link">查看卡券</view>
|
||||
<view class="btn pwd" @click="pay(orderDetail)" v-if="[1].includes(orderDetail.state)">立即付款</view>
|
||||
<view class="btn pwd" v-if="[4].includes(orderDetail.state)" @click="goRefund">申请退款</view>
|
||||
<view
|
||||
class="btn pwd"
|
||||
@click="viewPwd(orderDetail)"
|
||||
v-if="[3].includes(orderDetail.state) && orderDetail.voucher_link"
|
||||
>查看卡券</view
|
||||
>
|
||||
<view
|
||||
class="btn pwd"
|
||||
@click="pay(orderDetail)"
|
||||
v-if="[1].includes(orderDetail.state)"
|
||||
>立即付款</view
|
||||
>
|
||||
<view
|
||||
class="btn pwd"
|
||||
v-if="[4].includes(orderDetail.state)"
|
||||
@click="goRefund"
|
||||
>申请退款</view
|
||||
>
|
||||
<view class="btn back" @click="backIndex">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onShow, onHide, onUnload } from '@dcloudio/uni-app';
|
||||
import { onMounted, reactive, ref, unref } from 'vue';
|
||||
import { queryOrderDetail, refundOrder, queryOrderState,login } from '../../api/ycnc';
|
||||
import { getQueryString } from '../../utils/utils'
|
||||
import usePay from './hooks/usePay';
|
||||
import useCode from './hooks/useCode';
|
||||
const authCode = ref('');
|
||||
const id = ref('');
|
||||
const orderNo = ref('');
|
||||
import { onShow, onHide, onUnload } from "@dcloudio/uni-app";
|
||||
import { onMounted, reactive, ref, unref } from "vue";
|
||||
import {
|
||||
queryOrderDetail,
|
||||
refundOrder,
|
||||
queryOrderState,
|
||||
login,
|
||||
} from "../../api/ycnc";
|
||||
import { getQueryString } from "../../utils/utils";
|
||||
|
||||
const id = ref("");
|
||||
const orderNo = ref("");
|
||||
const orderDetail = reactive({});
|
||||
const pageType = ref(0)
|
||||
let timer = undefined
|
||||
const pageType = ref(0);
|
||||
let timer = undefined;
|
||||
|
||||
// 用onshow 解决h5页面被缓存的问题
|
||||
onShow(async () => {
|
||||
const token = window.localStorage.getItem('token') || '';
|
||||
if(!token){
|
||||
const code = await useCode();
|
||||
authCode.value = code
|
||||
const {token} = await login({params:{code:unref(authCode)}});
|
||||
window.localStorage.setItem('token',token);
|
||||
}
|
||||
const order_id = getQueryString('order_id')
|
||||
const order_no = getQueryString('order_no')
|
||||
const isPayBack = getQueryString('isPayBack')
|
||||
if (!order_id && !order_no) return
|
||||
id.value = order_id
|
||||
const token = getQueryString("token") || uni.getStorageSync("token");
|
||||
uni.setStorageSync("token", token);
|
||||
const order_id = getQueryString("order_id");
|
||||
const order_no = getQueryString("order_no");
|
||||
const isPayBack = getQueryString("isPayBack");
|
||||
if (!order_id && !order_no) return;
|
||||
id.value = order_id;
|
||||
orderNo.value = order_no;
|
||||
if (isPayBack) {
|
||||
queryEvent()
|
||||
queryEvent();
|
||||
} else {
|
||||
getDetail();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
onHide(() => {
|
||||
timer && clearInterval(timer)
|
||||
})
|
||||
timer && clearInterval(timer);
|
||||
});
|
||||
|
||||
onUnload(() => {
|
||||
timer && clearInterval(timer)
|
||||
})
|
||||
timer && clearInterval(timer);
|
||||
});
|
||||
|
||||
const backIndex = () => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/ycnc/index`
|
||||
})
|
||||
}
|
||||
url: `/pages/ycnc/index`,
|
||||
});
|
||||
};
|
||||
|
||||
const timerEvent = () => {
|
||||
timer && clearInterval(timer)
|
||||
timer && clearInterval(timer);
|
||||
uni.showLoading({
|
||||
title: "加载中",
|
||||
mask: true,
|
||||
});
|
||||
timer = setInterval(()=>{
|
||||
queryEvent()
|
||||
}, 2500)
|
||||
}
|
||||
timer = setInterval(() => {
|
||||
queryEvent();
|
||||
}, 2500);
|
||||
};
|
||||
|
||||
const queryEvent = () => {
|
||||
uni.hideLoading()
|
||||
uni.hideLoading();
|
||||
const params = {
|
||||
order_id: unref(id),
|
||||
order_no: unref(orderNo)
|
||||
order_no: unref(orderNo),
|
||||
};
|
||||
queryOrderState({ params }).then((res) => {
|
||||
const { state, voucher_link } = res;
|
||||
if ([3].includes(state)) {
|
||||
if (voucher_link) {
|
||||
timer && clearInterval(timer);
|
||||
window.location.replace(voucher_link);
|
||||
} else {
|
||||
timerEvent();
|
||||
}
|
||||
queryOrderState({ params }).then(res => {
|
||||
const { state, voucher_link } = res
|
||||
if([3].includes(state)){
|
||||
if(voucher_link){
|
||||
timer && clearInterval(timer)
|
||||
window.location.replace(voucher_link)
|
||||
}else{
|
||||
timerEvent()
|
||||
} else if ([1, 2].includes(state)) {
|
||||
timerEvent();
|
||||
} else {
|
||||
timer && clearInterval(timer);
|
||||
getDetail();
|
||||
}
|
||||
}else if([1,2].includes(state)){
|
||||
timerEvent()
|
||||
}else{
|
||||
timer && clearInterval(timer)
|
||||
getDetail()
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const viewPwd = (detailData) => {
|
||||
const { voucher_link } = detailData
|
||||
const { voucher_link } = detailData;
|
||||
if (voucher_link) {
|
||||
console.log(`跳转外部链接-->${voucher_link}`);
|
||||
window.location.href = voucher_link
|
||||
window.location.href = voucher_link;
|
||||
} else {
|
||||
console.error(`voucher_link无有效值`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const goRefund = () => {
|
||||
const { id } = orderDetail
|
||||
const { id } = orderDetail;
|
||||
if (!id) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '无有效的订单id',
|
||||
icon: "none",
|
||||
title: "无有效的订单id",
|
||||
});
|
||||
return
|
||||
return;
|
||||
}
|
||||
const params = { order_id: id }
|
||||
refundOrder({ params }).then(res => {
|
||||
const params = { order_id: id };
|
||||
refundOrder({ params })
|
||||
.then((res) => {
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '退款成功',
|
||||
icon: "success",
|
||||
title: "退款成功",
|
||||
});
|
||||
getDetail();
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
|
||||
async function pay(orderData) {
|
||||
console.log(orderData);
|
||||
const { order_no, notify_url, price,brand,sign,plain_text,id } = orderData;
|
||||
// const params = {
|
||||
// order_id:id,
|
||||
// order_no: order_no
|
||||
// }
|
||||
// const res = await queryOrderDetail({params})
|
||||
// if(res.third_status === '03'){
|
||||
// uni.showToast({
|
||||
// title: '当前订单已支付成功,无需再支付~',
|
||||
// icon: 'none'
|
||||
// });
|
||||
// getDetail()
|
||||
// return
|
||||
// }
|
||||
const { payFunc } = usePay();
|
||||
payFunc({ order_no, notify_url, TranAmt: price,MerName:brand,sign,plain_text })
|
||||
const { order_no, notify_url, price, brand, sign, plain_text, id, pay_url } =
|
||||
orderData;
|
||||
window.location.replace(pay_url);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// getDetail()
|
||||
})
|
||||
});
|
||||
|
||||
const getDetail = () => {
|
||||
const params = {
|
||||
order_id: unref(id),
|
||||
order_no: unref(orderNo)
|
||||
}
|
||||
pageType.value = 1
|
||||
queryOrderDetail({ params }).then(res => {
|
||||
Object.assign(orderDetail, res)
|
||||
})
|
||||
}
|
||||
order_no: unref(orderNo),
|
||||
};
|
||||
pageType.value = 1;
|
||||
queryOrderDetail({ params }).then((res) => {
|
||||
Object.assign(orderDetail, res);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -205,14 +215,14 @@ const getDetail = () => {
|
|||
.wrapper {
|
||||
width: 702rpx;
|
||||
height: 486rpx;
|
||||
background: #FFFFFF;
|
||||
background: #ffffff;
|
||||
border-radius: 24rpx;
|
||||
margin-top: 24rpx;
|
||||
box-sizing: border-box;
|
||||
padding: 32rpx 24rpx;
|
||||
|
||||
.pro-info {
|
||||
border-bottom: 1rpx solid #F0E1E1;
|
||||
border-bottom: 1rpx solid #f0e1e1;
|
||||
|
||||
.title {
|
||||
font-weight: 500;
|
||||
|
@ -262,18 +272,18 @@ const getDetail = () => {
|
|||
.num {
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #9E9E9E;
|
||||
color: #9e9e9e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.order-info {
|
||||
border-bottom: 1rpx solid #F0E1E1;
|
||||
border-bottom: 1rpx solid #f0e1e1;
|
||||
|
||||
.info-item {
|
||||
font-weight: 400;
|
||||
font-size: 22rpx;
|
||||
color: #6C6C6C;
|
||||
color: #6c6c6c;
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
}
|
||||
|
@ -296,16 +306,16 @@ const getDetail = () => {
|
|||
.pwd {
|
||||
font-weight: 500;
|
||||
font-size: 32rpx;
|
||||
color: #FFFFFF;
|
||||
background: #EA0000;
|
||||
color: #ffffff;
|
||||
background: #ea0000;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.back {
|
||||
font-weight: 400;
|
||||
font-size: 32rpx;
|
||||
color: #B9C8C7;
|
||||
border: 2rpx solid #B9C8C7;
|
||||
color: #b9c8c7;
|
||||
border: 2rpx solid #b9c8c7;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -40,3 +40,56 @@ export function generateUUID() {
|
|||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
export function getQueryParams(url) {
|
||||
// 若未传入URL,则使用当前页面URL
|
||||
const targetUrl = url || window.location.href;
|
||||
// 用于存储查询参数的对象
|
||||
const queryParams = {};
|
||||
// 查找URL中问号的位置
|
||||
const queryStart = targetUrl.indexOf('?');
|
||||
|
||||
// 如果URL中不存在问号,说明没有查询参数
|
||||
if (queryStart === -1) {
|
||||
return queryParams;
|
||||
}
|
||||
|
||||
// 提取查询字符串部分(不包含问号)
|
||||
const queryString = targetUrl.substring(queryStart + 1);
|
||||
// 查找查询字符串中哈希符号的位置
|
||||
const hashIndex = queryString.indexOf('#');
|
||||
// 移除哈希符号及其后面的内容
|
||||
const cleanQuery = hashIndex !== -1 ? queryString.substring(0, hashIndex) : queryString;
|
||||
|
||||
// 如果查询字符串为空,直接返回空对象
|
||||
if (!cleanQuery) {
|
||||
return queryParams;
|
||||
}
|
||||
|
||||
// 按"&"分割查询字符串为参数数组
|
||||
const params = cleanQuery.split('&');
|
||||
|
||||
// 遍历参数数组
|
||||
for (const param of params) {
|
||||
// 按"="分割每个参数为键值对
|
||||
const [key, value] = param.split('=');
|
||||
|
||||
if (key) {
|
||||
// 对键和值进行URL解码
|
||||
const decodedKey = decodeURIComponent(key);
|
||||
const decodedValue = value !== undefined ? decodeURIComponent(value) : '';
|
||||
|
||||
// 处理重复参数名的情况,将其值存储为数组
|
||||
if (queryParams.hasOwnProperty(decodedKey)) {
|
||||
if (!Array.isArray(queryParams[decodedKey])) {
|
||||
queryParams[decodedKey] = [queryParams[decodedKey]];
|
||||
}
|
||||
queryParams[decodedKey].push(decodedValue);
|
||||
} else {
|
||||
queryParams[decodedKey] = decodedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return queryParams;
|
||||
}
|
Loading…
Reference in New Issue