手机银行版本试运行环境更新前提交一次代码

This commit is contained in:
xiaogang 2025-06-25 10:33:58 +08:00
parent 2d92c6594c
commit 7ff654ab22
6 changed files with 218 additions and 173 deletions

View File

@ -1,7 +1,7 @@
NODE_ENV = 'production' NODE_ENV = 'production'
# 邮储奶茶活动(正式环境) # 邮储奶茶活动(正式环境)
VITE_BASE_URL = 'https://milk.api.cdlsxd.cn' VITE_BASE_URL = 'https://tea.cdlsxd.cn'
VITE_YCNC_MERCH_CODE = '100510102303326' VITE_YCNC_MERCH_CODE = '100510102303326'
# 邮储音视频活动(生产环境) # 邮储音视频活动(生产环境)

View File

@ -1,185 +1,188 @@
<route lang="json5" type="page"> <route lang="json5" type="page">
{ {
style: { style: {
navigationStyle: 'custom', navigationStyle: "custom",
navigationBarTitleText: '商品详情', navigationBarTitleText: "商品详情",
navigationBarBackgroundColor:'#FFF', navigationBarBackgroundColor: "#FFF",
}, },
} }
</route> </route>
<template> <template>
<view class="w-full h-full flex flex-col"> <view class="w-full h-full flex flex-col">
<scroll-view scroll-y class="w-full h-full overflow-y-auto flex-1"> <scroll-view scroll-y class="w-full h-full overflow-y-auto flex-1">
<view class="container"> <view class="container">
<image class="banner" :src="detailObj.main_image"></image> <image class="banner" :src="detailObj.main_image"></image>
<view class="detail flex flex-col flex-justify-between"> <view class="detail flex flex-col flex-justify-between">
<view class="proname">{{ detailObj.name }}</view> <view class="proname">{{ detailObj.name }}</view>
<view class="num"> <view class="num">
<text class="price">{{ detailObj.price }}</text> <text class="price">{{ detailObj.price }}</text>
<text class="ori">{{ detailObj.show_price }}</text> <text class="ori">{{ detailObj.show_price }}</text>
</view> </view>
</view> </view>
<view class="desc" v-html="detailObj.description"> <view class="desc" v-html="detailObj.description"> </view>
<!-- <view class="desc">
</view>
<!-- <view class="desc">
<div class="big">购买须知</div> <div class="big">购买须知</div>
<div class="small">有效期</div> <div class="small">有效期</div>
<p class="prog"> <p class="prog">
代金券到账后10天有效逾期视为自动放弃不退不补 代金券到账后10天有效逾期视为自动放弃不退不补
</p> </p>
</view> --> </view> -->
</view> </view>
</scroll-view> </scroll-view>
<view class="pay-container"> <view class="pay-container">
<view class="pay-btn" @click="toPay"> <view class="pay-btn" @click="toPay"> 立即支付 </view>
立即支付
</view>
</view>
</view> </view>
</view>
</template> </template>
<script setup> <script setup>
import { onMounted, reactive, ref, unref } from 'vue'; import { onMounted, reactive, ref, unref } from "vue";
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from "@dcloudio/uni-app";
import { queryDetail, goPay, login } from '../../api/ycnc'; import { queryDetail, goPay, login } from "../../api/ycnc";
import { getQueryString } from '../../utils/utils' import { getQueryString } from "../../utils/utils";
const id = ref('') const id = ref("");
const detailObj = reactive({}) const detailObj = reactive({});
onLoad((options) => { onLoad((options) => {
const {product_id} = options; const { product_id } = options;
id.value = product_id id.value = product_id;
});
onMounted(() => {
const token = getQueryString("token") || uni.getStorageSync("token");
uni.setStorageSync("token", token);
getDetail();
});
const getDetail = () => {
const params = {
product_id: unref(id),
};
queryDetail({ params }).then((res) => {
Object.assign(detailObj, res);
});
};
const toPay = async () => {
const tempBackUrl = getQueryString("backUrl");
const backUrl = tempBackUrl
? encodeURIComponent(tempBackUrl)
: uni.getStorageSync("backUrl");
const params = {
product_id: unref(id),
backUrl: backUrl,
};
goPay({ params })
.then((res) => {
const { order_no, notify_url, sign, plain_text, pay_url } = res;
window.location.replace(pay_url);
}) })
.catch((err) => {
onMounted(() => { console.log(err);
getDetail() });
}) };
const getDetail = () => {
const params = {
product_id:unref(id)
}
queryDetail({params}).then(res => {
Object.assign(detailObj,res)
})
}
const toPay = async () => {
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,pay_url} = res;
window.location.replace(pay_url)
}).catch(err => {
console.log(err);
})
}
</script> </script>
<style lang='scss' scoped> <style lang="scss" scoped>
.banner{ .banner {
width: 100%; width: 100%;
height:600rpx; height: 600rpx;
display: block; display: block;
box-sizing: border-box; box-sizing: border-box;
} }
.detail{ .detail {
width: 694rpx; width: 694rpx;
// height: 138rpx; // height: 138rpx;
border-bottom: 2rpx solid rgba(0,0,0,0.04); border-bottom: 2rpx solid rgba(0, 0, 0, 0.04);
margin: 0 auto; margin: 0 auto;
box-sizing: border-box; box-sizing: border-box;
padding:25rpx 0; padding: 25rpx 0;
.proname{ .proname {
font-weight: bold; font-weight: bold;
font-size: 30rpx; font-size: 30rpx;
color: #333333; color: #333333;
margin-bottom:16rpx; margin-bottom: 16rpx;
} }
.price{ .price {
font-weight: 700; font-weight: 700;
font-size: 28rpx; font-size: 28rpx;
color: #EA0000; color: #ea0000;
margin-right:18rpx; margin-right: 18rpx;
} }
.ori{ .ori {
font-weight: 400; font-weight: 400;
font-size: 28rpx; font-size: 28rpx;
color: #A5A5A5; color: #a5a5a5;
text-decoration: line-through; text-decoration: line-through;
} }
} }
.desc{ .desc {
width: 694rpx; width: 694rpx;
margin:0 auto; margin: 0 auto;
padding-top:44rpx; padding-top: 44rpx;
padding-bottom:24rpx; padding-bottom: 24rpx;
// //
&:deep(.big-title) { &:deep(.big-title) {
font-weight: bold; font-weight: bold;
font-size: 40rpx; font-size: 40rpx;
color: #3D3D3D; color: #3d3d3d;
margin-bottom:16rpx; margin-bottom: 16rpx;
} }
&:deep(.small-area) { &:deep(.small-area) {
margin-bottom:16rpx; margin-bottom: 16rpx;
} }
&:deep(.small-title){ &:deep(.small-title) {
font-weight: 400; font-weight: 400;
font-size: 32rpx;
color: #333333;
margin-bottom:16rpx;
}
&:deep(.small-content){
font-weight: 400;
font-size: 28rpx;
color: #4D4D4D;
line-height: 1.6;
}
//
&:deep(.big){
font-weight: bold;
font-size: 40rpx;
color: #3D3D3D;
margin-bottom:16rpx;
}
&:deep(.small){
font-weight: 400;
font-size: 32rpx;
color: #333333;
margin-bottom:16rpx;
}
&:deep(.prog){
font-weight: 400;
font-size: 28rpx;
color: #4D4D4D;
margin-bottom:16rpx;
line-height: 1.6;
}
}
.pay-container{
width:100%;
height:138rpx;
border-top:1px solid rgba(0,0,0,0.1);
}
.pay-btn{
width: 600rpx;
height: 88rpx;
background: #EA0000;
border-radius: 54rpx 54rpx 54rpx 54rpx;
display: flex;
align-items: center;
justify-content: center;
font-weight: 500;
font-size: 32rpx; font-size: 32rpx;
color: #FFFFFF; color: #333333;
margin:25rpx auto; margin-bottom: 16rpx;
}
&:deep(.small-content) {
font-weight: 400;
font-size: 28rpx;
color: #4d4d4d;
line-height: 1.6;
}
//
&:deep(.big) {
font-weight: bold;
font-size: 40rpx;
color: #3d3d3d;
margin-bottom: 16rpx;
}
&:deep(.small) {
font-weight: 400;
font-size: 32rpx;
color: #333333;
margin-bottom: 16rpx;
}
&:deep(.prog) {
font-weight: 400;
font-size: 28rpx;
color: #4d4d4d;
margin-bottom: 16rpx;
line-height: 1.6;
}
} }
</style> .pay-container {
width: 100%;
height: 138rpx;
border-top: 1px solid rgba(0, 0, 0, 0.1);
}
.pay-btn {
width: 600rpx;
height: 88rpx;
background: #ea0000;
border-radius: 54rpx 54rpx 54rpx 54rpx;
display: flex;
align-items: center;
justify-content: center;
font-weight: 500;
font-size: 32rpx;
color: #ffffff;
margin: 25rpx auto;
}
</style>

