@zhangcf233/pay 1.2.3 → 1.2.5

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 CHANGED
@@ -1882,11 +1882,62 @@ const user = {
1882
1882
  url: DefaultAgreement
1883
1883
  }
1884
1884
  };
1885
+ const balance = {
1886
+ theme: "#4287FF",
1887
+ name: "余额",
1888
+ needId: false,
1889
+ balance: {
1890
+ disabled: false,
1891
+ key: "PlaMoney",
1892
+ api: "/PlayerUser/GetMoney"
1893
+ },
1894
+ price: {
1895
+ disabled: false,
1896
+ custom: true,
1897
+ prices: [
1898
+ {
1899
+ price: 200
1900
+ },
1901
+ {
1902
+ price: 500
1903
+ },
1904
+ {
1905
+ price: 1e3
1906
+ },
1907
+ {
1908
+ price: 5e3
1909
+ },
1910
+ {
1911
+ price: 1e4
1912
+ },
1913
+ {
1914
+ price: 2e4
1915
+ }
1916
+ ]
1917
+ },
1918
+ channel: {
1919
+ api: "/SystemPayment/GetList",
1920
+ ignores: DefaultIgnorePlatform
1921
+ },
1922
+ pay: {
1923
+ key: "Money"
1924
+ },
1925
+ identity: {
1926
+ disable: false,
1927
+ api: "/PlayerUser/GetUserInfo",
1928
+ auth: "/PlayerUser/Authentication"
1929
+ },
1930
+ agreement: {
1931
+ disable: true,
1932
+ url: DefaultAgreement
1933
+ }
1934
+ };
1885
1935
  const PayAllConfig = {
1886
1936
  agent,
1887
1937
  user,
1888
1938
  krlotto,
1889
- answerer
1939
+ answerer,
1940
+ balance
1890
1941
  };
