diff --git a/.env b/.env index 07cad84..f07324f 100644 --- a/.env +++ b/.env @@ -1,3 +1,7 @@ # 邮储奶茶活动 -VITE_YCNC_APPID = '2vikrqptiia9pe9bf5ztrd' -VITE_YCNC_SECRET = '6fpfwdkgcggyk0yf2yb6bt' \ No newline at end of file +# VITE_YCNC_APPID = '2vikrqptiia9pe9bf5ztrd' +# VITE_YCNC_SECRET = '6fpfwdkgcggyk0yf2yb6bt' + +# 邮储音视频 +VITE_YCNC_APPID = '2vi3695tiia9pe9bf5yyyi' +VITE_YCNC_SECRET = '6fpf26837kmgr0yf2yf643' \ No newline at end of file diff --git a/.env.production b/.env.production index 873e03e..59cfd18 100644 --- a/.env.production +++ b/.env.production @@ -4,7 +4,6 @@ # 邮储奶茶活动(测试环境) # VITE_BASE_URL = 'http://milk.test.api.cdlsxd.cn' # VITE_YCNC_MERCH_CODE = '100310100018908' -# VITE_YCNC_MERCH_CODE = '100610100019042' # 邮储奶茶活动(正式环境) # VITE_BASE_URL = 'https://milk.api.cdlsxd.cn' # VITE_YCNC_MERCH_CODE = '100510102303326' diff --git a/README.md b/README.md index 4bf3205..8721583 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,5 @@ vite打包配置文件,主要是一些插件 ### 各个模块的说明 ycnc 邮储奶茶活动 xyyk 兴业半价优酷的活动 +ycysp 邮储音视频活动------>测试环境下,vite.config.js配置base,http配置请求content-type diff --git a/custom.page.js b/custom.page.js index 4737eca..3e4e797 100644 --- a/custom.page.js +++ b/custom.page.js @@ -5,6 +5,7 @@ import path from 'path' const config = { pages:'./src/pages', pagesInclude:['ycysp/home.vue','ycysp/pay.vue','ycysp/order.vue','ycysp/orderDetail.vue',] + // pagesInclude:['ycnc',] } const { pages, pagesInclude } = config @@ -37,7 +38,8 @@ const getPages = () => { const targetExclude = targetPages.filter(elem => !targetModule[ele].includes(elem)).map(current => `${ele}/${current}`) excludePages.push(...targetExclude) }) - console.log('排除的模块以及页面',[...excludeModule,...excludePages]); + console.log('打包的模块以及页面',[...config.pagesInclude]); + console.error('排除的模块以及页面',[...excludeModule,...excludePages]); return { exclude:[...excludeModule,...excludePages], } diff --git a/index.html b/index.html index fe0aa83..bac152f 100644 --- a/index.html +++ b/index.html @@ -16,16 +16,17 @@
+ - - + diff --git a/src/App.vue b/src/App.vue index c3a3ba0..94f67af 100644 --- a/src/App.vue +++ b/src/App.vue @@ -7,9 +7,9 @@ export default { onHide: function () { }, created(){ - const script = document.createElement('script'); - script.src = './static/YT_Client_api.js'; // 本地JS文件的路径 - document.body.appendChild(script); + // const script = document.createElement('script'); + // script.src = './static/YT_Client_api.js'; // 本地JS文件的路径 + // document.body.appendChild(script); } } diff --git a/src/pages/ycnc/order.vue b/src/pages/ycnc/order.vue index 4e3cfab..d4ccf65 100644 --- a/src/pages/ycnc/order.vue +++ b/src/pages/ycnc/order.vue @@ -49,7 +49,7 @@ import { useMessage } from 'wot-design-uni' import OrderItem from './components/order-item'; import usePay from './hooks/usePay'; - import { getOrderList,deleteOrder,refundOrder } from '../../api/ycnc'; + 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' @@ -117,9 +117,20 @@ } - function pay(orderData){ + async function pay(orderData){ console.log(orderData); const {order_no,notify_url,price,brand,sign,plain_text} = orderData; + const queryParams = {order_no} + const res = await queryOrderDetail({queryParams}) + 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}) } @@ -193,7 +204,6 @@ }) function queryNext(){ - console.log(unref(isLastPage)); if(unref(isLastPage)){ console.error('已经是最后一页'); return false; diff --git a/src/pages/ycnc/orderDetail.vue b/src/pages/ycnc/orderDetail.vue index 7782de0..3f0403e 100644 --- a/src/pages/ycnc/orderDetail.vue +++ b/src/pages/ycnc/orderDetail.vue @@ -155,9 +155,19 @@ const goRefund = () => { }) } -function pay(orderData) { +async function pay(orderData) { console.log(orderData); const { order_no, notify_url, price,brand,sign,plain_text } = orderData; + const queryParams = {order_no} + const res = await queryOrderDetail({queryParams}) + 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 }) } diff --git a/src/pages/ycysp/config.js b/src/pages/ycysp/config.js index 4a55e96..469238e 100644 --- a/src/pages/ycysp/config.js +++ b/src/pages/ycysp/config.js @@ -1,3 +1,30 @@ +const config = { + 1:{ + name:'优酷', + }, + 2:{ + name:'腾讯', + }, + 3:{ + name:'网易云', + }, + 4:{ + name:'芒果TV', + }, + 5:{ + name:'QQ音乐', + }, + 6:{ + name:'喜马拉雅', + }, + 7:{ + name:'哔哩哔哩', + }, + 8:{ + name:'爱奇艺', + }, +} + export const stateConfig = { 1: "待支付", 2: "已支付", @@ -51,3 +78,5 @@ export const tabs = [ status: 7, }, ]; + +export default config diff --git a/src/pages/ycysp/order.vue b/src/pages/ycysp/order.vue index 795f6d5..8aef422 100644 --- a/src/pages/ycysp/order.vue +++ b/src/pages/ycysp/order.vue @@ -101,14 +101,16 @@ function handleClick({ index, name }) { function pay(orderData) { console.log(orderData); - const { order_no, notify_url, price, brand, sign, plain_text } = + const { order_no, notify_url, sign, plain_text } = orderData.pay_info; + const price = orderData.order_amount + const MerName = orderData.brandName const { payFunc } = usePay(); payFunc({ order_no, notify_url, TranAmt: price, - MerName: brand, + MerName: MerName, sign, plain_text, }); diff --git a/src/pages/ycysp/orderDetail.vue b/src/pages/ycysp/orderDetail.vue index 6a12d0f..0bd61de 100644 --- a/src/pages/ycysp/orderDetail.vue +++ b/src/pages/ycysp/orderDetail.vue @@ -28,7 +28,7 @@ 充值账号: - {{ maskPhoneNumber(orderDetail.account) }} + {{ orderDetail.account ? maskPhoneNumber(orderDetail.account) : '' }} 数量 @@ -151,13 +151,15 @@ function maskPhoneNumber(phoneNumber) { } function pay(orderData) { - const { order_no, notify_url, price, brand, sign, plain_text } = orderData; + const { order_no, notify_url,sign, plain_text } = orderData; + const price = orderData.order_amount + const MerName = orderData.brandName const { payFunc } = usePay(); payFunc({ order_no, notify_url, TranAmt: price, - MerName: brand, + MerName: MerName, sign, plain_text, }); diff --git a/src/pages/ycysp/pay.vue b/src/pages/ycysp/pay.vue index 13be27c..1029413 100644 --- a/src/pages/ycysp/pay.vue +++ b/src/pages/ycysp/pay.vue @@ -35,7 +35,7 @@ 充值账户:{{ maskPhoneNumber(orderDetail.account) }}充值账户:{{ orderDetail.account ? maskPhoneNumber(orderDetail.account) : '' }} 充值类型:{{ orderDetail.product_type }} @@ -55,6 +55,7 @@ import { onShow, onLoad } from "@dcloudio/uni-app"; import { ref, reactive, unref, onMounted, computed } from "vue"; import { createOrder, getOrderList } from "@/api/ycysp"; import usePay from "./hooks/usePay"; +import config from './config'; const orderDetail = reactive({}); const _order_no = ref(""); @@ -83,8 +84,8 @@ const goPay = () => { payFunc({ order_no, notify_url, - TranAmt: voucherAmount, - MerName: config[brandFlag].name, + TranAmt: orderDetail.order_amount, + MerName: orderDetail.brandName, sign, plain_text, }); diff --git a/vite.plugin.js b/vite.plugin.js index 0464ff0..4eed0a5 100644 --- a/vite.plugin.js +++ b/vite.plugin.js @@ -1,32 +1,36 @@ +const fs = require("fs-extra"); +const path = require("path"); -const fs = require('fs-extra') -const path = require('path'); - -// Vite插件函数 -function vitePluginRemoveDir(options = {}) { - // 默认要删除的目录名 - const { dirName} = options; - if(!dirName.length){ - return {} +// Vite插件函数 +function vitePluginRemoveDir(options = {}) { + // 默认要删除的目录名 + const { dirName } = options; + if (!dirName.length) { + return {}; } - return { - name: 'vite-plugin-remove-dir', // 插件名称 - closeBundle(){ - const distDir = path.resolve(process.cwd(), 'dist'); - // 构建结束后执行的逻辑 - for(const item of dirName){ - const fullPath = path.join(distDir, ['production'].includes(process.env.NODE_ENV) ? 'build' : 'dev',process.env.UNI_PLATFORM,`static/${item}`); // 构造要删除的目录的完整路径 - console.log('fullPath',fullPath); - // 尝试删除目录 - try { - fs.removeSync(fullPath); - console.log(`目录${fullPath}成功删除.`); - } catch (err) { - console.log(`目录${fullPath}删除失败-->${err}`); - } + return { + name: "vite-plugin-remove-dir", // 插件名称 + closeBundle() { + const distDir = path.resolve(process.cwd(), "dist"); + // 构建结束后执行的逻辑 + for (const item of dirName) { + const fullPath = path.join( + distDir, + ["production"].includes(process.env.NODE_ENV) ? "build" : "dev", + process.env.UNI_PLATFORM, + `static/${item}` + ); // 构造要删除的目录的完整路径 + console.log("fullPath", fullPath); + // 尝试删除目录 + try { + fs.removeSync(fullPath); + console.log(`目录${fullPath}成功删除.`); + } catch (err) { + console.log(`目录${fullPath}删除失败-->${err}`); } - } - }; -} - -module.exports = vitePluginRemoveDir; \ No newline at end of file + } + }, + }; +} + +module.exports = vitePluginRemoveDir;