roomPosition.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view class="pages" :style="{'height':(h)+'px','padding-top':mt+'px'}">
  3. <c-nav-bar title="位置定位" :showIcon="true"></c-nav-bar>
  4. <view class="content">
  5. <view class="card">
  6. <view class="card1" @tap="open()">
  7. <text>所属城市
  8. <text style="margin-left: 30rpx;" v-if="str.name==undefined||str.name==''">请选择所属城市</text>
  9. <text style="margin-left: 30rpx;" v-else>{{str.name}}</text>
  10. </text>
  11. <u-icon name="arrow-right" size="24"></u-icon>
  12. </view>
  13. </view>
  14. <view class="card">
  15. <view class="card1">
  16. <text style="margin-right: 30rpx;">详细地址</text>
  17. <u--input placeholder="请输入您的地址" border="none" v-model="formData.areaDetail"></u--input>
  18. </view>
  19. </view>
  20. <view class="card">
  21. <view class="card1">
  22. <text>单元、门牌号</text>
  23. </view>
  24. <view style="margin-top: 20rpx;">
  25. <span>
  26. <u--textarea border='none' :maxlength='300' count v-model="formData.introduction"
  27. placeholder="请输入单元、门牌号" height='250'></u--textarea>
  28. </span>
  29. </view>
  30. </view>
  31. <view class="card" style="padding-bottom: 180rpx;">
  32. <view class="card1">
  33. <text>地图位置</text>
  34. </view>
  35. <view style="margin-top: 20rpx;" class="collapseTitle">
  36. 点击地图可调整至更精确位置
  37. </view>
  38. <view style="margin-top: 20rpx;">
  39. <view class="content-map">
  40. <map style="width: 100%;height: 100%;" :latitude="latitude" :longitude="longitude" :scale="16"
  41. :title="title" />
  42. </view>
  43. </view>
  44. </view>
  45. <cityPicker :column="column" :default-value="defaultValue" :mask-close-able="maskCloseAble"
  46. @confirm="confirm" @cancel="cancel" :visible="visible" />
  47. </view>
  48. <view class="bottom">
  49. <view class="btn">
  50. 确定
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import cityPicker from '@/uni_modules/piaoyi-cityPicker/components/piaoyi-cityPicker/piaoyi-cityPicker'
  57. // 引入高德地图api提供的微信小程序的接口
  58. var amapFile = require('@/utils/amap-wx.130.js');
  59. // 创建地图
  60. var myAmapFun = new amapFile.AMapWX({
  61. key: '1173b1eb83eb93bff1fb4a5987503a51'
  62. }); //key值要申请为 去高德地图申请微信小程序的key
  63. // var myAmapFun = new amapFile.AMapWX({key: ''}); //key我的
  64. export default {
  65. data() {
  66. return {
  67. selectIndex: undefined,
  68. selectAddr: {},
  69. searchWords: "",
  70. id: 1, // 使用 marker点击事件 需要填写id
  71. title: 'map',
  72. latitude: 39.91667, // 纬度
  73. longitude: 116.41667, // 经度
  74. markers: [{
  75. latitude: 39.91667, // 纬度
  76. longitude: 116.41667, // 经度
  77. width: 30,
  78. height: 30,
  79. iconPath: ''
  80. // iconPath: '../../static/ditu.png'
  81. }],
  82. dataTips: [],
  83. // type: '',
  84. value: '',
  85. value1: '',
  86. fileList: [],
  87. fileList1: [],
  88. imgUrlList: [],
  89. fileList2: [],
  90. result: '',
  91. visible: false,
  92. maskCloseAble: true,
  93. str: {
  94. name: '浙江省舟山市嵊泗县'
  95. },
  96. defaultValue: '330922',
  97. // defaultValue: ['河北省','唐山市','丰南区'],
  98. column: 3,
  99. address: '',
  100. formData: {}
  101. }
  102. },
  103. components: {
  104. cityPicker
  105. },
  106. onLoad(option) {
  107. if (option) {
  108. this.formData = JSON.parse(option.item)
  109. this.latitude = this.formData.lat
  110. this.longitude = this.formData.lon
  111. this.markers[0].latitude = this.formData.lat
  112. this.markers[0].longitude = this.formData.lon
  113. }
  114. // var self = this;
  115. // this.myPosition()
  116. // uni.getLocation({
  117. // type: 'gcj02',
  118. // success: function(res) {
  119. // console.log(res, '当前地址定位');
  120. // if (res.errMsg == "getLocation:ok") {
  121. // console.log(self.mark, 'onload里面看看');
  122. // self.longitude = res.longitude;
  123. // self.latitude = res.latitude;
  124. // self.$set(self.markers[0], "longitude", res.longitude);
  125. // self.$set(self.markers[0], "latitude", res.latitude);
  126. // self.mapFlafg = true;
  127. // console.log(self.markers, "markers")
  128. // // self.markers[0].longitude = res.longitude;
  129. // // self.markers[0].latitude = res.latitude;
  130. // }
  131. // },
  132. // complete: () => {
  133. // // 获取当前位置的地点列表
  134. // myAmapFun.getPoiAround({
  135. // location: self.longitude + ',' + self.latitude,
  136. // success: (data) => {
  137. // console.log("获取当前的列表", data);
  138. // this.dataTips = data.poisData;
  139. // },
  140. // fail: (info) => {
  141. // console.log(info, '点击地图错误信息1')
  142. // }
  143. // })
  144. // }
  145. // });
  146. },
  147. methods: {
  148. changeBegin() {
  149. this.visible = true
  150. },
  151. myPosition() {
  152. var myAmapFun = new amapFile.AMapWX({
  153. key: '1173b1eb83eb93bff1fb4a5987503a51'
  154. });
  155. let that = this;
  156. //获取地址
  157. myAmapFun.getRegeo({
  158. success: function(data) {
  159. that.longitude = data[0].longitude
  160. that.latitude = data[0].latitude
  161. console.log(that.longitude, that.latitude, '1111');
  162. },
  163. fail: function(info) {
  164. //失败回调
  165. console.log(info)
  166. uni.navigateBack();
  167. }
  168. })
  169. },
  170. open() {
  171. this.visible = true
  172. },
  173. confirm(val) {
  174. this.str = val
  175. console.log(this.str, '333')
  176. this.visible = false
  177. },
  178. cancel() {
  179. this.visible = false
  180. },
  181. onShareAppMessage(res) {
  182. if (res.from === 'button') { // 来自页面内分享按钮
  183. console.log(res.target, '1')
  184. }
  185. return {
  186. title: 'data-cityPicker省市区地址选择器!',
  187. path: '/pages/cityPicker/cityPicker'
  188. }
  189. },
  190. onShareTimeline(res) {
  191. if (res.from === 'button') { // 来自页面内分享按钮
  192. console.log(res.target, '2')
  193. }
  194. return {
  195. title: 'data-cityPicker省市区地址选择器!'
  196. }
  197. },
  198. change() {
  199. },
  200. close() {
  201. },
  202. }
  203. }
  204. </script>
  205. <style lang="scss" scoped>
  206. /deep/.u-cell__body {
  207. padding: 0;
  208. }
  209. ::v-deep .u-cell__body {
  210. padding: 0;
  211. }
  212. .pages {
  213. box-sizing: border-box;
  214. height: 100%;
  215. background: #F9FAFC;
  216. .content {
  217. padding: 20rpx;
  218. height: 100%;
  219. .card {
  220. background: #fff;
  221. border-radius: 16rpx;
  222. padding: 30rpx 33rpx;
  223. margin-bottom: 20rpx;
  224. .upload {
  225. margin-top: 48rpx;
  226. width: 100%;
  227. height: 200rpx;
  228. border-radius: 16rpx;
  229. background-color: #F5F8FA;
  230. display: flex;
  231. align-items: center;
  232. text-align: center;
  233. .upload-one {
  234. margin: 0 245rpx;
  235. width: 200rpx;
  236. height: 200rpx;
  237. image {
  238. width: 100%;
  239. height: 100%;
  240. }
  241. }
  242. }
  243. .collapseTitle {
  244. font-size: 22rpx;
  245. color: #a5a5a5;
  246. margin-bottom: 20rpx;
  247. }
  248. .card1 {
  249. display: flex;
  250. flex-direction: row;
  251. justify-content: space-between;
  252. align-items: center;
  253. .as-content {
  254. color: #a5a5a5;
  255. }
  256. }
  257. }
  258. }
  259. .content-map {
  260. border: 1rpx solid black;
  261. height: 355rpx;
  262. }
  263. .bottom {
  264. position: fixed;
  265. bottom: 0;
  266. z-index: 999999;
  267. background: #fff;
  268. width: 100%;
  269. padding: 20rpx 0 30rpx;
  270. box-sizing: border-box;
  271. .btn {
  272. background: #33AFFC;
  273. color: white;
  274. text-align: center;
  275. height: 96rpx;
  276. margin: 0 auto;
  277. font-size: 34rpx;
  278. line-height: 96rpx;
  279. align-self: center;
  280. border-radius: 48rpx;
  281. width: 690rpx;
  282. }
  283. }
  284. }
  285. </style>