roomPosition.vue 11 KB

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