gxd-uni-library-editx 1.0.78 → 1.0.80-beta1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gxd-uni-library-editx",
3
- "version": "1.0.78",
3
+ "version": "1.0.80-beta1",
4
4
  "private": false,
5
5
  "description": "聚福宝基础插件专用库",
6
6
  "main": "index.js",
@@ -249,6 +249,10 @@ export default {
249
249
  type: Boolean,
250
250
  default: false
251
251
  },
252
+ payThird: { //是否支持补差
253
+ tyep: Boolean,
254
+ default: true
255
+ },
252
256
  // payChannels: { //三方支付列表
253
257
  // type: Array,
254
258
  // default: () => {
@@ -614,6 +618,10 @@ export default {
614
618
  },
615
619
 
616
620
  handleConfirmAllWxPay(){
621
+ if(!this.payThird){
622
+ this.$xdAlert({content: "请选择兑换方式"});
623
+ return Promise.reject("请选择兑换方式");
624
+ }
617
625
  return new Promise((resolve, reject) => {
618
626
  uni.showModal({
619
627
  title: '提示',
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
  import helper from "@/utils/helper";
3
- import {getJfbConfig,getColorBaseUrl} from "@/lib/conf.domain";
4
-
5
3
  class XdNetwork {
6
4
  constructor(){
7
5
  this.eventObj = {
@@ -111,8 +109,8 @@ class XdNetwork {
111
109
  getNetworkEnv(paths=[]){
112
110
  if(paths.length === 0) {
113
111
  paths = [
114
- {path: `${getColorBaseUrl(getJfbConfig('apiBasePath'))}/common/10x10.png`, size:0.94},
115
- {path: `${getColorBaseUrl(getJfbConfig('apiBasePath'))}/common/100x100.png`, size: 1.078},
112
+ {path: 'https://image.jufubao.cn/network/10x10.png', size:0.94},
113
+ {path: 'https://image.jufubao.cn/network/100x100.png', size: 1.078},
116
114
  ]
117
115
  }
118
116
  let promiseArr= [];
@@ -0,0 +1,135 @@
1
+ 'use strict';
2
+ import helper from "@/utils/helper";
3
+ import {getJfbConfig,getColorBaseUrl} from "@/lib/conf.domain";
4
+
5
+ class XdNetwork {
6
+ constructor(){
7
+ this.eventObj = {
8
+ online: [],
9
+ offline: [],
10
+ };
11
+
12
+ //网络定义
13
+ this.status = {
14
+ strong: '',//0-230ms
15
+ normal: '',//230-750ms
16
+ low: '' //750-1400ms
17
+ };
18
+
19
+ this.init();
20
+ }
21
+
22
+ addEvent(eventName, cb){
23
+ this.eventObj[eventName].push(cb);
24
+ return this;
25
+ }
26
+
27
+ $mount(type){
28
+ let eventsFn = this.eventObj[type];
29
+ eventsFn.map(item=>{
30
+ item();
31
+ })
32
+ }
33
+
34
+ handleH5(){
35
+ let timer = null;
36
+ const handleOffline = () => {
37
+ if (timer) {
38
+ clearTimeout(timer);
39
+ timer = null;
40
+ }
41
+ timer = setTimeout(() => {
42
+ this.$mount('offline');
43
+ }, 100)
44
+ };
45
+ const handleOnline = () => {
46
+ if (timer) {
47
+ clearTimeout(timer);
48
+ timer = null;
49
+ }
50
+ timer = setTimeout(() => {
51
+ this.$mount('online');
52
+ }, 100)
53
+ };
54
+ if (window.addEventListener) {
55
+ window.addEventListener("offline", function () {
56
+ handleOffline();
57
+ }, true);
58
+ window.addEventListener("online", function () {
59
+ handleOnline();
60
+ }, true);
61
+ }
62
+ else if (window['attachEvent']) {
63
+ window['attachEvent']("onoffline", function () {
64
+ handleOffline();
65
+ });
66
+ window['attachEvent']("online", function () {
67
+ handleOnline();
68
+ });
69
+ }
70
+ else {
71
+ window.onoffline = function () {
72
+ handleOffline();
73
+ };
74
+ window.ononline = function () {
75
+ handleOnline();
76
+ };
77
+ }
78
+ }
79
+
80
+ init(){
81
+ //#ifdef H5
82
+ this.handleH5();
83
+ // #endif
84
+ //#ifndef H5
85
+ uni.onNetworkStatusChange(({isConnected, networkType})=>{
86
+ uni.getNetworkType({
87
+ success: function (res) {
88
+ console.log('onNetworkStatusChange', isConnected, res.networkType)
89
+ }
90
+ });
91
+ });
92
+ // #endif
93
+ }
94
+
95
+ handleImage(image){
96
+ let time = new Date().getTime();
97
+ return new Promise((resolve, reject) => {
98
+ uni.getImageInfo({
99
+ src: `${image.path}?v=${time}`,
100
+ success:(res)=>{
101
+ let end = (new Date().getTime() - time)/1000;
102
+ resolve(helper.divisionFloatNumber(image.size, end));
103
+ },
104
+ fail:()=>{
105
+ reject(0)
106
+ }
107
+ })
108
+ });
109
+ }
110
+
111
+ getNetworkEnv(paths=[]){
112
+ if(paths.length === 0) {
113
+ paths = [
114
+ {path: `${getColorBaseUrl(getJfbConfig('apiBasePath'))}/common/10x10.png`, size:0.94},
115
+ {path: `${getColorBaseUrl(getJfbConfig('apiBasePath'))}/common/100x100.png`, size: 1.078},
116
+ ]
117
+ }
118
+ let promiseArr= [];
119
+ paths.map(path=>{
120
+ promiseArr.push(this.handleImage(path));
121
+ });
122
+ return new Promise((resolve, reject) => {
123
+ Promise.all(promiseArr)
124
+ .then(res=>{
125
+ console.log(res)
126
+ resolve((res[0] + res[1])/2);
127
+ })
128
+ .catch()
129
+ });
130
+ }
131
+ }
132
+
133
+ export default function () {
134
+ return new XdNetwork();
135
+ };