@cloudbase/weda-ui 0.2.16 → 1.0.24

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.
Files changed (194) hide show
  1. package/README.md +41 -169
  2. package/package.json +23 -11
  3. package/src/configs/components/calendar.json +4 -1
  4. package/src/configs/components/chart/bar.json +724 -0
  5. package/src/configs/components/chart/line.json +679 -0
  6. package/src/configs/components/chart/pie.json +497 -0
  7. package/src/configs/components/chart/statisticsCard.json +61 -13
  8. package/src/configs/components/container.json +7 -2
  9. package/src/configs/components/dataView.json +21 -6
  10. package/src/configs/components/form/checkbox.json +97 -5
  11. package/src/configs/components/form/radio.json +96 -4
  12. package/src/configs/components/form/select.json +245 -11
  13. package/src/configs/components/graphicCard.json +84 -73
  14. package/src/configs/components/image.json +7 -2
  15. package/src/configs/components/link.json +19 -3
  16. package/src/configs/components/listView.json +65 -18
  17. package/src/configs/components/lottery.json +151 -0
  18. package/src/configs/components/modal.json +37 -5
  19. package/src/configs/components/navLayout.json +87 -75
  20. package/src/configs/components/navigationBar.json +59 -0
  21. package/src/configs/components/richtextview.json +4 -1
  22. package/src/configs/components/scrollVeiw.json +74 -22
  23. package/src/configs/components/swiper.json +4 -1
  24. package/src/configs/components/tabs.json +51 -8
  25. package/src/configs/components/text.json +33 -25
  26. package/src/configs/components/wxOpenApi/phone.json +141 -0
  27. package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
  28. package/src/configs/components/wxOpenApi/share.json +167 -0
  29. package/src/configs/components/wxOpenApi/userInfo.json +174 -0
  30. package/src/configs/index.js +20 -0
  31. package/src/index.js +2 -0
  32. package/src/mp/components/button/index.wxml +1 -2
  33. package/src/mp/components/chart/bar/index.js +258 -0
  34. package/src/mp/components/chart/bar/index.json +6 -0
  35. package/src/mp/components/chart/bar/index.wxml +3 -0
  36. package/src/mp/components/chart/bar/index.wxss +9 -0
  37. package/src/mp/components/chart/common/config/bar.js +50 -0
  38. package/src/mp/components/chart/common/config/global.js +16 -0
  39. package/src/mp/components/chart/common/config/line.js +48 -0
  40. package/src/mp/components/chart/common/config/pie.js +36 -0
  41. package/src/mp/components/chart/common/core/eChartBar.js +263 -0
  42. package/src/mp/components/chart/common/core/eChartBase.js +375 -0
  43. package/src/mp/components/chart/common/core/eChartLine.js +229 -0
  44. package/src/mp/components/chart/common/core/eChartPie.js +166 -0
  45. package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
  46. package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
  47. package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
  48. package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
  49. package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
  50. package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
  51. package/src/mp/components/chart/line/index.js +247 -0
  52. package/src/mp/components/chart/line/index.json +6 -0
  53. package/src/mp/components/chart/line/index.wxml +3 -0
  54. package/src/mp/components/chart/line/index.wxss +9 -0
  55. package/src/mp/components/chart/pie/index.js +182 -0
  56. package/src/mp/components/chart/pie/index.json +6 -0
  57. package/src/mp/components/chart/pie/index.wxml +4 -0
  58. package/src/mp/components/chart/pie/index.wxss +9 -0
  59. package/src/mp/components/chart/statisticsCard/index.js +33 -6
  60. package/src/mp/components/form/checkbox/index.js +41 -2
  61. package/src/mp/components/form/checkbox/index.wxml +1 -1
  62. package/src/mp/components/form/form/index.wxml +1 -2
  63. package/src/mp/components/form/input/index.js +1 -1
  64. package/src/mp/components/form/location/index.js +43 -2
  65. package/src/mp/components/form/radio/index.js +38 -0
  66. package/src/mp/components/form/select/index.js +348 -40
  67. package/src/mp/components/form/select/index.wxml +21 -6
  68. package/src/mp/components/form/select/region/index.js +101 -0
  69. package/src/mp/components/form/textarea/index.wxml +6 -5
  70. package/src/mp/components/form/uploader/index.js +76 -44
  71. package/src/mp/components/form/uploader/index.wxml +15 -3
  72. package/src/mp/components/form/uploaderFile/index.js +61 -29
  73. package/src/mp/components/graphicCard/index.js +26 -28
  74. package/src/mp/components/listView/index.js +52 -64
  75. package/src/mp/components/listView/index.wxml +2 -2
  76. package/src/mp/components/listView/index.wxss +5 -0
  77. package/src/mp/components/lottery/index.js +270 -0
  78. package/src/mp/components/lottery/index.json +4 -0
  79. package/src/mp/components/lottery/index.wxml +43 -0
  80. package/src/mp/components/lottery/index.wxss +317 -0
  81. package/src/mp/components/navLayout/index.js +3 -3
  82. package/src/mp/components/navigationBar/index.js +193 -0
  83. package/src/mp/components/navigationBar/index.json +6 -0
  84. package/src/mp/components/navigationBar/index.wxml +88 -0
  85. package/src/mp/components/navigationBar/index.wxss +1257 -0
  86. package/src/mp/components/tabs/index.js +7 -2
  87. package/src/mp/components/tabs/index.wxml +2 -1
  88. package/src/mp/components/text/index.js +0 -25
  89. package/src/mp/components/text/index.wxml +3 -3
  90. package/src/mp/components/wxOpenApi/phone/index.js +117 -0
  91. package/src/mp/components/wxOpenApi/phone/index.json +4 -0
  92. package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
  93. package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
  94. package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
  95. package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
  96. package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
  97. package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
  98. package/src/mp/components/wxOpenApi/share/index.js +117 -0
  99. package/src/mp/components/wxOpenApi/share/index.json +4 -0
  100. package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
  101. package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
  102. package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
  103. package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
  104. package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
  105. package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
  106. package/src/mp/index.json +10 -1
  107. package/src/mp/style/weda-ui.wxss +2 -0
  108. package/src/mp/utils/constant.js +15 -0
  109. package/src/mp/utils/destr.js +48 -0
  110. package/src/mp/utils/lodash.js +2 -0
  111. package/src/mp/utils/platform.js +25 -0
  112. package/src/mp/utils/tcb.js +44 -0
  113. package/src/setupTests.js +2 -1
  114. package/src/web/components/button/index.css +8 -1
  115. package/src/web/components/button/index.tsx +3 -2
  116. package/src/web/components/chart/bar/index.tsx +140 -0
  117. package/src/web/components/chart/common/config/bar.js +49 -0
  118. package/src/web/components/chart/common/config/global.js +16 -0
  119. package/src/web/components/chart/common/config/line.js +50 -0
  120. package/src/web/components/chart/common/config/pie.js +37 -0
  121. package/src/web/components/chart/common/core/eChartBar.js +265 -0
  122. package/src/web/components/chart/common/core/eChartBase.ts +383 -0
  123. package/src/web/components/chart/common/core/eChartLine.js +231 -0
  124. package/src/web/components/chart/common/core/eChartPie.js +170 -0
  125. package/src/web/components/chart/common/core/type.ts +34 -0
  126. package/src/web/components/chart/common/echart.css +106 -0
  127. package/src/web/components/chart/common/echarts.ts +33 -0
  128. package/src/web/components/chart/common/useChart.tsx +69 -0
  129. package/src/web/components/chart/line/index.tsx +136 -0
  130. package/src/web/components/chart/pie/index.tsx +99 -0
  131. package/src/web/components/chart/statisticsCard/index.tsx +29 -8
  132. package/src/web/components/form/checkbox/index.tsx +61 -23
  133. package/src/web/components/form/formcell/index.tsx +10 -5
  134. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +3 -3
  135. package/src/web/components/form/location/components/LocationPC/location.PC.jsx +2 -2
  136. package/src/web/components/form/radio/index.tsx +90 -53
  137. package/src/web/components/form/select/h5.tsx +371 -72
  138. package/src/web/components/form/select/index.css +10 -0
  139. package/src/web/components/form/select/index.tsx +392 -145
  140. package/src/web/components/form/select/region/index.ts +122 -31
  141. package/src/web/components/form/select/time.jsx +90 -0
  142. package/src/web/components/form/select/year.tsx +170 -0
  143. package/src/web/components/form/tips/index.css +4 -0
  144. package/src/web/components/form/tips/index.tsx +4 -3
  145. package/src/web/components/form/uploader/uploader.h5.tsx +28 -19
  146. package/src/web/components/form/uploader/uploader.pc.tsx +17 -20
  147. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +48 -44
  148. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +28 -26
  149. package/src/web/components/graphicCard/index.css +1 -5
  150. package/src/web/components/graphicCard/index.tsx +4 -3
  151. package/src/web/components/image/image.tsx +1 -1
  152. package/src/web/components/image/index.tsx +1 -1
  153. package/src/web/components/index.js +13 -2
  154. package/src/web/components/link/index.tsx +6 -3
  155. package/src/web/components/listView/index.css +4 -0
  156. package/src/web/components/listView/index.tsx +10 -18
  157. package/src/web/components/lottery/index.css +327 -0
  158. package/src/web/components/lottery/index.tsx +567 -0
  159. package/src/web/components/lottery/lotteryUtil.ts +130 -0
  160. package/src/web/components/modal/index.tsx +3 -1
  161. package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
  162. package/src/web/components/navigationBar/common.tsx +198 -0
  163. package/src/web/components/navigationBar/h5Menu.tsx +179 -0
  164. package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
  165. package/src/web/components/navigationBar/index.css +762 -0
  166. package/src/web/components/navigationBar/index.tsx +231 -0
  167. package/src/web/components/navigationBar/type.d.ts +111 -0
  168. package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
  169. package/src/web/components/phone/index.css +0 -0
  170. package/src/web/components/phone/index.tsx +22 -0
  171. package/src/web/components/phoneCode/index.css +0 -0
  172. package/src/web/components/phoneCode/index.tsx +22 -0
  173. package/src/web/components/richTextView/index.tsx +3 -5
  174. package/src/web/components/share/index.css +0 -0
  175. package/src/web/components/share/index.tsx +38 -0
  176. package/src/web/components/tabs/index.tsx +2 -0
  177. package/src/web/components/tabs/tabs.h5.tsx +43 -33
  178. package/src/web/components/tabs/tabs.pc.tsx +23 -10
  179. package/src/web/components/text/index.tsx +6 -14
  180. package/src/web/components/userInfo/index.css +0 -0
  181. package/src/web/components/userInfo/index.tsx +30 -0
  182. package/src/web/utils/{constant.js → constant.ts} +17 -2
  183. package/src/web/utils/lodash.ts +2 -0
  184. package/src/web/utils/platform.js +10 -1
  185. package/src/web/utils/tcb.js +20 -6
  186. package/src/web/weda-ui.css +2 -0
  187. package/CHANGELOG.md +0 -240
  188. package/src/.DS_Store +0 -0
  189. package/src/configs/.DS_Store +0 -0
  190. package/src/mp/.gitignore +0 -10
  191. package/src/web/.DS_Store +0 -0
  192. package/src/web/components/form/select/region/cities.ts +0 -2410
  193. package/src/web/components/form/select/region/provinces.ts +0 -240
  194. package/src/web/components/form/select/region/regions.ts +0 -20645
