@zhangcf233/pay 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pay.es.js +113 -7
- package/dist/pay.umd.js +2 -2
- package/dist/types/components/popup.vue.d.ts +10 -2
- package/dist/types/types/config.d.ts +2 -0
- package/package.json +1 -1
package/dist/pay.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('@charset "UTF-8";.pay-error-container[data-v-0817c014]{position:relative}.pay-error-container .loading[data-v-0817c014]{width:100%;height:100%;position:absolute;background:#fff;z-index:1;transition:all .3s;justify-content:center;align-items:center}.pay-error-container .message[data-v-0817c014]{font-size:.1rem}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-20b4bf5f]{font-family:WeChat-Bold}.root[data-v-20b4bf5f]{text-align:center}.cell[data-v-70746494]{display:flex;align-items:center;justify-content:space-between;height:.3rem}.cell .name[data-v-70746494]{width:30vw;color:gray;font-size:.14rem;display:flex;align-items:center;justify-content:end}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-ea027830]{font-family:WeChat-Bold}.custom-price .input[data-v-ea027830]{font-size:.2rem}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-79d1ed34]{font-family:WeChat-Bold}.price-root[data-v-79d1ed34]{position:relative;text-align:center;background:#f3f3f3;border-radius:.08rem;padding:.1rem 0;display:flex;flex-direction:column;height:.6rem;box-sizing:border-box;justify-content:space-between;align-items:center}.price-root .gift[data-v-79d1ed34]{position:absolute;top:-.1rem;right:-.05rem;background:linear-gradient(248.45deg,#fa1e1e,#ff7752 99.44%);padding:0 .05rem;border-radius:.1rem .1rem .1rem 0;font-size:.1rem;border-width:.02rem;border-color:#fff;border-style:solid;box-sizing:border-box;color:#fff}.price-root .token-count[data-v-79d1ed34]{display:flex;justify-content:center;align-items:center;font-size:.2rem}.price-root .token-count img[data-v-79d1ed34]{width:.16rem;height:.16rem;margin-right:.02rem}.price-root .price[data-v-79d1ed34]{font-size:.14rem}.only-price[data-v-79d1ed34]{align-items:center;justify-content:center}.only-price .price[data-v-79d1ed34]{font-size:.2rem}.content[data-v-737beb57]{width:100%;margin:.2rem 0;display:grid;grid-template-columns:repeat(3,1fr);gap:.1rem;box-sizing:border-box;font-weight:500}.loading[data-v-737beb57]{display:flex;justify-content:center;align-items:center}.select[data-v-737beb57]{color:#fff}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-
|
|
1
|
+
!function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('@charset "UTF-8";.pay-error-container[data-v-0817c014]{position:relative}.pay-error-container .loading[data-v-0817c014]{width:100%;height:100%;position:absolute;background:#fff;z-index:1;transition:all .3s;justify-content:center;align-items:center}.pay-error-container .message[data-v-0817c014]{font-size:.1rem}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-20b4bf5f]{font-family:WeChat-Bold}.root[data-v-20b4bf5f]{text-align:center}.cell[data-v-70746494]{display:flex;align-items:center;justify-content:space-between;height:.3rem}.cell .name[data-v-70746494]{width:30vw;color:gray;font-size:.14rem;display:flex;align-items:center;justify-content:end}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-ea027830]{font-family:WeChat-Bold}.custom-price .input[data-v-ea027830]{font-size:.2rem}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-79d1ed34]{font-family:WeChat-Bold}.price-root[data-v-79d1ed34]{position:relative;text-align:center;background:#f3f3f3;border-radius:.08rem;padding:.1rem 0;display:flex;flex-direction:column;height:.6rem;box-sizing:border-box;justify-content:space-between;align-items:center}.price-root .gift[data-v-79d1ed34]{position:absolute;top:-.1rem;right:-.05rem;background:linear-gradient(248.45deg,#fa1e1e,#ff7752 99.44%);padding:0 .05rem;border-radius:.1rem .1rem .1rem 0;font-size:.1rem;border-width:.02rem;border-color:#fff;border-style:solid;box-sizing:border-box;color:#fff}.price-root .token-count[data-v-79d1ed34]{display:flex;justify-content:center;align-items:center;font-size:.2rem}.price-root .token-count img[data-v-79d1ed34]{width:.16rem;height:.16rem;margin-right:.02rem}.price-root .price[data-v-79d1ed34]{font-size:.14rem}.only-price[data-v-79d1ed34]{align-items:center;justify-content:center}.only-price .price[data-v-79d1ed34]{font-size:.2rem}.content[data-v-737beb57]{width:100%;margin:.2rem 0;display:grid;grid-template-columns:repeat(3,1fr);gap:.1rem;box-sizing:border-box;font-weight:500}.loading[data-v-737beb57]{display:flex;justify-content:center;align-items:center}.select[data-v-737beb57]{color:#fff}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-4e76879e]{font-family:WeChat-Bold}.pay-popup[data-v-4e76879e]{display:flex;flex-direction:column;width:100vw;box-sizing:border-box;overflow:hidden;padding:0 .15rem .2rem;transition:all .3s}.title[data-v-4e76879e]{text-align:center;margin:.16rem 0}.check-box[data-v-4e76879e]{display:flex;justify-content:center;align-items:center;font-size:.12rem;padding:.1rem 0}.protocol-popup[data-v-4e76879e]{height:70vh;width:100vw;overflow-x:hidden}.protocol-popup .prptocol[data-v-4e76879e]{display:flex;flex-direction:column;justify-content:center;align-items:center;height:100%}.protocol-popup .prptocol .btn-box[data-v-4e76879e]{height:10%;width:100%;display:flex;justify-content:space-around;padding:.1rem;box-sizing:content-box}.protocol-popup .prptocol .btn-box>*[data-v-4e76879e]{width:45%}.protocol-popup .prptocol iframe[data-v-4e76879e]{display:block;width:100%;height:90%;margin:0;border:0}.agree-dialog .check-box[data-v-4e76879e]{margin:.2rem}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => {
|
|
@@ -194,6 +194,7 @@ const sendPay = async ({ channel, key, value, prefix }) => {
|
|
|
194
194
|
};
|
|
195
195
|
const BaseTheme = "orange";
|
|
196
196
|
const ignorePlatform = ["platform"];
|
|
197
|
+
const BaseAgreement = "https://qi0irqynw8.feishu.cn/docx/Ea1PdrV5SonBfHxAIHUchKjVnVf";
|
|
197
198
|
const AgentConfig = {
|
|
198
199
|
needId: false,
|
|
199
200
|
name: "店铺余额",
|
|
@@ -234,7 +235,8 @@ const AgentConfig = {
|
|
|
234
235
|
},
|
|
235
236
|
pay: {
|
|
236
237
|
key: "Money"
|
|
237
|
-
}
|
|
238
|
+
},
|
|
239
|
+
agreement: BaseAgreement
|
|
238
240
|
};
|
|
239
241
|
const UserConfig = {
|
|
240
242
|
theme: "#ff4f4f",
|
|
@@ -275,7 +277,8 @@ const UserConfig = {
|
|
|
275
277
|
},
|
|
276
278
|
pay: {
|
|
277
279
|
key: "Money"
|
|
278
|
-
}
|
|
280
|
+
},
|
|
281
|
+
agreement: BaseAgreement
|
|
279
282
|
};
|
|
280
283
|
const PayAllConfig = {
|
|
281
284
|
agent: AgentConfig,
|
|
@@ -973,6 +976,12 @@ let PayPopup$1 = class PayPopup extends Vue {
|
|
|
973
976
|
super(...arguments);
|
|
974
977
|
__publicField(this, "config");
|
|
975
978
|
__publicField(this, "id");
|
|
979
|
+
// 同意协议本地标识
|
|
980
|
+
__publicField(this, "isAgreeProtocolFlag", "__isAgreeProtocol__");
|
|
981
|
+
// 是否同意支付协议
|
|
982
|
+
__publicField(this, "isAgreeProtocol", false);
|
|
983
|
+
// 是否弹出充值协议
|
|
984
|
+
__publicField(this, "isOpenProtocol", false);
|
|
976
985
|
// 默认主题
|
|
977
986
|
__publicField(this, "baseTheme", BaseTheme);
|
|
978
987
|
// 弹出层是否显示
|
|
@@ -995,10 +1004,20 @@ let PayPopup$1 = class PayPopup extends Vue {
|
|
|
995
1004
|
channel: false
|
|
996
1005
|
});
|
|
997
1006
|
}
|
|
1007
|
+
onIsAgreeProtocolChange(n) {
|
|
1008
|
+
if (n) {
|
|
1009
|
+
localStorage.setItem(this.isAgreeProtocolFlag, "true");
|
|
1010
|
+
} else {
|
|
1011
|
+
localStorage.removeItem(this.isAgreeProtocolFlag);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
998
1014
|
async mounted() {
|
|
999
1015
|
this.$nextTick(() => {
|
|
1000
1016
|
this.visible = true;
|
|
1001
1017
|
this.initLoad();
|
|
1018
|
+
this.isAgreeProtocol = Boolean(
|
|
1019
|
+
localStorage.getItem(this.isAgreeProtocolFlag) || false
|
|
1020
|
+
);
|
|
1002
1021
|
});
|
|
1003
1022
|
}
|
|
1004
1023
|
// 初始化加载状态
|
|
@@ -1014,8 +1033,31 @@ let PayPopup$1 = class PayPopup extends Vue {
|
|
|
1014
1033
|
onClosed() {
|
|
1015
1034
|
this.$emit("onClosed");
|
|
1016
1035
|
}
|
|
1036
|
+
// 打开协议弹窗
|
|
1037
|
+
openProtocol() {
|
|
1038
|
+
this.isOpenProtocol = true;
|
|
1039
|
+
}
|
|
1040
|
+
// 同意协议
|
|
1041
|
+
agreeProtocol() {
|
|
1042
|
+
this.isAgreeProtocol = true;
|
|
1043
|
+
this.isOpenProtocol = false;
|
|
1044
|
+
}
|
|
1045
|
+
// 不同意协议
|
|
1046
|
+
notAgree() {
|
|
1047
|
+
this.isAgreeProtocol = false;
|
|
1048
|
+
this.isOpenProtocol = false;
|
|
1049
|
+
}
|
|
1050
|
+
// 同意并支付
|
|
1051
|
+
agreeProtocolAndPay() {
|
|
1052
|
+
this.agreeProtocol();
|
|
1053
|
+
this.onTopup();
|
|
1054
|
+
}
|
|
1017
1055
|
// 点击充值
|
|
1018
1056
|
async onTopup() {
|
|
1057
|
+
if (!this.isAgreeProtocol) {
|
|
1058
|
+
this.openProtocol();
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1019
1061
|
const { key, prefix } = this.config.pay;
|
|
1020
1062
|
const value = String(this.id || this.price.price);
|
|
1021
1063
|
if (!this.channel) {
|
|
@@ -1028,7 +1070,6 @@ let PayPopup$1 = class PayPopup extends Vue {
|
|
|
1028
1070
|
value,
|
|
1029
1071
|
prefix
|
|
1030
1072
|
});
|
|
1031
|
-
this.onClosed();
|
|
1032
1073
|
}
|
|
1033
1074
|
/** 余额变动*/
|
|
1034
1075
|
onBanlanceChange(money) {
|
|
@@ -1062,6 +1103,9 @@ __decorateClass([
|
|
|
1062
1103
|
__decorateClass([
|
|
1063
1104
|
Prop({ default: void 0 })
|
|
1064
1105
|
], PayPopup$1.prototype, "id", 2);
|
|
1106
|
+
__decorateClass([
|
|
1107
|
+
Watch("isAgreeProtocol")
|
|
1108
|
+
], PayPopup$1.prototype, "onIsAgreeProtocolChange", 1);
|
|
1065
1109
|
PayPopup$1 = __decorateClass([
|
|
1066
1110
|
Component$1({
|
|
1067
1111
|
components: {
|
|
@@ -1110,7 +1154,31 @@ var render = function() {
|
|
|
1110
1154
|
on: {
|
|
1111
1155
|
"change": _vm.onChannelChange
|
|
1112
1156
|
}
|
|
1113
|
-
}), _c("
|
|
1157
|
+
}), _c("div", {
|
|
1158
|
+
staticClass: "check-box"
|
|
1159
|
+
}, [_c("van-checkbox", {
|
|
1160
|
+
attrs: {
|
|
1161
|
+
"checked-color": _vm.config.theme,
|
|
1162
|
+
"icon-size": "12"
|
|
1163
|
+
},
|
|
1164
|
+
model: {
|
|
1165
|
+
value: _vm.isAgreeProtocol,
|
|
1166
|
+
callback: function($$v) {
|
|
1167
|
+
_vm.isAgreeProtocol = $$v;
|
|
1168
|
+
},
|
|
1169
|
+
expression: "isAgreeProtocol"
|
|
1170
|
+
}
|
|
1171
|
+
}, [_vm._v(" 阅读并同意 "), _c("span", {
|
|
1172
|
+
style: {
|
|
1173
|
+
color: _vm.config.theme
|
|
1174
|
+
},
|
|
1175
|
+
on: {
|
|
1176
|
+
"click": function($event) {
|
|
1177
|
+
$event.stopPropagation();
|
|
1178
|
+
return _vm.openProtocol.apply(null, arguments);
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
}, [_vm._v("充值协议")])])], 1), _c("Button", {
|
|
1114
1182
|
attrs: {
|
|
1115
1183
|
"disabled": _vm.disable,
|
|
1116
1184
|
"color": _vm.config.theme || _vm.baseTheme,
|
|
@@ -1119,7 +1187,45 @@ var render = function() {
|
|
|
1119
1187
|
on: {
|
|
1120
1188
|
"click": _vm.onTopup
|
|
1121
1189
|
}
|
|
1122
|
-
}, [_vm._v(" 立即支付 " + _vm._s(_vm.finalPrice) + " 元 ")])
|
|
1190
|
+
}, [_vm._v(" 立即支付 " + _vm._s(_vm.finalPrice) + " 元 ")]), _c("van-popup", {
|
|
1191
|
+
staticClass: "protocol-popup",
|
|
1192
|
+
attrs: {
|
|
1193
|
+
"position": "bottom",
|
|
1194
|
+
"overlay": true,
|
|
1195
|
+
"round": ""
|
|
1196
|
+
},
|
|
1197
|
+
model: {
|
|
1198
|
+
value: _vm.isOpenProtocol,
|
|
1199
|
+
callback: function($$v) {
|
|
1200
|
+
_vm.isOpenProtocol = $$v;
|
|
1201
|
+
},
|
|
1202
|
+
expression: "isOpenProtocol"
|
|
1203
|
+
}
|
|
1204
|
+
}, [_c("div", {
|
|
1205
|
+
staticClass: "prptocol"
|
|
1206
|
+
}, [_c("iframe", {
|
|
1207
|
+
attrs: {
|
|
1208
|
+
"src": _vm.config.agreement
|
|
1209
|
+
}
|
|
1210
|
+
}), _c("div", {
|
|
1211
|
+
staticClass: "btn-box"
|
|
1212
|
+
}, [_c("van-button", {
|
|
1213
|
+
attrs: {
|
|
1214
|
+
"block": ""
|
|
1215
|
+
},
|
|
1216
|
+
on: {
|
|
1217
|
+
"click": _vm.notAgree
|
|
1218
|
+
}
|
|
1219
|
+
}, [_vm._v("不同意")]), _c("van-button", {
|
|
1220
|
+
attrs: {
|
|
1221
|
+
"color": _vm.config.theme,
|
|
1222
|
+
"block": "",
|
|
1223
|
+
"type": "primary"
|
|
1224
|
+
},
|
|
1225
|
+
on: {
|
|
1226
|
+
"click": _vm.agreeProtocolAndPay
|
|
1227
|
+
}
|
|
1228
|
+
}, [_vm._v("同意并支付")])], 1)])])], 2);
|
|
1123
1229
|
};
|
|
1124
1230
|
var staticRenderFns = [];
|
|
1125
1231
|
const popup_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
@@ -1130,7 +1236,7 @@ var __component__ = /* @__PURE__ */ normalizeComponent(
|
|
|
1130
1236
|
staticRenderFns,
|
|
1131
1237
|
false,
|
|
1132
1238
|
__vue2_injectStyles,
|
|
1133
|
-
"
|
|
1239
|
+
"4e76879e",
|
|
1134
1240
|
null,
|
|
1135
1241
|
null
|
|
1136
1242
|
);
|
package/dist/pay.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('@charset "UTF-8";.pay-error-container[data-v-0817c014]{position:relative}.pay-error-container .loading[data-v-0817c014]{width:100%;height:100%;position:absolute;background:#fff;z-index:1;transition:all .3s;justify-content:center;align-items:center}.pay-error-container .message[data-v-0817c014]{font-size:.1rem}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-20b4bf5f]{font-family:WeChat-Bold}.root[data-v-20b4bf5f]{text-align:center}.cell[data-v-70746494]{display:flex;align-items:center;justify-content:space-between;height:.3rem}.cell .name[data-v-70746494]{width:30vw;color:gray;font-size:.14rem;display:flex;align-items:center;justify-content:end}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-ea027830]{font-family:WeChat-Bold}.custom-price .input[data-v-ea027830]{font-size:.2rem}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-79d1ed34]{font-family:WeChat-Bold}.price-root[data-v-79d1ed34]{position:relative;text-align:center;background:#f3f3f3;border-radius:.08rem;padding:.1rem 0;display:flex;flex-direction:column;height:.6rem;box-sizing:border-box;justify-content:space-between;align-items:center}.price-root .gift[data-v-79d1ed34]{position:absolute;top:-.1rem;right:-.05rem;background:linear-gradient(248.45deg,#fa1e1e,#ff7752 99.44%);padding:0 .05rem;border-radius:.1rem .1rem .1rem 0;font-size:.1rem;border-width:.02rem;border-color:#fff;border-style:solid;box-sizing:border-box;color:#fff}.price-root .token-count[data-v-79d1ed34]{display:flex;justify-content:center;align-items:center;font-size:.2rem}.price-root .token-count img[data-v-79d1ed34]{width:.16rem;height:.16rem;margin-right:.02rem}.price-root .price[data-v-79d1ed34]{font-size:.14rem}.only-price[data-v-79d1ed34]{align-items:center;justify-content:center}.only-price .price[data-v-79d1ed34]{font-size:.2rem}.content[data-v-737beb57]{width:100%;margin:.2rem 0;display:grid;grid-template-columns:repeat(3,1fr);gap:.1rem;box-sizing:border-box;font-weight:500}.loading[data-v-737beb57]{display:flex;justify-content:center;align-items:center}.select[data-v-737beb57]{color:#fff}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-
|
|
2
|
-
var __defProp=Object.defineProperty,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__publicField=(e,t,n)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,n),n);!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vant"),require("vue"),require("vue-class-component"),require("vue-property-decorator")):"function"==typeof define&&define.amd?define(["exports","vant","vue","vue-class-component","vue-property-decorator"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).PayPlugin={},e.vant,e.Vue,e.Component,e.vuePropertyDecorator)}(this,function(e,t,n,i,o){var r,s;async function a(e,t,n="POST"){return new Promise((i,o)=>{const r=localStorage.getItem("AppToken")||"";if(!r)throw new Error("token 不存在");fetch(e,{method:n,headers:{AppToken:r,"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(t).toString()}).then(async e=>{if(!e.ok){const t=await e.text();throw new Error(`HTTP ${e.status} ${e.statusText}: ${t}`)}try{return await e.json()}catch(t){o("解析 JSON 异常")}}).then(e=>{i(e)}).catch(e=>{let t=(null==e?void 0:e.message)||"未知异常";e.message.includes("404")?t="资源未找到":e.message.includes("500")?t="服务器错误":e instanceof TypeError&&"Failed to fetch"===e.message&&(t="网络连接失败"),o(t)})})}const c=(e,n="请求失败")=>(t.Dialog({title:n,message:e}),{status:!1,message:e}),l=/LT-APP/.test(navigator.userAgent),p=null==(s=null==(r=n.prototype)?void 0:r.$jsBridge)?void 0:s.inApp,u=Boolean(window.ReactNativeWebView),d=async e=>{const{id:t,key:i,value:o,prefix:r}=e;let s=location.origin+`/Payment/${r||""}Alipay`;const d=l||p||u;if(s+=`?qrcode=${d}&id=${t}`,!i||!o)return c("支付参数异常",`支付时缺少 key value 参数:${JSON.stringify(e)}`);if(s+=`&${i}=${o}`,!d)return location.href=s,{status:!0,message:"成功",data:h};var h;const{Data:f,Status:g,Message:v}=await a(s,{},"GET");return g?f?void(p?n.prototype.$jsBridge.openLink(f):location.href=f):c("支付跳转地址不存在"):c("支付请求失败",v||"请求支付结果异常")};const h=/miniProgram/i.test(navigator.userAgent)&&/micromessenger/i.test(navigator.userAgent),f=e=>{var n;const{id:i,appid:o,key:r,value:s,prefix:a}=e;if(!o)return void t.Dialog({title:"小程序 id 不存在"});if(!localStorage.getItem("AppToken"))return void t.Dialog({title:"环境异常",message:"本地 AppToken 不存在! 请重新登录",showCancelButton:!1,confirmButtonText:"确定"});const c={appid:o,payKey:r,payValue:s,paymentId:i,payApi:`${location.origin}}/Payment/${a}Weixin`,tokenKey:"AppToken",tokenValue:localStorage.getItem("AppToken")},l=`weixin://dl/business/?appid=${o}&path=pages/home/index&query=${encodeURIComponent(Object.entries(c).map(([e,t])=>`${e}=${String(t)}`).join("&"))}`;if(window.ReactNativeWebView)null==(n=window.ReactNativeWebView)||n.postMessage(JSON.stringify({type:"openUrl",data:{url:l},code:200}));else if(h){const e=Object.entries(c).map(([e,t])=>`${e}=${String(t)}`).join("&");uni.navigateTo({url:`/pages/home/pay?${e}`})}else location.href=l},g={alipay:d,wechat:f};function v(e,t){return e.filter(({type:e})=>!t.includes(e)&&(e in g||void 0))}const m=["platform"],y={needId:!1,name:"店铺余额",theme:"#4089ff",balance:{disabled:!1,key:"Money",api:"/AgentUser/GetMoney"},price:{disabled:!1,custom:!0,prices:[{price:800},{price:12800},{price:38800},{price:68800},{price:128800},{price:268800}]},channel:{api:"/SystemPayment/GetList",ignores:m},pay:{key:"Money"}},_={agent:y,user:{theme:"#ff4f4f",name:"幸运币余额",needId:!1,balance:{disabled:!1,key:"PlaMoney",api:"/PlayerUser/GetMoney"},price:{disabled:!1,custom:!0,prices:[{price:200},{price:500},{price:1e3},{price:5e3},{price:1e4},{price:2e4}]},channel:{api:"/SystemPayment/GetList",ignores:m},pay:{key:"Money"}}};var b=Object.defineProperty,P=Object.getOwnPropertyDescriptor,C=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?P(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&b(t,n,r),r};let w=class extends o.Vue{constructor(){super(...arguments),__publicField(this,"load"),__publicField(this,"loading",!0),__publicField(this,"message","")}get showLoading(){return this.loading||this.message}async mounted(){await this.retry()}test(){this.loading=!0,setTimeout(()=>{this.loading=!1},100)}async retry(){this.message="",this.loading=!0;const e=await this.load().finally(()=>{this.loading=!1}).catch(e=>{this.message=e});null!=e&&this.$emit("done",e)}};C([o.Prop()],w.prototype,"load",2),w=C([o.Component],w);function $(e,t,n,i,o,r,s,a){var c,l="function"==typeof e?e.options:e;if(t&&(l.render=t,l.staticRenderFns=n,l._compiled=!0),i&&(l.functional=!0),r&&(l._scopeId="data-v-"+r),s?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},l._ssrRegister=c):o&&(c=a?function(){o.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:o),c)if(l.functional){l._injectStyles=c;var p=l.render;l.render=function(e,t){return c.call(t),p(e,t)}}else{var u=l.beforeCreate;l.beforeCreate=u?[].concat(u,c):[c]}return{exports:e,options:l}}const x={};var k=$(w,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"pay-error-container"},[n("div",{staticClass:"loading",style:{display:e.showLoading?"flex":"none"}},[e.message?n("van-tag",{attrs:{type:"danger"},on:{click:e.retry}},[e._v(" "+e._s(e.message)+" 点击重试 ")]):n("van-loading",{staticClass:"loading-icon",attrs:{size:"20",type:"spinner"}})],1),e._t("default")],2)},[],!1,O,"0817c014",null,null);function O(e){for(let t in x)this[t]=x[t]}const T=function(){return k.exports}();var j=Object.defineProperty,F=Object.getOwnPropertyDescriptor,S=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?F(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&j(t,n,r),r};let E=class extends n{constructor(){super(...arguments),__publicField(this,"config"),__publicField(this,"value",0)}load(){const{key:e,api:t}=this.config.balance;if(!t||!e)throw new Error("不存在 key 或 api");return(async(e,t)=>{const n=await a(e);return t in n?n[t]:(c(JSON.stringify(n)||"解析数据异常",`余额数据中不存在 ${t}`),0)})(t,e)}onBalanceLoad(e){this.value=e/100,this.$emit("change",e)}};S([o.Inject()],E.prototype,"config",2),E=S([o.Component({components:{PayError:T}})],E);const D={};var A=$(E,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"root wechat-font"},[n("PayError",{attrs:{load:e.load},on:{done:e.onBalanceLoad}},[n("h1",[e._v(" "+e._s(e.value)+" ")])])],1)},[],!1,I,"20b4bf5f",null,null);function I(e){for(let t in D)this[t]=D[t]}const L=function(){return A.exports}();var N=Object.defineProperty,B=Object.getOwnPropertyDescriptor,R=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?B(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&N(t,n,r),r};let V=class extends n{constructor(){super(...arguments),__publicField(this,"config"),__publicField(this,"channels",[]),__publicField(this,"select",0),__publicField(this,"showPopover",!1)}get actions(){return this.channels.length?this.channels.map(({name:e,id:t,icon:n},i)=>({text:e,id:t,disabled:i==this.select})):[]}onSelect(e,t){this.select=t,this.$emit("change",this.channels[t])}get name(){let e=this.channels[this.select];return e?e.name:""}get ignores(){return this.config.channel.ignores||[]}load(){return(async(e,t)=>v((await a(e)).map(({Id:e,PaymentValue:t,PaymentName:n,PaymentIcon:i,AgentDescribe:o})=>{const r=function(e){return e.includes("支付宝")?"alipay":e.includes("微信")?"wechat":e.includes("平台币")?"platform":e.includes("苹果")?"apple":"unknow"}(t);return{id:e,name:t,icon:i,type:r,appid:o}}),t))(this.config.channel.api,this.ignores)}onLoadChannels(e){this.channels=v(e,this.ignores),this.$emit("change",this.channels[0])}};R([o.Inject()],V.prototype,"config",2),V=R([i({components:{PayError:T}})],V);const M={};var q=$(V,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("van-popover",{attrs:{trigger:"click",actions:e.actions,placement:"top-end"},on:{select:e.onSelect},scopedSlots:e._u([{key:"reference",fn:function(){return[n("div",{staticClass:"cell"},[n("h5",[e._v("付款方式")]),n("PayError",{staticClass:"name",attrs:{load:e.load},on:{done:e.onLoadChannels}},[n("div",[e._v(" "+e._s(e.name)+" "),n("van-icon",{attrs:{name:"arrow"}})],1)])],1)]},proxy:!0}]),model:{value:e.showPopover,callback:function(t){e.showPopover=t},expression:"showPopover"}})},[],!1,U,"70746494",null,null);function U(e){for(let t in M)this[t]=M[t]}const G=function(){return q.exports}();var W=Object.defineProperty,J=Object.getOwnPropertyDescriptor,z=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?J(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&W(t,n,r),r};let K=class extends n{constructor(){super(...arguments),__publicField(this,"customPrice"),__publicField(this,"value",null)}onChange(e){this.$emit("input",Number(e))}};z([o.Prop({default:null})],K.prototype,"customPrice",2),K=z([i],K);const X={};var H=$(K,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"custom-price"},[n("h5",[e._v("自定义金额")]),n("van-field",{staticClass:"input wechat-font",attrs:{type:"digit",placeholder:"请输入金额",clearable:""},on:{input:e.onChange},model:{value:e.value,callback:function(t){e.value=t},expression:"value"}})],1)},[],!1,Q,"ea027830",null,null);function Q(e){for(let t in X)this[t]=X[t]}const Y=function(){return H.exports}();var Z=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,te=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?ee(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&Z(t,n,r),r};let ne=class extends n{constructor(){super(...arguments),__publicField(this,"price")}get realPrice(){return this.price.price/100}get onlyPrice(){return!this.price.count}};te([o.Prop({default:{}})],ne.prototype,"price",2),ne=te([i],ne);const ie={};var oe=$(ne,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"price-root wechat-font",class:{"only-price":e.onlyPrice}},[e.price.giftCount?n("span",{staticClass:"gift"},[e._v(" 赠"+e._s(e.price.giftCount)+" ")]):e._e(),e.price.count?n("span",{staticClass:"token-count"},[n("img",{attrs:{src:"https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/npdd/user/my-v3/imgs/niu-coin-top-up-icon.png"}}),e._v(" "+e._s(e.price.count)+" ")]):e._e(),n("span",{staticClass:"price"},[e._v("¥"+e._s(e.realPrice))])])},[],!1,re,"79d1ed34",null,null);function re(e){for(let t in ie)this[t]=ie[t]}const se=function(){return oe.exports}();var ae=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,le=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?ce(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&ae(t,n,r),r};let pe=class extends n{constructor(){super(...arguments),__publicField(this,"config"),__publicField(this,"value",0),__publicField(this,"prices",[]),__publicField(this,"customPrice",0),__publicField(this,"loading",!0),__publicField(this,"message","")}async mounted(){}load(){const{load:e,prices:t}=this.config.price;return e||(t?new Promise(e=>e(t)):void 0)}onLoadPrices(e){this.prices=e,this.changePrice(0)}changePrice(e){this.value=e,this.$emit("change",this.prices[e])}onCustomPriceChange(e){e?this.$emit("change",{price:100*e}):this.$emit("change",this.prices[this.value])}};le([o.Inject()],pe.prototype,"config",2),le([o.Watch("customPrice")],pe.prototype,"onCustomPriceChange",1),pe=le([i({components:{PriceItem:se,PayError:T,PriceCustom:Y}})],pe);const ue={};var de=$(pe,function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.config.price.disabled?e._e():n("div",{staticClass:"price-container"},[n("h5",[e._v("选择充值金额")]),n("PayError",{attrs:{load:e.load},on:{done:e.onLoadPrices}},[n("div",{staticClass:"content"},e._l(e.prices,function(t,i){return n("price-item",{key:i,staticClass:"price-item",class:{select:i==e.value},style:{backgroundColor:i==e.value?e.config.theme||"orange":""},attrs:{price:t},nativeOn:{click:function(t){return e.changePrice(i)}}})}),1)]),e.config.price.custom?[n("PriceCustom",{model:{value:e.customPrice,callback:function(t){e.customPrice=t},expression:"customPrice"}})]:e._e()],2)},[],!1,he,"737beb57",null,null);function he(e){for(let t in ue)this[t]=ue[t]}const fe=function(){return de.exports}();var ge=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,me=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?ve(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&ge(t,n,r),r};let ye=class extends n{constructor(){super(...arguments),__publicField(this,"config"),__publicField(this,"id"),__publicField(this,"baseTheme","orange"),__publicField(this,"visible",!1),__publicField(this,"balance",0),__publicField(this,"price",{price:0}),__publicField(this,"channel",null),__publicField(this,"loading",{balance:!1,price:!1,channel:!1})}async mounted(){this.$nextTick(()=>{this.visible=!0,this.initLoad()})}initLoad(){this.loading.balance=this.config.balance.disabled,this.loading.price=this.config.price.disabled}onClose(){this.$emit("onClose")}onClosed(){this.$emit("onClosed")}async onTopup(){const{key:e,prefix:n}=this.config.pay,i=String(this.id||this.price.price);this.channel?(await(async({channel:e,key:n,value:i,prefix:o})=>{const{type:r,id:s,appid:a}=e,c=String(Number(i)/100);switch(r in g||t.Toast("暂不支持此渠道"),r){case"alipay":return await d({id:s,key:n,value:c,prefix:o});case"wechat":return a?await f({appid:a,prefix:o,key:n,value:i,id:s}):t.Dialog({title:"参数异常",message:"此渠道未配置小程序 appid 请先使用其他渠道!"});default:t.Toast("暂不支持此渠道")}})({channel:this.channel,key:e,value:i,prefix:n}),this.onClosed()):c("渠道不存在")}onBanlanceChange(e){this.loading.balance=!0}onChannelChange(e){this.channel=e,this.loading.channel=!0}onPriceChange(e){this.price=e,this.loading.price=!0}get finalPrice(){return this.price.price/100}get disable(){return!Object.values(this.loading).every(e=>!0===e)}get title(){return this.config.name}};me([o.Provide("config"),o.Prop({default:y})],ye.prototype,"config",2),me([o.Prop({default:void 0})],ye.prototype,"id",2),ye=me([i({components:{Balance:L,Divider:t.Divider,PriceContainer:fe,Button:t.Button,PriceCustom:Y,Channels:G}})],ye);const _e={};var be=$(ye,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("van-popup",{staticClass:"pay-popup",attrs:{position:"bottom",overlay:!0,round:""},on:{closed:e.onClosed,close:e.onClose},model:{value:e.visible,callback:function(t){e.visible=t},expression:"visible"}},[n("h4",{staticClass:"title"},[e._v(" "+e._s(e.title)+" ")]),e.config.balance.disabled?e._e():[n("Balance",{on:{change:e.onBanlanceChange}}),n("Divider")],e.config.price.disabled?e._e():[n("PriceContainer",{on:{change:e.onPriceChange}}),n("Divider")],n("Channels",{on:{change:e.onChannelChange}}),n("Divider"),n("Button",{attrs:{disabled:e.disable,color:e.config.theme||e.baseTheme,block:""},on:{click:e.onTopup}},[e._v(" 立即支付 "+e._s(e.finalPrice)+" 元 ")])],2)},[],!1,Pe,"4ac1c510",null,null);function Pe(e){for(let t in _e)this[t]=_e[t]}const Ce=function(){return be.exports}(),we={install(e){e.prototype.$pay={create:(e,...i)=>new Promise((o,r)=>{const s=_[e],{needId:a}=s,c=i[0];if(a&&!c)return void t.Dialog({title:"参数异常",message:`${e} 类型需要传入订单号 当前未传入!`});const l=new(n.extend(Ce))({propsData:{config:s,id:c}});l.$on("onClosed",()=>{o(),setTimeout(()=>{var e;l.$destroy(),null==(e=l.$el.parentNode)||e.removeChild(l.$el)},300)}),l.$mount(),document.body.appendChild(l.$el)})}}};e.PayPlugin=we,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
!function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('@charset "UTF-8";.pay-error-container[data-v-0817c014]{position:relative}.pay-error-container .loading[data-v-0817c014]{width:100%;height:100%;position:absolute;background:#fff;z-index:1;transition:all .3s;justify-content:center;align-items:center}.pay-error-container .message[data-v-0817c014]{font-size:.1rem}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-20b4bf5f]{font-family:WeChat-Bold}.root[data-v-20b4bf5f]{text-align:center}.cell[data-v-70746494]{display:flex;align-items:center;justify-content:space-between;height:.3rem}.cell .name[data-v-70746494]{width:30vw;color:gray;font-size:.14rem;display:flex;align-items:center;justify-content:end}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-ea027830]{font-family:WeChat-Bold}.custom-price .input[data-v-ea027830]{font-size:.2rem}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-79d1ed34]{font-family:WeChat-Bold}.price-root[data-v-79d1ed34]{position:relative;text-align:center;background:#f3f3f3;border-radius:.08rem;padding:.1rem 0;display:flex;flex-direction:column;height:.6rem;box-sizing:border-box;justify-content:space-between;align-items:center}.price-root .gift[data-v-79d1ed34]{position:absolute;top:-.1rem;right:-.05rem;background:linear-gradient(248.45deg,#fa1e1e,#ff7752 99.44%);padding:0 .05rem;border-radius:.1rem .1rem .1rem 0;font-size:.1rem;border-width:.02rem;border-color:#fff;border-style:solid;box-sizing:border-box;color:#fff}.price-root .token-count[data-v-79d1ed34]{display:flex;justify-content:center;align-items:center;font-size:.2rem}.price-root .token-count img[data-v-79d1ed34]{width:.16rem;height:.16rem;margin-right:.02rem}.price-root .price[data-v-79d1ed34]{font-size:.14rem}.only-price[data-v-79d1ed34]{align-items:center;justify-content:center}.only-price .price[data-v-79d1ed34]{font-size:.2rem}.content[data-v-737beb57]{width:100%;margin:.2rem 0;display:grid;grid-template-columns:repeat(3,1fr);gap:.1rem;box-sizing:border-box;font-weight:500}.loading[data-v-737beb57]{display:flex;justify-content:center;align-items:center}.select[data-v-737beb57]{color:#fff}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-4e76879e]{font-family:WeChat-Bold}.pay-popup[data-v-4e76879e]{display:flex;flex-direction:column;width:100vw;box-sizing:border-box;overflow:hidden;padding:0 .15rem .2rem;transition:all .3s}.title[data-v-4e76879e]{text-align:center;margin:.16rem 0}.check-box[data-v-4e76879e]{display:flex;justify-content:center;align-items:center;font-size:.12rem;padding:.1rem 0}.protocol-popup[data-v-4e76879e]{height:70vh;width:100vw;overflow-x:hidden}.protocol-popup .prptocol[data-v-4e76879e]{display:flex;flex-direction:column;justify-content:center;align-items:center;height:100%}.protocol-popup .prptocol .btn-box[data-v-4e76879e]{height:10%;width:100%;display:flex;justify-content:space-around;padding:.1rem;box-sizing:content-box}.protocol-popup .prptocol .btn-box>*[data-v-4e76879e]{width:45%}.protocol-popup .prptocol iframe[data-v-4e76879e]{display:block;width:100%;height:90%;margin:0;border:0}.agree-dialog .check-box[data-v-4e76879e]{margin:.2rem}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();
|
|
2
|
+
var __defProp=Object.defineProperty,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__publicField=(e,t,n)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,n),n);!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vant"),require("vue"),require("vue-class-component"),require("vue-property-decorator")):"function"==typeof define&&define.amd?define(["exports","vant","vue","vue-class-component","vue-property-decorator"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).PayPlugin={},e.vant,e.Vue,e.Component,e.vuePropertyDecorator)}(this,function(e,t,n,i,o){var r,s;async function a(e,t,n="POST"){return new Promise((i,o)=>{const r=localStorage.getItem("AppToken")||"";if(!r)throw new Error("token 不存在");fetch(e,{method:n,headers:{AppToken:r,"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(t).toString()}).then(async e=>{if(!e.ok){const t=await e.text();throw new Error(`HTTP ${e.status} ${e.statusText}: ${t}`)}try{return await e.json()}catch(t){o("解析 JSON 异常")}}).then(e=>{i(e)}).catch(e=>{let t=(null==e?void 0:e.message)||"未知异常";e.message.includes("404")?t="资源未找到":e.message.includes("500")?t="服务器错误":e instanceof TypeError&&"Failed to fetch"===e.message&&(t="网络连接失败"),o(t)})})}const c=(e,n="请求失败")=>(t.Dialog({title:n,message:e}),{status:!1,message:e}),l=/LT-APP/.test(navigator.userAgent),p=null==(s=null==(r=n.prototype)?void 0:r.$jsBridge)?void 0:s.inApp,u=Boolean(window.ReactNativeWebView),d=async e=>{const{id:t,key:i,value:o,prefix:r}=e;let s=location.origin+`/Payment/${r||""}Alipay`;const d=l||p||u;if(s+=`?qrcode=${d}&id=${t}`,!i||!o)return c("支付参数异常",`支付时缺少 key value 参数:${JSON.stringify(e)}`);if(s+=`&${i}=${o}`,!d)return location.href=s,{status:!0,message:"成功",data:h};var h;const{Data:g,Status:f,Message:v}=await a(s,{},"GET");return f?g?void(p?n.prototype.$jsBridge.openLink(g):location.href=g):c("支付跳转地址不存在"):c("支付请求失败",v||"请求支付结果异常")};const h=/miniProgram/i.test(navigator.userAgent)&&/micromessenger/i.test(navigator.userAgent),g=e=>{var n;const{id:i,appid:o,key:r,value:s,prefix:a}=e;if(!o)return void t.Dialog({title:"小程序 id 不存在"});if(!localStorage.getItem("AppToken"))return void t.Dialog({title:"环境异常",message:"本地 AppToken 不存在! 请重新登录",showCancelButton:!1,confirmButtonText:"确定"});const c={appid:o,payKey:r,payValue:s,paymentId:i,payApi:`${location.origin}}/Payment/${a}Weixin`,tokenKey:"AppToken",tokenValue:localStorage.getItem("AppToken")},l=`weixin://dl/business/?appid=${o}&path=pages/home/index&query=${encodeURIComponent(Object.entries(c).map(([e,t])=>`${e}=${String(t)}`).join("&"))}`;if(window.ReactNativeWebView)null==(n=window.ReactNativeWebView)||n.postMessage(JSON.stringify({type:"openUrl",data:{url:l},code:200}));else if(h){const e=Object.entries(c).map(([e,t])=>`${e}=${String(t)}`).join("&");uni.navigateTo({url:`/pages/home/pay?${e}`})}else location.href=l},f={alipay:d,wechat:g};function v(e,t){return e.filter(({type:e})=>!t.includes(e)&&(e in f||void 0))}const m=["platform"],y="https://qi0irqynw8.feishu.cn/docx/Ea1PdrV5SonBfHxAIHUchKjVnVf",_={needId:!1,name:"店铺余额",theme:"#4089ff",balance:{disabled:!1,key:"Money",api:"/AgentUser/GetMoney"},price:{disabled:!1,custom:!0,prices:[{price:800},{price:12800},{price:38800},{price:68800},{price:128800},{price:268800}]},channel:{api:"/SystemPayment/GetList",ignores:m},pay:{key:"Money"},agreement:y},P={agent:_,user:{theme:"#ff4f4f",name:"幸运币余额",needId:!1,balance:{disabled:!1,key:"PlaMoney",api:"/PlayerUser/GetMoney"},price:{disabled:!1,custom:!0,prices:[{price:200},{price:500},{price:1e3},{price:5e3},{price:1e4},{price:2e4}]},channel:{api:"/SystemPayment/GetList",ignores:m},pay:{key:"Money"},agreement:y}};var b=Object.defineProperty,C=Object.getOwnPropertyDescriptor,w=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?C(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&b(t,n,r),r};let $=class extends o.Vue{constructor(){super(...arguments),__publicField(this,"load"),__publicField(this,"loading",!0),__publicField(this,"message","")}get showLoading(){return this.loading||this.message}async mounted(){await this.retry()}test(){this.loading=!0,setTimeout(()=>{this.loading=!1},100)}async retry(){this.message="",this.loading=!0;const e=await this.load().finally(()=>{this.loading=!1}).catch(e=>{this.message=e});null!=e&&this.$emit("done",e)}};w([o.Prop()],$.prototype,"load",2),$=w([o.Component],$);function k(e,t,n,i,o,r,s,a){var c,l="function"==typeof e?e.options:e;if(t&&(l.render=t,l.staticRenderFns=n,l._compiled=!0),i&&(l.functional=!0),r&&(l._scopeId="data-v-"+r),s?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},l._ssrRegister=c):o&&(c=a?function(){o.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:o),c)if(l.functional){l._injectStyles=c;var p=l.render;l.render=function(e,t){return c.call(t),p(e,t)}}else{var u=l.beforeCreate;l.beforeCreate=u?[].concat(u,c):[c]}return{exports:e,options:l}}const x={};var O=k($,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"pay-error-container"},[n("div",{staticClass:"loading",style:{display:e.showLoading?"flex":"none"}},[e.message?n("van-tag",{attrs:{type:"danger"},on:{click:e.retry}},[e._v(" "+e._s(e.message)+" 点击重试 ")]):n("van-loading",{staticClass:"loading-icon",attrs:{size:"20",type:"spinner"}})],1),e._t("default")],2)},[],!1,A,"0817c014",null,null);function A(e){for(let t in x)this[t]=x[t]}const F=function(){return O.exports}();var T=Object.defineProperty,S=Object.getOwnPropertyDescriptor,j=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?S(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&T(t,n,r),r};let E=class extends n{constructor(){super(...arguments),__publicField(this,"config"),__publicField(this,"value",0)}load(){const{key:e,api:t}=this.config.balance;if(!t||!e)throw new Error("不存在 key 或 api");return(async(e,t)=>{const n=await a(e);return t in n?n[t]:(c(JSON.stringify(n)||"解析数据异常",`余额数据中不存在 ${t}`),0)})(t,e)}onBalanceLoad(e){this.value=e/100,this.$emit("change",e)}};j([o.Inject()],E.prototype,"config",2),E=j([o.Component({components:{PayError:F}})],E);const I={};var D=k(E,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"root wechat-font"},[n("PayError",{attrs:{load:e.load},on:{done:e.onBalanceLoad}},[n("h1",[e._v(" "+e._s(e.value)+" ")])])],1)},[],!1,B,"20b4bf5f",null,null);function B(e){for(let t in I)this[t]=I[t]}const L=function(){return D.exports}();var N=Object.defineProperty,V=Object.getOwnPropertyDescriptor,q=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?V(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&N(t,n,r),r};let R=class extends n{constructor(){super(...arguments),__publicField(this,"config"),__publicField(this,"channels",[]),__publicField(this,"select",0),__publicField(this,"showPopover",!1)}get actions(){return this.channels.length?this.channels.map(({name:e,id:t,icon:n},i)=>({text:e,id:t,disabled:i==this.select})):[]}onSelect(e,t){this.select=t,this.$emit("change",this.channels[t])}get name(){let e=this.channels[this.select];return e?e.name:""}get ignores(){return this.config.channel.ignores||[]}load(){return(async(e,t)=>v((await a(e)).map(({Id:e,PaymentValue:t,PaymentName:n,PaymentIcon:i,AgentDescribe:o})=>{const r=function(e){return e.includes("支付宝")?"alipay":e.includes("微信")?"wechat":e.includes("平台币")?"platform":e.includes("苹果")?"apple":"unknow"}(t);return{id:e,name:t,icon:i,type:r,appid:o}}),t))(this.config.channel.api,this.ignores)}onLoadChannels(e){this.channels=v(e,this.ignores),this.$emit("change",this.channels[0])}};q([o.Inject()],R.prototype,"config",2),R=q([i({components:{PayError:F}})],R);const M={};var U=k(R,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("van-popover",{attrs:{trigger:"click",actions:e.actions,placement:"top-end"},on:{select:e.onSelect},scopedSlots:e._u([{key:"reference",fn:function(){return[n("div",{staticClass:"cell"},[n("h5",[e._v("付款方式")]),n("PayError",{staticClass:"name",attrs:{load:e.load},on:{done:e.onLoadChannels}},[n("div",[e._v(" "+e._s(e.name)+" "),n("van-icon",{attrs:{name:"arrow"}})],1)])],1)]},proxy:!0}]),model:{value:e.showPopover,callback:function(t){e.showPopover=t},expression:"showPopover"}})},[],!1,W,"70746494",null,null);function W(e){for(let t in M)this[t]=M[t]}const G=function(){return U.exports}();var z=Object.defineProperty,J=Object.getOwnPropertyDescriptor,H=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?J(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&z(t,n,r),r};let K=class extends n{constructor(){super(...arguments),__publicField(this,"customPrice"),__publicField(this,"value",null)}onChange(e){this.$emit("input",Number(e))}};H([o.Prop({default:null})],K.prototype,"customPrice",2),K=H([i],K);const X={};var Q=k(K,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"custom-price"},[n("h5",[e._v("自定义金额")]),n("van-field",{staticClass:"input wechat-font",attrs:{type:"digit",placeholder:"请输入金额",clearable:""},on:{input:e.onChange},model:{value:e.value,callback:function(t){e.value=t},expression:"value"}})],1)},[],!1,Y,"ea027830",null,null);function Y(e){for(let t in X)this[t]=X[t]}const Z=function(){return Q.exports}();var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?te(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&ee(t,n,r),r};let ie=class extends n{constructor(){super(...arguments),__publicField(this,"price")}get realPrice(){return this.price.price/100}get onlyPrice(){return!this.price.count}};ne([o.Prop({default:{}})],ie.prototype,"price",2),ie=ne([i],ie);const oe={};var re=k(ie,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"price-root wechat-font",class:{"only-price":e.onlyPrice}},[e.price.giftCount?n("span",{staticClass:"gift"},[e._v(" 赠"+e._s(e.price.giftCount)+" ")]):e._e(),e.price.count?n("span",{staticClass:"token-count"},[n("img",{attrs:{src:"https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/npdd/user/my-v3/imgs/niu-coin-top-up-icon.png"}}),e._v(" "+e._s(e.price.count)+" ")]):e._e(),n("span",{staticClass:"price"},[e._v("¥"+e._s(e.realPrice))])])},[],!1,se,"79d1ed34",null,null);function se(e){for(let t in oe)this[t]=oe[t]}const ae=function(){return re.exports}();var ce=Object.defineProperty,le=Object.getOwnPropertyDescriptor,pe=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?le(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&ce(t,n,r),r};let ue=class extends n{constructor(){super(...arguments),__publicField(this,"config"),__publicField(this,"value",0),__publicField(this,"prices",[]),__publicField(this,"customPrice",0),__publicField(this,"loading",!0),__publicField(this,"message","")}async mounted(){}load(){const{load:e,prices:t}=this.config.price;return e||(t?new Promise(e=>e(t)):void 0)}onLoadPrices(e){this.prices=e,this.changePrice(0)}changePrice(e){this.value=e,this.$emit("change",this.prices[e])}onCustomPriceChange(e){e?this.$emit("change",{price:100*e}):this.$emit("change",this.prices[this.value])}};pe([o.Inject()],ue.prototype,"config",2),pe([o.Watch("customPrice")],ue.prototype,"onCustomPriceChange",1),ue=pe([i({components:{PriceItem:ae,PayError:F,PriceCustom:Z}})],ue);const de={};var he=k(ue,function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.config.price.disabled?e._e():n("div",{staticClass:"price-container"},[n("h5",[e._v("选择充值金额")]),n("PayError",{attrs:{load:e.load},on:{done:e.onLoadPrices}},[n("div",{staticClass:"content"},e._l(e.prices,function(t,i){return n("price-item",{key:i,staticClass:"price-item",class:{select:i==e.value},style:{backgroundColor:i==e.value?e.config.theme||"orange":""},attrs:{price:t},nativeOn:{click:function(t){return e.changePrice(i)}}})}),1)]),e.config.price.custom?[n("PriceCustom",{model:{value:e.customPrice,callback:function(t){e.customPrice=t},expression:"customPrice"}})]:e._e()],2)},[],!1,ge,"737beb57",null,null);function ge(e){for(let t in de)this[t]=de[t]}const fe=function(){return he.exports}();var ve=Object.defineProperty,me=Object.getOwnPropertyDescriptor,ye=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?me(t,n):t,s=e.length-1;s>=0;s--)(o=e[s])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&ve(t,n,r),r};let _e=class extends n{constructor(){super(...arguments),__publicField(this,"config"),__publicField(this,"id"),__publicField(this,"isAgreeProtocolFlag","__isAgreeProtocol__"),__publicField(this,"isAgreeProtocol",!1),__publicField(this,"isOpenProtocol",!1),__publicField(this,"baseTheme","orange"),__publicField(this,"visible",!1),__publicField(this,"balance",0),__publicField(this,"price",{price:0}),__publicField(this,"channel",null),__publicField(this,"loading",{balance:!1,price:!1,channel:!1})}onIsAgreeProtocolChange(e){e?localStorage.setItem(this.isAgreeProtocolFlag,"true"):localStorage.removeItem(this.isAgreeProtocolFlag)}async mounted(){this.$nextTick(()=>{this.visible=!0,this.initLoad(),this.isAgreeProtocol=Boolean(localStorage.getItem(this.isAgreeProtocolFlag)||!1)})}initLoad(){this.loading.balance=this.config.balance.disabled,this.loading.price=this.config.price.disabled}onClose(){this.$emit("onClose")}onClosed(){this.$emit("onClosed")}openProtocol(){this.isOpenProtocol=!0}agreeProtocol(){this.isAgreeProtocol=!0,this.isOpenProtocol=!1}notAgree(){this.isAgreeProtocol=!1,this.isOpenProtocol=!1}agreeProtocolAndPay(){this.agreeProtocol(),this.onTopup()}async onTopup(){if(!this.isAgreeProtocol)return void this.openProtocol();const{key:e,prefix:n}=this.config.pay,i=String(this.id||this.price.price);this.channel?await(async({channel:e,key:n,value:i,prefix:o})=>{const{type:r,id:s,appid:a}=e,c=String(Number(i)/100);switch(r in f||t.Toast("暂不支持此渠道"),r){case"alipay":return await d({id:s,key:n,value:c,prefix:o});case"wechat":return a?await g({appid:a,prefix:o,key:n,value:i,id:s}):t.Dialog({title:"参数异常",message:"此渠道未配置小程序 appid 请先使用其他渠道!"});default:t.Toast("暂不支持此渠道")}})({channel:this.channel,key:e,value:i,prefix:n}):c("渠道不存在")}onBanlanceChange(e){this.loading.balance=!0}onChannelChange(e){this.channel=e,this.loading.channel=!0}onPriceChange(e){this.price=e,this.loading.price=!0}get finalPrice(){return this.price.price/100}get disable(){return!Object.values(this.loading).every(e=>!0===e)}get title(){return this.config.name}};ye([o.Provide("config"),o.Prop({default:_})],_e.prototype,"config",2),ye([o.Prop({default:void 0})],_e.prototype,"id",2),ye([o.Watch("isAgreeProtocol")],_e.prototype,"onIsAgreeProtocolChange",1),_e=ye([i({components:{Balance:L,Divider:t.Divider,PriceContainer:fe,Button:t.Button,PriceCustom:Z,Channels:G}})],_e);var Pe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("van-popup",{staticClass:"pay-popup",attrs:{position:"bottom",overlay:!0,round:""},on:{closed:e.onClosed,close:e.onClose},model:{value:e.visible,callback:function(t){e.visible=t},expression:"visible"}},[n("h4",{staticClass:"title"},[e._v(" "+e._s(e.title)+" ")]),e.config.balance.disabled?e._e():[n("Balance",{on:{change:e.onBanlanceChange}}),n("Divider")],e.config.price.disabled?e._e():[n("PriceContainer",{on:{change:e.onPriceChange}}),n("Divider")],n("Channels",{on:{change:e.onChannelChange}}),n("div",{staticClass:"check-box"},[n("van-checkbox",{attrs:{"checked-color":e.config.theme,"icon-size":"12"},model:{value:e.isAgreeProtocol,callback:function(t){e.isAgreeProtocol=t},expression:"isAgreeProtocol"}},[e._v(" 阅读并同意 "),n("span",{style:{color:e.config.theme},on:{click:function(t){return t.stopPropagation(),e.openProtocol.apply(null,arguments)}}},[e._v("充值协议")])])],1),n("Button",{attrs:{disabled:e.disable,color:e.config.theme||e.baseTheme,block:""},on:{click:e.onTopup}},[e._v(" 立即支付 "+e._s(e.finalPrice)+" 元 ")]),n("van-popup",{staticClass:"protocol-popup",attrs:{position:"bottom",overlay:!0,round:""},model:{value:e.isOpenProtocol,callback:function(t){e.isOpenProtocol=t},expression:"isOpenProtocol"}},[n("div",{staticClass:"prptocol"},[n("iframe",{attrs:{src:e.config.agreement}}),n("div",{staticClass:"btn-box"},[n("van-button",{attrs:{block:""},on:{click:e.notAgree}},[e._v("不同意")]),n("van-button",{attrs:{color:e.config.theme,block:"",type:"primary"},on:{click:e.agreeProtocolAndPay}},[e._v("同意并支付")])],1)])])],2)};const be={};var Ce=k(_e,Pe,[],!1,we,"4e76879e",null,null);function we(e){for(let t in be)this[t]=be[t]}const $e=function(){return Ce.exports}(),ke={install(e){e.prototype.$pay={create:(e,...i)=>new Promise((o,r)=>{const s=P[e],{needId:a}=s,c=i[0];if(a&&!c)return void t.Dialog({title:"参数异常",message:`${e} 类型需要传入订单号 当前未传入!`});const l=new(n.extend($e))({propsData:{config:s,id:c}});l.$on("onClosed",()=>{o(),setTimeout(()=>{var e;l.$destroy(),null==(e=l.$el.parentNode)||e.removeChild(l.$el)},300)}),l.$mount(),document.body.appendChild(l.$el)})}}};e.PayPlugin=ke,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import Vue from
|
|
2
|
-
import { Channel, Config, Price } from
|
|
1
|
+
import Vue from "vue";
|
|
2
|
+
import { Channel, Config, Price } from "../types";
|
|
3
3
|
export default class PayPopup extends Vue {
|
|
4
4
|
config: Config;
|
|
5
5
|
id?: string;
|
|
6
|
+
isAgreeProtocolFlag: string;
|
|
7
|
+
isAgreeProtocol: boolean;
|
|
8
|
+
isOpenProtocol: boolean;
|
|
6
9
|
baseTheme: string;
|
|
7
10
|
visible: boolean;
|
|
8
11
|
balance: number;
|
|
@@ -13,10 +16,15 @@ export default class PayPopup extends Vue {
|
|
|
13
16
|
price: boolean;
|
|
14
17
|
channel: boolean;
|
|
15
18
|
};
|
|
19
|
+
onIsAgreeProtocolChange(n: boolean): void;
|
|
16
20
|
mounted(): Promise<void>;
|
|
17
21
|
initLoad(): void;
|
|
18
22
|
onClose(): void;
|
|
19
23
|
onClosed(): void;
|
|
24
|
+
openProtocol(): void;
|
|
25
|
+
agreeProtocol(): void;
|
|
26
|
+
notAgree(): void;
|
|
27
|
+
agreeProtocolAndPay(): void;
|
|
20
28
|
onTopup(): Promise<void>;
|
|
21
29
|
/** 余额变动*/
|
|
22
30
|
onBanlanceChange(money: number): void;
|