From 2d92c6594c60ee9145c66292ad15afbfbe14dcbf Mon Sep 17 00:00:00 2001
From: xiaogang <825201136@qq.com>
Date: Fri, 13 Jun 2025 14:59:02 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.env.development | 2 +-
.env.test | 3 +-
index.html | 9 +-
src/pages.json | 2 +-
src/pages/ycnc/components/nav-bar.vue | 16 +
src/pages/ycnc/detail.vue | 43 +--
src/pages/ycnc/index.vue | 247 ++++++-------
src/pages/ycnc/order.vue | 475 +++++++++++-------------
src/pages/ycnc/orderDetail.vue | 514 +++++++++++++-------------
src/utils/utils.js | 55 ++-
10 files changed, 694 insertions(+), 672 deletions(-)
create mode 100644 src/pages/ycnc/components/nav-bar.vue
diff --git a/.env.development b/.env.development
index e36b881..d6bbe4c 100644
--- a/.env.development
+++ b/.env.development
@@ -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'
diff --git a/.env.test b/.env.test
index 7bf308a..f9fbec3 100644
--- a/.env.test
+++ b/.env.test
@@ -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'
diff --git a/index.html b/index.html
index 7890c6e..a09b32b 100644
--- a/index.html
+++ b/index.html
@@ -16,16 +16,15 @@
-
-
-
+
-->
+
+
\ No newline at end of file
diff --git a/src/pages/ycnc/detail.vue b/src/pages/ycnc/detail.vue
index 2ac7c02..94cf036 100644
--- a/src/pages/ycnc/detail.vue
+++ b/src/pages/ycnc/detail.vue
@@ -12,7 +12,7 @@
-
+
{{ detailObj.name }}
@@ -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'
- }
- }
- }
\ No newline at end of file
+
diff --git a/src/pages/ycnc/order.vue b/src/pages/ycnc/order.vue
index b9a934f..8e2c96d 100644
--- a/src/pages/ycnc/order.vue
+++ b/src/pages/ycnc/order.vue
@@ -1,279 +1,256 @@
- {
- style: {
- navigationStyle: 'custom',
- navigationBarTitleText: '我的订单',
- navigationBarBackgroundColor:'#FFF',
- },
- }
+{
+ style: {
+ navigationStyle: "custom",
+ navigationBarTitleText: "我的订单",
+ navigationBarBackgroundColor: "#FFF",
+ },
+}
-
-
-
-
-
-
+
-
-
-
-
- 没有更多了~
-
-
-
- 暂无订单,快去下单吧~
-
-
-
-
-
-
+
+
+
+
+ 没有更多了~
+
+
+
+ 暂无订单,快去下单吧~
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/src/pages/ycnc/orderDetail.vue b/src/pages/ycnc/orderDetail.vue
index 9d3c4e4..8e39dc7 100644
--- a/src/pages/ycnc/orderDetail.vue
+++ b/src/pages/ycnc/orderDetail.vue
@@ -1,311 +1,321 @@
- {
- style: {
- navigationStyle: 'custom',
- navigationBarTitleText: '订单详情',
- navigationBarBackgroundColor:'#FFF',
- },
- }
+{
+ style: {
+ navigationStyle: "custom",
+ navigationBarTitleText: "订单详情",
+ navigationBarBackgroundColor: "#FFF",
+ },
+}
-
-
-
- 订单详情
-
-
-
-
- {{ orderDetail.product_name }}
- ¥{{ orderDetail.price }}元
-
-
- 数量
- x1
-
-
-
+
+
+
+ 订单详情
+
+
+
+
+ {{ orderDetail.product_name }}
+ ¥{{ orderDetail.price }}元
-
- 订单编号:{{ orderDetail.order_no }}
- 支付时间:{{
- orderDetail.exchange_time }}
- 下单时间:{{ orderDetail.create_time }}
- 订单金额:{{ orderDetail.price }}
+
+ 数量
+ x1
+
-
- 查看卡券
- 立即付款
- 申请退款
- 返回首页
-
+
+
+ 订单编号:{{ orderDetail.order_no }}
+ 支付时间:{{ orderDetail.exchange_time }}
+ 下单时间:{{ orderDetail.create_time }}
+ 订单金额:{{ orderDetail.price }}
+
+
+ 查看卡券
+ 立即付款
+ 申请退款
+ 返回首页
+
+
\ No newline at end of file
+
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 7f12c2b..b4c69a6 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -39,4 +39,57 @@ export function generateUUID() {
uuid += (i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16);
}
return uuid;
- }
\ No newline at end of file
+ }
+
+ 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;
+}
\ No newline at end of file