1891
1942
  const plugin = {
1892
1943
  install(vue, options = {}) {
@@ -1904,7 +1955,7 @@ const plugin = {
1904
1955
  needId,
1905
1956
  price: { incoming }
1906
1957
  } = config;
1907
- const { id, url = "/", price: incomePrice, onTopup } = options2;
1958
+ const { id, url = "/", price: incomePrice, onTopup, customConfig } = options2;
1908
1959
  if (needId && !id) {
1909
1960
  Dialog({
1910
1961
  title: "参数异常",
@@ -1919,6 +1970,9 @@ const plugin = {
1919
1970
  });
1920
1971
  return;
1921
1972
  }
1973
+ if (customConfig) {
1974
+ Object.assign(config, customConfig);
1975
+ }
1922
1976
  const Constructor = Vue.extend(PayPopup2);
1923
1977
  const instance = new Constructor({
1924
1978
  // 注入配置
package/dist/pay.umd.js CHANGED
@@ -1,2 +1,2 @@
1
1
  !function(){"use strict";try{if("undefined"!=typeof document){var t=document.createElement("style");t.appendChild(document.createTextNode('@charset "UTF-8";.protocol-popup[data-v-16cd68bd]{height:70vh;width:100vw;overflow-x:hidden}.protocol-popup .protocol[data-v-16cd68bd]{display:flex;flex-direction:column;justify-content:center;align-items:center;height:100%}.protocol-popup .protocol .btn-box[data-v-16cd68bd]{height:10%;width:100%;display:flex;justify-content:space-around;padding:.1rem;box-sizing:content-box}.protocol-popup .protocol .btn-box>*[data-v-16cd68bd]{width:45%}.protocol-popup .protocol iframe[data-v-16cd68bd]{display:block;width:100%;height:90%;margin:0;border:0;padding:.16rem;box-sizing:border-box}.agreement[data-v-27f1af06]{display:flex;justify-content:center;align-items:center;font-size:.12rem;margin:.16rem 0 0}.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-4dcfe5ca]{display:flex;align-items:center;justify-content:space-between;height:.3rem}.cell .name[data-v-4dcfe5ca]{width:30vw;color:gray;font-size:.14rem;display:flex;align-items:center;justify-content:end}.identity[data-v-5f9eb7e3]{margin-top:.16rem}@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-05e06290]{font-family:WeChat-Bold}.custom-price .input[data-v-05e06290]{font-size:.2rem;padding:0;margin-top:.16rem}@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-599f1980]{font-family:WeChat-Bold}.price-root[data-v-599f1980]{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-599f1980]{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-599f1980]{display:flex;justify-content:center;align-items:center;font-size:.2rem}.price-root .token-count img[data-v-599f1980]{width:.16rem;height:.16rem;margin-right:.02rem}.price-root .price[data-v-599f1980]{font-size:.12rem}.only-price[data-v-599f1980]{align-items:center;justify-content:center}.only-price .price[data-v-599f1980]{font-size:.2rem}.content[data-v-01a7ad83]{width:100%;margin:.16rem 0;display:grid;grid-template-columns:repeat(3,1fr);gap:.1rem;box-sizing:border-box;font-weight:500}.loading[data-v-01a7ad83]{display:flex;justify-content:center;align-items:center}.select[data-v-01a7ad83]{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-6bf8b9f6]{font-family:WeChat-Bold}.pay-popup[data-v-6bf8b9f6]{display:flex;flex-direction:column;width:100vw;box-sizing:border-box;overflow:hidden;padding:0 .15rem .2rem;transition:all .3s;text-align:center}.title[data-v-6bf8b9f6]{text-align:center;margin:.16rem 0}.pay-button[data-v-6bf8b9f6]{margin:.16rem 0 0}iframe[data-v-6bf8b9f6]{height:1px;width:1px;opacity:0;position:absolute}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}}();
2
- !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){"use strict";var r=Object.defineProperty,a=(e,t,n)=>(((e,t,n)=>{t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);async function s(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,data:void 0}),l=navigator.userAgent,p=/ZW-APP/.test(l),u=async e=>{const{id:t,key:n,value:i,prefix:o,url:r}=e;let a=location.origin+`/Payment/${o||""}Alipay`;if(a+=`?id=${t}`,r&&(a+=`&url=${r}`),n&&i){if(a+=`&${n}=${i}&t=${Date.now()}`,p){a+="&qrcode=true";const{data:e,message:t}=await d(a);if(!e)return;a=e}return a}c("支付参数异常",`支付时缺少 key value 参数:${JSON.stringify(e)}`)},d=async e=>{const t=await(await fetch(e,{method:"GET",headers:{AppToken:localStorage.getItem("AppToken")??""}})).json();return t.Status?{status:!0,message:"成功",data:t.Data}:c(JSON.stringify(t),"获取支付链接失败")},h=async e=>{const{id:n,key:i,value:o,prefix:r,url:a}=e;let s=location.origin+`/Payment/${r||""}Paypal?${i}=${o}&id=${n}`;a&&(s+=`&url=${a}`),t.Toast({type:"loading",duration:0,mask:!0}),location.href=s},g=/miniProgram/i.test(navigator.userAgent)&&/micromessenger/i.test(navigator.userAgent),f=e=>{var n;const{id:i,appid:o,key:r,value:a,prefix:s=""}=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:a,paymentId:i,payApi:`${location.origin}/Payment/${s}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(g){const e=Object.entries(c).map(([e,t])=>`${e}=${String(t)}`).join("&");uni.navigateTo({url:`/pages/home/pay?${e}`})}else location.href=l},m={alipay:u,wechat:f,paypal:h};function y(e,t){return e.filter(({type:e})=>!t.includes(e)&&(e in m||void 0))}const v=["platform"],P="https://czyxzs.xuelm.cn/agreement.html",b={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:v},pay:{key:"Money"},identity:{disable:!0,api:"/AgentUser/GetUserInfo",auth:"/AgentUser/Authentication"},agreement:{disable:!1,url:P}};var w=Object.defineProperty,_=Object.getOwnPropertyDescriptor,$=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?_(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&w(t,n,r),r};let C=class extends n{constructor(){super(...arguments),a(this,"value"),a(this,"config"),a(this,"open",!1)}mounted(){this.open=this.value}onValue(e){this.open=e}onOpen(e){this.$emit("input",e)}disagree(){this.$emit("disagree")}agreeProtocolAndPay(){this.$emit("agreeProtocolAndPay")}};$([o.Prop({default:!1})],C.prototype,"value",2),$([o.Inject()],C.prototype,"config",2),$([o.Watch("value")],C.prototype,"onValue",1),$([o.Watch("open")],C.prototype,"onOpen",1),C=$([i],C);function x(e,t,n,i,o,r,a,s){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),a?(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(a)},l._ssrRegister=c):o&&(c=s?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 k={};var O=x(C,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("van-popup",{staticClass:"protocol-popup",attrs:{position:"bottom",overlay:!0,round:""},model:{value:e.open,callback:function(t){e.open=t},expression:"open"}},[n("div",{staticClass:"protocol"},[e.config.agreement.disable?e._e():[n("iframe",{attrs:{src:e.config.agreement.url}})],n("div",{staticClass:"btn-box"},[n("van-button",{attrs:{block:""},on:{click:e.disagree}},[e._v("不同意")]),n("van-button",{attrs:{color:e.config.theme,block:"",type:"primary"},on:{click:e.agreeProtocolAndPay}},[e._v("同意并支付")])],1)],2)])},[],!1,I,"16cd68bd",null,null);function I(e){for(let t in k)this[t]=k[t]}const j=function(){return O.exports}();var S=Object.defineProperty,A=Object.getOwnPropertyDescriptor,T=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?A(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&S(t,n,r),r};let E=class extends n{constructor(){super(...arguments),a(this,"value"),a(this,"config"),a(this,"agreeProtocolFlag","__isAgreeProtocol__"),a(this,"agree",!1),a(this,"show",!1)}mounted(){this.agree=Boolean(localStorage.getItem(this.agreeProtocolFlag)||!1)}onOpen(e){this.$emit("input",e),e?localStorage.setItem(this.agreeProtocolFlag,"true"):localStorage.removeItem(this.agreeProtocolFlag)}onValue(e){this.agree=e}openProtocol(){this.show=!0}disagree(){this.agree=!1,this.show=!1}agreeProtocol(){this.agree=!0,this.show=!1}agreeProtocolAndPay(){this.agreeProtocol(),this.$nextTick(()=>{this.$emit("pay")})}};T([o.Prop({default:!1})],E.prototype,"value",2),T([o.Inject()],E.prototype,"config",2),T([o.Watch("agree")],E.prototype,"onOpen",1),T([o.Watch("value")],E.prototype,"onValue",1),E=T([i({components:{AgreementPopup:j}})],E);var D=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"agreement"},[n("van-checkbox",{attrs:{"checked-color":e.config.theme,"icon-size":"12"},model:{value:e.agree,callback:function(t){e.agree=t},expression:"agree"}},[e._v(" 阅读并同意 "),n("span",{style:{color:e.config.theme},on:{click:function(t){return t.stopPropagation(),e.openProtocol.apply(null,arguments)}}},[e._v("充值协议")])]),n("AgreementPopup",{on:{disagree:e.disagree,agreeProtocolAndPay:e.agreeProtocolAndPay},model:{value:e.show,callback:function(t){e.show=t},expression:"show"}})],1)};const U={};var L=x(E,D,[],!1,R,"27f1af06",null,null);function R(e){for(let t in U)this[t]=U[t]}const N=function(){return L.exports}();var G=Object.defineProperty,V=Object.getOwnPropertyDescriptor,B=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?V(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&G(t,n,r),r};let M=class extends o.Vue{constructor(){super(...arguments),a(this,"load"),a(this,"loading",!0),a(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)}};B([o.Prop()],M.prototype,"load",2),M=B([o.Component],M);const q={};var W=x(M,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,z,"0817c014",null,null);function z(e){for(let t in q)this[t]=q[t]}const F=function(){return W.exports}();var K=Object.defineProperty,J=Object.getOwnPropertyDescriptor,X=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?J(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&K(t,n,r),r};let H=class extends n{constructor(){super(...arguments),a(this,"config"),a(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 s(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)}};X([o.Inject()],H.prototype,"config",2),H=X([o.Component({components:{PayError:F}})],H);const Z={};var Q=x(H,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,Y,"20b4bf5f",null,null);function Y(e){for(let t in Z)this[t]=Z[t]}const ee=function(){return Q.exports}();const te=async(e,t)=>function(e){return navigator.userAgent.toLowerCase().includes("micromessenger")?e.sort((e,t)=>"wechat"==e.type?-1:1):e}(y((await s(e)).map(({Id:e,PaymentValue:t,PaymentName:n,PaymentIcon:i,AgentDescribe:o})=>{const r=function(e){if(e.includes("支付宝"))return"alipay";if(e.includes("微信"))return"wechat";if(e.includes("平台币"))return"platform";if(e.includes("苹果"))return"apple";if(e.includes("PayPal"))return"paypal";if(e.includes("Google"))return"google";return"unknow"}(t);return{id:e,name:t,icon:i,type:r,appid:o}}),t));var ne=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,oe=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?ie(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&ne(t,n,r),r};let re=class extends n{constructor(){super(...arguments),a(this,"config"),a(this,"channels",[]),a(this,"select",0),a(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 te(this.config.channel.api,this.ignores)}onLoadChannels(e){this.channels=y(e,this.ignores),this.$emit("change",this.channels[0])}};oe([o.Inject()],re.prototype,"config",2),re=oe([i({components:{PayError:F}})],re);const ae={};var se=x(re,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(e._s(e.$t(e.$getI18nKeyInPay("payment"))))]),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,ce,"4dcfe5ca",null,null);function ce(e){for(let t in ae)this[t]=ae[t]}const le=function(){return se.exports}();var pe=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,de=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?ue(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&pe(t,n,r),r};let he=class extends n{constructor(){super(...arguments),a(this,"config"),a(this,"name",""),a(this,"id",""),a(this,"status",!1)}get params(){return{RealName:this.name,IdCard:this.id}}async onSubmit(){await(async(e,t)=>{const{Message:n,Status:i}=await s(e,t);if(!i)throw new Error(n);return!0})(this.config.identity.auth,this.params).catch(e=>{t.Dialog({title:"认证失败",message:e})})&&this.$emit("done",this.params)}};de([o.Inject()],he.prototype,"config",2),he=de([i],he);const ge={};var fe=x(he,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("van-form",{on:{submit:e.onSubmit}},[n("van-field",{attrs:{name:"姓名",label:"姓名",placeholder:"姓名",rules:[{required:!0,message:"请填写姓名"}]},model:{value:e.name,callback:function(t){e.name=t},expression:"name"}}),n("van-field",{attrs:{name:"身份证号码",label:"身份证号码",placeholder:"身份证号码",rules:[{required:!0,message:"请填写身份证号码"}]},model:{value:e.id,callback:function(t){e.id=t},expression:"id"}}),n("div",{staticStyle:{margin:"16px"}},[n("van-button",{attrs:{block:"",color:e.config.theme,"native-type":"submit"}},[e._v("认证")])],1)],1)},[],!1,me,null,null,null);function me(e){for(let t in ge)this[t]=ge[t]}const ye=function(){return fe.exports}();var ve=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,be=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?Pe(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&ve(t,n,r),r};let we=class extends n{constructor(){super(...arguments),a(this,"config"),a(this,"showPopup",!1),a(this,"info",{status:!1,name:""})}get text(){return this.info.status?`已实名 ${this.info.name}`:"未实名 点击进行实名认证"}load(){return(async e=>{const t={status:!1,name:""},{RealName:n}=await s(e);if(null==n)throw new Error("不存在实名信息");return""==n||(t.name=n,t.status=!0),t})(this.config.identity.api)}done(e){Object.assign(this.info,e),this.$emit("onIdentity",e)}openPopup(){this.info.status||(this.showPopup=!0)}authDone(e){this.showPopup=!1,this.done({status:!0,name:e.RealName})}};be([o.Inject()],we.prototype,"config",2),we=be([i({components:{PayError:F,Identity:ye}})],we);const _e={};var $e=x(we,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("PayError",{attrs:{load:e.load},on:{done:e.done}},[n("van-notice-bar",{staticClass:"identity",attrs:{"left-icon":"user-circle-o",text:e.text},on:{click:e.openPopup}}),n("van-popup",{attrs:{position:"bottom",overlay:"",round:""},model:{value:e.showPopup,callback:function(t){e.showPopup=t},expression:"showPopup"}},[n("Identity",{on:{done:e.authDone}})],1)],1)},[],!1,Ce,"5f9eb7e3",null,null);function Ce(e){for(let t in _e)this[t]=_e[t]}const xe=function(){return $e.exports}();var ke=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Ie=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?Oe(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&ke(t,n,r),r};let je=class extends n{constructor(){super(...arguments),a(this,"customPrice"),a(this,"value",null)}onChange(e){this.$emit("input",Number(e))}};Ie([o.Prop({default:null})],je.prototype,"customPrice",2),je=Ie([i],je);const Se={};var Ae=x(je,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,Te,"05e06290",null,null);function Te(e){for(let t in Se)this[t]=Se[t]}const Ee=function(){return Ae.exports}();var De=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Le=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?Ue(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&De(t,n,r),r};let Re=class extends n{constructor(){super(...arguments),a(this,"price")}get realPrice(){return this.price.price/100}get onlyPrice(){return!this.price.count}};Le([o.Prop({default:{}})],Re.prototype,"price",2),Re=Le([i],Re);const Ne={};var Ge=x(Re,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.gift?n("span",{staticClass:"gift"},[e._v(" 赠"+e._s(e.price.gift)+" ")]):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/100)+" ")]):e._e(),n("span",{staticClass:"price"},[e._v(e._s(e.price.symbol||"¥")+e._s(e.realPrice))])])},[],!1,Ve,"599f1980",null,null);function Ve(e){for(let t in Ne)this[t]=Ne[t]}const Be=function(){return Ge.exports}();var Me=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,We=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?qe(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&Me(t,n,r),r};let ze=class extends n{constructor(){super(...arguments),a(this,"config"),a(this,"value",0),a(this,"prices",[]),a(this,"customPrice",0),a(this,"loading",!0),a(this,"message","")}async mounted(){}load(){const{load:e,prices:t}=this.config.price;return e?new Promise(async t=>await t(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])}};We([o.Inject()],ze.prototype,"config",2),We([o.Watch("customPrice")],ze.prototype,"onCustomPriceChange",1),ze=We([i({components:{PriceItem:Be,PayError:F,PriceCustom:Ee}})],ze);const Fe={};var Ke=x(ze,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(e._s(e.$t(e.$getI18nKeyInPay("select"))))]),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,Je,"01a7ad83",null,null);function Je(e){for(let t in Fe)this[t]=Fe[t]}const Xe=function(){return Ke.exports}();var He=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Qe=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?Ze(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&He(t,n,r),r};let Ye=class extends n{constructor(){super(...arguments),a(this,"config"),a(this,"id"),a(this,"url"),a(this,"incomePrice"),a(this,"isAgreeProtocol",!1),a(this,"baseTheme","orange"),a(this,"visible",!1),a(this,"balance",0),a(this,"price",{price:0}),a(this,"channel",null),a(this,"loading",{balance:!1,price:!1,channel:!1,identity:!1}),a(this,"iframeSrc",""),a(this,"isPaying",!1)}async mounted(){this.$nextTick(()=>{this.visible=!0,this.initLoad()})}initLoad(){this.loading.balance=this.config.balance.disabled,this.incomePrice?this.loading.price=!0:this.loading.price=this.config.price.disabled,this.loading.identity=this.config.identity.disable,this.isAgreeProtocol=this.config.agreement.disable}onClose(){this.$emit("onClose")}onClosed(){this.$emit("onClosed")}get agreementRef(){return this.$refs.agreementRef}async onTopup(){if(!this.isAgreeProtocol)return void this.agreementRef.openProtocol();const{key:e,prefix:n}=this.config.pay,i=String(this.id||this.price.id||this.price.price/100);if(!this.channel)return void c("渠道不存在");this.isPaying=!0,this.iframeSrc="";const o=await(async e=>{const{type:n}=e;switch(n in m||t.Toast("暂不支持此渠道"),n){case"alipay":return await u(e);case"wechat":const{appid:n}=e;return n?await f(e):t.Dialog({title:"参数异常",message:"此渠道未配置小程序 appid 请先使用其他渠道!"});case"paypal":return await h(e);default:t.Toast("暂不支持此渠道")}})({...this.channel,key:e,value:i,prefix:n,url:this.url});o&&(this.iframeSrc=o),setTimeout(()=>{this.isPaying=!1,this.visible=!1},3e3),this.$emit("onTopup")}onBanlanceChange(e){this.loading.balance=!0}onChannelChange(e){this.channel=e,this.loading.channel=!0}onPriceChange(e){this.price=e,this.loading.price=!0}onIdentityChange(e){this.loading.identity=e.status}get finalPrice(){return this.incomePrice?this.incomePrice/100:this.price.price/100}get disable(){return!Object.values(this.loading).every(e=>!0===e)||this.isPaying}get title(){return this.config.name}};Qe([o.Provide("config"),o.Prop({default:b})],Ye.prototype,"config",2),Qe([o.Prop({default:void 0})],Ye.prototype,"id",2),Qe([o.Prop({default:void 0})],Ye.prototype,"url",2),Qe([o.Prop({default:void 0})],Ye.prototype,"incomePrice",2),Ye=Qe([i({components:{Balance:ee,Divider:t.Divider,PriceContainer:Xe,Button:t.Button,PriceCustom:Ee,Channels:le,Agreement:N,Identity:xe}})],Ye);const et={};var tt=x(Ye,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("van-popup",{staticClass:"pay-popup",attrs:{position:"bottom",overlay:"",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.$t(e.title))+" ")]),e.config.balance.disabled?e._e():[n("Balance",{on:{change:e.onBanlanceChange}}),n("Divider")],e.config.price.disabled?e._e():[e.config.price.incoming?[n("h1",[e._v("¥"+e._s(e.finalPrice))])]:n("PriceContainer",{on:{change:e.onPriceChange}}),n("Divider")],n("Channels",{on:{change:e.onChannelChange}}),e.config.identity.disable?e._e():[n("Identity",{on:{onIdentity:e.onIdentityChange}})],e.config.agreement.disable?e._e():[n("Agreement",{ref:"agreementRef",on:{pay:e.onTopup},model:{value:e.isAgreeProtocol,callback:function(t){e.isAgreeProtocol=t},expression:"isAgreeProtocol"}})],n("Button",{staticClass:"pay-button",attrs:{disabled:e.disable,color:e.config.theme||e.baseTheme,block:""},on:{click:e.onTopup}},[e.isPaying?[e._v(" 拉起支付中 请稍候... ")]:[e._v(" "+e._s(e.$t(e.$getI18nKeyInPay("pay")))+" "+e._s(e.price.symbol||"¥")+e._s(e.finalPrice)+" ")]],2),e.iframeSrc?n("iframe",{attrs:{src:e.iframeSrc}}):e._e()],2)},[],!1,nt,"6bf8b9f6",null,null);function nt(e){for(let t in et)this[t]=et[t]}const it=function(){return tt.exports}(),ot={"plugin-pay":{balance:"余额",select:"选择充值金额",payment:"付款方式",pay:"立即支付"}},rt={zh:{name:"简体中文",icon:"🇨🇳",messages:ot},ko:{name:"한국어",icon:"🇰🇷",messages:{"plugin-pay":{balance:"균형",select:"충전 금액을 선택하세요",payment:"결제 방법",pay:"지금 결제하세요"}}}},at=Object.keys(rt).reduce((e,t)=>(e[t]=rt[t].messages,e),{}),st=e=>`plugin-pay.${e}`,ct={agent:b,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:v},pay:{key:"Money"},identity:{disable:!0,api:"/PlayerUser/GetUserInfo",auth:"/PlayerUser/Authentication"},agreement:{disable:!1,url:P}},krlotto:{theme:"#ff5757",name:st("balance"),needId:!1,balance:{disabled:!1,key:"PlaMoney",api:"/PlayerUser/GetMoney"},price:{disabled:!1,online:!0,load:async()=>await(async e=>await s(e))("/Payment/GetPayPal")},channel:{api:"/SystemPayment/GetList",ignores:["alipay","apple","platform","wechat","google"]},pay:{key:"type"},identity:{disable:!0,api:"/PlayerUser/GetUserInfo",auth:"/PlayerUser/Authentication"},agreement:{disable:!0}},answerer:{theme:"#5486f7",name:"购买套餐",needId:!0,balance:{disabled:!0},price:{disabled:!1,incoming:!0},channel:{api:"/SystemPayment/GetList",ignores:[]},pay:{key:"goodsId",prefix:"Answerer"},identity:{disable:!0,api:"/PlayerUser/GetUserInfo",auth:"/PlayerUser/Authentication"},agreement:{disable:!0}}},lt={install(e,i={}){let o=i.i18n;o&&Object.keys(at).forEach(e=>{o.mergeLocaleMessage(e,at[e])});e.prototype.$pay={create:(e,i)=>new Promise((r,a)=>{const s={...i},c=ct[e],{needId:l,price:{incoming:p}}=c,{id:u,url:d="/",price:h,onTopup:g}=s;if(l&&!u)return void t.Dialog({title:"参数异常",message:`${e} 类型需要传入订单号 当前未传入!`});if(p&&!h)return void t.Dialog({title:"参数异常",message:"需要传入价格 当前未传入!"});const f=new(n.extend(it))({propsData:{config:c,id:u,url:encodeURIComponent(`#${d}`),incomePrice:h},i18n:o});f.$on("onClosed",()=>{r(),setTimeout(()=>{var e;f.$destroy(),null==(e=f.$el.parentNode)||e.removeChild(f.$el)},300)}),g&&f.$on("onTopup",g),f.$mount(),document.body.appendChild(f.$el)})},e.prototype.$getI18nKeyInPay=st}};e.PayPlugin=lt,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
2
+ !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){"use strict";var r=Object.defineProperty,a=(e,t,n)=>(((e,t,n)=>{t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);async function s(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,data:void 0}),l=navigator.userAgent,p=/ZW-APP/.test(l),u=async e=>{const{id:t,key:n,value:i,prefix:o,url:r}=e;let a=location.origin+`/Payment/${o||""}Alipay`;if(a+=`?id=${t}`,r&&(a+=`&url=${r}`),n&&i){if(a+=`&${n}=${i}&t=${Date.now()}`,p){a+="&qrcode=true";const{data:e,message:t}=await d(a);if(!e)return;a=e}return a}c("支付参数异常",`支付时缺少 key value 参数:${JSON.stringify(e)}`)},d=async e=>{const t=await(await fetch(e,{method:"GET",headers:{AppToken:localStorage.getItem("AppToken")??""}})).json();return t.Status?{status:!0,message:"成功",data:t.Data}:c(JSON.stringify(t),"获取支付链接失败")},h=async e=>{const{id:n,key:i,value:o,prefix:r,url:a}=e;let s=location.origin+`/Payment/${r||""}Paypal?${i}=${o}&id=${n}`;a&&(s+=`&url=${a}`),t.Toast({type:"loading",duration:0,mask:!0}),location.href=s},g=/miniProgram/i.test(navigator.userAgent)&&/micromessenger/i.test(navigator.userAgent),f=e=>{var n;const{id:i,appid:o,key:r,value:a,prefix:s=""}=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:a,paymentId:i,payApi:`${location.origin}/Payment/${s}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(g){const e=Object.entries(c).map(([e,t])=>`${e}=${String(t)}`).join("&");uni.navigateTo({url:`/pages/home/pay?${e}`})}else location.href=l},m={alipay:u,wechat:f,paypal:h};function y(e,t){return e.filter(({type:e})=>!t.includes(e)&&(e in m||void 0))}const v=["platform"],P="https://czyxzs.xuelm.cn/agreement.html",b={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:v},pay:{key:"Money"},identity:{disable:!0,api:"/AgentUser/GetUserInfo",auth:"/AgentUser/Authentication"},agreement:{disable:!1,url:P}};var w=Object.defineProperty,_=Object.getOwnPropertyDescriptor,$=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?_(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&w(t,n,r),r};let C=class extends n{constructor(){super(...arguments),a(this,"value"),a(this,"config"),a(this,"open",!1)}mounted(){this.open=this.value}onValue(e){this.open=e}onOpen(e){this.$emit("input",e)}disagree(){this.$emit("disagree")}agreeProtocolAndPay(){this.$emit("agreeProtocolAndPay")}};$([o.Prop({default:!1})],C.prototype,"value",2),$([o.Inject()],C.prototype,"config",2),$([o.Watch("value")],C.prototype,"onValue",1),$([o.Watch("open")],C.prototype,"onOpen",1),C=$([i],C);function k(e,t,n,i,o,r,a,s){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),a?(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(a)},l._ssrRegister=c):o&&(c=s?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(C,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("van-popup",{staticClass:"protocol-popup",attrs:{position:"bottom",overlay:!0,round:""},model:{value:e.open,callback:function(t){e.open=t},expression:"open"}},[n("div",{staticClass:"protocol"},[e.config.agreement.disable?e._e():[n("iframe",{attrs:{src:e.config.agreement.url}})],n("div",{staticClass:"btn-box"},[n("van-button",{attrs:{block:""},on:{click:e.disagree}},[e._v("不同意")]),n("van-button",{attrs:{color:e.config.theme,block:"",type:"primary"},on:{click:e.agreeProtocolAndPay}},[e._v("同意并支付")])],1)],2)])},[],!1,I,"16cd68bd",null,null);function I(e){for(let t in x)this[t]=x[t]}const j=function(){return O.exports}();var S=Object.defineProperty,A=Object.getOwnPropertyDescriptor,T=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?A(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&S(t,n,r),r};let E=class extends n{constructor(){super(...arguments),a(this,"value"),a(this,"config"),a(this,"agreeProtocolFlag","__isAgreeProtocol__"),a(this,"agree",!1),a(this,"show",!1)}mounted(){this.agree=Boolean(localStorage.getItem(this.agreeProtocolFlag)||!1)}onOpen(e){this.$emit("input",e),e?localStorage.setItem(this.agreeProtocolFlag,"true"):localStorage.removeItem(this.agreeProtocolFlag)}onValue(e){this.agree=e}openProtocol(){this.show=!0}disagree(){this.agree=!1,this.show=!1}agreeProtocol(){this.agree=!0,this.show=!1}agreeProtocolAndPay(){this.agreeProtocol(),this.$nextTick(()=>{this.$emit("pay")})}};T([o.Prop({default:!1})],E.prototype,"value",2),T([o.Inject()],E.prototype,"config",2),T([o.Watch("agree")],E.prototype,"onOpen",1),T([o.Watch("value")],E.prototype,"onValue",1),E=T([i({components:{AgreementPopup:j}})],E);var D=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"agreement"},[n("van-checkbox",{attrs:{"checked-color":e.config.theme,"icon-size":"12"},model:{value:e.agree,callback:function(t){e.agree=t},expression:"agree"}},[e._v(" 阅读并同意 "),n("span",{style:{color:e.config.theme},on:{click:function(t){return t.stopPropagation(),e.openProtocol.apply(null,arguments)}}},[e._v("充值协议")])]),n("AgreementPopup",{on:{disagree:e.disagree,agreeProtocolAndPay:e.agreeProtocolAndPay},model:{value:e.show,callback:function(t){e.show=t},expression:"show"}})],1)};const U={};var L=k(E,D,[],!1,G,"27f1af06",null,null);function G(e){for(let t in U)this[t]=U[t]}const R=function(){return L.exports}();var M=Object.defineProperty,N=Object.getOwnPropertyDescriptor,V=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?N(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&M(t,n,r),r};let B=class extends o.Vue{constructor(){super(...arguments),a(this,"load"),a(this,"loading",!0),a(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)}};V([o.Prop()],B.prototype,"load",2),B=V([o.Component],B);const q={};var W=k(B,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,F,"0817c014",null,null);function F(e){for(let t in q)this[t]=q[t]}const z=function(){return W.exports}();var K=Object.defineProperty,J=Object.getOwnPropertyDescriptor,X=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?J(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&K(t,n,r),r};let H=class extends n{constructor(){super(...arguments),a(this,"config"),a(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 s(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)}};X([o.Inject()],H.prototype,"config",2),H=X([o.Component({components:{PayError:z}})],H);const Z={};var Q=k(H,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,Y,"20b4bf5f",null,null);function Y(e){for(let t in Z)this[t]=Z[t]}const ee=function(){return Q.exports}();const te=async(e,t)=>function(e){return navigator.userAgent.toLowerCase().includes("micromessenger")?e.sort((e,t)=>"wechat"==e.type?-1:1):e}(y((await s(e)).map(({Id:e,PaymentValue:t,PaymentName:n,PaymentIcon:i,AgentDescribe:o})=>{const r=function(e){if(e.includes("支付宝"))return"alipay";if(e.includes("微信"))return"wechat";if(e.includes("平台币"))return"platform";if(e.includes("苹果"))return"apple";if(e.includes("PayPal"))return"paypal";if(e.includes("Google"))return"google";return"unknow"}(t);return{id:e,name:t,icon:i,type:r,appid:o}}),t));var ne=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,oe=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?ie(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&ne(t,n,r),r};let re=class extends n{constructor(){super(...arguments),a(this,"config"),a(this,"channels",[]),a(this,"select",0),a(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 te(this.config.channel.api,this.ignores)}onLoadChannels(e){this.channels=y(e,this.ignores),this.$emit("change",this.channels[0])}};oe([o.Inject()],re.prototype,"config",2),re=oe([i({components:{PayError:z}})],re);const ae={};var se=k(re,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(e._s(e.$t(e.$getI18nKeyInPay("payment"))))]),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,ce,"4dcfe5ca",null,null);function ce(e){for(let t in ae)this[t]=ae[t]}const le=function(){return se.exports}();var pe=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,de=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?ue(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&pe(t,n,r),r};let he=class extends n{constructor(){super(...arguments),a(this,"config"),a(this,"name",""),a(this,"id",""),a(this,"status",!1)}get params(){return{RealName:this.name,IdCard:this.id}}async onSubmit(){await(async(e,t)=>{const{Message:n,Status:i}=await s(e,t);if(!i)throw new Error(n);return!0})(this.config.identity.auth,this.params).catch(e=>{t.Dialog({title:"认证失败",message:e})})&&this.$emit("done",this.params)}};de([o.Inject()],he.prototype,"config",2),he=de([i],he);const ge={};var fe=k(he,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("van-form",{on:{submit:e.onSubmit}},[n("van-field",{attrs:{name:"姓名",label:"姓名",placeholder:"姓名",rules:[{required:!0,message:"请填写姓名"}]},model:{value:e.name,callback:function(t){e.name=t},expression:"name"}}),n("van-field",{attrs:{name:"身份证号码",label:"身份证号码",placeholder:"身份证号码",rules:[{required:!0,message:"请填写身份证号码"}]},model:{value:e.id,callback:function(t){e.id=t},expression:"id"}}),n("div",{staticStyle:{margin:"16px"}},[n("van-button",{attrs:{block:"",color:e.config.theme,"native-type":"submit"}},[e._v("认证")])],1)],1)},[],!1,me,null,null,null);function me(e){for(let t in ge)this[t]=ge[t]}const ye=function(){return fe.exports}();var ve=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,be=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?Pe(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&ve(t,n,r),r};let we=class extends n{constructor(){super(...arguments),a(this,"config"),a(this,"showPopup",!1),a(this,"info",{status:!1,name:""})}get text(){return this.info.status?`已实名 ${this.info.name}`:"未实名 点击进行实名认证"}load(){return(async e=>{const t={status:!1,name:""},{RealName:n}=await s(e);if(null==n)throw new Error("不存在实名信息");return""==n||(t.name=n,t.status=!0),t})(this.config.identity.api)}done(e){Object.assign(this.info,e),this.$emit("onIdentity",e)}openPopup(){this.info.status||(this.showPopup=!0)}authDone(e){this.showPopup=!1,this.done({status:!0,name:e.RealName})}};be([o.Inject()],we.prototype,"config",2),we=be([i({components:{PayError:z,Identity:ye}})],we);const _e={};var $e=k(we,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("PayError",{attrs:{load:e.load},on:{done:e.done}},[n("van-notice-bar",{staticClass:"identity",attrs:{"left-icon":"user-circle-o",text:e.text},on:{click:e.openPopup}}),n("van-popup",{attrs:{position:"bottom",overlay:"",round:""},model:{value:e.showPopup,callback:function(t){e.showPopup=t},expression:"showPopup"}},[n("Identity",{on:{done:e.authDone}})],1)],1)},[],!1,Ce,"5f9eb7e3",null,null);function Ce(e){for(let t in _e)this[t]=_e[t]}const ke=function(){return $e.exports}();var xe=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Ie=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?Oe(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&xe(t,n,r),r};let je=class extends n{constructor(){super(...arguments),a(this,"customPrice"),a(this,"value",null)}onChange(e){this.$emit("input",Number(e))}};Ie([o.Prop({default:null})],je.prototype,"customPrice",2),je=Ie([i],je);const Se={};var Ae=k(je,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,Te,"05e06290",null,null);function Te(e){for(let t in Se)this[t]=Se[t]}const Ee=function(){return Ae.exports}();var De=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Le=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?Ue(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&De(t,n,r),r};let Ge=class extends n{constructor(){super(...arguments),a(this,"price")}get realPrice(){return this.price.price/100}get onlyPrice(){return!this.price.count}};Le([o.Prop({default:{}})],Ge.prototype,"price",2),Ge=Le([i],Ge);const Re={};var Me=k(Ge,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.gift?n("span",{staticClass:"gift"},[e._v(" 赠"+e._s(e.price.gift)+" ")]):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/100)+" ")]):e._e(),n("span",{staticClass:"price"},[e._v(e._s(e.price.symbol||"¥")+e._s(e.realPrice))])])},[],!1,Ne,"599f1980",null,null);function Ne(e){for(let t in Re)this[t]=Re[t]}const Ve=function(){return Me.exports}();var Be=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,We=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?qe(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&Be(t,n,r),r};let Fe=class extends n{constructor(){super(...arguments),a(this,"config"),a(this,"value",0),a(this,"prices",[]),a(this,"customPrice",0),a(this,"loading",!0),a(this,"message","")}async mounted(){}load(){const{load:e,prices:t}=this.config.price;return e?new Promise(async t=>await t(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])}};We([o.Inject()],Fe.prototype,"config",2),We([o.Watch("customPrice")],Fe.prototype,"onCustomPriceChange",1),Fe=We([i({components:{PriceItem:Ve,PayError:z,PriceCustom:Ee}})],Fe);const ze={};var Ke=k(Fe,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(e._s(e.$t(e.$getI18nKeyInPay("select"))))]),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,Je,"01a7ad83",null,null);function Je(e){for(let t in ze)this[t]=ze[t]}const Xe=function(){return Ke.exports}();var He=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Qe=(e,t,n,i)=>{for(var o,r=i>1?void 0:i?Ze(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(i?o(t,n,r):o(r))||r);return i&&r&&He(t,n,r),r};let Ye=class extends n{constructor(){super(...arguments),a(this,"config"),a(this,"id"),a(this,"url"),a(this,"incomePrice"),a(this,"isAgreeProtocol",!1),a(this,"baseTheme","orange"),a(this,"visible",!1),a(this,"balance",0),a(this,"price",{price:0}),a(this,"channel",null),a(this,"loading",{balance:!1,price:!1,channel:!1,identity:!1}),a(this,"iframeSrc",""),a(this,"isPaying",!1)}async mounted(){this.$nextTick(()=>{this.visible=!0,this.initLoad()})}initLoad(){this.loading.balance=this.config.balance.disabled,this.incomePrice?this.loading.price=!0:this.loading.price=this.config.price.disabled,this.loading.identity=this.config.identity.disable,this.isAgreeProtocol=this.config.agreement.disable}onClose(){this.$emit("onClose")}onClosed(){this.$emit("onClosed")}get agreementRef(){return this.$refs.agreementRef}async onTopup(){if(!this.isAgreeProtocol)return void this.agreementRef.openProtocol();const{key:e,prefix:n}=this.config.pay,i=String(this.id||this.price.id||this.price.price/100);if(!this.channel)return void c("渠道不存在");this.isPaying=!0,this.iframeSrc="";const o=await(async e=>{const{type:n}=e;switch(n in m||t.Toast("暂不支持此渠道"),n){case"alipay":return await u(e);case"wechat":const{appid:n}=e;return n?await f(e):t.Dialog({title:"参数异常",message:"此渠道未配置小程序 appid 请先使用其他渠道!"});case"paypal":return await h(e);default:t.Toast("暂不支持此渠道")}})({...this.channel,key:e,value:i,prefix:n,url:this.url});o&&(this.iframeSrc=o),setTimeout(()=>{this.isPaying=!1,this.visible=!1},3e3),this.$emit("onTopup")}onBanlanceChange(e){this.loading.balance=!0}onChannelChange(e){this.channel=e,this.loading.channel=!0}onPriceChange(e){this.price=e,this.loading.price=!0}onIdentityChange(e){this.loading.identity=e.status}get finalPrice(){return this.incomePrice?this.incomePrice/100:this.price.price/100}get disable(){return!Object.values(this.loading).every(e=>!0===e)||this.isPaying}get title(){return this.config.name}};Qe([o.Provide("config"),o.Prop({default:b})],Ye.prototype,"config",2),Qe([o.Prop({default:void 0})],Ye.prototype,"id",2),Qe([o.Prop({default:void 0})],Ye.prototype,"url",2),Qe([o.Prop({default:void 0})],Ye.prototype,"incomePrice",2),Ye=Qe([i({components:{Balance:ee,Divider:t.Divider,PriceContainer:Xe,Button:t.Button,PriceCustom:Ee,Channels:le,Agreement:R,Identity:ke}})],Ye);const et={};var tt=k(Ye,function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("van-popup",{staticClass:"pay-popup",attrs:{position:"bottom",overlay:"",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.$t(e.title))+" ")]),e.config.balance.disabled?e._e():[n("Balance",{on:{change:e.onBanlanceChange}}),n("Divider")],e.config.price.disabled?e._e():[e.config.price.incoming?[n("h1",[e._v("¥"+e._s(e.finalPrice))])]:n("PriceContainer",{on:{change:e.onPriceChange}}),n("Divider")],n("Channels",{on:{change:e.onChannelChange}}),e.config.identity.disable?e._e():[n("Identity",{on:{onIdentity:e.onIdentityChange}})],e.config.agreement.disable?e._e():[n("Agreement",{ref:"agreementRef",on:{pay:e.onTopup},model:{value:e.isAgreeProtocol,callback:function(t){e.isAgreeProtocol=t},expression:"isAgreeProtocol"}})],n("Button",{staticClass:"pay-button",attrs:{disabled:e.disable,color:e.config.theme||e.baseTheme,block:""},on:{click:e.onTopup}},[e.isPaying?[e._v(" 拉起支付中 请稍候... ")]:[e._v(" "+e._s(e.$t(e.$getI18nKeyInPay("pay")))+" "+e._s(e.price.symbol||"¥")+e._s(e.finalPrice)+" ")]],2),e.iframeSrc?n("iframe",{attrs:{src:e.iframeSrc}}):e._e()],2)},[],!1,nt,"6bf8b9f6",null,null);function nt(e){for(let t in et)this[t]=et[t]}const it=function(){return tt.exports}(),ot={"plugin-pay":{balance:"余额",select:"选择充值金额",payment:"付款方式",pay:"立即支付"}},rt={zh:{name:"简体中文",icon:"🇨🇳",messages:ot},ko:{name:"한국어",icon:"🇰🇷",messages:{"plugin-pay":{balance:"균형",select:"충전 금액을 선택하세요",payment:"결제 방법",pay:"지금 결제하세요"}}}},at=Object.keys(rt).reduce((e,t)=>(e[t]=rt[t].messages,e),{}),st=e=>`plugin-pay.${e}`,ct={agent:b,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:v},pay:{key:"Money"},identity:{disable:!0,api:"/PlayerUser/GetUserInfo",auth:"/PlayerUser/Authentication"},agreement:{disable:!1,url:P}},krlotto:{theme:"#ff5757",name:st("balance"),needId:!1,balance:{disabled:!1,key:"PlaMoney",api:"/PlayerUser/GetMoney"},price:{disabled:!1,online:!0,load:async()=>await(async e=>await s(e))("/Payment/GetPayPal")},channel:{api:"/SystemPayment/GetList",ignores:["alipay","apple","platform","wechat","google"]},pay:{key:"type"},identity:{disable:!0,api:"/PlayerUser/GetUserInfo",auth:"/PlayerUser/Authentication"},agreement:{disable:!0}},answerer:{theme:"#5486f7",name:"购买套餐",needId:!0,balance:{disabled:!0},price:{disabled:!1,incoming:!0},channel:{api:"/SystemPayment/GetList",ignores:[]},pay:{key:"goodsId",prefix:"Answerer"},identity:{disable:!0,api:"/PlayerUser/GetUserInfo",auth:"/PlayerUser/Authentication"},agreement:{disable:!0}},balance:{theme:"#4287FF",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:v},pay:{key:"Money"},identity:{disable:!1,api:"/PlayerUser/GetUserInfo",auth:"/PlayerUser/Authentication"},agreement:{disable:!0,url:P}}},lt={install(e,i={}){let o=i.i18n;o&&Object.keys(at).forEach(e=>{o.mergeLocaleMessage(e,at[e])});e.prototype.$pay={create:(e,i)=>new Promise((r,a)=>{const s={...i},c=ct[e],{needId:l,price:{incoming:p}}=c,{id:u,url:d="/",price:h,onTopup:g,customConfig:f}=s;if(l&&!u)return void t.Dialog({title:"参数异常",message:`${e} 类型需要传入订单号 当前未传入!`});if(p&&!h)return void t.Dialog({title:"参数异常",message:"需要传入价格 当前未传入!"});f&&Object.assign(c,f);const m=new(n.extend(it))({propsData:{config:c,id:u,url:encodeURIComponent(`#${d}`),incomePrice:h},i18n:o});m.$on("onClosed",()=>{r(),setTimeout(()=>{var e;m.$destroy(),null==(e=m.$el.parentNode)||e.removeChild(m.$el)},300)}),g&&m.$on("onTopup",g),m.$mount(),document.body.appendChild(m.$el)})},e.prototype.$getI18nKeyInPay=st}};e.PayPlugin=lt,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,2 @@
1
+ import { Config } from "../types";
2
+ export declare const balance: Config;
@@ -4,4 +4,5 @@ export declare const PayAllConfig: {
4
4
  readonly user: import("../types").Config;
5
5
  readonly krlotto: import("../types").Config;
6
6
  readonly answerer: import("../types").Config;
7
+ readonly balance: import("../types").Config;
7
8
  };
@@ -1,6 +1,6 @@
1
1
  import { ChannelType } from "./channel";
2
2
  import { Price } from "./price";
3
- export type PayCreateType = "agent" | "user" | "krlotto" | "answerer";
3
+ export type PayCreateType = "agent" | "user" | "krlotto" | "answerer" | "balance";
4
4
  export type PayAllConfigType = {
5
5
  [key in PayCreateType]: Config;
6
6
  };
@@ -1,4 +1,4 @@
1
- import { PayCreateType } from "./config";
1
+ import { Config, PayCreateType } from "./config";
2
2
  export type VoidCallback = () => void;
3
3
  export type PayCreate = (type: PayCreateType, options?: PayCreateOptions) => Promise<void>;
4
4
  /** 配置参数*/
@@ -19,4 +19,6 @@ export interface PayCreateOptions {
19
19
  * 点击充值按钮回调
20
20
  */
21
21
  onTopup?: () => void;
22
+ /** 自定义配置*/
23
+ customConfig: Partial<Config>;
22
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhangcf233/pay",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "main": "dist/pay.umd.js",
5
5
  "module": "dist/pay.es.js",
6
6
  "types": "dist/types/index.d.ts",