index.ux 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <import name="add-desktop" src="/src/components/addDesktop"></import>
  2. <template>
  3. <div class="content">
  4. <add-desktop></add-desktop>
  5. <div class="box">
  6. <div class="item" style="justify-content: space-between;">
  7. <text>国家</text>
  8. <text>{{ info.country }}</text>
  9. </div>
  10. <div class="item">
  11. <text>省份</text>
  12. <text>{{ info.province }}</text>
  13. </div>
  14. <div class="item">
  15. <text>城市</text>
  16. <text>{{ info.city }}</text>
  17. </div>
  18. <div class="item">
  19. <text>地区</text>
  20. <text>{{ info.district }}</text>
  21. </div>
  22. <div class="item">
  23. <text>运营商</text>
  24. <text>未知</text>
  25. </div>
  26. <div class="item">
  27. <text>经纬度</text>
  28. <text>{{ location.longitude }}--{{ location.latitude }}</text>
  29. </div>
  30. <div class="item">
  31. <text>国家识别码</text>
  32. <text>CN</text>
  33. </div>
  34. <div class="item">
  35. <text>IP地址</text>
  36. <text>--</text>
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import network from '@system.network'
  43. import device from '@system.device'
  44. import telecom from '@system.telecom'
  45. import geolocation from '@system.geolocation'
  46. import fetch from '@system.fetch'
  47. export default {
  48. private: {
  49. title: '欢迎体验快应用开发',
  50. location:{longitude: 114.060682, latitude: 22.5606468},
  51. info:{
  52. country: "中国",
  53. province: "福建省",
  54. city: "厦门市",
  55. district:'湖里区',
  56. }
  57. },
  58. onInit() {
  59. device.getInfo({
  60. success: function(ret) {
  61. console.log(`handling success, brand = ${JSON.stringify(ret)}`)
  62. }
  63. })
  64. var that = this
  65. geolocation.getLocation({
  66. success: function(data) {
  67. console.log(
  68. `handling success: longitude = ${data.longitude}, latitude = ${
  69. data.latitude
  70. }`
  71. )
  72. var key = '948b7da20bd04112e259c809fca83671' // 个人高德web服务 key
  73. fetch.fetch({
  74. url: `https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=${data.longitude},${data.latitude}&key=${key}&extensions=base`,
  75. header:{
  76. 'Content-Type':'application/json',
  77. },
  78. success: function(response) {
  79. const info = JSON.parse(response.data)
  80. that.info = info.regeocode.addressComponent // info.regeocode.formatted_address
  81. console.log('info',info.regeocode)
  82. },
  83. fail: function(data, code) {
  84. console.log(`handling fail, errMsg = ${data}`)
  85. }
  86. })
  87. console.log('data',data)
  88. },
  89. fail: function(data, code) {
  90. console.log(`handling fail, code = ${code}, errorMsg=${data}`)
  91. }
  92. })
  93. }
  94. }
  95. </script>
  96. <style lang="less">
  97. .content {
  98. padding: 28px;
  99. background: linear-gradient(to bottom, #a9d4ff, #cce6ff);
  100. flex-direction: column;
  101. align-items: center;
  102. }
  103. .box{
  104. width: 100%;
  105. flex-direction: column;
  106. background-color: #fff;
  107. border-radius: 30px;
  108. min-height: 1000px;
  109. padding: 30px 28px;
  110. }
  111. .item{
  112. justify-content: space-between;
  113. padding: 20px 0;
  114. }
  115. </style>