roomPosition.vue 11 KB

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