roomPosition.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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. changeBegin(){
  150. this.visible=true
  151. },
  152. myPosition() {
  153. var myAmapFun = new amapFile.AMapWX({
  154. key: '1173b1eb83eb93bff1fb4a5987503a51'
  155. });
  156. let that = this;
  157. //获取地址
  158. myAmapFun.getRegeo({
  159. success: function(data) {
  160. that.longitude = data[0].longitude
  161. that.latitude = data[0].latitude
  162. console.log(that.longitude, that.latitude, '1111');
  163. },
  164. fail: function(info) {
  165. //失败回调
  166. console.log(info)
  167. uni.navigateBack();
  168. }
  169. })
  170. },
  171. open() {
  172. this.visible = true
  173. },
  174. confirm(val) {
  175. this.str = val
  176. console.log(this.str, '333')
  177. this.visible = false
  178. },
  179. cancel() {
  180. this.visible = false
  181. },
  182. onShareAppMessage(res) {
  183. if (res.from === 'button') { // 来自页面内分享按钮
  184. console.log(res.target, '1')
  185. }
  186. return {
  187. title: 'data-cityPicker省市区地址选择器!',
  188. path: '/pages/cityPicker/cityPicker'
  189. }
  190. },
  191. onShareTimeline(res) {
  192. if (res.from === 'button') { // 来自页面内分享按钮
  193. console.log(res.target, '2')
  194. }
  195. return {
  196. title: 'data-cityPicker省市区地址选择器!'
  197. }
  198. },
  199. change() {
  200. },
  201. close() {
  202. },
  203. }
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. /deep/.u-cell__body {
  208. padding: 0;
  209. }
  210. ::v-deep .u-cell__body {
  211. padding: 0;
  212. }
  213. .pages {
  214. height: 100vh;
  215. background: #F9FAFC;
  216. .content {
  217. padding: 20rpx;
  218. height: 100vh;
  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: absolute;
  265. bottom: 0;
  266. height: 9%;
  267. background: #fff;
  268. width: 100%;
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. padding: 0 30rpx;
  273. box-sizing: border-box;
  274. flex-direction: column;
  275. .btn {
  276. background: #33AFFC;
  277. color: white;
  278. text-align: center;
  279. height: 73rpx;
  280. line-height: 73rpx;
  281. align-self: center;
  282. border-radius: 35rpx;
  283. width: 80%;
  284. }
  285. }
  286. }
  287. </style>