feat:实现了微信小程序、H5、华为快应用三端适配微信 / 支付宝 / 华为官方支付规范的支付功能

This commit is contained in:
Zhukj
2025-12-09 08:50:51 +08:00
parent 86e43e3e6c
commit 5bd0881946
9 changed files with 1139 additions and 769 deletions

164
main.js
View File

@@ -1,67 +1,99 @@
// #ifdef H5
import './common/js/pc'
// #endif
import Vue from 'vue'
import App from './App'
import store from './store'
import Util from './common/js/util.js'
import Http from './common/js/http.js'
import Lang from './common/js/lang.js'
import Config from './common/js/config.js'
import EventBus from './common/js/event-bus.js'
import DomEventBridge from './common/js/dom-event-bridge.js'
import globalConfig from './common/js/golbalConfig.js';
import {
uniStorage
} from './common/js/storage.js'
Vue.prototype.$store = store //挂在vue
Vue.config.productionTip = false
Vue.prototype.$util = Util;
Vue.prototype.$api = Http;
Vue.prototype.$langConfig = Lang; //语言包对象
Vue.prototype.$lang = Lang.lang; //解析语言包
Vue.prototype.$config = Config;
// #ifdef H5
EventBus.setDomBridge(DomEventBridge)
// #endif
Vue.prototype.$eventBus = EventBus;
Vue.mixin(globalConfig);
App.mpType = 'app';
// 重写存储,增加前缀
uniStorage();
//常用组件
import loadingCover from '@/components/loading-cover/loading-cover.vue';
Vue.component('loading-cover', loadingCover);
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
Vue.component('ns-empty', nsEmpty);
import MescrollUni from "@/components/mescroll/my-list-mescroll.vue";
Vue.component("mescroll-uni", MescrollUni); //上拉加载,下拉刷新组件
import MescrollBody from "@/components/mescroll/mescroll-body.vue"
Vue.component('mescroll-body', MescrollBody);
import NsLogin from "@/components/ns-login/ns-login.vue"
Vue.component('ns-login', NsLogin);
import PrivacyPopup from '@/components/wx-privacy-popup/privacy-popup.vue';
Vue.component('privacy-popup', PrivacyPopup)
const app = new Vue({
...App,
store
})
// #ifdef H5
import './common/js/pc'
// #endif
import Vue from 'vue'
import App from './App'
import store from './store'
import Util from './common/js/util.js'
import Http from './common/js/http.js'
import Lang from './common/js/lang.js'
import Config from './common/js/config.js'
import EventBus from './common/js/event-bus.js'
import DomEventBridge from './common/js/dom-event-bridge.js'
import globalConfig from './common/js/golbalConfig.js';
import {
uniStorage
} from './common/js/storage.js'
Vue.prototype.$store = store //挂在vue
Vue.config.productionTip = false
Vue.prototype.$util = Util;
Vue.prototype.$api = Http;
Vue.prototype.$langConfig = Lang; //语言包对象
Vue.prototype.$lang = Lang.lang; //解析语言包
Vue.prototype.$config = Config;
// #ifdef H5
EventBus.setDomBridge(DomEventBridge)
// #endif
Vue.prototype.$eventBus = EventBus;
Vue.mixin(globalConfig);
App.mpType = 'app';
// 重写存储,增加前缀
uniStorage();
//常用组件
import loadingCover from '@/components/loading-cover/loading-cover.vue';
Vue.component('loading-cover', loadingCover);
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
Vue.component('ns-empty', nsEmpty);
import MescrollUni from "@/components/mescroll/my-list-mescroll.vue";
Vue.component("mescroll-uni", MescrollUni); //上拉加载,下拉刷新组件
import MescrollBody from "@/components/mescroll/mescroll-body.vue"
Vue.component('mescroll-body', MescrollBody);
import NsLogin from "@/components/ns-login/ns-login.vue"
Vue.component('ns-login', NsLogin);
import PrivacyPopup from '@/components/wx-privacy-popup/privacy-popup.vue';
// 只保留一次组件注册(删除重复行)
Vue.component('privacy-popup', PrivacyPopup)
// 全局登录方法(替换成你的真实后端接口地址)
Vue.prototype.$doGlobalLogin = async function() {
return new Promise((resolve, reject) => {
uni.login({
success: async (loginRes) => {
if (!loginRes.code) {
reject("获取登录凭证失败,请重试");
return;
}
try {
// !!替换为你的真实后端登录接口地址!!
const res = await uni.request({
url: "https://dev.aigc-quickapp.com/api/user/login",
method: "POST",
data: { code: loginRes.code }
});
if (res.data?.success) {
uni.setStorageSync("token", res.data.token);
resolve(true);
} else {
reject(res.data?.msg || "登录失败");
}
} catch (err) {
reject("网络异常");
}
},
fail: () => reject("登录授权失败")
});
});
};
// 只创建一次Vue实例删除重复声明
const app = new Vue({
...App,
store
})
app.$mount()