roomPosition.vue 10 KB

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