stayInfo.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <view class="pages">
  3. <view class="content">
  4. <view class="card">
  5. <view class="card1" @click="goToPosition()">
  6. <text>位置定位</text>
  7. <text>></text>
  8. </view>
  9. </view>
  10. <view class="card">
  11. <view class="card1">
  12. <text style="margin-right: 30rpx;">联系电话</text>
  13. <u--input placeholder="请输入内容" border="none" v-model="stayInfo.landlinePhone"></u--input>
  14. </view>
  15. </view>
  16. <view class="card">
  17. <view class="card1">
  18. <text>酒店简介</text>
  19. </view>
  20. <view style="margin-top: 20rpx;">
  21. <span>
  22. <u--textarea border='none' :maxlength='300' count v-model="stayInfo.introduction"
  23. placeholder="请输入酒店简介" height='250'></u--textarea>
  24. </span>
  25. </view>
  26. </view>
  27. <view class="card" style="padding: 0;">
  28. <view>
  29. <u-collapse :border='false' accordion @change="change" @close="close" @open="open">
  30. <u-collapse-item title="环境\内饰照片(0/10)" name="Docs guide">
  31. <text class="collapseTitle">至少上传1张,建议上传5-10张,需展示完整内饰</text>
  32. <view class="upload" v-if="stayInfo.picList.length==0">
  33. <u-upload :fileList="stayInfo.picList" multiple :maxCount="10"
  34. :maxSize="10 * 1024 * 1024" @afterRead="afterRead" @delete="deletePic"
  35. @oversize="overSize">
  36. <view class="upload-one">
  37. <image
  38. src="https://i.ringzle.com/file/20240103/1d3cf8e7ad184d17a253b3b08dfd0c53.png"
  39. mode="aspectFill"></image>
  40. </view>
  41. </u-upload>
  42. </view>
  43. <view class="uploads" v-else>
  44. <u-upload :fileList="stayInfo.picList" multiple :maxCount="10"
  45. :maxSize="10 * 1024 * 1024" @afterRead="afterRead" @delete="deletePic"
  46. @oversize="overSize">
  47. <view class="upload-image">
  48. <image
  49. src="https://i.ringzle.com/file/20240103/1d3cf8e7ad184d17a253b3b08dfd0c53.png"
  50. mode="aspectFill"></image>
  51. </view>
  52. </u-upload>
  53. </view>
  54. </u-collapse-item>
  55. <!-- <u-collapse-item title="环境照片" name="Docs guide">
  56. <text class="collapseTitle">至少上传1张,建议上传5-10张,需展示完整环境</text>
  57. <view class="upload" v-if="fileList1.length==0">
  58. <u-upload :fileList="fileList1" multiple :maxCount="10" :maxSize="10 * 1024 * 1024"
  59. @afterRead="afterRead" @delete="deletePic" @oversize="overSize">
  60. <view class="upload-one">
  61. <image
  62. src="https://i.ringzle.com/file/20240103/1d3cf8e7ad184d17a253b3b08dfd0c53.png"
  63. mode="aspectFill">
  64. </image>
  65. </view>
  66. </u-upload>
  67. </view>
  68. <view class="uploads" v-else>
  69. <u-upload :fileList="fileList1" multiple :maxCount="10" :maxSize="10 * 1024 * 1024"
  70. @afterRead="afterRead" @delete="deletePic" @oversize="overSize">
  71. <view class="upload-image">
  72. <image
  73. src="https://i.ringzle.com/file/20240103/1d3cf8e7ad184d17a253b3b08dfd0c53.png"
  74. mode="aspectFill"></image>
  75. </view>
  76. </u-upload>
  77. </view>
  78. </u-collapse-item> -->
  79. </u-collapse>
  80. </view>
  81. </view>
  82. </view>
  83. <view class="bottom">
  84. <view class="btn">
  85. 确定
  86. </view>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. export default {
  92. data() {
  93. return {
  94. value: '',
  95. value1: '',
  96. fileList: [],
  97. fileList1: [],
  98. imgUrlList: [],
  99. fileList2: [],
  100. stayInfo: {
  101. picList: []
  102. }
  103. }
  104. },
  105. onLoad() {
  106. this.getStayInfo()
  107. },
  108. methods: {
  109. goToPosition() {
  110. const qwe=JSON.stringify(this.stayInfo)
  111. console.log(qwe,'qweqweqweqwe');
  112. uni.navigateTo({
  113. url: '/pagesMy/stayInfo/roomPosition?item=' + JSON.stringify(this.stayInfo)
  114. })
  115. },
  116. getStayInfo() {
  117. this.$api.get('/merchant/hotel/mine/getMerchantHomestayInfo/' + '1711268640588517378').then(res => {
  118. if (res.data.code == 0) {
  119. this.stayInfo = res.data.data
  120. } else {
  121. uni.showToast({
  122. title: res.data.msg,
  123. })
  124. setTimeout(() => {
  125. uni.navigateBack()
  126. }, 1500)
  127. }
  128. console.log(res, 'res------');
  129. })
  130. },
  131. change() {
  132. },
  133. close() {
  134. },
  135. open() {
  136. },
  137. // 删除图片
  138. deletePic(event) {
  139. console.log('jinlaile1');
  140. this[`stayInfo.picList{event.name}`].splice(event.index, 1)
  141. },
  142. // 新增图片
  143. async afterRead(event) {
  144. console.log('jinlaile2', event);
  145. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  146. let lists = [].concat(event.file)
  147. let fileListLen = this.stayInfo.picList.length
  148. lists.map((item) => {
  149. this.stayInfo.picList.push({
  150. ...item,
  151. status: 'uploading',
  152. message: '上传中'
  153. })
  154. })
  155. for (let i = 0; i < lists.length; i++) {
  156. const result = await this.uploadFilePromise(lists[i].url)
  157. let item = this.stayInfo.picList[fileListLen]
  158. this.stayInfo.picList.splice(fileListLen, 1, Object.assign(item, {
  159. status: 'success',
  160. message: '',
  161. url: result
  162. }))
  163. fileListLen++
  164. }
  165. },
  166. uploadFilePromise(url) {
  167. console.log('jinlaile3');
  168. return new Promise((resolve, reject) => {
  169. let a = uni.uploadFile({
  170. url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
  171. filePath: url,
  172. name: 'file',
  173. formData: {
  174. user: 'test'
  175. },
  176. success: (res) => {
  177. setTimeout(() => {
  178. resolve(res.data.data)
  179. }, 1000)
  180. }
  181. });
  182. })
  183. },
  184. // deletePic(event) {
  185. // this.fileList.splice(event.index, 1);
  186. // },
  187. // overSize(e) {
  188. // uni.$u.toast('上传图片大小不能超过10MB!');
  189. // },
  190. // // 新增图片
  191. // async afterRead(event) {
  192. // console.log('jinlaile');
  193. // // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  194. // let Lists = [].concat(event.file);
  195. // let fileListLen = this.fileList.length;
  196. // Lists.map((item) => {
  197. // this.picList.push(
  198. // item.url,
  199. // )
  200. // })
  201. // for (let i = 0; i < Lists.length; i++) {
  202. // const result = await this.uploadFilePromise(Lists[i].url);
  203. // wx.getImageInfo({
  204. // src: Lists[i].url,
  205. // success: res => {
  206. // this.imgUrlList.push(result)
  207. // }
  208. // })
  209. // }
  210. // },
  211. // //上传图片
  212. // uploadFilePromise(url) {
  213. // return new Promise((resolve, reject) => {
  214. // let a = uni.uploadFile({
  215. // url: 'https://i.ringzle.com/island-cloud-server/oss/file/upload',
  216. // filePath: url,
  217. // name: 'file',
  218. // header: {
  219. // token: wx.getStorageSync('access_token')
  220. // },
  221. // success: (res) => {
  222. // let data = JSON.parse(res.data);
  223. // this.fileList.push({
  224. // url: data.data.url
  225. // })
  226. // resolve(data.data.url);
  227. // }
  228. // });
  229. // })
  230. // },
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. /deep/.u-cell__body {
  236. padding: 0;
  237. }
  238. ::v-deep .u-cell__body {
  239. padding: 0;
  240. }
  241. .pages {
  242. height: 100vh;
  243. background: #F9FAFC;
  244. .content {
  245. padding: 20rpx;
  246. height: 100vh;
  247. .card {
  248. background: #fff;
  249. border-radius: 16rpx;
  250. padding: 30rpx 33rpx;
  251. margin-bottom: 20rpx;
  252. .upload {
  253. margin-top: 48rpx;
  254. width: 100%;
  255. height: 200rpx;
  256. border-radius: 16rpx;
  257. background-color: #F5F8FA;
  258. display: flex;
  259. align-items: center;
  260. text-align: center;
  261. .upload-one {
  262. margin: 0 245rpx;
  263. width: 200rpx;
  264. height: 200rpx;
  265. image {
  266. width: 100%;
  267. height: 100%;
  268. }
  269. }
  270. }
  271. .collapseTitle {
  272. font-size: 22rpx;
  273. color: #a5a5a5;
  274. margin-bottom: 20rpx;
  275. }
  276. .card1 {
  277. display: flex;
  278. flex-direction: row;
  279. justify-content: space-between;
  280. align-items: center;
  281. }
  282. }
  283. }
  284. .bottom {
  285. position: absolute;
  286. bottom: 0;
  287. height: 9%;
  288. background: #fff;
  289. width: 100%;
  290. display: flex;
  291. justify-content: center;
  292. align-items: center;
  293. padding: 0 30rpx;
  294. box-sizing: border-box;
  295. flex-direction: column;
  296. .btn {
  297. background: #33AFFC;
  298. color: white;
  299. text-align: center;
  300. height: 73rpx;
  301. line-height: 73rpx;
  302. align-self: center;
  303. border-radius: 35rpx;
  304. width: 80%;
  305. }
  306. }
  307. }
  308. </style>