roomPosition.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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.latitude||!this.longitude) return this.$showToast('请进行地图标点')
  183. // if (!this.$u.test.mobile(this.stayInfo.landlinePhone)) {
  184. // this.$showToast('请输入正确手机号');
  185. // return
  186. // }
  187. this.stayInfo.introduction = null
  188. this.stayInfo.picList = [];
  189. this.imgUrlList.forEach((i) => {
  190. if (i.url) {
  191. this.stayInfo.picList.push(i.url)
  192. }
  193. })
  194. this.$api.post('/merchant/hotel/mine/updMHomestayInfo', this.stayInfo).then(res => {
  195. console.log(res)
  196. if (res.data.code == 0) {
  197. this.$showToast('保存成功');
  198. // setTimeout(() => {
  199. // this.getStayInfo()
  200. // }, 1000)
  201. } else this.$showToast(res.data.msg);
  202. })
  203. },
  204. // 删除图片
  205. deletePic(event) {
  206. this.imgUrlList.splice(event.index, 1)
  207. },
  208. // 新增图片
  209. async afterRead(event) {
  210. let lists = [].concat(event.file)
  211. let fileListLen = this.imgUrlList.length
  212. lists.map((item) => {
  213. this.imgUrlList.push({
  214. ...item,
  215. status: 'uploading',
  216. message: '上传中'
  217. })
  218. })
  219. for (let i = 0; i < lists.length; i++) {
  220. const result = await this.uploadFilePromise(lists[i].url)
  221. let item = this.imgUrlList[fileListLen]
  222. this.imgUrlList.splice(fileListLen, 1, Object.assign(item, {
  223. status: 'success',
  224. message: '',
  225. url: result
  226. }))
  227. fileListLen++
  228. }
  229. console.log(this.imgUrlList)
  230. },
  231. uploadFilePromise(url) {
  232. return new Promise((resolve, reject) => {
  233. let a = uni.uploadFile({
  234. url: 'https://i.ringzle.com/island-cloud-server/oss/file/upload', // 仅为示例,非真实的接口地址
  235. filePath: url,
  236. name: 'file',
  237. formData: {
  238. user: 'test'
  239. },
  240. success: (res) => {
  241. console.log(res)
  242. let data = JSON.parse(res.data);
  243. console.log(data)
  244. resolve(data.data.url)
  245. }
  246. });
  247. })
  248. },
  249. changeBegin() {
  250. this.visible = true
  251. },
  252. myPosition() {
  253. var myAmapFun = new amapFile.AMapWX({
  254. key: '1173b1eb83eb93bff1fb4a5987503a51'
  255. });
  256. let that = this;
  257. //获取地址
  258. myAmapFun.getRegeo({
  259. success: function(data) {
  260. that.longitude = data[0].longitude
  261. that.latitude = data[0].latitude
  262. console.log(that.longitude, that.latitude, '1111');
  263. },
  264. fail: function(info) {
  265. //失败回调
  266. console.log(info)
  267. uni.navigateBack();
  268. }
  269. })
  270. },
  271. open() {
  272. this.visible = true
  273. },
  274. confirm(val) {
  275. this.str = val
  276. console.log(this.str, '333')
  277. this.visible = false
  278. },
  279. cancel() {
  280. this.visible = false
  281. },
  282. onShareAppMessage(res) {
  283. if (res.from === 'button') { // 来自页面内分享按钮
  284. console.log(res.target, '1')
  285. }
  286. return {
  287. title: 'data-cityPicker省市区地址选择器!',
  288. path: '/pages/cityPicker/cityPicker'
  289. }
  290. },
  291. onShareTimeline(res) {
  292. if (res.from === 'button') { // 来自页面内分享按钮
  293. console.log(res.target, '2')
  294. }
  295. return {
  296. title: 'data-cityPicker省市区地址选择器!'
  297. }
  298. },
  299. change() {
  300. },
  301. close() {
  302. },
  303. }
  304. }
  305. </script>
  306. <style lang="less">
  307. .u-upload__wrap__preview__image {
  308. width: 196rpx !important;
  309. height: 130rpx !important;
  310. }
  311. .u-upload__button {
  312. width: 196rpx !important;
  313. height: 130rpx !important;
  314. }
  315. .card ::v-deep .u-icon__icon {
  316. font-size: 30rpx !important;
  317. margin-bottom: 10rpx;
  318. left: 2rpx !important;
  319. top: 6rpx !important;
  320. }
  321. </style>
  322. <style lang="scss" scoped>
  323. /deep/.u-cell__body {
  324. padding: 0;
  325. }
  326. ::v-deep .u-cell__body {
  327. padding: 0;
  328. }
  329. .pages {
  330. box-sizing: border-box;
  331. height: 100%;
  332. background: #F9FAFC;
  333. .content {
  334. padding: 20rpx;
  335. height: 100%;
  336. .card {
  337. background: #fff;
  338. border-radius: 16rpx;
  339. padding: 30rpx 33rpx;
  340. margin-bottom: 20rpx;
  341. .upload {
  342. margin-top: 48rpx;
  343. width: 100%;
  344. height: 200rpx;
  345. border-radius: 16rpx;
  346. background-color: #F5F8FA;
  347. display: flex;
  348. align-items: center;
  349. text-align: center;
  350. .upload-one {
  351. margin: 0 245rpx;
  352. width: 200rpx;
  353. height: 200rpx;
  354. image {
  355. width: 100%;
  356. height: 100%;
  357. }
  358. }
  359. }
  360. .collapseTitle {
  361. font-size: 22rpx;
  362. color: #a5a5a5;
  363. margin-bottom: 20rpx;
  364. }
  365. .card1 {
  366. display: flex;
  367. flex-direction: row;
  368. justify-content: space-between;
  369. align-items: center;
  370. text {
  371. font-size: 30rpx;
  372. color: #333;
  373. font-weight: Regular;
  374. }
  375. .card-input {
  376. font-size: 30rpx;
  377. color: #333;
  378. font-weight: Regular;
  379. }
  380. .as-content {
  381. color: #a5a5a5;
  382. }
  383. }
  384. }
  385. }
  386. .content-map {
  387. border: 1rpx solid black;
  388. height: 355rpx;
  389. }
  390. .bottom {
  391. position: fixed;
  392. bottom: 0;
  393. z-index: 999999;
  394. background: #fff;
  395. width: 100%;
  396. padding: 20rpx 0 30rpx;
  397. box-sizing: border-box;
  398. .btn {
  399. background: #33AFFC;
  400. color: white;
  401. text-align: center;
  402. height: 96rpx;
  403. margin: 0 auto;
  404. font-size: 34rpx;
  405. line-height: 96rpx;
  406. align-self: center;
  407. border-radius: 48rpx;
  408. width: 690rpx;
  409. }
  410. }
  411. }
  412. </style>