@cloudbase/weda-ui 0.2.14 → 0.2.17

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