@cloudbase/weda-ui-mp 0.2.20

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 (635) hide show
  1. package/README.md +1 -0
  2. package/actions/showMessage/index.js +3 -0
  3. package/actions/showModal/index.js +3 -0
  4. package/actions/showToast/index.js +3 -0
  5. package/app.js +0 -0
  6. package/components/button/index.js +89 -0
  7. package/components/button/index.json +4 -0
  8. package/components/button/index.wxml +22 -0
  9. package/components/button/index.wxss +13 -0
  10. package/components/calendar/arrowright--line.svg +3 -0
  11. package/components/calendar/index.js +439 -0
  12. package/components/calendar/index.json +5 -0
  13. package/components/calendar/index.wxml +35 -0
  14. package/components/calendar/index.wxss +203 -0
  15. package/components/carousel/index.js +91 -0
  16. package/components/carousel/index.json +7 -0
  17. package/components/carousel/index.wxml +6 -0
  18. package/components/chart/bar/index.js +331 -0
  19. package/components/chart/bar/index.json +6 -0
  20. package/components/chart/bar/index.wxml +1 -0
  21. package/components/chart/bar/index.wxss +9 -0
  22. package/components/chart/common/config/bar.js +50 -0
  23. package/components/chart/common/config/global.js +16 -0
  24. package/components/chart/common/config/line.js +48 -0
  25. package/components/chart/common/config/pie.js +36 -0
  26. package/components/chart/common/core/eChartBar.js +267 -0
  27. package/components/chart/common/core/eChartBase.js +450 -0
  28. package/components/chart/common/core/eChartLine.js +251 -0
  29. package/components/chart/common/core/eChartPie.js +169 -0
  30. package/components/chart/common/data-transform.js +284 -0
  31. package/components/chart/common/lib/echarts.min.js +18 -0
  32. package/components/chart/ec-canvas/ec-canvas.js +277 -0
  33. package/components/chart/ec-canvas/ec-canvas.json +4 -0
  34. package/components/chart/ec-canvas/ec-canvas.wxml +4 -0
  35. package/components/chart/ec-canvas/ec-canvas.wxss +4 -0
  36. package/components/chart/ec-canvas/wx-canvas.js +111 -0
  37. package/components/chart/line/index.js +326 -0
  38. package/components/chart/line/index.json +6 -0
  39. package/components/chart/line/index.wxml +1 -0
  40. package/components/chart/line/index.wxss +9 -0
  41. package/components/chart/pie/index.js +257 -0
  42. package/components/chart/pie/index.json +6 -0
  43. package/components/chart/pie/index.wxml +1 -0
  44. package/components/chart/pie/index.wxss +9 -0
  45. package/components/chart/statisticsCard/index.js +255 -0
  46. package/components/chart/statisticsCard/index.json +4 -0
  47. package/components/chart/statisticsCard/index.wxml +9 -0
  48. package/components/chart/statisticsCard/index.wxss +42 -0
  49. package/components/common/form-item-wrapper/index.js +20 -0
  50. package/components/common/form-item-wrapper/index.json +5 -0
  51. package/components/common/form-item-wrapper/index.wxml +3 -0
  52. package/components/container/index.js +32 -0
  53. package/components/container/index.json +4 -0
  54. package/components/container/index.wxml +3 -0
  55. package/components/customer-service/index.js +37 -0
  56. package/components/customer-service/index.json +5 -0
  57. package/components/customer-service/index.wxml +3 -0
  58. package/components/customer-service/index.wxss +11 -0
  59. package/components/dataView/index.js +125 -0
  60. package/components/dataView/index.json +7 -0
  61. package/components/dataView/index.wxml +28 -0
  62. package/components/form/checkbox/index.js +145 -0
  63. package/components/form/checkbox/index.json +7 -0
  64. package/components/form/checkbox/index.wxml +13 -0
  65. package/components/form/checkbox/index.wxss +1 -0
  66. package/components/form/form/index.js +189 -0
  67. package/components/form/form/index.json +4 -0
  68. package/components/form/form/index.wxml +5 -0
  69. package/components/form/form/index.wxss +3 -0
  70. package/components/form/form/wd-form.wxss +1113 -0
  71. package/components/form/formcell/index.js +57 -0
  72. package/components/form/formcell/index.json +4 -0
  73. package/components/form/formcell/index.wxml +11 -0
  74. package/components/form/formcell/index.wxss +31 -0
  75. package/components/form/input/index.js +116 -0
  76. package/components/form/input/index.json +7 -0
  77. package/components/form/input/index.wxml +25 -0
  78. package/components/form/input/index.wxss +22 -0
  79. package/components/form/location/components/mapChoose/index.js +516 -0
  80. package/components/form/location/components/mapChoose/index.json +4 -0
  81. package/components/form/location/components/mapChoose/index.wxml +54 -0
  82. package/components/form/location/components/mapChoose/index.wxss +301 -0
  83. package/components/form/location/index.js +520 -0
  84. package/components/form/location/index.json +10 -0
  85. package/components/form/location/index.wxml +29 -0
  86. package/components/form/location/index.wxss +151 -0
  87. package/components/form/location/location-btn.svg +4 -0
  88. package/components/form/location/location.svg +4 -0
  89. package/components/form/radio/index.js +124 -0
  90. package/components/form/radio/index.json +7 -0
  91. package/components/form/radio/index.wxml +13 -0
  92. package/components/form/radio/index.wxss +1 -0
  93. package/components/form/select/allTimePicker/dataUtils.js +377 -0
  94. package/components/form/select/allTimePicker/index.js +487 -0
  95. package/components/form/select/allTimePicker/index.json +7 -0
  96. package/components/form/select/allTimePicker/index.wxml +35 -0
  97. package/components/form/select/allTimePicker/index.wxss +118 -0
  98. package/components/form/select/dropdown-select/index.js +287 -0
  99. package/components/form/select/dropdown-select/index.json +4 -0
  100. package/components/form/select/dropdown-select/index.wxml +35 -0
  101. package/components/form/select/dropdown-select/index.wxss +293 -0
  102. package/components/form/select/formats-util.js +15 -0
  103. package/components/form/select/index.js +1032 -0
  104. package/components/form/select/index.json +10 -0
  105. package/components/form/select/index.wxml +57 -0
  106. package/components/form/select/index.wxss +61 -0
  107. package/components/form/select/region/index.js +120 -0
  108. package/components/form/selectMultiple/dropdown-select/index.js +231 -0
  109. package/components/form/selectMultiple/dropdown-select/index.json +4 -0
  110. package/components/form/selectMultiple/dropdown-select/index.wxml +37 -0
  111. package/components/form/selectMultiple/dropdown-select/index.wxss +305 -0
  112. package/components/form/selectMultiple/index.js +366 -0
  113. package/components/form/selectMultiple/index.json +9 -0
  114. package/components/form/selectMultiple/index.wxml +34 -0
  115. package/components/form/selectMultiple/index.wxss +127 -0
  116. package/components/form/switch/index.js +90 -0
  117. package/components/form/switch/index.json +7 -0
  118. package/components/form/switch/index.wxml +11 -0
  119. package/components/form/switch/index.wxss +1 -0
  120. package/components/form/textarea/index.js +90 -0
  121. package/components/form/textarea/index.json +7 -0
  122. package/components/form/textarea/index.wxml +8 -0
  123. package/components/form/textarea/index.wxss +10 -0
  124. package/components/form/tips/index.js +41 -0
  125. package/components/form/tips/index.json +4 -0
  126. package/components/form/tips/index.wxml +1 -0
  127. package/components/form/tips/index.wxss +5 -0
  128. package/components/form/uploader/compress.js +31 -0
  129. package/components/form/uploader/index.js +289 -0
  130. package/components/form/uploader/index.json +10 -0
  131. package/components/form/uploader/index.wxml +38 -0
  132. package/components/form/uploader/index.wxss +47 -0
  133. package/components/form/uploader/weui-uploader.js +305 -0
  134. package/components/form/uploader/weui-uploader.json +7 -0
  135. package/components/form/uploader/weui-uploader.wxml +49 -0
  136. package/components/form/uploader/weui-uploader.wxss +26 -0
  137. package/components/form/uploaderFile/index.js +489 -0
  138. package/components/form/uploaderFile/index.json +9 -0
  139. package/components/form/uploaderFile/index.wxml +52 -0
  140. package/components/form/uploaderFile/index.wxss +171 -0
  141. package/components/form-checkbox/index.js +78 -0
  142. package/components/form-checkbox/index.json +9 -0
  143. package/components/form-checkbox/index.wxml +6 -0
  144. package/components/form-date/index.js +72 -0
  145. package/components/form-date/index.json +9 -0
  146. package/components/form-date/index.wxml +25 -0
  147. package/components/form-email/index.js +99 -0
  148. package/components/form-email/index.json +9 -0
  149. package/components/form-email/index.wxml +28 -0
  150. package/components/form-field-behavior/form-field-behavior.js +472 -0
  151. package/components/form-field-behavior/item-behavior.js +455 -0
  152. package/components/form-field-behavior/validator.js +137 -0
  153. package/components/form-image-uploader/index.js +83 -0
  154. package/components/form-image-uploader/index.json +9 -0
  155. package/components/form-image-uploader/index.wxml +27 -0
  156. package/components/form-input/index.js +103 -0
  157. package/components/form-input/index.json +9 -0
  158. package/components/form-input/index.wxml +29 -0
  159. package/components/form-location/index.js +98 -0
  160. package/components/form-location/index.json +9 -0
  161. package/components/form-location/index.wxml +28 -0
  162. package/components/form-multi-region/index.js +62 -0
  163. package/components/form-multi-region/index.json +9 -0
  164. package/components/form-multi-region/index.wxml +6 -0
  165. package/components/form-phone/index.js +95 -0
  166. package/components/form-phone/index.json +9 -0
  167. package/components/form-phone/index.wxml +28 -0
  168. package/components/form-radio/index.js +70 -0
  169. package/components/form-radio/index.json +9 -0
  170. package/components/form-radio/index.wxml +6 -0
  171. package/components/form-region/index.js +59 -0
  172. package/components/form-region/index.json +9 -0
  173. package/components/form-region/index.wxml +6 -0
  174. package/components/form-select/index.js +114 -0
  175. package/components/form-select/index.json +9 -0
  176. package/components/form-select/index.wxml +31 -0
  177. package/components/form-select-multiple/index.js +97 -0
  178. package/components/form-select-multiple/index.json +9 -0
  179. package/components/form-select-multiple/index.wxml +29 -0
  180. package/components/form-switch/index.js +43 -0
  181. package/components/form-switch/index.json +9 -0
  182. package/components/form-switch/index.wxml +6 -0
  183. package/components/form-text-area/index.js +95 -0
  184. package/components/form-text-area/index.json +9 -0
  185. package/components/form-text-area/index.wxml +26 -0
  186. package/components/form-time/index.js +72 -0
  187. package/components/form-time/index.json +9 -0
  188. package/components/form-time/index.wxml +6 -0
  189. package/components/form-upload-file/index.js +73 -0
  190. package/components/form-upload-file/index.json +9 -0
  191. package/components/form-upload-file/index.wxml +26 -0
  192. package/components/form-url/index.js +104 -0
  193. package/components/form-url/index.json +9 -0
  194. package/components/form-url/index.wxml +28 -0
  195. package/components/formdetail/index.js +328 -0
  196. package/components/formdetail/index.json +7 -0
  197. package/components/formdetail/index.wxml +7 -0
  198. package/components/formdetail/index.wxss +277 -0
  199. package/components/formdetail/wd-form-detail.wxss +250 -0
  200. package/components/graphicCard/chevron-right.svg +3 -0
  201. package/components/graphicCard/index.js +205 -0
  202. package/components/graphicCard/index.json +7 -0
  203. package/components/graphicCard/index.wxml +27 -0
  204. package/components/graphicCard/index.wxss +165 -0
  205. package/components/grid/_util.wxss +67 -0
  206. package/components/grid/col/index.js +110 -0
  207. package/components/grid/col/index.json +4 -0
  208. package/components/grid/col/index.wxml +3 -0
  209. package/components/grid/index.js +94 -0
  210. package/components/grid/index.json +4 -0
  211. package/components/grid/index.wxml +3 -0
  212. package/components/grid/index.wxss +1206 -0
  213. package/components/grid/row/index.js +78 -0
  214. package/components/grid/row/index.json +4 -0
  215. package/components/grid/row/index.wxml +3 -0
  216. package/components/image/index.js +203 -0
  217. package/components/image/index.json +7 -0
  218. package/components/image/index.wxml +9 -0
  219. package/components/image/index.wxss +49 -0
  220. package/components/listView/arrow-right-line.svg +3 -0
  221. package/components/listView/emptyText.svg +7 -0
  222. package/components/listView/index.js +710 -0
  223. package/components/listView/index.json +7 -0
  224. package/components/listView/index.wxml +82 -0
  225. package/components/listView/index.wxss +290 -0
  226. package/components/listView/more-line.svg +3 -0
  227. package/components/lottery/index.js +303 -0
  228. package/components/lottery/index.json +4 -0
  229. package/components/lottery/index.wxml +41 -0
  230. package/components/lottery/index.wxss +340 -0
  231. package/components/modal/index.js +66 -0
  232. package/components/modal/index.json +9 -0
  233. package/components/modal/index.wxml +18 -0
  234. package/components/modal/index.wxss +56 -0
  235. package/components/navLayout/index.js +123 -0
  236. package/components/navLayout/index.json +8 -0
  237. package/components/navLayout/index.wxml +22 -0
  238. package/components/navLayout/index.wxss +135 -0
  239. package/components/navigationBar/index.js +205 -0
  240. package/components/navigationBar/index.json +5 -0
  241. package/components/navigationBar/index.wxml +83 -0
  242. package/components/navigationBar/index.wxss +205 -0
  243. package/components/qrcode/index.js +155 -0
  244. package/components/qrcode/index.json +5 -0
  245. package/components/qrcode/index.wxml +2 -0
  246. package/components/qrcode/index.wxss +10 -0
  247. package/components/richText/index.js +90 -0
  248. package/components/richText/index.json +7 -0
  249. package/components/richText/index.wxml +3 -0
  250. package/components/richText/index.wxss +70 -0
  251. package/components/richText/mp-html/index.js +2 -0
  252. package/components/richText/mp-html/index.json +6 -0
  253. package/components/richText/mp-html/index.wxml +1 -0
  254. package/components/richText/mp-html/index.wxss +10 -0
  255. package/components/richText/mp-html/node/node.js +178 -0
  256. package/components/richText/mp-html/node/node.json +7 -0
  257. package/components/richText/mp-html/node/node.wxml +60 -0
  258. package/components/richText/mp-html/node/node.wxss +156 -0
  259. package/components/richText/mp-html/parser.js +2 -0
  260. package/components/scrollView/index.js +144 -0
  261. package/components/scrollView/index.json +4 -0
  262. package/components/scrollView/index.wxml +38 -0
  263. package/components/slot/index.js +25 -0
  264. package/components/slot/index.json +4 -0
  265. package/components/slot/index.wxml +3 -0
  266. package/components/status-content/arrow-right.svg +1 -0
  267. package/components/status-content/close.svg +1 -0
  268. package/components/status-content/error.svg +6 -0
  269. package/components/status-content/index.js +51 -0
  270. package/components/status-content/index.json +4 -0
  271. package/components/status-content/index.wxml +28 -0
  272. package/components/status-content/index.wxss +145 -0
  273. package/components/swiper/index.js +65 -0
  274. package/components/swiper/index.json +4 -0
  275. package/components/swiper/index.wxml +3 -0
  276. package/components/tabs/index.js +67 -0
  277. package/components/tabs/index.json +4 -0
  278. package/components/tabs/index.wxml +10 -0
  279. package/components/tabs/index.wxss +61 -0
  280. package/components/text/index.js +40 -0
  281. package/components/text/index.json +4 -0
  282. package/components/text/index.wxml +7 -0
  283. package/components/text/index.wxss +27 -0
  284. package/components/tooltip/index.js +290 -0
  285. package/components/tooltip/index.json +4 -0
  286. package/components/tooltip/index.wxml +18 -0
  287. package/components/tooltip/index.wxss +72 -0
  288. package/components/tooltip/wd-tooltip.wxss +31 -0
  289. package/components/wd-ad/index.js +66 -0
  290. package/components/wd-ad/index.json +5 -0
  291. package/components/wd-ad/index.wxml +3 -0
  292. package/components/wd-ad/index.wxss +3 -0
  293. package/components/wd-audio/index.js +273 -0
  294. package/components/wd-audio/index.json +5 -0
  295. package/components/wd-audio/index.wxml +3 -0
  296. package/components/wd-button/index.js +284 -0
  297. package/components/wd-button/index.json +7 -0
  298. package/components/wd-button/index.wxml +32 -0
  299. package/components/wd-button/index.wxss +2 -0
  300. package/components/wd-button/wd-button.wxss +513 -0
  301. package/components/wd-calendar/arrowright--line.svg +3 -0
  302. package/components/wd-calendar/index.js +157 -0
  303. package/components/wd-calendar/index.json +5 -0
  304. package/components/wd-calendar/index.wxml +36 -0
  305. package/components/wd-calendar/index.wxss +203 -0
  306. package/components/wd-calendar/weeks.js +41 -0
  307. package/components/wd-canvas/index.js +250 -0
  308. package/components/wd-canvas/index.json +5 -0
  309. package/components/wd-canvas/index.wxml +2 -0
  310. package/components/wd-canvas/index.wxss +0 -0
  311. package/components/wd-card/index.js +76 -0
  312. package/components/wd-card/index.json +5 -0
  313. package/components/wd-card/index.wxml +11 -0
  314. package/components/wd-card/index.wxss +6 -0
  315. package/components/wd-card/wd-card.wxss +120 -0
  316. package/components/wd-cascader/index.js +201 -0
  317. package/components/wd-cascader/index.json +12 -0
  318. package/components/wd-cascader/index.wxml +59 -0
  319. package/components/wd-cascader/index.wxss +2 -0
  320. package/components/wd-cascader/utils.js +73 -0
  321. package/components/wd-cascader/wd-cascader.wxss +284 -0
  322. package/components/wd-checkbox-list/index.js +170 -0
  323. package/components/wd-checkbox-list/index.json +7 -0
  324. package/components/wd-checkbox-list/index.wxml +37 -0
  325. package/components/wd-checkbox-list/index.wxss +2 -0
  326. package/components/wd-checkbox-list/wd-checkbox-list.wxss +259 -0
  327. package/components/wd-date/calendar/index.js +111 -0
  328. package/components/wd-date/calendar/index.json +7 -0
  329. package/components/wd-date/calendar/index.wxml +38 -0
  330. package/components/wd-date/date-picker/index.js +101 -0
  331. package/components/wd-date/date-picker/index.json +9 -0
  332. package/components/wd-date/date-picker/index.wxml +41 -0
  333. package/components/wd-date/date-picker/index.wxss +7 -0
  334. package/components/wd-date/index.js +129 -0
  335. package/components/wd-date/index.json +10 -0
  336. package/components/wd-date/index.wxml +36 -0
  337. package/components/wd-date/index.wxss +9 -0
  338. package/components/wd-date/modal/index.js +31 -0
  339. package/components/wd-date/modal/index.json +5 -0
  340. package/components/wd-date/modal/index.wxml +14 -0
  341. package/components/wd-date/modal/index.wxss +3 -0
  342. package/components/wd-date/time-picker/index.js +202 -0
  343. package/components/wd-date/time-picker/index.json +5 -0
  344. package/components/wd-date/time-picker/index.wxml +13 -0
  345. package/components/wd-date/time-picker/index.wxss +9 -0
  346. package/components/wd-date/wd-date.wxss +5 -0
  347. package/components/wd-date/year-month-picker/index.js +128 -0
  348. package/components/wd-date/year-month-picker/index.json +5 -0
  349. package/components/wd-date/year-month-picker/index.wxml +8 -0
  350. package/components/wd-date/year-month-picker/index.wxss +9 -0
  351. package/components/wd-date-range/index.js +172 -0
  352. package/components/wd-date-range/index.json +10 -0
  353. package/components/wd-date-range/index.wxml +41 -0
  354. package/components/wd-date-range/index.wxss +9 -0
  355. package/components/wd-date-range/wd-date-range.wxss +5 -0
  356. package/components/wd-divider/index.js +46 -0
  357. package/components/wd-divider/index.json +5 -0
  358. package/components/wd-divider/index.wxml +1 -0
  359. package/components/wd-divider/index.wxss +2 -0
  360. package/components/wd-divider/wd-divider.wxss +32 -0
  361. package/components/wd-form/form-utils.js +59 -0
  362. package/components/wd-form/index.js +769 -0
  363. package/components/wd-form/index.json +5 -0
  364. package/components/wd-form/index.wxml +15 -0
  365. package/components/wd-form/index.wxss +38 -0
  366. package/components/wd-form/remote-value.js +76 -0
  367. package/components/wd-form/wd-form.wxss +1113 -0
  368. package/components/wd-form-arr/index.js +348 -0
  369. package/components/wd-form-arr/index.json +7 -0
  370. package/components/wd-form-arr/index.wxml +5 -0
  371. package/components/wd-form-arr/index.wxss +2 -0
  372. package/components/wd-form-arr/wd-form-obj.wxss +104 -0
  373. package/components/wd-form-item/index.js +106 -0
  374. package/components/wd-form-item/index.json +7 -0
  375. package/components/wd-form-item/index.wxml +47 -0
  376. package/components/wd-form-item/index.wxss +2 -0
  377. package/components/wd-form-item/wd-form-item.wxss +1113 -0
  378. package/components/wd-form-item-obj/index.js +113 -0
  379. package/components/wd-form-item-obj/index.json +8 -0
  380. package/components/wd-form-item-obj/index.wxml +51 -0
  381. package/components/wd-form-item-obj/index.wxss +2 -0
  382. package/components/wd-form-item-obj/wd-form-item.wxss +1113 -0
  383. package/components/wd-form-item-read-only/index.js +59 -0
  384. package/components/wd-form-item-read-only/index.json +5 -0
  385. package/components/wd-form-item-read-only/index.wxml +10 -0
  386. package/components/wd-form-obj/index.js +305 -0
  387. package/components/wd-form-obj/index.json +7 -0
  388. package/components/wd-form-obj/index.wxml +5 -0
  389. package/components/wd-form-obj/index.wxss +2 -0
  390. package/components/wd-form-obj/wd-form-obj.wxss +104 -0
  391. package/components/wd-icon/index.js +148 -0
  392. package/components/wd-icon/index.json +7 -0
  393. package/components/wd-icon/index.wxml +4 -0
  394. package/components/wd-icon/index.wxss +4 -0
  395. package/components/wd-icon/wd-icon.wxss +154 -0
  396. package/components/wd-image/index.js +244 -0
  397. package/components/wd-image/index.json +7 -0
  398. package/components/wd-image/index.wxml +11 -0
  399. package/components/wd-image/index.wxss +11 -0
  400. package/components/wd-image/wd-image.wxss +86 -0
  401. package/components/wd-input/index.js +62 -0
  402. package/components/wd-input/index.json +7 -0
  403. package/components/wd-input/index.wxml +58 -0
  404. package/components/wd-input/inner-input/index.js +210 -0
  405. package/components/wd-input/inner-input/index.json +9 -0
  406. package/components/wd-input/inner-input/index.wxml +79 -0
  407. package/components/wd-input/inner-input/index.wxss +2 -0
  408. package/components/wd-input/inner-input/wd-input.wxss +1599 -0
  409. package/components/wd-input-email/index.js +63 -0
  410. package/components/wd-input-email/index.json +7 -0
  411. package/components/wd-input-email/index.wxml +56 -0
  412. package/components/wd-input-group/index.js +65 -0
  413. package/components/wd-input-group/index.json +5 -0
  414. package/components/wd-input-group/index.wxml +16 -0
  415. package/components/wd-input-group/index.wxss +2 -0
  416. package/components/wd-input-group/wd-input-group.wxss +105 -0
  417. package/components/wd-input-number/index.js +595 -0
  418. package/components/wd-input-number/index.json +10 -0
  419. package/components/wd-input-number/index.wxml +66 -0
  420. package/components/wd-input-number/index.wxss +8 -0
  421. package/components/wd-input-number/number.js +309 -0
  422. package/components/wd-input-number/wd-input-number.wxss +249 -0
  423. package/components/wd-input-phone/index.js +83 -0
  424. package/components/wd-input-phone/index.json +7 -0
  425. package/components/wd-input-phone/index.wxml +56 -0
  426. package/components/wd-input-url/index.js +63 -0
  427. package/components/wd-input-url/index.json +7 -0
  428. package/components/wd-input-url/index.wxml +56 -0
  429. package/components/wd-input-wrap/index.js +112 -0
  430. package/components/wd-input-wrap/index.json +7 -0
  431. package/components/wd-input-wrap/index.wxml +32 -0
  432. package/components/wd-input-wrap/index.wxss +2 -0
  433. package/components/wd-input-wrap/wd-input-wrap.wxss +229 -0
  434. package/components/wd-layout/index.js +41 -0
  435. package/components/wd-layout/index.json +5 -0
  436. package/components/wd-layout/index.wxml +13 -0
  437. package/components/wd-layout/index.wxss +2 -0
  438. package/components/wd-layout/wd-layout.wxss +84 -0
  439. package/components/wd-location/index.js +57 -0
  440. package/components/wd-location/index.json +10 -0
  441. package/components/wd-location/index.wxml +49 -0
  442. package/components/wd-markdown/index.js +99 -0
  443. package/components/wd-markdown/index.json +7 -0
  444. package/components/wd-markdown/index.wxml +3 -0
  445. package/components/wd-markdown/index.wxss +128 -0
  446. package/components/wd-markdown/utils/highlight.min.js +1 -0
  447. package/components/wd-markdown/utils/hljs_css.min.js +1 -0
  448. package/components/wd-markdown/utils/hljs_javascript.min.js +1 -0
  449. package/components/wd-markdown/utils/markdown-it.min.js +3 -0
  450. package/components/wd-menu-base-layout/index.js +20 -0
  451. package/components/wd-menu-base-layout/index.json +5 -0
  452. package/components/wd-menu-base-layout/index.wxml +3 -0
  453. package/components/wd-menu-horizontal-layout/index.js +20 -0
  454. package/components/wd-menu-horizontal-layout/index.json +5 -0
  455. package/components/wd-menu-horizontal-layout/index.wxml +3 -0
  456. package/components/wd-menu-layout/index.js +73 -0
  457. package/components/wd-menu-layout/index.json +8 -0
  458. package/components/wd-menu-layout/index.wxml +69 -0
  459. package/components/wd-menu-layout/index.wxss +13 -0
  460. package/components/wd-menu-layout/utils/index.js +40 -0
  461. package/components/wd-menu-layout/wd-menu-layout.wxss +647 -0
  462. package/components/wd-menu-list/index.js +256 -0
  463. package/components/wd-menu-list/index.json +7 -0
  464. package/components/wd-menu-list/index.wxml +50 -0
  465. package/components/wd-menu-list/index.wxss +146 -0
  466. package/components/wd-menu-list/wd-menu-list.wxss +636 -0
  467. package/components/wd-menu-nav-layout/index.js +20 -0
  468. package/components/wd-menu-nav-layout/index.json +5 -0
  469. package/components/wd-menu-nav-layout/index.wxml +3 -0
  470. package/components/wd-menu-nav-tab-layout/index.js +20 -0
  471. package/components/wd-menu-nav-tab-layout/index.json +5 -0
  472. package/components/wd-menu-nav-tab-layout/index.wxml +3 -0
  473. package/components/wd-menu-plant-layout/index.js +20 -0
  474. package/components/wd-menu-plant-layout/index.json +5 -0
  475. package/components/wd-menu-plant-layout/index.wxml +3 -0
  476. package/components/wd-menu-tab-layout/index.js +20 -0
  477. package/components/wd-menu-tab-layout/index.json +5 -0
  478. package/components/wd-menu-tab-layout/index.wxml +3 -0
  479. package/components/wd-menu-vertical-layout/index.js +20 -0
  480. package/components/wd-menu-vertical-layout/index.json +5 -0
  481. package/components/wd-menu-vertical-layout/index.wxml +3 -0
  482. package/components/wd-modal/index.js +184 -0
  483. package/components/wd-modal/index.json +5 -0
  484. package/components/wd-modal/index.wxml +16 -0
  485. package/components/wd-modal/index.wxss +2 -0
  486. package/components/wd-modal/wd-modal.wxss +213 -0
  487. package/components/wd-official-account/index.js +28 -0
  488. package/components/wd-official-account/index.json +5 -0
  489. package/components/wd-official-account/index.wxml +1 -0
  490. package/components/wd-official-account/index.wxss +4 -0
  491. package/components/wd-progress/index.js +134 -0
  492. package/components/wd-progress/index.json +7 -0
  493. package/components/wd-progress/index.wxml +32 -0
  494. package/components/wd-progress/index.wxss +2 -0
  495. package/components/wd-progress/wd-progress.wxss +1148 -0
  496. package/components/wd-radio-list/index.js +157 -0
  497. package/components/wd-radio-list/index.json +7 -0
  498. package/components/wd-radio-list/index.wxml +37 -0
  499. package/components/wd-radio-list/index.wxss +2 -0
  500. package/components/wd-radio-list/wd-radio-list.wxss +187 -0
  501. package/components/wd-rating/index.js +359 -0
  502. package/components/wd-rating/index.json +9 -0
  503. package/components/wd-rating/index.wxml +38 -0
  504. package/components/wd-rating/index.wxss +2 -0
  505. package/components/wd-rating/wd-rating.wxss +1138 -0
  506. package/components/wd-region/index.js +38 -0
  507. package/components/wd-region/index.json +10 -0
  508. package/components/wd-region/index.wxml +28 -0
  509. package/components/wd-region/index.wxss +4 -0
  510. package/components/wd-select/index.js +78 -0
  511. package/components/wd-select/index.json +10 -0
  512. package/components/wd-select/index.wxml +52 -0
  513. package/components/wd-select/select.wxss +749 -0
  514. package/components/wd-select-multiple/index.js +74 -0
  515. package/components/wd-select-multiple/index.json +10 -0
  516. package/components/wd-select-multiple/index.wxml +52 -0
  517. package/components/wd-side-tab/index.js +121 -0
  518. package/components/wd-side-tab/index.json +7 -0
  519. package/components/wd-side-tab/index.wxml +7 -0
  520. package/components/wd-side-tab/index.wxss +1 -0
  521. package/components/wd-switch/index.js +67 -0
  522. package/components/wd-switch/index.json +7 -0
  523. package/components/wd-switch/index.wxml +28 -0
  524. package/components/wd-switch/index.wxss +2 -0
  525. package/components/wd-switch/wd-switch.wxss +1234 -0
  526. package/components/wd-tabbar/index.js +196 -0
  527. package/components/wd-tabbar/index.json +7 -0
  528. package/components/wd-tabbar/index.wxml +10 -0
  529. package/components/wd-tabbar/index.wxss +2 -0
  530. package/components/wd-tabbar/wd-tabbar.wxss +96 -0
  531. package/components/wd-tabs/index.js +62 -0
  532. package/components/wd-tabs/index.json +5 -0
  533. package/components/wd-tabs/index.wxml +34 -0
  534. package/components/wd-tabs/index.wxss +8 -0
  535. package/components/wd-tabs/wd-tabs.wxss +278 -0
  536. package/components/wd-tag/index.js +171 -0
  537. package/components/wd-tag/index.json +7 -0
  538. package/components/wd-tag/index.wxml +22 -0
  539. package/components/wd-tag/index.wxss +3 -0
  540. package/components/wd-tag/tag-behavior.js +57 -0
  541. package/components/wd-tag/tag-item/index.js +198 -0
  542. package/components/wd-tag/tag-item/index.json +7 -0
  543. package/components/wd-tag/tag-item/index.wxml +15 -0
  544. package/components/wd-tag/wd-tag.wxss +325 -0
  545. package/components/wd-tag-select/index.js +107 -0
  546. package/components/wd-tag-select/index.json +8 -0
  547. package/components/wd-tag-select/index.wxml +42 -0
  548. package/components/wd-tag-select/index.wxss +4 -0
  549. package/components/wd-tag-select/wd-tag-select.wxss +1275 -0
  550. package/components/wd-text/index.js +162 -0
  551. package/components/wd-text/index.json +5 -0
  552. package/components/wd-text/index.wxml +8 -0
  553. package/components/wd-text/index.wxss +2 -0
  554. package/components/wd-text/wd-text.wxss +261 -0
  555. package/components/wd-textarea/index.js +97 -0
  556. package/components/wd-textarea/index.json +7 -0
  557. package/components/wd-textarea/index.wxml +31 -0
  558. package/components/wd-textarea/index.wxss +7 -0
  559. package/components/wd-textarea/wd-textarea.wxss +98 -0
  560. package/components/wd-time/index.js +124 -0
  561. package/components/wd-time/index.json +11 -0
  562. package/components/wd-time/index.wxml +36 -0
  563. package/components/wd-time/index.wxss +9 -0
  564. package/components/wd-time/wd-time.wxss +5 -0
  565. package/components/wd-top-tab/index.js +121 -0
  566. package/components/wd-top-tab/index.json +7 -0
  567. package/components/wd-top-tab/index.wxml +6 -0
  568. package/components/wd-top-tab/index.wxss +5 -0
  569. package/components/wd-unified-link/index.js +115 -0
  570. package/components/wd-unified-link/index.json +5 -0
  571. package/components/wd-unified-link/index.wxml +3 -0
  572. package/components/wd-unified-link/index.wxss +2 -0
  573. package/components/wd-unified-link/wd-link.wxss +51 -0
  574. package/components/wd-upload-file/index.js +54 -0
  575. package/components/wd-upload-file/index.json +8 -0
  576. package/components/wd-upload-file/index.wxml +41 -0
  577. package/components/wd-upload-image/index.js +64 -0
  578. package/components/wd-upload-image/index.json +8 -0
  579. package/components/wd-upload-image/index.wxml +45 -0
  580. package/components/web-view/index.js +69 -0
  581. package/components/web-view/index.json +5 -0
  582. package/components/web-view/index.wxml +1 -0
  583. package/components/web-view/index.wxss +1 -0
  584. package/components/wedaVideo/index.js +183 -0
  585. package/components/wedaVideo/index.json +4 -0
  586. package/components/wedaVideo/index.wxml +29 -0
  587. package/components/wedaVideo/index.wxss +20 -0
  588. package/components/wxOpenApi/phone/index.js +122 -0
  589. package/components/wxOpenApi/phone/index.json +4 -0
  590. package/components/wxOpenApi/phone/index.wxml +4 -0
  591. package/components/wxOpenApi/phone/index.wxss +26 -0
  592. package/components/wxOpenApi/phoneCode/index.js +102 -0
  593. package/components/wxOpenApi/phoneCode/index.json +4 -0
  594. package/components/wxOpenApi/phoneCode/index.wxml +4 -0
  595. package/components/wxOpenApi/phoneCode/index.wxss +26 -0
  596. package/components/wxOpenApi/share/index.js +134 -0
  597. package/components/wxOpenApi/share/index.json +4 -0
  598. package/components/wxOpenApi/share/index.wxml +4 -0
  599. package/components/wxOpenApi/share/index.wxss +26 -0
  600. package/components/wxOpenApi/userInfo/index.js +97 -0
  601. package/components/wxOpenApi/userInfo/index.json +4 -0
  602. package/components/wxOpenApi/userInfo/index.wxml +4 -0
  603. package/components/wxOpenApi/userInfo/index.wxss +26 -0
  604. package/index.json +133 -0
  605. package/package.json +19 -0
  606. package/style/utils.wxss +167 -0
  607. package/style/wd-design.wxss +628 -0
  608. package/style/wd-font-icon.wxss +4656 -0
  609. package/style/weda-ui.wxss +475 -0
  610. package/style/wedatea2td.wxss +56 -0
  611. package/utils/classnames.js +39 -0
  612. package/utils/color.js +81 -0
  613. package/utils/common-behavior.js +1 -0
  614. package/utils/constant.js +132 -0
  615. package/utils/date.js +51 -0
  616. package/utils/dayjs.min.js +1 -0
  617. package/utils/debounce.js +134 -0
  618. package/utils/deepEqual.js +42 -0
  619. package/utils/destr.js +49 -0
  620. package/utils/dr_square_point.js +29 -0
  621. package/utils/enum.js +1268 -0
  622. package/utils/error.js +26 -0
  623. package/utils/getCustomInfo.js +34 -0
  624. package/utils/getFormLegacy.js +401 -0
  625. package/utils/getModelParams.js +149 -0
  626. package/utils/getWedaApi.js +1 -0
  627. package/utils/handleEvents.js +34 -0
  628. package/utils/lodash.js +65 -0
  629. package/utils/platform.js +162 -0
  630. package/utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js +1323 -0
  631. package/utils/qrcode/weapp.qrcode.min.js +911 -0
  632. package/utils/range.js +82 -0
  633. package/utils/tcb.js +177 -0
  634. package/utils/tool.js +74 -0
  635. package/utils/widget-api.js +28 -0
