stayInfo.vue 8.9 KB

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