邮储奶茶项目

This commit is contained in:
xiaogang 2024-07-02 09:26:16 +08:00
parent 4807ac0d60
commit 3bd09a9c5d
16 changed files with 581 additions and 182 deletions

1
.env
View File

@ -1,3 +1,4 @@
# 邮储奶茶活动
VITE_YCNC_APPID = '2vikrqptiia9pe9bf5ztrd'
VITE_YCNC_SECRET = '6fpfwdkgcggyk0yf2yb6bt'
VITE_TEST_TOKEN = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjdXN0Tm8iOiIzOTY3ODA2ODcwMjIyIiwiZXhwIjoxNzE5NTQxNzA5LCJpZCI6IjIifQ.cDjKKYYTYOPPYUh8XidADpxr8xZ_WXbZ9b1pZt1Kzm4'

View File

@ -73,6 +73,7 @@
"sass": "^1.77.5",
"sass-loader": "^10.1.1",
"unocss": "~0.58.9",
"vite": "5.2.8"
"vite": "5.2.8",
"vite-plugin-zip-pack": "1.0.7"
}
}

View File

@ -105,6 +105,9 @@ importers:
vite:
specifier: 5.2.8
version: 5.2.8(@types/node@20.14.2)(sass@1.77.5)(terser@5.31.1)
vite-plugin-zip-pack:
specifier: 1.0.7
version: 1.0.7(vite@5.2.8(@types/node@20.14.2)(sass@1.77.5)(terser@5.31.1))
packages:
@ -2012,6 +2015,9 @@ packages:
core-js@3.37.1:
resolution: {integrity: sha512-Xn6qmxrQZyB0FFY8E3bgRXei3lWDJHhvI+u0q9TKIYM49G8pAr0FgnnrFRAmsbptZL1yxRADVXn+x5AGsbBfyw==}
core-util-is@1.0.3:
resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
cross-env@7.0.3:
resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==}
engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'}
@ -2456,6 +2462,9 @@ packages:
ieee754@1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
immediate@3.0.6:
resolution: {integrity: sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==}
immutable@4.3.6:
resolution: {integrity: sha512-Ju0+lEMyzMVZarkTn/gqRpdqd5dOPaz1mCZ0SH3JV6iFw81PldE/PEB1hWVEA288HPt4WXW8O7AWxB10M+03QQ==}
@ -2526,6 +2535,9 @@ packages:
is-typedarray@1.0.0:
resolution: {integrity: sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==}
isarray@1.0.0:
resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==}
isexe@2.0.0:
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
@ -2745,6 +2757,9 @@ packages:
jsonfile@6.1.0:
resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==}
jszip@3.10.1:
resolution: {integrity: sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==}
kleur@3.0.3:
resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==}
engines: {node: '>=6'}
@ -2767,6 +2782,9 @@ packages:
licia@1.40.0:
resolution: {integrity: sha512-iNujT47WfM7NTHOhxnXUdvW2ELAXNuViJZaLimId6a6b++5VQmse042Wkrx774KoYvVwD98qbdEtS3CWaAzzFQ==}
lie@3.3.0:
resolution: {integrity: sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==}
lilconfig@2.1.0:
resolution: {integrity: sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==}
engines: {node: '>=10'}
@ -3163,6 +3181,9 @@ packages:
resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==}
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
process-nextick-args@2.0.1:
resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==}
process@0.11.10:
resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==}
engines: {node: '>= 0.6.0'}
@ -3220,6 +3241,9 @@ packages:
read-cache@1.0.0:
resolution: {integrity: sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==}
readable-stream@2.3.8:
resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==}
readdirp@3.6.0:
resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==}
engines: {node: '>=8.10.0'}
@ -3291,6 +3315,9 @@ packages:
safe-area-insets@1.4.1:
resolution: {integrity: sha512-r/nRWTjFGhhm3w1Z6Kd/jY11srN+lHt2mNl1E/emQGW8ic7n3Avu4noibklfSM+Y34peNphHD/BSZecav0sXYQ==}
safe-buffer@5.1.2:
resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==}
safe-buffer@5.2.1:
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
@ -3356,6 +3383,9 @@ packages:
resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==}
engines: {node: '>= 0.4'}
setimmediate@1.0.5:
resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==}
setprototypeof@1.2.0:
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
@ -3425,6 +3455,9 @@ packages:
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
engines: {node: '>=8'}
string_decoder@1.1.1:
resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==}
strip-ansi@6.0.1:
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
engines: {node: '>=8'}
@ -3658,6 +3691,11 @@ packages:
resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==}
engines: {node: '>= 0.8'}
vite-plugin-zip-pack@1.0.7:
resolution: {integrity: sha512-URNInflOMS8eSv9kfHK9O+TYBhFrbe3+0v5TM0PQZOTJ73/VDl1pfQC1f0xu687+c1zMuirMjsVQ3e23F3xU7w==}
peerDependencies:
vite: '>=2.x'
vite@5.2.8:
resolution: {integrity: sha512-OyZR+c1CE8yeHw5V5t59aXsUPPVTHMDjEZz8MgguLL/Q7NblxhZUlTu9xSPqlsUO/y+X7dlU05jdhvyycD55DA==}
engines: {node: ^18.0.0 || >=20.0.0}
@ -6738,6 +6776,8 @@ snapshots:
core-js@3.37.1: {}
core-util-is@1.0.3: {}
cross-env@7.0.3:
dependencies:
cross-spawn: 7.0.3
@ -7180,6 +7220,8 @@ snapshots:
ieee754@1.2.1: {}
immediate@3.0.6: {}
immutable@4.3.6: {}
import-local@3.1.0:
@ -7230,6 +7272,8 @@ snapshots:
is-typedarray@1.0.0: {}
isarray@1.0.0: {}
isexe@2.0.0: {}
istanbul-lib-coverage@3.2.2: {}
@ -7696,6 +7740,13 @@ snapshots:
optionalDependencies:
graceful-fs: 4.2.11
jszip@3.10.1:
dependencies:
lie: 3.3.0
pako: 1.0.11
readable-stream: 2.3.8
setimmediate: 1.0.5
kleur@3.0.3: {}
klona@2.0.6: {}
@ -7710,6 +7761,10 @@ snapshots:
licia@1.40.0: {}
lie@3.3.0:
dependencies:
immediate: 3.0.6
lilconfig@2.1.0: {}
lines-and-columns@1.2.4: {}
@ -8058,6 +8113,8 @@ snapshots:
ansi-styles: 5.2.0
react-is: 17.0.2
process-nextick-args@2.0.1: {}
process@0.11.10: {}
prompts@2.4.2:
@ -8109,6 +8166,16 @@ snapshots:
dependencies:
pify: 2.3.0
readable-stream@2.3.8:
dependencies:
core-util-is: 1.0.3
inherits: 2.0.4
isarray: 1.0.0
process-nextick-args: 2.0.1
safe-buffer: 5.1.2
string_decoder: 1.1.1
util-deprecate: 1.0.2
readdirp@3.6.0:
dependencies:
picomatch: 2.3.1
@ -8192,6 +8259,8 @@ snapshots:
safe-area-insets@1.4.1: {}
safe-buffer@5.1.2: {}
safe-buffer@5.2.1: {}
safer-buffer@2.1.2: {}
@ -8271,6 +8340,8 @@ snapshots:
gopd: 1.0.1
has-property-descriptors: 1.0.2
setimmediate@1.0.5: {}
setprototypeof@1.2.0: {}
shebang-command@2.0.0:
@ -8332,6 +8403,10 @@ snapshots:
is-fullwidth-code-point: 3.0.0
strip-ansi: 6.0.1
string_decoder@1.1.1:
dependencies:
safe-buffer: 5.1.2
strip-ansi@6.0.1:
dependencies:
ansi-regex: 5.0.1
@ -8569,6 +8644,11 @@ snapshots:
vary@1.1.2: {}
vite-plugin-zip-pack@1.0.7(vite@5.2.8(@types/node@20.14.2)(sass@1.77.5)(terser@5.31.1)):
dependencies:
jszip: 3.10.1
vite: 5.2.8(@types/node@20.14.2)(sass@1.77.5)(terser@5.31.1)
vite@5.2.8(@types/node@20.14.2)(sass@1.77.5)(terser@5.31.1):
dependencies:
esbuild: 0.20.2