@@ -0,0 +1,1323 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * 微信小程序JavaScriptSDK
4
+ *
5
+ * @version 1.2
6
+ * @date 2019-03-06
7
+ */
8
+
9
+ var ERROR_CONF = {
10
+ KEY_ERR: 311,
11
+ KEY_ERR_MSG: 'key格式错误',
12
+ PARAM_ERR: 310,
13
+ PARAM_ERR_MSG: '请求参数信息有误',
14
+ SYSTEM_ERR: 600,
15
+ SYSTEM_ERR_MSG: '系统错误',
16
+ WX_ERR_CODE: 1000,
17
+ WX_OK_CODE: 200,
18
+ };
19
+ var BASE_URL = 'https://apis.map.qq.com/ws/';
20
+ var URL_SEARCH = BASE_URL + 'place/v1/search';
21
+ var URL_SUGGESTION = BASE_URL + 'place/v1/suggestion';
22
+ var URL_GET_GEOCODER = BASE_URL + 'geocoder/v1/';
23
+ var URL_CITY_LIST = BASE_URL + 'district/v1/list';
24
+ var URL_AREA_LIST = BASE_URL + 'district/v1/getchildren';
25
+ var URL_DISTANCE = BASE_URL + 'distance/v1/';
26
+ var URL_DIRECTION = BASE_URL + 'direction/v1/';
27
+ var MODE = {
28
+ driving: 'driving',
29
+ transit: 'transit',
30
+ };
31
+ var EARTH_RADIUS = 6378136.49;
32
+ var Utils = {
33
+ /**
34
+ * md5加密方法
35
+ * 版权所有©2011 Sebastian Tschan,https://blueimp.net
36
+ */
37
+ safeAdd(x, y) {
38
+ var lsw = (x & 0xffff) + (y & 0xffff);
39
+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
40
+ return (msw << 16) | (lsw & 0xffff);
41
+ },
42
+ bitRotateLeft(num, cnt) {
43
+ return (num << cnt) | (num >>> (32 - cnt));
44
+ },
45
+ md5cmn(q, a, b, x, s, t) {
46
+ return this.safeAdd(
47
+ this.bitRotateLeft(
48
+ this.safeAdd(this.safeAdd(a, q), this.safeAdd(x, t)),
49
+ s
50
+ ),
51
+ b
52
+ );
53
+ },
54
+ md5ff(a, b, c, d, x, s, t) {
55
+ return this.md5cmn((b & c) | (~b & d), a, b, x, s, t);
56
+ },
57
+ md5gg(a, b, c, d, x, s, t) {
58
+ return this.md5cmn((b & d) | (c & ~d), a, b, x, s, t);
59
+ },
60
+ md5hh(a, b, c, d, x, s, t) {
61
+ return this.md5cmn(b ^ c ^ d, a, b, x, s, t);
62
+ },
63
+ md5ii(a, b, c, d, x, s, t) {
64
+ return this.md5cmn(c ^ (b | ~d), a, b, x, s, t);
65
+ },
66
+ binlMD5(x, len) {
67
+ /* append padding */
68
+ x[len >> 5] |= 0x80 << len % 32;
69
+ x[(((len + 64) >>> 9) << 4) + 14] = len;
70
+
71
+ var i;
72
+ var olda;
73
+ var oldb;
74
+ var oldc;
75
+ var oldd;
76
+ var a = 1732584193;
77
+ var b = -271733879;
78
+ var c = -1732584194;
79
+ var d = 271733878;
80
+
81
+ for (i = 0; i < x.length; i += 16) {
82
+ olda = a;
83
+ oldb = b;
84
+ oldc = c;
85
+ oldd = d;
86
+
87
+ a = this.md5ff(a, b, c, d, x[i], 7, -680876936);
88
+ d = this.md5ff(d, a, b, c, x[i + 1], 12, -389564586);
89
+ c = this.md5ff(c, d, a, b, x[i + 2], 17, 606105819);
90
+ b = this.md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
91
+ a = this.md5ff(a, b, c, d, x[i + 4], 7, -176418897);
92
+ d = this.md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
93
+ c = this.md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
94
+ b = this.md5ff(b, c, d, a, x[i + 7], 22, -45705983);
95
+ a = this.md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
96
+ d = this.md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
97
+ c = this.md5ff(c, d, a, b, x[i + 10], 17, -42063);
98
+ b = this.md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
99
+ a = this.md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
100
+ d = this.md5ff(d, a, b, c, x[i + 13], 12, -40341101);
101
+ c = this.md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
102
+ b = this.md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
103
+
104
+ a = this.md5gg(a, b, c, d, x[i + 1], 5, -165796510);
105
+ d = this.md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
106
+ c = this.md5gg(c, d, a, b, x[i + 11], 14, 643717713);
107
+ b = this.md5gg(b, c, d, a, x[i], 20, -373897302);
108
+ a = this.md5gg(a, b, c, d, x[i + 5], 5, -701558691);
109
+ d = this.md5gg(d, a, b, c, x[i + 10], 9, 38016083);
110
+ c = this.md5gg(c, d, a, b, x[i + 15], 14, -660478335);
111
+ b = this.md5gg(b, c, d, a, x[i + 4], 20, -405537848);
112
+ a = this.md5gg(a, b, c, d, x[i + 9], 5, 568446438);
113
+ d = this.md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
114
+ c = this.md5gg(c, d, a, b, x[i + 3], 14, -187363961);
115
+ b = this.md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
116
+ a = this.md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
117
+ d = this.md5gg(d, a, b, c, x[i + 2], 9, -51403784);
118
+ c = this.md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
119
+ b = this.md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
120
+
121
+ a = this.md5hh(a, b, c, d, x[i + 5], 4, -378558);
122
+ d = this.md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
123
+ c = this.md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
124
+ b = this.md5hh(b, c, d, a, x[i + 14], 23, -35309556);
125
+ a = this.md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
126
+ d = this.md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
127
+ c = this.md5hh(c, d, a, b, x[i + 7], 16, -155497632);
128
+ b = this.md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
129
+ a = this.md5hh(a, b, c, d, x[i + 13], 4, 681279174);
130
+ d = this.md5hh(d, a, b, c, x[i], 11, -358537222);
131
+ c = this.md5hh(c, d, a, b, x[i + 3], 16, -722521979);
132
+ b = this.md5hh(b, c, d, a, x[i + 6], 23, 76029189);
133
+ a = this.md5hh(a, b, c, d, x[i + 9], 4, -640364487);
134
+ d = this.md5hh(d, a, b, c, x[i + 12], 11, -421815835);
135
+ c = this.md5hh(c, d, a, b, x[i + 15], 16, 530742520);
136
+ b = this.md5hh(b, c, d, a, x[i + 2], 23, -995338651);
137
+
138
+ a = this.md5ii(a, b, c, d, x[i], 6, -198630844);
139
+ d = this.md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
140
+ c = this.md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
141
+ b = this.md5ii(b, c, d, a, x[i + 5], 21, -57434055);
142
+ a = this.md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
143
+ d = this.md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
144
+ c = this.md5ii(c, d, a, b, x[i + 10], 15, -1051523);
145
+ b = this.md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
146
+ a = this.md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
147
+ d = this.md5ii(d, a, b, c, x[i + 15], 10, -30611744);
148
+ c = this.md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
149
+ b = this.md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
150
+ a = this.md5ii(a, b, c, d, x[i + 4], 6, -145523070);
151
+ d = this.md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
152
+ c = this.md5ii(c, d, a, b, x[i + 2], 15, 718787259);
153
+ b = this.md5ii(b, c, d, a, x[i + 9], 21, -343485551);
154
+
155
+ a = this.safeAdd(a, olda);
156
+ b = this.safeAdd(b, oldb);
157
+ c = this.safeAdd(c, oldc);
158
+ d = this.safeAdd(d, oldd);
159
+ }
160
+ return [a, b, c, d];
161
+ },
162
+ binl2rstr(input) {
163
+ var i;
164
+ var output = '';
165
+ var length32 = input.length * 32;
166
+ for (i = 0; i < length32; i += 8) {
167
+ output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff);
168
+ }
169
+ return output;
170
+ },
171
+ rstr2binl(input) {
172
+ var i;
173
+ var output = [];
174
+ output[(input.length >> 2) - 1] = undefined;
175
+ for (i = 0; i < output.length; i += 1) {
176
+ output[i] = 0;
177
+ }
178
+ var length8 = input.length * 8;
179
+ for (i = 0; i < length8; i += 8) {
180
+ output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32;
181
+ }
182
+ return output;
183
+ },
184
+ rstrMD5(s) {
185
+ return this.binl2rstr(this.binlMD5(this.rstr2binl(s), s.length * 8));
186
+ },
187
+ rstrHMACMD5(key, data) {
188
+ var i;
189
+ var bkey = this.rstr2binl(key);
190
+ var ipad = [];
191
+ var opad = [];
192
+ var hash;
193
+ ipad[15] = opad[15] = undefined;
194
+ if (bkey.length > 16) {
195
+ bkey = this.binlMD5(bkey, key.length * 8);
196
+ }
197
+ for (i = 0; i < 16; i += 1) {
198
+ ipad[i] = bkey[i] ^ 0x36363636;
199
+ opad[i] = bkey[i] ^ 0x5c5c5c5c;
200
+ }
201
+ hash = this.binlMD5(
202
+ ipad.concat(this.rstr2binl(data)),
203
+ 512 + data.length * 8
204
+ );
205
+ return this.binl2rstr(this.binlMD5(opad.concat(hash), 512 + 128));
206
+ },
207
+ rstr2hex(input) {
208
+ var hexTab = '0123456789abcdef';
209
+ var output = '';
210
+ var x;
211
+ var i;
212
+ for (i = 0; i < input.length; i += 1) {
213
+ x = input.charCodeAt(i);
214
+ output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f);
215
+ }
216
+ return output;
217
+ },
218
+ str2rstrUTF8(input) {
219
+ return unescape(encodeURIComponent(input));
220
+ },
221
+ rawMD5(s) {
222
+ return this.rstrMD5(this.str2rstrUTF8(s));
223
+ },
224
+ hexMD5(s) {
225
+ return this.rstr2hex(this.rawMD5(s));
226
+ },
227
+ rawHMACMD5(k, d) {
228
+ // eslint-disable-next-line no-undef
229
+ return this.rstrHMACMD5(this.str2rstrUTF8(k), str2rstrUTF8(d));
230
+ },
231
+ hexHMACMD5(k, d) {
232
+ return this.rstr2hex(this.rawHMACMD5(k, d));
233
+ },
234
+
235
+ md5(string, key, raw) {
236
+ if (!key) {
237
+ if (!raw) {
238
+ return this.hexMD5(string);
239
+ }
240
+ return this.rawMD5(string);
241
+ }
242
+ if (!raw) {
243
+ return this.hexHMACMD5(key, string);
244
+ }
245
+ return this.rawHMACMD5(key, string);
246
+ },
247
+ /**
248
+ * 得到md5加密后的sig参数
249
+ * @param {Object} requestParam 接口参数
250
+ * @param {String} sk签名字符串
251
+ * @param {String} featrue 方法名
252
+ * @return 返回加密后的sig参数
253
+ */
254
+ getSig(requestParam, sk, feature, mode) {
255
+ var sig = null;
256
+ var requestArr = [];
257
+ Object.keys(requestParam)
258
+ .sort()
259
+ .forEach(function (key) {
260
+ requestArr.push(key + '=' + requestParam[key]);
261
+ });
262
+ if (feature == 'search') {
263
+ sig = '/ws/place/v1/search?' + requestArr.join('&') + sk;
264
+ }
265
+ if (feature == 'suggest') {
266
+ sig = '/ws/place/v1/suggestion?' + requestArr.join('&') + sk;
267
+ }
268
+ if (feature == 'reverseGeocoder') {
269
+ sig = '/ws/geocoder/v1/?' + requestArr.join('&') + sk;
270
+ }
271
+ if (feature == 'geocoder') {
272
+ sig = '/ws/geocoder/v1/?' + requestArr.join('&') + sk;
273
+ }
274
+ if (feature == 'getCityList') {
275
+ sig = '/ws/district/v1/list?' + requestArr.join('&') + sk;
276
+ }
277
+ if (feature == 'getDistrictByCityId') {
278
+ sig = '/ws/district/v1/getchildren?' + requestArr.join('&') + sk;
279
+ }
280
+ if (feature == 'calculateDistance') {
281
+ sig = '/ws/distance/v1/?' + requestArr.join('&') + sk;
282
+ }
283
+ if (feature == 'direction') {
284
+ sig = '/ws/direction/v1/' + mode + '?' + requestArr.join('&') + sk;
285
+ }
286
+ sig = this.md5(sig);
287
+ return sig;
288
+ },
289
+ /**
290
+ * 得到终点query字符串
291
+ * @param {Array|String} 检索数据
292
+ */
293
+ location2query(data) {
294
+ if (typeof data == 'string') {
295
+ return data;
296
+ }
297
+ var query = '';
298
+ for (var i = 0; i < data.length; i++) {
299
+ var d = data[i];
300
+ if (query) {
301
+ query += ';';
302
+ }
303
+ if (d.location) {
304
+ query = query + d.location.lat + ',' + d.location.lng;
305
+ }
306
+ if (d.latitude && d.longitude) {
307
+ query = query + d.latitude + ',' + d.longitude;
308
+ }
309
+ }
310
+ return query;
311
+ },
312
+
313
+ /**
314
+ * 计算角度
315
+ */
316
+ rad(d) {
317
+ return (d * Math.PI) / 180.0;
318
+ },
319
+ /**
320
+ * 处理终点location数组
321
+ * @return 返回终点数组
322
+ */
323
+ getEndLocation(location) {
324
+ var to = location.split(';');
325
+ var endLocation = [];
326
+ for (var i = 0; i < to.length; i++) {
327
+ endLocation.push({
328
+ lat: parseFloat(to[i].split(',')[0]),
329
+ lng: parseFloat(to[i].split(',')[1]),
330
+ });
331
+ }
332
+ return endLocation;
333
+ },
334
+
335
+ /**
336
+ * 计算两点间直线距离
337
+ * @param a 表示纬度差
338
+ * @param b 表示经度差
339
+ * @return 返回的是距离,单位m
340
+ */
341
+ getDistance(latFrom, lngFrom, latTo, lngTo) {
342
+ var radLatFrom = this.rad(latFrom);
343
+ var radLatTo = this.rad(latTo);
344
+ var a = radLatFrom - radLatTo;
345
+ var b = this.rad(lngFrom) - this.rad(lngTo);
346
+ var distance =
347
+ 2 *
348
+ Math.asin(
349
+ Math.sqrt(
350
+ Math.pow(Math.sin(a / 2), 2) +
351
+ Math.cos(radLatFrom) *
352
+ Math.cos(radLatTo) *
353
+ Math.pow(Math.sin(b / 2), 2)
354
+ )
355
+ );
356
+ distance = distance * EARTH_RADIUS;
357
+ distance = Math.round(distance * 10000) / 10000;
358
+ return parseFloat(distance.toFixed(0));
359
+ },
360
+ /**
361
+ * 使用微信接口进行定位
362
+ */
363
+ getWXLocation(success, fail, complete) {
364
+ wx.getLocation({
365
+ type: 'gcj02',
366
+ success: success,
367
+ fail: fail,
368
+ complete: complete,
369
+ });
370
+ },
371
+
372
+ /**
373
+ * 获取location参数
374
+ */
375
+ getLocationParam(location) {
376
+ if (typeof location == 'string') {
377
+ var locationArr = location.split(',');
378
+ if (locationArr.length === 2) {
379
+ location = {
380
+ latitude: location.split(',')[0],
381
+ longitude: location.split(',')[1],
382
+ };
383
+ } else {
384
+ location = {};
385
+ }
386
+ }
387
+ return location;
388
+ },
389
+
390
+ /**
391
+ * 回调函数默认处理
392
+ */
393
+ polyfillParam(param) {
394
+ param.success = param.success || function () {};
395
+ param.fail = param.fail || function () {};
396
+ param.complete = param.complete || function () {};
397
+ },
398
+
399
+ /**
400
+ * 验证param对应的key值是否为空
401
+ *
402
+ * @param {Object} param 接口参数
403
+ * @param {String} key 对应参数的key
404
+ */
405
+ checkParamKeyEmpty(param, key) {
406
+ if (!param[key]) {
407
+ var errconf = this.buildErrorConfig(
408
+ ERROR_CONF.PARAM_ERR,
409
+ ERROR_CONF.PARAM_ERR_MSG + key + '参数格式有误'
410
+ );
411
+ param.fail(errconf);
412
+ param.complete(errconf);
413
+ return true;
414
+ }
415
+ return false;
416
+ },
417
+
418
+ /**
419
+ * 验证参数中是否存在检索词keyword
420
+ *
421
+ * @param {Object} param 接口参数
422
+ */
423
+ checkKeyword(param) {
424
+ return !this.checkParamKeyEmpty(param, 'keyword');
425
+ },
426
+
427
+ /**
428
+ * 验证location值
429
+ *
430
+ * @param {Object} param 接口参数
431
+ */
432
+ checkLocation(param) {
433
+ var location = this.getLocationParam(param.location);
434
+ if (!location || !location.latitude || !location.longitude) {
435
+ var errconf = this.buildErrorConfig(
436
+ ERROR_CONF.PARAM_ERR,
437
+ ERROR_CONF.PARAM_ERR_MSG + ' location参数格式有误'
438
+ );
439
+ param.fail(errconf);
440
+ param.complete(errconf);
441
+ return false;
442
+ }
443
+ return true;
444
+ },
445
+
446
+ /**
447
+ * 构造错误数据结构
448
+ * @param {Number} errCode 错误码
449
+ * @param {Number} errMsg 错误描述
450
+ */
451
+ buildErrorConfig(errCode, errMsg) {
452
+ return {
453
+ status: errCode,
454
+ message: errMsg,
455
+ };
456
+ },
457
+
458
+ /**
459
+ *
460
+ * 数据处理函数
461
+ * 根据传入参数不同处理不同数据
462
+ * @param {String} feature 功能名称
463
+ * search 地点搜索
464
+ * suggest关键词提示
465
+ * reverseGeocoder逆地址解析
466
+ * geocoder地址解析
467
+ * getCityList获取城市列表:父集
468
+ * getDistrictByCityId获取区县列表:子集
469
+ * calculateDistance距离计算
470
+ * @param {Object} param 接口参数
471
+ * @param {Object} data 数据
472
+ */
473
+ handleData(param, data, feature) {
474
+ if (feature == 'search') {
475
+ var searchResult = data.data;
476
+ var searchSimplify = [];
477
+ for (var i = 0; i < searchResult.length; i++) {
478
+ searchSimplify.push({
479
+ id: searchResult[i].id || null,
480
+ title: searchResult[i].title || null,
481
+ latitude:
482
+ (searchResult[i].location && searchResult[i].location.lat) || null,
483
+ longitude:
484
+ (searchResult[i].location && searchResult[i].location.lng) || null,
485
+ address: searchResult[i].address || null,
486
+ category: searchResult[i].category || null,
487
+ tel: searchResult[i].tel || null,
488
+ adcode:
489
+ (searchResult[i].ad_info && searchResult[i].ad_info.adcode) || null,
490
+ city:
491
+ (searchResult[i].ad_info && searchResult[i].ad_info.city) || null,
492
+ district:
493
+ (searchResult[i].ad_info && searchResult[i].ad_info.district) ||
494
+ null,
495
+ province:
496
+ (searchResult[i].ad_info && searchResult[i].ad_info.province) ||
497
+ null,
498
+ });
499
+ }
500
+ param.success(data, {
501
+ searchResult: searchResult,
502
+ searchSimplify: searchSimplify,
503
+ });
504
+ } else if (feature == 'suggest') {
505
+ var suggestResult = data.data;
506
+ var suggestSimplify = [];
507
+ // eslint-disable-next-line no-redeclare
508
+ for (var i = 0; i < suggestResult.length; i++) {
509
+ suggestSimplify.push({
510
+ adcode: suggestResult[i].adcode || null,
511
+ address: suggestResult[i].address || null,
512
+ category: suggestResult[i].category || null,
513
+ city: suggestResult[i].city || null,
514
+ district: suggestResult[i].district || null,
515
+ id: suggestResult[i].id || null,
516
+ latitude:
517
+ (suggestResult[i].location && suggestResult[i].location.lat) ||
518
+ null,
519
+ longitude:
520
+ (suggestResult[i].location && suggestResult[i].location.lng) ||
521
+ null,
522
+ province: suggestResult[i].province || null,
523
+ title: suggestResult[i].title || null,
524
+ type: suggestResult[i].type || null,
525
+ });
526
+ }
527
+ param.success(data, {
528
+ suggestResult: suggestResult,
529
+ suggestSimplify: suggestSimplify,
530
+ });
531
+ } else if (feature == 'reverseGeocoder') {
532
+ var reverseGeocoderResult = data.result;
533
+ var reverseGeocoderSimplify = {
534
+ address: reverseGeocoderResult.address || null,
535
+ latitude:
536
+ (reverseGeocoderResult.location &&
537
+ reverseGeocoderResult.location.lat) ||
538
+ null,
539
+ longitude:
540
+ (reverseGeocoderResult.location &&
541
+ reverseGeocoderResult.location.lng) ||
542
+ null,
543
+ adcode:
544
+ (reverseGeocoderResult.ad_info &&
545
+ reverseGeocoderResult.ad_info.adcode) ||
546
+ null,
547
+ city:
548
+ (reverseGeocoderResult.address_component &&
549
+ reverseGeocoderResult.address_component.city) ||
550
+ null,
551
+ district:
552
+ (reverseGeocoderResult.address_component &&
553
+ reverseGeocoderResult.address_component.district) ||
554
+ null,
555
+ nation:
556
+ (reverseGeocoderResult.address_component &&
557
+ reverseGeocoderResult.address_component.nation) ||
558
+ null,
559
+ province:
560
+ (reverseGeocoderResult.address_component &&
561
+ reverseGeocoderResult.address_component.province) ||
562
+ null,
563
+ street:
564
+ (reverseGeocoderResult.address_component &&
565
+ reverseGeocoderResult.address_component.street) ||
566
+ null,
567
+ street_number:
568
+ (reverseGeocoderResult.address_component &&
569
+ reverseGeocoderResult.address_component.street_number) ||
570
+ null,
571
+ recommend:
572
+ (reverseGeocoderResult.formatted_addresses &&
573
+ reverseGeocoderResult.formatted_addresses.recommend) ||
574
+ null,
575
+ rough:
576
+ (reverseGeocoderResult.formatted_addresses &&
577
+ reverseGeocoderResult.formatted_addresses.rough) ||
578
+ null,
579
+ };
580
+ if (reverseGeocoderResult.pois) {
581
+ //判断是否返回周边poi
582
+ var pois = reverseGeocoderResult.pois;
583
+ var poisSimplify = [];
584
+ // eslint-disable-next-line no-redeclare
585
+ for (var i = 0; i < pois.length; i++) {
586
+ poisSimplify.push({
587
+ id: pois[i].id || null,
588
+ title: pois[i].title || null,
589
+ latitude: (pois[i].location && pois[i].location.lat) || null,
590
+ longitude: (pois[i].location && pois[i].location.lng) || null,
591
+ address: pois[i].address || null,
592
+ category: pois[i].category || null,
593
+ adcode: (pois[i].ad_info && pois[i].ad_info.adcode) || null,
594
+ city: (pois[i].ad_info && pois[i].ad_info.city) || null,
595
+ district: (pois[i].ad_info && pois[i].ad_info.district) || null,
596
+ province: (pois[i].ad_info && pois[i].ad_info.province) || null,
597
+ });
598
+ }
599
+ param.success(data, {
600
+ reverseGeocoderResult: reverseGeocoderResult,
601
+ reverseGeocoderSimplify: reverseGeocoderSimplify,
602
+ pois: pois,
603
+ poisSimplify: poisSimplify,
604
+ });
605
+ } else {
606
+ param.success(data, {
607
+ reverseGeocoderResult: reverseGeocoderResult,
608
+ reverseGeocoderSimplify: reverseGeocoderSimplify,
609
+ });
610
+ }
611
+ } else if (feature == 'geocoder') {
612
+ var geocoderResult = data.result;
613
+ var geocoderSimplify = {
614
+ title: geocoderResult.title || null,
615
+ latitude:
616
+ (geocoderResult.location && geocoderResult.location.lat) || null,
617
+ longitude:
618
+ (geocoderResult.location && geocoderResult.location.lng) || null,
619
+ adcode:
620
+ (geocoderResult.ad_info && geocoderResult.ad_info.adcode) || null,
621
+ province:
622
+ (geocoderResult.address_components &&
623
+ geocoderResult.address_components.province) ||
624
+ null,
625
+ city:
626
+ (geocoderResult.address_components &&
627
+ geocoderResult.address_components.city) ||
628
+ null,
629
+ district:
630
+ (geocoderResult.address_components &&
631
+ geocoderResult.address_components.district) ||
632
+ null,
633
+ street:
634
+ (geocoderResult.address_components &&
635
+ geocoderResult.address_components.street) ||
636
+ null,
637
+ street_number:
638
+ (geocoderResult.address_components &&
639
+ geocoderResult.address_components.street_number) ||
640
+ null,
641
+ level: geocoderResult.level || null,
642
+ };
643
+ param.success(data, {
644
+ geocoderResult: geocoderResult,
645
+ geocoderSimplify: geocoderSimplify,
646
+ });
647
+ } else if (feature == 'getCityList') {
648
+ var provinceResult = data.result[0];
649
+ var cityResult = data.result[1];
650
+ var districtResult = data.result[2];
651
+ param.success(data, {
652
+ provinceResult: provinceResult,
653
+ cityResult: cityResult,
654
+ districtResult: districtResult,
655
+ });
656
+ } else if (feature == 'getDistrictByCityId') {
657
+ var districtByCity = data.result[0];
658
+ param.success(data, districtByCity);
659
+ } else if (feature == 'calculateDistance') {
660
+ var calculateDistanceResult = data.result.elements;
661
+ var distance = [];
662
+ // eslint-disable-next-line no-redeclare
663
+ for (var i = 0; i < calculateDistanceResult.length; i++) {
664
+ distance.push(calculateDistanceResult[i].distance);
665
+ }
666
+ param.success(data, {
667
+ calculateDistanceResult: calculateDistanceResult,
668
+ distance: distance,
669
+ });
670
+ } else if (feature == 'direction') {
671
+ var direction = data.result.routes;
672
+ param.success(data, direction);
673
+ } else {
674
+ param.success(data);
675
+ }
676
+ },
677
+
678
+ /**
679
+ * 构造微信请求参数,公共属性处理
680
+ *
681
+ * @param {Object} param 接口参数
682
+ * @param {Object} param 配置项
683
+ * @param {String} feature 方法名
684
+ */
685
+ buildWxRequestConfig(param, options, feature) {
686
+ var that = this;
687
+ options.header = { 'content-type': 'application/json' };
688
+ options.method = 'GET';
689
+ options.success = function (res) {
690
+ var data = res.data;
691
+ if (data.status === 0) {
692
+ that.handleData(param, data, feature);
693
+ } else {
694
+ param.fail(data);
695
+ }
696
+ };
697
+ options.fail = function (res) {
698
+ res.statusCode = ERROR_CONF.WX_ERR_CODE;
699
+ param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg));
700
+ };
701
+ options.complete = function (res) {
702
+ var statusCode = +res.statusCode;
703
+ switch (statusCode) {
704
+ case ERROR_CONF.WX_ERR_CODE: {
705
+ param.complete(
706
+ that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)
707
+ );
708
+ break;
709
+ }
710
+ case ERROR_CONF.WX_OK_CODE: {
711
+ var data = res.data;
712
+ if (data.status === 0) {
713
+ param.complete(data);
714
+ } else {
715
+ param.complete(that.buildErrorConfig(data.status, data.message));
716
+ }
717
+ break;
718
+ }
719
+ default: {
720
+ param.complete(
721
+ that.buildErrorConfig(
722
+ ERROR_CONF.SYSTEM_ERR,
723
+ ERROR_CONF.SYSTEM_ERR_MSG
724
+ )
725
+ );
726
+ }
727
+ }
728
+ };
729
+ return options;
730
+ },
731
+
732
+ /**
733
+ * 处理用户参数是否传入坐标进行不同的处理
734
+ */
735
+ locationProcess(param, locationsuccess, locationfail, locationcomplete) {
736
+ var that = this;
737
+ locationfail =
738
+ locationfail ||
739
+ function (res) {
740
+ res.statusCode = ERROR_CONF.WX_ERR_CODE;
741
+ param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg));
742
+ };
743
+ locationcomplete =
744
+ locationcomplete ||
745
+ function (res) {
746
+ if (res.statusCode == ERROR_CONF.WX_ERR_CODE) {
747
+ param.complete(
748
+ that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)
749
+ );
750
+ }
751
+ };
752
+ if (!param.location) {
753
+ that.getWXLocation(locationsuccess, locationfail, locationcomplete);
754
+ } else if (that.checkLocation(param)) {
755
+ var location = Utils.getLocationParam(param.location);
756
+ locationsuccess(location);
757
+ }
758
+ },
759
+ };
760
+
761
+ class QQMapWX {
762
+ /**
763
+ * 构造函数
764
+ *
765
+ * @param {Object} options 接口参数,key 为必选参数
766
+ */
767
+ constructor(options) {
768
+ if (!options.key) {
769
+ throw Error('key值不能为空');
770
+ }
771
+ this.key = options.key;
772
+ }
773
+
774
+ /**
775
+ * POI周边检索
776
+ *
777
+ * @param {Object} options 接口参数对象
778
+ *
779
+ * 参数对象结构可以参考
780
+ * @see http://lbs.qq.com/webservice_v1/guide-search.html
781
+ */
782
+ search(options) {
783
+ var that = this;
784
+ options = options || {};
785
+
786
+ Utils.polyfillParam(options);
787
+
788
+ if (!Utils.checkKeyword(options)) {
789
+ return;
790
+ }
791
+
792
+ var requestParam = {
793
+ keyword: options.keyword,
794
+ orderby: options.orderby || '_distance',
795
+ page_size: options.page_size || 10,
796
+ page_index: options.page_index || 1,
797
+ output: 'json',
798
+ key: that.key,
799
+ };
800
+
801
+ if (options.address_format) {
802
+ requestParam.address_format = options.address_format;
803
+ }
804
+
805
+ if (options.filter) {
806
+ requestParam.filter = options.filter;
807
+ }
808
+
809
+ var distance = options.distance || '1000';
810
+ var auto_extend = options.auto_extend || 1;
811
+ var region = null;
812
+ var rectangle = null;
813
+
814
+ //判断城市限定参数
815
+ if (options.region) {
816
+ region = options.region;
817
+ }
818
+
819
+ //矩形限定坐标(暂时只支持字符串格式)
820
+ if (options.rectangle) {
821
+ rectangle = options.rectangle;
822
+ }
823
+
824
+ var locationsuccess = function (result) {
825
+ if (region && !rectangle) {
826
+ //城市限定参数拼接
827
+ requestParam.boundary =
828
+ 'region(' +
829
+ region +
830
+ ',' +
831
+ auto_extend +
832
+ ',' +
833
+ result.latitude +
834
+ ',' +
835
+ result.longitude +
836
+ ')';
837
+ if (options.sig) {
838
+ requestParam.sig = Utils.getSig(requestParam, options.sig, 'search');
839
+ }
840
+ } else if (rectangle && !region) {
841
+ //矩形搜索
842
+ requestParam.boundary = 'rectangle(' + rectangle + ')';
843
+ if (options.sig) {
844
+ requestParam.sig = Utils.getSig(requestParam, options.sig, 'search');
845
+ }
846
+ } else {
847
+ requestParam.boundary =
848
+ 'nearby(' +
849
+ result.latitude +
850
+ ',' +
851
+ result.longitude +
852
+ ',' +
853
+ distance +
854
+ ',' +
855
+ auto_extend +
856
+ ')';
857
+ if (options.sig) {
858
+ requestParam.sig = Utils.getSig(requestParam, options.sig, 'search');
859
+ }
860
+ }
861
+ wx.request(
862
+ Utils.buildWxRequestConfig(
863
+ options,
864
+ {
865
+ url: URL_SEARCH,
866
+ data: requestParam,
867
+ },
868
+ 'search'
869
+ )
870
+ );
871
+ };
872
+ Utils.locationProcess(options, locationsuccess);
873
+ }
874
+
875
+ /**
876
+ * sug模糊检索
877
+ *
878
+ * @param {Object} options 接口参数对象
879
+ *
880
+ * 参数对象结构可以参考
881
+ * http://lbs.qq.com/webservice_v1/guide-suggestion.html
882
+ */
883
+ getSuggestion(options) {
884
+ var that = this;
885
+ options = options || {};
886
+ Utils.polyfillParam(options);
887
+
888
+ if (!Utils.checkKeyword(options)) {
889
+ return;
890
+ }
891
+
892
+ var requestParam = {
893
+ keyword: options.keyword,
894
+ region: options.region || '全国',
895
+ region_fix: options.region_fix || 0,
896
+ policy: options.policy || 0,
897
+ page_size: options.page_size || 10, //控制显示条数
898
+ page_index: options.page_index || 1, //控制页数
899
+ get_subpois: options.get_subpois || 0, //返回子地点
900
+ output: 'json',
901
+ key: that.key,
902
+ };
903
+ //长地址
904
+ if (options.address_format) {
905
+ requestParam.address_format = options.address_format;
906
+ }
907
+ //过滤
908
+ if (options.filter) {
909
+ requestParam.filter = options.filter;
910
+ }
911
+ //排序
912
+ if (options.location) {
913
+ var locationsuccess = function (result) {
914
+ requestParam.location = result.latitude + ',' + result.longitude;
915
+ if (options.sig) {
916
+ requestParam.sig = Utils.getSig(requestParam, options.sig, 'suggest');
917
+ }
918
+ wx.request(
919
+ Utils.buildWxRequestConfig(
920
+ options,
921
+ {
922
+ url: URL_SUGGESTION,
923
+ data: requestParam,
924
+ },
925
+ 'suggest'
926
+ )
927
+ );
928
+ };
929
+ Utils.locationProcess(options, locationsuccess);
930
+ } else {
931
+ if (options.sig) {
932
+ requestParam.sig = Utils.getSig(requestParam, options.sig, 'suggest');
933
+ }
934
+ wx.request(
935
+ Utils.buildWxRequestConfig(
936
+ options,
937
+ {
938
+ url: URL_SUGGESTION,
939
+ data: requestParam,
940
+ },
941
+ 'suggest'
942
+ )
943
+ );
944
+ }
945
+ }
946
+
947
+ /**
948
+ * 逆地址解析
949
+ *
950
+ * @param {Object} options 接口参数对象
951
+ *
952
+ * 请求参数结构可以参考
953
+ * http://lbs.qq.com/webservice_v1/guide-gcoder.html
954
+ */
955
+ reverseGeocoder(options) {
956
+ var that = this;
957
+ options = options || {};
958
+ Utils.polyfillParam(options);
959
+ var requestParam = {
960
+ coord_type: options.coord_type || 5,
961
+ get_poi: options.get_poi || 0,
962
+ output: 'json',
963
+ key: that.key,
964
+ };
965
+ if (options.poi_options) {
966
+ requestParam.poi_options = options.poi_options;
967
+ }
968
+
969
+ var locationsuccess = function (result) {
970
+ requestParam.location = result.latitude + ',' + result.longitude;
971
+ if (options.sig) {
972
+ requestParam.sig = Utils.getSig(
973
+ requestParam,
974
+ options.sig,
975
+ 'reverseGeocoder'
976
+ );
977
+ }
978
+ wx.request(
979
+ Utils.buildWxRequestConfig(
980
+ options,
981
+ {
982
+ url: URL_GET_GEOCODER,
983
+ data: requestParam,
984
+ },
985
+ 'reverseGeocoder'
986
+ )
987
+ );
988
+ };
989
+ Utils.locationProcess(options, locationsuccess);
990
+ }
991
+
992
+ /**
993
+ * 地址解析
994
+ *
995
+ * @param {Object} options 接口参数对象
996
+ *
997
+ * 请求参数结构可以参考
998
+ * http://lbs.qq.com/webservice_v1/guide-geocoder.html
999
+ */
1000
+ geocoder(options) {
1001
+ var that = this;
1002
+ options = options || {};
1003
+ Utils.polyfillParam(options);
1004
+
1005
+ if (Utils.checkParamKeyEmpty(options, 'address')) {
1006
+ return;
1007
+ }
1008
+
1009
+ var requestParam = {
1010
+ address: options.address,
1011
+ output: 'json',
1012
+ key: that.key,
1013
+ };
1014
+
1015
+ //城市限定
1016
+ if (options.region) {
1017
+ requestParam.region = options.region;
1018
+ }
1019
+
1020
+ if (options.sig) {
1021
+ requestParam.sig = Utils.getSig(requestParam, options.sig, 'geocoder');
1022
+ }
1023
+
1024
+ wx.request(
1025
+ Utils.buildWxRequestConfig(
1026
+ options,
1027
+ {
1028
+ url: URL_GET_GEOCODER,
1029
+ data: requestParam,
1030
+ },
1031
+ 'geocoder'
1032
+ )
1033
+ );
1034
+ }
1035
+
1036
+ /**
1037
+ * 获取城市列表
1038
+ *
1039
+ * @param {Object} options 接口参数对象
1040
+ *
1041
+ * 请求参数结构可以参考
1042
+ * http://lbs.qq.com/webservice_v1/guide-region.html
1043
+ */
1044
+ getCityList(options) {
1045
+ var that = this;
1046
+ options = options || {};
1047
+ Utils.polyfillParam(options);
1048
+ var requestParam = {
1049
+ output: 'json',
1050
+ key: that.key,
1051
+ };
1052
+
1053
+ if (options.sig) {
1054
+ requestParam.sig = Utils.getSig(requestParam, options.sig, 'getCityList');
1055
+ }
1056
+
1057
+ wx.request(
1058
+ Utils.buildWxRequestConfig(
1059
+ options,
1060
+ {
1061
+ url: URL_CITY_LIST,
1062
+ data: requestParam,
1063
+ },
1064
+ 'getCityList'
1065
+ )
1066
+ );
1067
+ }
1068
+
1069
+ /**
1070
+ * 获取对应城市ID的区县列表
1071
+ *
1072
+ * @param {Object} options 接口参数对象
1073
+ *
1074
+ * 请求参数结构可以参考
1075
+ * http://lbs.qq.com/webservice_v1/guide-region.html
1076
+ */
1077
+ getDistrictByCityId(options) {
1078
+ var that = this;
1079
+ options = options || {};
1080
+ Utils.polyfillParam(options);
1081
+
1082
+ if (Utils.checkParamKeyEmpty(options, 'id')) {
1083
+ return;
1084
+ }
1085
+
1086
+ var requestParam = {
1087
+ id: options.id || '',
1088
+ output: 'json',
1089
+ key: that.key,
1090
+ };
1091
+
1092
+ if (options.sig) {
1093
+ requestParam.sig = Utils.getSig(
1094
+ requestParam,
1095
+ options.sig,
1096
+ 'getDistrictByCityId'
1097
+ );
1098
+ }
1099
+
1100
+ wx.request(
1101
+ Utils.buildWxRequestConfig(
1102
+ options,
1103
+ {
1104
+ url: URL_AREA_LIST,
1105
+ data: requestParam,
1106
+ },
1107
+ 'getDistrictByCityId'
1108
+ )
1109
+ );
1110
+ }
1111
+
1112
+ /**
1113
+ * 用于单起点到多终点的路线距离(非直线距离)计算:
1114
+ * 支持两种距离计算方式:步行和驾车。
1115
+ * 起点到终点最大限制直线距离10公里。
1116
+ *
1117
+ * 新增直线距离计算。
1118
+ *
1119
+ * @param {Object} options 接口参数对象
1120
+ *
1121
+ * 请求参数结构可以参考
1122
+ * http://lbs.qq.com/webservice_v1/guide-distance.html
1123
+ */
1124
+ calculateDistance(options) {
1125
+ var that = this;
1126
+ options = options || {};
1127
+ Utils.polyfillParam(options);
1128
+
1129
+ if (Utils.checkParamKeyEmpty(options, 'to')) {
1130
+ return;
1131
+ }
1132
+
1133
+ var requestParam = {
1134
+ mode: options.mode || 'walking',
1135
+ to: Utils.location2query(options.to),
1136
+ output: 'json',
1137
+ key: that.key,
1138
+ };
1139
+
1140
+ if (options.from) {
1141
+ options.location = options.from;
1142
+ }
1143
+
1144
+ //计算直线距离
1145
+ if (requestParam.mode == 'straight') {
1146
+ var locationsuccess = function (result) {
1147
+ var locationTo = Utils.getEndLocation(requestParam.to); //处理终点坐标
1148
+ var data = {
1149
+ message: 'query ok',
1150
+ result: {
1151
+ elements: [],
1152
+ },
1153
+ status: 0,
1154
+ };
1155
+ for (var i = 0; i < locationTo.length; i++) {
1156
+ data.result.elements.push({
1157
+ //将坐标存入
1158
+ distance: Utils.getDistance(
1159
+ result.latitude,
1160
+ result.longitude,
1161
+ locationTo[i].lat,
1162
+ locationTo[i].lng
1163
+ ),
1164
+ duration: 0,
1165
+ from: {
1166
+ lat: result.latitude,
1167
+ lng: result.longitude,
1168
+ },
1169
+ to: {
1170
+ lat: locationTo[i].lat,
1171
+ lng: locationTo[i].lng,
1172
+ },
1173
+ });
1174
+ }
1175
+ var calculateResult = data.result.elements;
1176
+ var distanceResult = [];
1177
+ // eslint-disable-next-line no-redeclare
1178
+ for (var i = 0; i < calculateResult.length; i++) {
1179
+ distanceResult.push(calculateResult[i].distance);
1180
+ }
1181
+ return options.success(data, {
1182
+ calculateResult: calculateResult,
1183
+ distanceResult: distanceResult,
1184
+ });
1185
+ };
1186
+
1187
+ Utils.locationProcess(options, locationsuccess);
1188
+ } else {
1189
+ // eslint-disable-next-line no-redeclare
1190
+ var locationsuccess = function (result) {
1191
+ requestParam.from = result.latitude + ',' + result.longitude;
1192
+ if (options.sig) {
1193
+ requestParam.sig = Utils.getSig(
1194
+ requestParam,
1195
+ options.sig,
1196
+ 'calculateDistance'
1197
+ );
1198
+ }
1199
+ wx.request(
1200
+ Utils.buildWxRequestConfig(
1201
+ options,
1202
+ {
1203
+ url: URL_DISTANCE,
1204
+ data: requestParam,
1205
+ },
1206
+ 'calculateDistance'
1207
+ )
1208
+ );
1209
+ };
1210
+
1211
+ Utils.locationProcess(options, locationsuccess);
1212
+ }
1213
+ }
1214
+
1215
+ /**
1216
+ * 路线规划:
1217
+ *
1218
+ * @param {Object} options 接口参数对象
1219
+ *
1220
+ * 请求参数结构可以参考
1221
+ * https://lbs.qq.com/webservice_v1/guide-road.html
1222
+ */
1223
+ direction(options) {
1224
+ var that = this;
1225
+ options = options || {};
1226
+ Utils.polyfillParam(options);
1227
+
1228
+ if (Utils.checkParamKeyEmpty(options, 'to')) {
1229
+ return;
1230
+ }
1231
+
1232
+ var requestParam = {
1233
+ output: 'json',
1234
+ key: that.key,
1235
+ };
1236
+
1237
+ //to格式处理
1238
+ if (typeof options.to == 'string') {
1239
+ requestParam.to = options.to;
1240
+ } else {
1241
+ requestParam.to = options.to.latitude + ',' + options.to.longitude;
1242
+ }
1243
+ //初始化局部请求域名
1244
+ var SET_URL_DIRECTION = null;
1245
+ //设置默认mode属性
1246
+ options.mode = options.mode || MODE.driving;
1247
+
1248
+ //设置请求域名
1249
+ SET_URL_DIRECTION = URL_DIRECTION + options.mode;
1250
+
1251
+ if (options.from) {
1252
+ options.location = options.from;
1253
+ }
1254
+
1255
+ if (options.mode == MODE.driving) {
1256
+ if (options.from_poi) {
1257
+ requestParam.from_poi = options.from_poi;
1258
+ }
1259
+ if (options.heading) {
1260
+ requestParam.heading = options.heading;
1261
+ }
1262
+ if (options.speed) {
1263
+ requestParam.speed = options.speed;
1264
+ }
1265
+ if (options.accuracy) {
1266
+ requestParam.accuracy = options.accuracy;
1267
+ }
1268
+ if (options.road_type) {
1269
+ requestParam.road_type = options.road_type;
1270
+ }
1271
+ if (options.to_poi) {
1272
+ requestParam.to_poi = options.to_poi;
1273
+ }
1274
+ if (options.from_track) {
1275
+ requestParam.from_track = options.from_track;
1276
+ }
1277
+ if (options.waypoints) {
1278
+ requestParam.waypoints = options.waypoints;
1279
+ }
1280
+ if (options.policy) {
1281
+ requestParam.policy = options.policy;
1282
+ }
1283
+ if (options.plate_number) {
1284
+ requestParam.plate_number = options.plate_number;
1285
+ }
1286
+ }
1287
+
1288
+ if (options.mode == MODE.transit) {
1289
+ if (options.departure_time) {
1290
+ requestParam.departure_time = options.departure_time;
1291
+ }
1292
+ if (options.policy) {
1293
+ requestParam.policy = options.policy;
1294
+ }
1295
+ }
1296
+
1297
+ var locationsuccess = function (result) {
1298
+ requestParam.from = result.latitude + ',' + result.longitude;
1299
+ if (options.sig) {
1300
+ requestParam.sig = Utils.getSig(
1301
+ requestParam,
1302
+ options.sig,
1303
+ 'direction',
1304
+ options.mode
1305
+ );
1306
+ }
1307
+ wx.request(
1308
+ Utils.buildWxRequestConfig(
1309
+ options,
1310
+ {
1311
+ url: SET_URL_DIRECTION,
1312
+ data: requestParam,
1313
+ },
1314
+ 'direction'
1315
+ )
1316
+ );
1317
+ };
1318
+
1319
+ Utils.locationProcess(options, locationsuccess);
1320
+ }
1321
+ }
1322
+
1323
+ module.exports = QQMapWX;