@@ -0,0 +1,182 @@
1
+ import * as echarts from '../common/lib/echarts.min';
2
+ import EchartPie from '../common/core/eChartPie';
3
+ Component({
4
+ options: {
5
+ virtualHost: true,
6
+ multipleSlots: true,
7
+ },
8
+ properties: {
9
+ id: {
10
+ type: String,
11
+ value: '',
12
+ },
13
+ className: {
14
+ type: String,
15
+ value: '',
16
+ },
17
+ style: {
18
+ type: String,
19
+ value: '',
20
+ },
21
+ chartType: {
22
+ // 图形类型
23
+ type: String,
24
+ value: 'bight',
25
+ },
26
+ title: {
27
+ // 图表标题
28
+ type: String,
29
+ },
30
+ isTitle: {
31
+ // 是否显示标题
32
+ type: Boolean,
33
+ value: false,
34
+ },
35
+ titleLocation: {
36
+ type: String,
37
+ value: 'top',
38
+ },
39
+ dataSource: {
40
+ // 数据源
41
+ type: Object,
42
+ },
43
+ filterData: {
44
+ // 数据筛选
45
+ type: Array,
46
+ value: [],
47
+ },
48
+ setColor: {
49
+ // 设置颜色
50
+ type: Array,
51
+ value: [],
52
+ },
53
+ xField: {
54
+ // x轴字段选择
55
+ type: Object,
56
+ value: {
57
+ format: '',
58
+ type: '', // 数据源字段 类型
59
+ title: '', // 字段名中文
60
+ name: '', // 字段名英文
61
+ },
62
+ },
63
+ xStatistics: {
64
+ // x轴统计维度
65
+ type: String,
66
+ value: '', // 统计纬度, 只有选择时间类型才有,y 年,m月,d 日,w周,h时,min 分,s秒
67
+ },
68
+ xIsCountEmpty: {
69
+ // x轴 是否统计空值
70
+ type: Boolean,
71
+ value: false,
72
+ },
73
+ yField: {
74
+ // Y轴字段,分组字段,是否分组
75
+ type: Object,
76
+ value: {
77
+ numValue: [{ key: '', operationType: '' }],
78
+ groupKey: '',
79
+ },
80
+ },
81
+ isLegend: {
82
+ // 是否显示图例
83
+ type: Boolean,
84
+ value: false,
85
+ },
86
+ legend: {
87
+ // 图例
88
+ type: String,
89
+ value: 'bottom', // 左 left 右right, 上top,下 bottom
90
+ },
91
+
92
+ // 高级属性
93
+ isSeriesShowSymbol: {
94
+ // 是否显示数据标签 开启后 属性 series.label.show 要同时设置为true
95
+ type: Boolean,
96
+ value: true,
97
+ },
98
+ isPercent: {
99
+ // 百分比
100
+ type: Boolean,
101
+ value: false,
102
+ },
103
+ isUnit: {
104
+ // 显示单位
105
+ type: Boolean,
106
+ value: false,
107
+ },
108
+ unit: {
109
+ // 数字显示的单位 百分比,千分比,千,万,百万,亿,十亿
110
+ type: String,
111
+ value: '%',
112
+ },
113
+ decimalDigits: {
114
+ // 小数位数
115
+ type: Number,
116
+ value: 0,
117
+ },
118
+ suffix: {
119
+ // 后缀
120
+ type: String,
121
+ value: '',
122
+ },
123
+ },
124
+ data: {
125
+ ec: {},
126
+ canvas_id: {
127
+ type: String,
128
+ value: `canvas_pie_${Date.now()}_${Math.random() * 100}`,
129
+ },
130
+ },
131
+ lifetimes: {
132
+ attached() {
133
+ // 在组件实例进入页面节点树时执行
134
+ this.initData();
135
+ },
136
+ detached() {
137
+ // 在组件实例被从页面节点树移除时执行
138
+ },
139
+ },
140
+ // 以下是旧式的定义方式,可以保持对 <2.2.3 版本基础库的兼容
141
+ attached() {
142
+ // 在组件实例进入页面节点树时执行
143
+ this.initData();
144
+ },
145
+ detached() {
146
+ // 在组件实例被从页面节点树移除时执行
147
+ },
148
+ observers: {
149
+ // 当参数变化时
150
+ '**': async function() {
151
+ const objEChartPie = new EchartPie();
152
+ await objEChartPie.setOptions(this.properties);
153
+ const options = await objEChartPie.getOptions();
154
+ this._chart && this._chart.setOption(options);
155
+ },
156
+ },
157
+ methods: {
158
+ initData() {
159
+ this.setData({
160
+ ec: {
161
+ onInit: this.initChart.bind(this),
162
+ },
163
+ });
164
+ },
165
+ async initChart(canvas, width, height, dpr) {
166
+ const objEchart = echarts.init(canvas, null, {
167
+ width,
168
+ height,
169
+ devicePixelRatio: dpr,
170
+ });
171
+ canvas.setChart(objEchart);
172
+ const objEChartPie = new EchartPie();
173
+ await objEChartPie.setOptions(this.properties);
174
+ const options = await objEChartPie.getOptions();
175
+ // objEchart.clear();
176
+ console.log('设置前参数pie', options);
177
+ objEchart.setOption(options);
178
+ this._chart = objEchart;
179
+ return objEchart;
180
+ },
181
+ },
182
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ "ec-canvas": "../ec-canvas/ec-canvas"
5
+ }
6
+ }
@@ -0,0 +1,4 @@
1
+ <view wx:if="ec" class="{{className}} ec_container" style="{{style}}" id="{{id}}">
2
+ <ec-canvas canvas-id="{{canvas_id}}" ec="{{ ec }}"></ec-canvas>
3
+ </view>
4
+
@@ -0,0 +1,9 @@
1
+ /**index.wxss**/
2
+ ec-canvas {
3
+ width: 100%;
4
+ height: 100%;
5
+ }
6
+ .ec_container {
7
+ width: 100%;
8
+ height: 380px;
9
+ }
@@ -108,15 +108,32 @@ Component({
108
108
  }
109
109
  return integer;
110
110
  },