View File

@ -32,3 +32,9 @@ export const goPay = (params) => http({
...params
})
export const queryOrderDetail = (params) => http({
url:'/api/v1/auth/order/query',
method:'POST',
...params
})

View File

@ -8,7 +8,6 @@ const httpInterceptor = {
// 拦截前触发
invoke(options) {
// 接口请求支持通过 query 参数配置 queryString
console.log('options', options)
if (options.query) {
const queryStr = qs.stringify(options.query)
if (options.url.includes('?')) {

View File

@ -23,6 +23,14 @@
"navigationStyle": "custom",
"navigationBarTitleText": "我的订单"
}
},
{
"path": "pages/ycnc/orderDetail",
"type": "page",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "订单详情"
}
}
],
"globalStyle": {

View File

@ -1,5 +1,5 @@
<template>
<view class="order-item-wrapper flex flex-col box-border">
<view class="order-item-wrapper flex flex-col box-border" @click="goDetail">
<view class="nav-info flex flex-justify-between" >
<view>订单编号{{ detail.order_no }}</view>
<view>{{ stateConfig[detail.state] }}</view>
@ -13,22 +13,20 @@
<view class="flex flex-1 flex-col">
<view class="flex flex-justify-between name info-item">
<view class="text-over">{{ detail.product_name }}</view>
<!-- <view>{{ detail.order_no }}</view> -->
<view>5</view>
<view class="amount"><text></text>{{ detail.price }}<text></text></view>
</view>
<view class="flex flex-justify-between num">
<view>数量</view>
<!-- <view>x{{ detail.order_no }}</view> -->
<view>x1</view>
</view>
</view>
</view>
<view class="time">下单时间{{ detail.create_time }}</view>
</view>
<view class="btns flex flex-justify-end">
<view class="btns flex flex-justify-end" v-if="[1,3].includes(detail.state)">
<!-- <view class="btn del" v-if="[1,2].includes(detail.state)">删除订单</view> -->
<view class="btn pay" v-if="[1].includes(detail.state)" @click="goPay">立即付款</view>
<view class="btn view" v-if="[3].includes(detail.state)">查看卡密</view>
<view class="btn view" v-if="[3].includes(detail.state)" @click="goPwd">查看卡密</view>
</view>
</view>
</template>
@ -42,9 +40,22 @@
default:() => ({})
}
})
const emits = defineEmits(['pay-event'])
function goPay(){
emits('pay-event', detail);
const emits = defineEmits(['pay-event','detail-event','pwd-event'])
function goPay(e){
if(e.stopPropagation) { //W3C
e.stopPropagation();
}
emits('pay-event', props.detail);
}
function goDetail(e){
emits('detail-event', props.detail);
}
function goPwd(e){
if(e.stopPropagation) { //W3C
e.stopPropagation();
}
emits('pwd-event', props.detail);
}
</script>
@ -92,6 +103,17 @@
overflow: hidden;
white-space: nowrap;
}
.amount{
color: #333333;
font-weight: 400;
font-size:24rpx;
text:nth-child(1){
font-size:20rpx;
}
text:nth-child(2){
font-size:22rpx;
}
}
.name{
font-size: 24rpx;
color: #333333;
@ -111,8 +133,9 @@
border-radius: 68rpx;
font-weight: 400;
font-size: 28rpx;
text-align: center;
line-height: 64rpx;
display: flex;
align-items: center;
justify-content: center;
margin-left:48rpx;
}
.del{

View File

@ -1,9 +1,13 @@
<template>
<view class="pro-item-wrapper flex flex-col box-border" @click="toDetail">
<view class="pro-item-wrapper flex flex-col box-border flex-justify-between" @click="toDetail">
<view class="img-container">
<image
:src="detail.voucherUrl"
:src="detail.voucherIcon"
mode="scaleToFill"
class="img"
/>
</view>
<view class="bottom-container">
<view class="brand">{{ config[detail.brandFlag].name}}</view>
<view class="name">{{ detail.voucherTitle }}</view>
@ -37,7 +41,6 @@
}
})
const goBuy = (e) => {
e = e || window.event;
if(e.stopPropagation) { //W3C
e.stopPropagation();
}
@ -52,11 +55,9 @@
.pro-item-wrapper{
width:212rpx;
height:370rpx;
// background: url('../../../static/ycnc/bg-product.png') no-repeat;
// background: url('/static/ycnc/bg-product.png') no-repeat;
background: url('/static/ycnc/bg-product.jpg') no-repeat;
background-size: 100% 100%;
padding: 4rpx 4rpx 10rpx;
padding: 6rpx 6rpx 10rpx;
margin-top:20rpx;
margin-right: 20rpx;
&:nth-child(3n){
@ -64,7 +65,7 @@
}
}
.bottom-container{
padding: 0 12rpx;
padding: 0 8rpx;
}
.brand{
font-weight: 400;
@ -72,20 +73,21 @@
color: #887F6E;
}
.img{
.img-container{
width:100%;
height:156rpx;
display: block;
height:152rpx;
box-sizing: border-box;
border:1px solid red;
margin-bottom:12rpx;
border-radius:16rpx;
border-radius: 18rpx;
overflow: hidden;
.img{
width:100%;
height: 100%;
}
}
.name{
font-weight: 400;
font-size: 28rpx;
color: #3B2609;
margin:4rpx 0;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
@ -108,25 +110,13 @@
// text-decoration: line-through;
}
}
// .btn{
// width:166rpx;
// height:66rpx;
// background: url('../../../static/ycnc/bg-btn.png') no-repeat;
// background-size: 100% 100%;
// font-weight: 400;
// font-size: 26rpx;
// color: #FFFFFF;
// text-align: center;
// line-height: 66rpx;
// margin-top:12rpx;
// }
.btn{
width: 166rpx;
height: 56rpx;
background: linear-gradient( 180deg, #FFF8EA 0%, #FFD9BC 100%);
box-shadow: 0rpx 1 2rpx 0rpx #FAD5A8;
border-radius: 28rpx;
margin-top:18rpx;
margin-top:20rpx;
.btn-content {
width: 158rpx;
height: 48rpx;

View File

@ -13,21 +13,30 @@
<view class="container">
<image class="banner" :src="detailObj.main_image"></image>
<view class="detail flex flex-col flex-justify-between">
<view class="name">{{ detailObj.name }}</view>
<view class="proname">{{ detailObj.name }}</view>
<view class="num">
<text class="price">{{ detailObj.show_price }}</text>
<text class="ori">{{ detailObj.price }}</text>
</view>
</view>
<view class="notice" v-html="detailObj.description">
<view class="desc" v-html="detailObj.description">
</view>
<!-- <view class="desc">
<div class="big">购买须知</div>
<div class="small">有效期</div>
<p class="prog">
代金券到账后10天有效逾期视为自动放弃不退不补
</p>
</view> -->
</view>
</scroll-view>
<view class="pay-container">
<view class="pay-btn" @click="toPay">
立即支付
</view>
</view>
</view>
</template>
<script setup>
@ -72,7 +81,7 @@
}
</script>
<style lang='scss'>
<style lang='scss' scoped>
.banner{
width: 100%;
height:600rpx;
@ -82,15 +91,16 @@
}
.detail{
width: 694rpx;
height: 138rpx;
// height: 138rpx;
border-bottom: 2rpx solid rgba(0,0,0,0.04);
margin: 0 auto;
box-sizing: border-box;
padding:25rpx 0;
.name{
.proname{
font-weight: normal;
font-size: 30rpx;
color: #333333;
margin-bottom:16rpx;
}
.price{
font-weight: 700;
@ -105,23 +115,64 @@
text-decoration: line-through;
}
}
// .notice{
// width: 694rpx;
// margin:0 auto;
// padding-top:40rpx;
// .title{
// font-weight: normal;
// font-size: 40rpx;
// color: #3D3D3D;
// }
// }
.desc{
width: 694rpx;
margin:0 auto;
padding-top:44rpx;
padding-bottom:24rpx;
&:deep(.big-title) {
font-weight: bold;
font-size: 40rpx;
color: #3D3D3D;
margin-bottom:16rpx;
}
&:deep(.small-area) {
margin-bottom:16rpx;
}
&:deep(.small-title){
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;
}
// .big{
// font-weight: bold;
// font-size: 40rpx;
// color: #3D3D3D;
// margin-bottom:16rpx;
// }
// .small{
// font-weight: 400;
// font-size: 32rpx;
// color: #333333;
// margin-bottom:16rpx;
// }
// .prog{
// font-weight: 400;
// font-size: 28rpx;
// color: #4D4D4D;
// margin-bottom:16rpx;
// }
}
.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;
text-align: center;
line-height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
font-weight: 500;
font-size: 32rpx;
color: #FFFFFF;

View File

@ -17,7 +17,7 @@ export default function usePay(){
MercUrl:notify_url,
TranAmt:Number(voucherAmount).toFixed(2),
TermSsn:order_no,
BackLink:`${window.location.origin}/#/pages/ycnc/order`,
BackLink:`${window.location.origin}/#/pages/ycnc/orderDetail?order_no=${order_no}`,
psbcmcc:'LSXD',
TxnDt:dayjs(Date.now()).format('YYYY-MM-DD'),
MercCode:'100610100019029'

View File

@ -60,82 +60,51 @@
provide('handleBuy', handleBuy);
provide('goDetail', goDetail);
window.authCallback = (params) => {
console.log('authCallback-index',params);
const {code} = params;
authCode.value = code;
console.log('code',code);
}
const getNewAuthorization = () => {
let appId = import.meta.env.VITE_YCNC_APPID;
let time = Date.now().toString();
let secret = import.meta.env.VITE_YCNC_SECRET;
let signBefore = appId + time + secret;
let sign = md5(signBefore);//md5
let param = {
appId: appId,
sign: sign,
time: time,
tran_code: "157",
fn: "authCallback",
needBind: ""
};
console.log('auth-param157-index',param);
Fw.device.api.getNewAuthorization(param)
}
// function handleParams(obj){
// return Object.entries(obj).reduce((total,curr) => {
// if(!total){
// total += `${curr[0]}=${curr[1]}`
// }else{
// total += `|${curr[0]}=${curr[1]}`
// }
// return total
// },'')
// }
// const payFunc = (args) => {
// const {order_no,notify_url,voucherAmount} = args;
// const Plain = {
// MercUrl:notify_url,
// TranAmt:Number(voucherAmount).toFixed(2),
// TermSsn:order_no,
// BackLink:`${window.location.origin}/#/pages/ycnc/order`,
// psbcmcc:'LSXD',
// TxnDt:dayjs(Date.now()).format('YYYY-MM-DD'),
// MercCode:'100610100019029'
// }
// const params = {
// Plain:handleParams(Plain),
// }
// console.log('handCodePay-params',params);
// Fw.device.api.handCodePay(params);
// }
const toOrder = () => {
uni.navigateTo({
url:'/pages/ycnc/order'
})
};
onMounted(async ()=>{
// getNewAuthorization();
// const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjdXN0Tm8iOiIzOTY3ODA2ODcwMjIyIiwiZXhwIjoxNzE5Mzk3Nzc0LCJpZCI6IjIifQ.bL7N5E0WMXDtvnbNrY58p-BuWDgBovz1VwpWrKd1_UU'
// uni.setStorageSync('token',token)
// queryProducts();
// const token = uni.getStorageSync('token') || '';
// if(!token){
// const code = await useCode();
// authCode.value = code
// const {token} = await login({params:{code:unref(authCode)}})
// uni.setStorageSync('token',token)
// window.authCallback = (params) => {
// console.log('authCallback-index',params);
// const {code} = params
// login({params:{code:code}}).then(res=>{
// uni.setStorageSync('token',res.token)
// })
// }
getNewAuthorization()
// const getNewAuthorization = () => {
// let appId = import.meta.env.VITE_YCNC_APPID;
// let time = Date.now().toString();
// let secret = import.meta.env.VITE_YCNC_SECRET;
// let signBefore = appId + time + secret;
// let sign = md5(signBefore);//md5
// let param = {
// appId: appId,
// sign: sign,
// time: time,
// tran_code: "157",
// fn: "authCallback",
// needBind: ""
// };
// console.log('auth-param157-index',param);
// Fw.device.api.getNewAuthorization(param)
// };
onMounted(async ()=>{
queryProducts();
// const authCode = await useCode()
// console.log('authCallback-mounted',authCode);
// let testToken = import.meta.env.VITE_TEST_TOKEN
// uni.setStorageSync('token',testToken)
const token = uni.getStorageSync('token') || '';
console.log('是否有token',!!token);
if(!token){
const code = await useCode();
authCode.value = code
const {token} = await login({params:{code:unref(authCode)}});
uni.setStorageSync('token',token);
// getNewAuthorization()
}
});
function handleData(arg,args){

View File

@ -9,13 +9,22 @@
<template>
<wd-tabs color="#333" inactiveColor="#888" @click="handleClick">
<block v-for="item in tabs" :key="item.type">
<block v-for="item in tabs" :key="item.state">
<wd-tab :title="item.tabName" :name="item.state">
<scroll-view scroll-y class="page-wrapper">
<view class="wrapper flex flex-col flex-items-center">
<view v-for="(ele,index) in list" :key="ele.id">
<OrderItem :detail="ele" @pay-event="pay"/>
<scroll-view scroll-y class="page-wrapper" @scrolltolower="queryNext">
<view class="wrapper flex flex-col flex-items-center" v-if="Array.isArray(list[item.state]) && list[item.state].length > 0">
<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="no-more" v-if="isLastPage">没有更多了~</view>
</view>
<view class="no-data" v-else>
<image
src="../../static/ycnc/bg-nodata.png"
mode="scaleToFill"
class="no-img"
/>
<text class="no-text">暂无订单快去下单吧~</text>
</view>
</scroll-view>
</wd-tab>
@ -27,39 +36,55 @@
import OrderItem from './components/order-item';
import usePay from './hooks/usePay';
import { getOrderList, goPay } from '../../api/ycnc';
import { onMounted, ref, unref } from 'vue';
import { onMounted, ref, unref,reactive,computed } from 'vue';
import { tabs } from './config';
const page = ref(1);
const pageSize = 10;
const activeName = ref(0);
const total = ref(0);
const list = ref([]);
const page = ref(1);
// const list = ref([]);
//
// 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)
const isLastPage = () => unref(page) === Math.ceil(unref(total) / pageSize)
//
const queryOrderList = () => {
if(isLastPage()){
console.log('已经是最后一页');
return false;
};
const activeTab = unref(activeName);
const params = {
page:unref(page),
pageSize:pageSize,
...(unref(activeName) !== 0 && {state:unref(activeName)})
...(activeTab !== 0 && {state:activeTab})
}
getOrderList({params}).then(res => {
const {count,data} = res
total.value = count;
list.value = data;
total.value = count
Object.assign(list,{[activeTab]:[...list[activeTab],...data]})
}).catch(err => {
total.value = 0;
list.value = 0;
Object.assign(list,{[activeTab]:[]})
})
}
function handleClick({index, name}){
page.value = 1;
total.value = 0;
Object.assign(list,{[name]:[]})
activeName.value = name;
// name
queryOrderList()
@ -67,26 +92,47 @@
}
function pay(orderData){
const {product_id,voucherAmount} = orderData
console.log('订单数据',orderData);
const params = {
product_id:product_id
}
goPay({params}).then(res => {
const {order_no,notify_url} = res;
const {order_no,notify_url,price} = orderData;
const {payFunc} = usePay();
payFunc({order_no,notify_url,voucherAmount})
}).catch(err => {
console.log(err);
payFunc({order_no,notify_url,price})
}
function viewDetail(orderData){
const {id,order_no} = orderData;
uni.navigateTo({
url:`/pages/ycnc/orderDetail?order_id=${id}&order_no=${order_no}`
})
}
function viewPwd(orderData){
const {voucher_link} = orderData
if(voucher_link){
window.location.href = voucher_link
}else{
console.error(`${voucher_link}无有效值`);
}
}
onMounted(()=>{
queryOrderList()
})
const isLastPage = computed(()=>{
return unref(page) === Math.ceil(unref(total) / pageSize)
})
function queryNext(){
console.log(unref(isLastPage));
if(unref(isLastPage)){
console.error('已经是最后一页');
return false;
};
page.value = page.value + 1
queryOrderList()
}
</script>
<style lang='scss'>
<style lang='scss' scoped>
.page-wrapper{
// width: 100vw;
// height: 100vh;
@ -94,23 +140,53 @@
height: 100%;
overflow-y: auto;
background: #FAFBFD;
box-sizing: border-box;
padding-bottom:30rpx
}
.wrapper{
width:100%;
}
.no-more{
font-weight: normal;
font-size: 18rpx;
color: #999999;
height:146rpx;
padding: 28rpx 0;
display: flex;
align-items: flex-end;
justify-content: center;
box-sizing: border-box;
}
.no-data{
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
.no-img{
width:446rpx;
height: 446rpx;
}
.no-text{
font-weight: normal;
font-size: 24rpx;
color: #999999;
}
}
/* 修改标签页下划线颜色*/
:deep(.wd-tabs__line) {
background: #EA0000;
// width:64rpx !important;
// height:4rpx !important;
}
:deep(.wd-tabs){
display: flex;
flex-direction: column;
height:100%;
}
:deep(.wd-tab),:deep(.wd-tab__body){
height:100%;
:deep(.wd-tab){
// height: 100%;
}
:deep(.wd-tab__body){
height:calc(100vh - 42rpx);
}
:deep(.wd-tabs__container){
flex:1;

View File

@ -0,0 +1,181 @@
<route lang="json5" type="page">
{
style: {
navigationStyle: 'custom',
navigationBarTitleText: '订单详情',
},
}
</route>
<template>
<view class="w-full h-full flex flex-col flex-items-center page">
<view class="wrapper">
<view class="pro-info">
<view class="title">订单详情</view>
<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="text-over">{{ orderDetail.product_name }}</view>
<view class="amount"><text></text>{{ orderDetail.price }}<text></text></view>
</view>
<view class="flex flex-justify-between num">
<view>数量</view>
<view>x1</view>
</view>
</view>
</view>
</view>
<view class="order-info">
<view class="info-item">订单编号{{ orderDetail.order_no }}</view>
<view class="info-item">支付时间{{ orderDetail.create_time }}</view>
<view class="info-item">下单时间{{ orderDetail.create_time }}</view>
<view class="info-item" style="margin-bottom: 24rpx;">订单金额{{ orderDetail.price }}</view>
</view>
</view>
<view class="btns">
<view class="btn pwd" @click="viewPwd">查看卡密</view>
<view class="btn back" @click="backIndex">返回首页</view>
</view>
</view>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { onMounted, reactive, ref, unref } from 'vue';
import { queryOrderDetail, goPay } from '../../api/ycnc';
const id = ref('');
const orderNo = ref('');
const orderDetail = reactive({});
onLoad((options) => {
const {order_id,order_no} = options;
id.value = order_id
orderNo.value = order_no
})
const backIndex = () => {
uni.navigateTo({
url:`/pages/ycnc/index`
})
}
const viewPwd = (detailData) => {
const {voucher_link} = detailData
if(voucher_link){
window.location.href = voucher_link
}else{
console.error(`${voucher_link}无有效值`);
}
}
onMounted(() => {
getDetail()
})
const getDetail = () => {
const params = {
order_id:unref(id),
order_no:unref(orderNo)
}
queryOrderDetail({params}).then(res => {
Object.assign(orderDetail,res)
})
}
</script>
<style lang="scss">
.page{
background-color: #fafafa;
}
.wrapper{
width: 702rpx;
height: 486rpx;
background: #FFFFFF;
border-radius: 24rpx;
margin-top:24rpx;
box-sizing: border-box;
padding:32rpx 24rpx;
.pro-info{
border-bottom: 1rpx solid #F0E1E1;
.title{
font-weight: 500;
font-size: 28rpx;
color: #333333;
margin-bottom: 28rpx;
}
.content{
margin-bottom:24rpx;
font-weight: 400;
.pro-img{
display: block;
width:90rpx;
height:90rpx;
margin-right:34rpx;
}
.text-over{
max-width:80%;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.name{
font-size: 24rpx;
color: #333333;
}
.amount{
color: #333333;
font-weight: 400;
font-size:24rpx;
text:nth-child(1){
font-size:20rpx;
}
text:nth-child(2){
font-size:22rpx;
}
}
.num{
font-size: 20rpx;
color: #9E9E9E;
}
}
}
.order-info{
border-bottom: 1rpx solid #F0E1E1;
.info-item{
font-weight: 400;
font-size: 22rpx;
color: #6C6C6C;
margin-top:24rpx;
}
}
}
.btns{
margin-top:146rpx;
display: flex;
.btn{
width: 312rpx;
height: 76rpx;
border-radius: 38rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.pwd{
font-weight: 500;
font-size: 32rpx;
color: #FFFFFF;
background: #EA0000;
margin-right:10rpx;
}
.back{
font-weight: 400;
font-size: 32rpx;
color: #B9C8C7;
border: 2rpx solid #B9C8C7;
}
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

3
uni-pages.d.ts vendored
View File

@ -6,7 +6,8 @@
interface NavigateToOptions {
url: "/pages/ycnc/index" |
"/pages/ycnc/detail" |
"/pages/ycnc/order";
"/pages/ycnc/order" |
"/pages/ycnc/orderDetail";
}
interface RedirectToOptions extends NavigateToOptions {}

View File

@ -2,12 +2,18 @@ import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import UniPages from '@uni-helper/vite-plugin-uni-pages'
import UnoCSS from 'unocss/vite'
import zipPack from "vite-plugin-zip-pack"
import dayjs from "dayjs";
// https://vitejs.dev/config/
import getPages from './build'
const exclude = getPages()
const exclude = getPages();
export default defineConfig({
const timeStringNow = dayjs().format("YYYY-MM-DD HH-mm-ss")
export default defineConfig(({ command, mode }) => {
const { UNI_PLATFORM } = process.env // 得到 mp-weixin, h5, app 等
return {
plugins: [
UniPages({
exclude: ['**/components/**/**.*',...exclude],
@ -18,5 +24,12 @@ export default defineConfig({
}),
uni(),
UnoCSS(),
],
zipPack({
inDir: `dist/build/${UNI_PLATFORM}`, // 输入的文件夹,就是要打包的文件夹
outDir: `dist/build`, // 打包好的 zip 文件放到哪个文件夹下
outFileName: `${UNI_PLATFORM}-${timeStringNow}.zip`, //文件名不能包含\/:*?"<>|
pathPrefix: ''
})
]
}
})