Electron-vue開(kāi)發(fā)的客戶端支付收款工具的實(shí)現(xiàn)
目前實(shí)現(xiàn)了支付寶當(dāng)面付的掃碼支付功能、二維碼支付功能,即主動(dòng)掃和被動(dòng)掃。測(cè)試請(qǐng)使用支付寶沙箱環(huán)境,支付寶是沙箱版。
最終效果如下:


前端頁(yè)面使用阿里的組件,ant-design-vue
通過(guò)node,使用nedb內(nèi)存數(shù)據(jù)庫(kù)進(jìn)行本地?cái)?shù)據(jù)存儲(chǔ)

安裝文件支持自定義。生成的exe,安裝過(guò)程如下

程序代碼簡(jiǎn)述

main.js
import devtools from '@vue/devtools'
import Vue from 'vue'
import axios from 'axios'
import App from './App'
import router from './router'
import store from './store'
import db from './nedb'//訂單表
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'
import alipayhelper from './alipayhelper'
import moment from 'moment'//導(dǎo)入文件
Vue.prototype.$moment = moment;//賦值使用
Vue.prototype.$db = db
Vue.prototype.alipayhelper = alipayhelper;
Vue.use(Antd)
if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
Vue.http = Vue.prototype.$http = axios
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
components: { App },
router,
store,
template: '<App/>'
}).$mount('#app')
alipayhelper.js 里存儲(chǔ)的支付寶收款方的APPID,pem路徑下應(yīng)用私鑰。這些信息可以通過(guò)阿里官方申請(qǐng),即可以在線收款
const path = require('path');
const fs = require('fs');
const moment = require('moment');
const crypto = require('crypto');
const electron = require('electron');
const dataPath = (electron.app || electron.remote.app).getPath('userData');
const home = (electron.app || electron.remote.app).getPath('home');
const appData = (electron.app || electron.remote.app).getPath('appData');
let ALI_PAY_SETTINGS = {
APP_ID: '2016100100638328',
APP_GATEWAY_URL: 'http://localhost',//用于接收支付寶異步通知
AUTH_REDIRECT_URL: 'xxxxxxx',//第三方授權(quán)或用戶信息授權(quán)后回調(diào)地址。授權(quán)鏈接中配置的redirect_uri的值必須與此值保持一致。
//__dirname 獲取當(dāng)前目錄,無(wú)法在生產(chǎn)模式assr 獲取到路徑
/* APP_PRIVATE_KEY_PATH: path.join(__dirname, 'pem', 'rsa_private_key.pem'),//應(yīng)用私鑰
APP_PUBLIC_KEY_PATH: path.join(__dirname, 'pem', 'rsa_public_key.pem'),//應(yīng)用公鑰
ALI_PUBLIC_KEY_PATH: path.join(__dirname, 'pem','ali_rsa_public_key.pem'),//阿里公鑰*/
APP_PRIVATE_KEY_PATH: path.join(__static, '/pem/rsa_private_key.pem'),//應(yīng)用私鑰
APP_PUBLIC_KEY_PATH: path.join(__static, '/pem/rsa_public_key.pem'),//應(yīng)用公鑰
ALI_PUBLIC_KEY_PATH: path.join(__static, '/pem/ali_rsa_public_key.pem'),//阿里公鑰
AES_PATH: path.join(__dirname, 'pem', 'remind', 'sandbox', 'aes.txt'),//aes加密(暫未使用)
ALI_GATEWAY_URL: 'https://openapi.alipaydev.com/gateway.do?',//用于接收支付寶異步通知
};
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
如何在vue里添加好看的lottie動(dòng)畫(huà)
這篇文章主要介紹了在vue里添加好看的lottie動(dòng)畫(huà)效果的方法,在vue中引入lottie非常簡(jiǎn)單,需要的朋友可以參考下2018-08-08
Vue中兩種生成二維碼(帶logo)并下載方式總結(jié)
與后端生成二維碼相比,前端生成二維碼更具有靈活性,下面這篇文章主要給大家介紹了關(guān)于Vue中兩種生成二維碼(帶logo)并下載的相關(guān)資料,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-03-03
淺談基于Vue.js的移動(dòng)組件庫(kù)cube-ui
這篇文章主要介紹了基于Vue.js的移動(dòng)組件庫(kù)cube-ui,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-12-12
Vue檢測(cè)屏幕變化來(lái)改變不同的charts樣式實(shí)例
這篇文章主要介紹了Vue檢測(cè)屏幕變化來(lái)改變不同的charts樣式實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-10-10
vue 使用 sortable 實(shí)現(xiàn) el-table 拖拽排序功能
這篇文章主要介紹了vue 使用 sortable 實(shí)現(xiàn) el-table 拖拽排序功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-12-12
vue3 與 vue2 優(yōu)點(diǎn)對(duì)比匯總
隨著用vue3 的開(kāi)發(fā)者越來(lái)越多,其必定是又她一定的有帶你,接下來(lái)這篇文章小編就為大家介紹vue3 對(duì)比 vue2 有什么優(yōu)點(diǎn)?感興趣的小伙伴請(qǐng)跟小編一起閱讀下文吧2021-09-09
vue3輸入單號(hào)和張數(shù)如何自動(dòng)生成連號(hào)的單號(hào)
最近遇到這樣的需求輸入連號(hào)事件,需要在表格中輸入物流單號(hào),物流號(hào)碼,生成的數(shù)量,名稱,點(diǎn)擊確定自動(dòng)生成固定數(shù)量的連號(hào)物流單號(hào),本文重點(diǎn)介紹vue3輸入單號(hào)和張數(shù),自動(dòng)生成連號(hào)的單號(hào),感興趣的朋友一起看看吧2024-02-02

