roomPosition.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <!-- <view class="pages" :style="{'height':(h)+'px','padding-top':mt+'px'}"> -->
  3. <view class="pages" :style="{'height':(h-th)+'px','padding-top':mt+'px'}">
  4. <c-nav-bar title="位置定位" :showIcon="true"></c-nav-bar>
  5. <view class="content">
  6. <view class="card">
  7. <!-- <view class="card1" @tap="open()"> -->
  8. <!-- <view class="card1">
  9. <text style="font-size: 30rpx; color: #333; font-weight: Regular; ">
  10. <text>所属城市</text>
  11. <text style="margin-left: 30rpx; text-align: right; width: 100%;"
  12. v-if="str.name==undefined||str.name==''">请选择所属城市</text>
  13. <text style="margin-left: 30rpx; text-align: right; width: 100%;" v-else>{{str.name}}</text>
  14. </text>
  15. <u-icon name="arrow-right" size="24"></u-icon>
  16. </view> -->
  17. <view class="card1">
  18. <text style="margin-right: 30rpx; font-size: 30rpx; color: #333; font-weight: Regular; ">所属城市</text>
  19. <u--input class="card-input" inputAlign="right" placeholder="请输入您的地址" border="none"
  20. v-model="str.name" style="text-align: right; font-size: Regular;"></u--input>
  21. </view>
  22. </view>
  23. <view class="card">
  24. <view class="card1">
  25. <text style="margin-right: 30rpx; font-size: 30rpx; color: #333; font-weight: Regular; ">详细地址</text>
  26. <u--input class="card-input" inputAlign="right" placeholder="请输入您的地址" border="none"
  27. v-model="formData.areaDetail" style="text-align: right; font-size: Regular;"></u--input>
  28. </view>
  29. </view>
  30. <view class="card">
  31. <view class="card1">
  32. <text class="label">联系电话</text>
  33. <u--input inputAlign="right" placeholder="请输入内容" border="none" v-model="stayInfo.landlinePhone"
  34. style="text-align: right;"></u--input>
  35. </view>
  36. </view>
  37. <view class="card c2">
  38. <!-- <view class="tit">内饰照片</view> -->
  39. <view class="label" style="color: #333; font-size: 30rpx; margin:20rpx 0 28rpx; font-weight: Heavy;">
  40. 内饰照片</view>
  41. <view class="imgs">
  42. <!-- <image src="" v-for="(item,index) in imgUrlList" :key="index"></image> -->
  43. <u-upload ref="uUpload" uploadText="上传图片" :fileList="imgUrlList" :maxSize="10 * 1024 * 1024"
  44. width="200" height="120" @afterRead="afterRead" @delete="deletePic">
  45. </u-upload>
  46. </view>
  47. </view>
  48. <view class="card" style="padding-bottom: 240rpx;">
  49. <view class="card1">
  50. <text>地图位置</text>
  51. </view>
  52. <!-- <view style="margin-top: 20rpx;" class="collapseTitle">
  53. 点击地图可调整至更精确位置
  54. </view> -->
  55. <view style="margin-top: 20rpx;">
  56. <view class="content-map">
  57. <map style="width: 100%;height: 100%;" :latitude="latitude" :longitude="longitude" :scale="16"
  58. :title="title" />
  59. </view>
  60. </view>
  61. </view>
  62. <cityPicker :column="column" :default-value="defaultValue" :mask-close-able="maskCloseAble"
  63. @confirm="confirm" @cancel="cancel" :visible="visible" />
  64. </view>
  65. <view class="bottom" @click="save">
  66. <view class="btn">
  67. 确定
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import cityPicker from '@/uni_modules/piaoyi-cityPicker/components/piaoyi-cityPicker/piaoyi-cityPicker'
  74. // 引入高德地图api提供的微信小程序的接口
  75. var amapFile = require('@/utils/amap-wx.130.js');
  76. // 创建地图
  77. var myAmapFun = new amapFile.AMapWX({
  78. key: '1173b1eb83eb93bff1fb4a5987503a51'
  79. }); //key值要申请为 去高德地图申请微信小程序的key
  80. // var myAmapFun = new amapFile.AMapWX({key: ''}); //key我的
  81. export default {
  82. data() {
  83. return {
  84. selectIndex: undefined,
  85. selectAddr: {},
  86. searchWords: "",
  87. id: 1, // 使用 marker点击事件 需要填写id
  88. title: 'map',
  89. latitude: 39.91667, // 纬度
  90. longitude: 116.41667, // 经度
  91. markers: [{
  92. latitude: 39.91667, // 纬度
  93. longitude: 116.41667, // 经度
  94. width: 30,
  95. height: 30,
  96. iconPath: ''
  97. // iconPath: '../../static/ditu.png'
  98. }],
  99. dataTips: [],
  100. // type: '',
  101. value: '',
  102. value1: '',
  103. fileList: [],
  104. fileList1: [],
  105. imgUrlList: [],
  106. fileList2: [],
  107. result: '',
  108. visible: false,
  109. maskCloseAble: true,
  110. str: {
  111. name: '浙江省舟山市嵊泗县'
  112. },
  113. defaultValue: '330922',
  114. // defaultValue: ['河北省','唐山市','丰南区'],
  115. column: 3,
  116. address: '',
  117. formData: {},
  118. stayInfo: {
  119. picList: []
  120. },
  121. homestayId: uni.getStorageSync('homestayId') || 0,
  122. }
  123. },
  124. components: {
  125. cityPicker
  126. },
  127. onLoad(option) {
  128. this.getStayInfo()
  129. // var self = this;
  130. // this.myPosition()
  131. // uni.getLocation({
  132. // type: 'gcj02',
  133. // success: function(res) {
  134. // console.log(res, '当前地址定位');
  135. // if (res.errMsg == "getLocation:ok") {
  136. // console.log(self.mark, 'onload里面看看');
  137. // self.longitude = res.longitude;
  138. // self.latitude = res.latitude;
  139. // self.$set(self.markers[0], "longitude", res.longitude);
  140. // self.$set(self.markers[0], "latitude", res.latitude);
  141. // self.mapFlafg = true;
  142. // console.log(self.markers, "markers")
  143. // // self.markers[0].longitude = res.longitude;
  144. // // self.markers[0].latitude = res.latitude;
  145. // }
  146. // },
  147. // complete: () => {
  148. // // 获取当前位置的地点列表
  149. // myAmapFun.getPoiAround({
  150. // location: self.longitude + ',' + self.latitude,
  151. // success: (data) => {
  152. // console.log("获取当前的列表", data);
  153. // this.dataTips = data.poisData;
  154. // },
  155. // fail: (info) => {
  156. // console.log(info, '点击地图错误信息1')
  157. // }
  158. // })
  159. // }
  160. // });
  161. },
  162. methods: {
  163. getStayInfo() {
  164. this.$api.get('/merchant/hotel/mine/getMerchantHomestayInfo/' + this.homestayId).then(res => {
  165. if (res.data.code == 0) {
  166. this.stayInfo = res.data.data;
  167. this.formData = this.stayInfo
  168. this.latitude = this.formData.lat
  169. this.longitude = this.formData.lon
  170. this.markers[0].latitude = this.formData.lat
  171. this.markers[0].longitude = this.formData.lon
  172. this.stayInfo.picList.forEach((item) => {
  173. this.imgUrlList.push({
  174. url: item
  175. })
  176. })
  177. }
  178. })
  179. },
  180. // 确定保存
  181. save() {
  182. // if (!this.$u.test.mobile(this.stayInfo.landlinePhone)) {
  183. // this.$showToast('请输入正确手机号');
  184. // return
  185. // }
  186. this.stayInfo.introduction = null
  187. this.stayInfo.picList = [];
  188. this.imgUrlList.forEach((i) => {
  189. if (i.url) {
  190. this.stayInfo.picList.push(i.url)
  191. }
  192. })
  193. this.$api.post('/merchant/hotel/mine/updMHomestayInfo', this.stayInfo).then(res => {
  194. console.log(res)
  195. if (res.data.code == 0) {
  196. this.$showToast('保存成功');
  197. // setTimeout(() => {
  198. // this.getStayInfo()
  199. // }, 1000)
  200. } else this.$showToast(res.data.msg);
  201. })
  202. },
  203. // 删除图片
  204. deletePic(event) {
  205. this.imgUrlList.splice(event.index, 1)
  206. },
  207. // 新增图片
  208. async afterRead(event) {
  209. let lists = [].concat(event.file)
  210. let fileListLen = this.imgUrlList.length
  211. lists.map((item) => {
  212. this.imgUrlList.push({
  213. ...item,
  214. status: 'uploading',
  215. message: '上传中'
  216. })
  217. })
  218. for (let i = 0; i < lists.length; i++) {
  219. const result = await this.uploadFilePromise(lists[i].url)
  220. let item = this.imgUrlList[fileListLen]
  221. this.imgUrlList.splice(fileListLen, 1, Object.assign(item, {
  222. status: 'success',
  223. message: '',
  224. url: result
  225. }))
  226. fileListLen++
  227. }
  228. console.log(this.imgUrlList)
  229. },
  230. uploadFilePromise(url) {
  231. return new Promise((resolve, reject) => {
  232. let a = uni.uploadFile({
  233. url: 'https://i.ringzle.com/island-cloud-server/oss/file/upload', // 仅为示例,非真实的接口地址
  234. filePath: url,
  235. name: 'file',
  236. formData: {
  237. user: 'test'
  238. },
  239. success: (res) => {
  240. console.log(res)
  241. let data = JSON.parse(res.data);
  242. console.log(data)
  243. resolve(data.data.url)
  244. }
  245. });
  246. })
  247. },
  248. changeBegin() {
  249. this.visible = true
  250. },
  251. myPosition() {
  252. var myAmapFun = new amapFile.AMapWX({
  253. key: '1173b1eb83eb93bff1fb4a5987503a51'
  254. });
  255. let that = this;
  256. //获取地址
  257. myAmapFun.getRegeo({
  258. success: function(data) {
  259. that.longitude = data[0].longitude
  260. that.latitude = data[0].latitude
  261. console.log(that.longitude, that.latitude, '1111');
  262. },
  263. fail: function(info) {
  264. //失败回调
  265. console.log(info)
  266. uni.navigateBack();
  267. }
  268. })
  269. },
  270. open() {
  271. this.visible = true
  272. },
  273. confirm(val) {
  274. this.str = val
  275. console.log(this.str, '333')
  276. this.visible = false
  277. },
  278. cancel() {
  279. this.visible = false
  280. },
  281. onShareAppMessage(res) {
  282. if (res.from === 'button') { // 来自页面内分享按钮
  283. console.log(res.target, '1')
  284. }
  285. return {
  286. title: 'data-cityPicker省市区地址选择器!',
  287. path: '/pages/cityPicker/cityPicker'
  288. }
  289. },
  290. onShareTimeline(res) {
  291. if (res.from === 'button') { // 来自页面内分享按钮
  292. console.log(res.target, '2')
  293. }
  294. return {
  295. title: 'data-cityPicker省市区地址选择器!'
  296. }
  297. },
  298. change() {
  299. },
  300. close() {
  301. },
  302. }
  303. }
  304. </script>
  305. <style lang="less">
  306. .u-upload__wrap__preview__image {
  307. width: 196rpx !important;
  308. height: 130rpx !important;
  309. }
  310. .u-upload__button {
  311. width: 196rpx !important;
  312. height: 130rpx !important;
  313. }
  314. .card ::v-deep .u-icon__icon {
  315. font-size: 30rpx !important;
  316. margin-bottom: 10rpx;
  317. left: 2rpx !important;
  318. top: 6rpx !important;
  319. }
  320. </style>
  321. <style lang="scss" scoped>
  322. /deep/.u-cell__body {
  323. padding: 0;
  324. }
  325. ::v-deep .u-cell__body {
  326. padding: 0;
  327. }
  328. .pages {
  329. box-sizing: border-box;
  330. height: 100%;
  331. background: #F9FAFC;
  332. .content {
  333. padding: 20rpx;
  334. height: 100%;
  335. .card {
  336. background: #fff;
  337. border-radius: 16rpx;
  338. padding: 30rpx 33rpx;
  339. margin-bottom: 20rpx;
  340. .upload {
  341. margin-top: 48rpx;
  342. width: 100%;
  343. height: 200rpx;
  344. border-radius: 16rpx;
  345. background-color: #F5F8FA;
  346. display: flex;
  347. align-items: center;
  348. text-align: center;
  349. .upload-one {
  350. margin: 0 245rpx;
  351. width: 200rpx;
  352. height: 200rpx;
  353. image {
  354. width: 100%;
  355. height: 100%;
  356. }
  357. }
  358. }
  359. .collapseTitle {
  360. font-size: 22rpx;
  361. color: #a5a5a5;
  362. margin-bottom: 20rpx;
  363. }
  364. .card1 {
  365. display: flex;
  366. flex-direction: row;
  367. justify-content: space-between;
  368. align-items: center;
  369. text {
  370. font-size: 30rpx;
  371. color: #333;
  372. font-weight: Regular;
  373. }
  374. .card-input {
  375. font-size: 30rpx;
  376. color: #333;
  377. font-weight: Regular;
  378. }
  379. .as-content {
  380. color: #a5a5a5;
  381. }
  382. }
  383. }
  384. }
  385. .content-map {
  386. border: 1rpx solid black;
  387. height: 355rpx;
  388. }
  389. .bottom {
  390. position: fixed;
  391. bottom: 0;
  392. z-index: 999999;
  393. background: #fff;
  394. width: 100%;
  395. padding: 20rpx 0 30rpx;
  396. box-sizing: border-box;
  397. .btn {
  398. background: #33AFFC;
  399. color: white;
  400. text-align: center;
  401. height: 96rpx;
  402. margin: 0 auto;
  403. font-size: 34rpx;
  404. line-height: 96rpx;
  405. align-self: center;
  406. border-radius: 48rpx;
  407. width: 690rpx;
  408. }
  409. }
  410. }
  411. </style>