View File

@ -10,7 +10,7 @@
<template> <template>
<scroll-view scroll-y class="page-wrapper"> <scroll-view scroll-y class="page-wrapper">
<view class="nav-btn" @click="toOrder">我的订单</view> <view class="nav-btn" @click="toOrder">我的订单(测试)</view>
<view class="wrapper flex flex-col flex-items-center box-border"> <view class="wrapper flex flex-col flex-items-center box-border">
<view v-for="(item, key) in productList" :key="key"> <view v-for="(item, key) in productList" :key="key">
<brand :products="item" :brandName="key" /> <brand :products="item" :brandName="key" />
@ -40,8 +40,10 @@ const goDetail = (productData) => {
const pay = (productData) => { const pay = (productData) => {
const { ProductId, voucherAmount, brandFlag } = productData; const { ProductId, voucherAmount, brandFlag } = productData;
const backUrl = encodeURIComponent(getQueryString("backUrl"));
const params = { const params = {
product_id: ProductId, product_id: ProductId,
backUrl: backUrl,
}; };
goPay({ params }) goPay({ params })
.then((res) => { .then((res) => {
@ -64,6 +66,12 @@ const toOrder = () => {
}); });
}; };
// function utf8ToBase64(str) {
// return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => {
// return String.fromCharCode('0x' + p1);
// }));
// }
onMounted(async () => { onMounted(async () => {
queryProducts(); queryProducts();
console.log( console.log(
@ -71,7 +79,9 @@ onMounted(async () => {
getQueryParams(window.location.href) getQueryParams(window.location.href)
); );
const token = getQueryString("token"); const token = getQueryString("token");
const backUrl = getQueryString("backUrl");
uni.setStorageSync("token", token); uni.setStorageSync("token", token);
uni.setStorageSync("backUrl", encodeURIComponent(backUrl));
}); });
function handleData(arg, args) { function handleData(arg, args) {

View File

@ -59,7 +59,7 @@ import {
} from "../../api/ycnc"; } from "../../api/ycnc";
import { onMounted, ref, unref, reactive, computed } from "vue"; import { onMounted, ref, unref, reactive, computed } from "vue";
import { tabs } from "./config"; import { tabs } from "./config";
import { deepClone } from "../../utils/utils"; import { deepClone, getQueryString } from "../../utils/utils";
const message = useMessage(); const message = useMessage();
const pageSize = 10; const pageSize = 10;
const activeName = ref(0); const activeName = ref(0);
@ -71,9 +71,14 @@ const replace = ref(false);
// //
const queryOrderList = () => { const queryOrderList = () => {
const activeTab = unref(activeName); const activeTab = unref(activeName);
const tempBackUrl = getQueryString("backUrl");
const backUrl = tempBackUrl
? encodeURIComponent(tempBackUrl)
: uni.getStorageSync("backUrl");
const params = { const params = {
page: unref(page), page: unref(page),
pageSize: pageSize, pageSize: pageSize,
backUrl: backUrl,
...(activeTab !== 0 && { state: activeTab }), ...(activeTab !== 0 && { state: activeTab }),
}; };
getOrderList({ params }) getOrderList({ params })
@ -176,6 +181,12 @@ function refund(orderData) {
} }
onMounted(() => { onMounted(() => {
const token = getQueryString("token") || uni.getStorageSync("token");
const _tempBackUrl = getQueryString("backUrl");
uni.setStorageSync("token", token);
if (_tempBackUrl) {
uni.setStorageSync("backUrl", encodeURIComponent(_tempBackUrl));
}
queryOrderList(); queryOrderList();
}); });

View File

@ -191,14 +191,13 @@ async function pay(orderData) {
window.location.replace(pay_url); window.location.replace(pay_url);
} }
onMounted(() => {
// getDetail()
});
const getDetail = () => { const getDetail = () => {
const tempBackUrl = getQueryString('backUrl')
const backUrl = tempBackUrl ? encodeURIComponent(tempBackUrl) : uni.getStorageSync('backUrl')
const params = { const params = {
order_id: unref(id), order_id: unref(id),
order_no: unref(orderNo), order_no: unref(orderNo),
backUrl:backUrl,
}; };
pageType.value = 1; pageType.value = 1;
queryOrderDetail({ params }).then((res) => { queryOrderDetail({ params }).then((res) => {

View File

@ -1,9 +1,31 @@
//获取url后面拼接的参数 //获取url后面拼接的参数
export const getQueryString = (name) => { export const getQueryString = (paramName) => {
let urlStr = window.location.href.split('?')[1] // let urlStr = window.location.href.split('?')[1]
const urlSearchParams = new URLSearchParams(urlStr) // const urlSearchParams = new URLSearchParams(urlStr)
const result = Object.fromEntries(urlSearchParams.entries()) // const result = Object.fromEntries(urlSearchParams.entries())
return name ? result[name] : result // return paramName ? result[paramName] : result
// 如果未传入 URL则使用当前页面的 URL
const targetUrl = window.location.href;
// 解析 URL 中的查询字符串部分
const queryString = targetUrl.split('?')[1];
// 如果没有查询字符串,直接返回空对象或 null
if (!queryString) return paramName ? null : {};
// 处理查询字符串中的每个参数
const params = queryString.split('&').reduce((acc, pair) => {
const [key, value] = pair.split('=').map(decodeURIComponent);
if (acc[key] !== undefined) {
acc[key] = Array.isArray(acc[key]) ? [...acc[key], value] : [acc[key], value];
} else {
acc[key] = value;
}
return acc;
}, {});
// 如果指定了参数名,则返回对应值,否则返回整个参数对象
return paramName ? params[paramName] || null : params;
} }
//是否iOS设备 //是否iOS设备