roomPosition.vue 10 KB

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