111
+ addDelimiter: function (fixedString, digit) {
112
+ let len = fixedString.length;
113
+ let result = '';
114
+ const decimalPoint = digit > 0 ? digit + 1 : 0;
115
+ for (let i = len - 1; i >= 0; i--) {
116
+ let stepFromTail = len - 1 - i;
117
+ let char = fixedString.charAt(i);
118
+
119
+ if (stepFromTail <= decimalPoint) {
120
+ // 小数部分不处理
121
+ result = char + result;
122
+ } else {
123
+ if ((stepFromTail - decimalPoint) % 3 === 0) {
124
+ if (char !== '-') {
125
+ result = ',' + result;
126
+ }
127
+ }
128
+ result = char + result;
129
+ }
130
+ }
131
+ return result;
132
+ },
111
133
  formatNumber: function (val, digits = 0) {
112
134
  return isNaN(val)
113
135
  ? val
114
- : Intl
115
- ? Intl.NumberFormat('en-US', {
116
- maximumFractionDigits: 10,
117
- minimumFractionDigits: digits,
118
- }).format(this.customToFixed(val, digits))
119
- : val;
136
+ : this.addDelimiter(this.customToFixed(val, digits), digits);
120
137
  },
121
138
  getSourceData: async function (
122
139
  dataSource,
@@ -223,4 +240,14 @@ Component({
223
240
  this._fetchData();
224
241
  },
225
242
  },
243
+ attached() {
244
+ this._fetchData();
245
+ },
246
+ observers: {
247
+ // 当参数变化时
248
+ 'datasource,filterData,field,operationType,label,isCountEmpty,isShowUnit,unit,decimalDigits,suffix':
249
+ function () {
250
+ this._fetchData();
251
+ },
252
+ },
226
253
  });
