roomPosition.vue 7.0 KB

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