@@ -1,5 +1,7 @@
1
1
  import classNames from '../../../utils/classnames';
2
+ import destr from '../../../utils/destr';
2
3
  import handleEvents from '../../../utils/handleEvents';
4
+ import { callWedaApi } from '../../../utils/tcb';
3
5
 
4
6
  Component({
5
7
  options: {
@@ -41,15 +43,24 @@ Component({
41
43
  type: Boolean,
42
44
  value: false,
43
45
  },
46
+ format: {
47
+ type: String,
48
+ value: '',
49
+ },
50
+ enumName: {
51
+ type: String,
52
+ value: '',
53
+ }
44
54
  },
45
55
  data: {
46
56
  cls: '',
47
57
  subCls: '',
48
58
  isFlex: true,
59
+ defaultRange: []
49
60
  },
50
61
  lifetimes: {
51
62
  attached() {
52
- const { className, layout, disabled } = this.properties;
63
+ const { className, layout, disabled, range } = this.properties;
53
64
  const isFlex = layout !== 'vertical';
54
65
  const cls = classNames({
55
66
  'weda-ui': true,
@@ -63,10 +74,26 @@ Component({
63
74
  'weui-cell_disabled': disabled,
64
75
  });
65
76
 
66
- this.setData({ cls, subCls, isFlex });
77
+ this.setData({ cls, subCls, isFlex, defaultRange: range });
67
78
  },
68
79
  },
69
80
  methods: {
81
+ _fetchData: async function () {
82
+ let data = await callWedaApi({
83
+ action: 'DescribeGeneralOptionsDetailList',
84
+ data: { OptNameList: [this.properties.enumName], PageIndex: 1, PageSize: 10 },
85
+ });
86
+ const config = destr(data?.Items?.[0]?.Config) ?? [];
87
+ const option = config.map(item => {
88
+ return {
89
+ label: item.value,
90
+ value: item.key,
91
+ checked: false
92
+ };
93
+ });
94
+ this.setData({ defaultRange: option });
95
+ },
96
+
70
97
  ...handleEvents([
71
98
  {
72
99
  name: 'change',
@@ -74,4 +101,16 @@ Component({
74
101
  },
75
102
  ]),
76
103
  },
104
+ observers: {
105
+ range: function (range) {
106
+ if (this.properties.format !== 'x-enum') {
107
+ this.setData({ defaultRange: range });
108
+ }
109
+ },
110
+ format: function (format) {
111
+ if (format === 'x-enum' && this.properties.enumName) {
112
+ this._fetchData();
113
+ }
114
+ }
115
+ },
77
116
  });
@@ -7,7 +7,7 @@
7
7
  requiredFlag="{{requiredFlag}}"
8
8
  >
9
9
  <checkbox-group class="{{isFlex ? 'weui-flex__item' : ''}}" bindchange="change">
10
- <label class="{{subCls}}" wx:for="{{range}}" wx:key="value">
10
+ <label class="{{subCls}}" wx:for="{{defaultRange}}" wx:key="value">
11
11
  <view class="weui-cell__hd">
12
12
  <checkbox
13
13
  class="weui-check"
@@ -1,6 +1,5 @@
1
- <view class="weui-form weda-ui {{className}} {{style}}">
1
+ <view class="weui-form weda-ui {{className}}" style="{{style}}">
2
2
  <view class="weui-cells__group weui-cells__group_form">
3
3
  <slot name="contentSlot" />
4
4
  </view>
5
5
  </view>
6
-
@@ -101,7 +101,7 @@ Component({
101
101
  this.setData({
102
102
  value: '',
103
103
  });
104
- this.triggerEvent('change', e.detail);
104
+ this.triggerEvent('clear', e.detail);
105
105
  },
106
106
  handleConfirm: function (e) {
107
107
  this.triggerEvent('confirm', e.detail);
@@ -156,7 +156,48 @@ Component({
156
156
  };
157
157
  const { locationType, customLocation } = this.properties;
158
158
  if (locationType === 1 || locationType === 2) {
159
- getCurrentLocation(locationType);
159
+ // 可以通过 wx.getSetting 先查询一下用户是否授权了 "scope.record" 这个 scope
160
+ wx.getSetting({
161
+ success: (res) => {
162
+ if (!res.authSetting['scope.userLocation']) {
163
+ // 没有授权
164
+ wx.authorize({
165
+ scope: 'scope.userLocation',
166
+ success: () => {
167
+ // 用户已经同意小程序使用定位功能,后续调用 wx.getLocation 接口不会弹窗询问
168
+ getCurrentLocation(locationType);
169
+ },
170
+ fail: (err) => {
171
+ console.log('authorize fail', err);
172
+ this.setData({
173
+ currentPosition: {
174
+ status: false,
175
+ message: err.errMsg,
176
+ },
177
+ currentLocations: {},
178
+ });
179
+ this.triggerEvent('change', {
180
+ value: null,
181
+ });
182
+ wx.showToast({
183
+ icon: 'none',
184
+ title: err.errMsg,
185
+ });
186
+ },
187
+ });
188
+ } else {
189
+ // 已经授权
190
+ getCurrentLocation(locationType);
191
+ }
192
+ },
193
+ fail: (err) => {
194
+ console.log('getSetting fail', err);
195
+ wx.showToast({
196
+ icon: 'none',
197
+ title: 'getSetting fail',
198
+ });
199
+ },
200
+ });
160
201
  } else if (locationType === 3) {
161
202
  this.setData({
162
203
  currentPosition: {
@@ -299,7 +340,7 @@ Component({
299
340
  let location = {
300
341
  address: poiname,
301
342
  geopoint: {
302
- coordinates: [latitude, longitude],
343
+ coordinates: [longitude, latitude],
303
344
  type: 'Point',
304
345
  },
305
346
  };
@@ -1,5 +1,7 @@
1
1
  import classNames from '../../../utils/classnames';
2
+ import destr from '../../../utils/destr';
2
3
  import handleEvents from '../../../utils/handleEvents';
4
+ import { callWedaApi } from '../../../utils/tcb';
3
5
 
4
6
  Component({
5
7
  options: {
@@ -41,6 +43,14 @@ Component({
41
43
  type: Boolean,
42
44
  value: false,
43
45
  },
46
+ format: {
47
+ type: String,
48
+ value: '',
49
+ },
50
+ enumName: {
51
+ type: String,
52
+ value: '',
53
+ }
44
54
  },
45
55
  data: {
46
56
  cls: '',
@@ -68,6 +78,22 @@ Component({
68
78
  },
69
79
  },
70
80
  methods: {
81
+ _fetchData: async function () {
82
+ let data = await callWedaApi({
83
+ action: 'DescribeGeneralOptionsDetailList',
84
+ data: { OptNameList: [this.properties.enumName], PageIndex: 1, PageSize: 10 },
85
+ });
86
+ const config = destr(data?.Items?.[0]?.Config) ?? [];
87
+ const option = config?.map(item => {
88
+ return {
89
+ label: item.value,
90
+ value: item.key,
91
+ checked: false
92
+ };
93
+ });
94
+ this.setData({ defaultRange: option });
95
+ },
96
+
71
97
  ...handleEvents([
72
98
  {
73
99
  name: 'change',
@@ -75,4 +101,16 @@ Component({
75
101
  },
76
102
  ]),
77
103
  },
104
+ observers: {
105
+ range: function (range) {
106
+ if (this.properties.format !== 'x-enum') {
107
+ this.setData({ defaultRange: range });
108
+ }
109
+ },
110
+ format: function (format) {
111
+ if (format === 'x-enum' && this.properties.enumName) {
112
+ this._fetchData();
113
+ }
114
+ }
115
+ },
78
116
  });