stayInfo.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="pages" :style="{'height':(h)+'px','padding-top':mt+'px'}">
  3. <c-nav-bar title="酒店民宿信息" :showIcon="true"></c-nav-bar>
  4. <view class="content">
  5. <view class="card" @click="goToPosition()">
  6. <text class="label">位置定位</text>
  7. <u-icon name="arrow-right" size="24"></u-icon>
  8. </view>
  9. <view class="card">
  10. <text class="label">联系电话</text>
  11. <u--input inputAlign="right" placeholder="请输入内容" border="none" v-model="stayInfo.landlinePhone"
  12. style="text-align: right;"></u--input>
  13. </view>
  14. <view class="card c2">
  15. <view class="tit">酒店简介</view>
  16. <view>
  17. <u--textarea customStyle="font-size:28rpx;line-height:28rpx" border='none' maxlength="300" count
  18. v-model="stayInfo.introduction" :value="stayInfo.introduction" placeholder="请输入酒店简介"
  19. height='360'></u--textarea>
  20. </view>
  21. </view>
  22. <view class="card c2">
  23. <view class="tit">内饰照片</view>
  24. <view class="imgs">
  25. <!-- <image src="" v-for="(item,index) in imgUrlList" :key="index"></image> -->
  26. <u-upload ref="uUpload" uploadText="上传图片" :fileList="imgUrlList" :maxSize="10 * 1024 * 1024"
  27. width="180" height="120" @afterRead="afterRead" @delete="deletePic">
  28. </u-upload>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="bottom">
  33. <view class="btn" @click="save()">
  34. 确定
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. homestayId: uni.getStorageSync('homestayId') || 0,
  44. value: '',
  45. value1: '',
  46. fileList: [],
  47. fileList1: [],
  48. imgUrlList: [],
  49. fileList2: [],
  50. stayInfo: {
  51. picList: []
  52. },
  53. }
  54. },
  55. onLoad() {
  56. this.getStayInfo()
  57. },
  58. filters: {
  59. // 去除富文本标签样式
  60. removeHtmlStyle(html) {
  61. const relStyle = /style\s*?=\s*?(['"])[\s\S]*?\1/g
  62. const relTag = /<.+?>/g
  63. const relClass = /class\s*?=\s*?(['"])[\s\S]*?\1/g
  64. let newHtml = ''
  65. if (html) {
  66. newHtml = html.replace(relStyle, '')
  67. newHtml = newHtml.replace(relTag, '')
  68. newHtml = newHtml.replace(relClass, '')
  69. }
  70. return newHtml
  71. }
  72. },
  73. methods: {
  74. goToPosition() {
  75. const qwe = JSON.stringify(this.stayInfo)
  76. uni.navigateTo({
  77. url: '/pagesMy/stayInfo/roomPosition?item=' + JSON.stringify(this.stayInfo)
  78. })
  79. },
  80. getStayInfo() {
  81. this.$api.get('/merchant/hotel/mine/getMerchantHomestayInfo/' + this.homestayId).then(res => {
  82. if (res.data.code == 0) {
  83. this.stayInfo = res.data.data;
  84. this.stayInfo.picList.forEach((item) => {
  85. this.imgUrlList.push({
  86. url: item
  87. })
  88. })
  89. }
  90. })
  91. },
  92. // 删除图片
  93. deletePic(event) {
  94. this.imgUrlList.splice(event.index, 1)
  95. },
  96. // 新增图片
  97. async afterRead(event) {
  98. let lists = [].concat(event.file)
  99. let fileListLen = this.imgUrlList.length
  100. lists.map((item) => {
  101. this.imgUrlList.push({
  102. ...item,
  103. status: 'uploading',
  104. message: '上传中'
  105. })
  106. })
  107. for (let i = 0; i < lists.length; i++) {
  108. const result = await this.uploadFilePromise(lists[i].url)
  109. let item = this.imgUrlList[fileListLen]
  110. this.imgUrlList.splice(fileListLen, 1, Object.assign(item, {
  111. status: 'success',
  112. message: '',
  113. url: result
  114. }))
  115. fileListLen++
  116. }
  117. console.log(this.imgUrlList)
  118. },
  119. uploadFilePromise(url) {
  120. return new Promise((resolve, reject) => {
  121. let a = uni.uploadFile({
  122. url: 'https://i.ringzle.com/island-cloud-server/oss/file/aliyunUpload', // 仅为示例,非真实的接口地址
  123. filePath: url,
  124. name: 'file',
  125. formData: {
  126. user: 'test'
  127. },
  128. success: (res) => {
  129. console.log(res)
  130. let data = JSON.parse(res.data);
  131. console.log(data)
  132. resolve(data.data.url)
  133. }
  134. });
  135. })
  136. },
  137. // 确定保存
  138. save() {
  139. // if (!this.$u.test.mobile(this.stayInfo.landlinePhone)) {
  140. // this.$showToast('请输入正确手机号');
  141. // return
  142. // }
  143. this.stayInfo.picList = [];
  144. this.imgUrlList.forEach((i) => {
  145. if (i.url) {
  146. this.stayInfo.picList.push(i.url)
  147. }
  148. })
  149. this.$api.post('/merchant/hotel/mine/updMHomestayInfo', this.stayInfo).then(res => {
  150. console.log(res)
  151. })
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="less">
  157. .u-upload__wrap__preview__image {
  158. width: 190rpx !important;
  159. height: 120rpx !important;
  160. }
  161. .u-upload__button {
  162. width: 190rpx !important;
  163. height: 120rpx !important;
  164. }
  165. </style>
  166. <style lang="scss" scoped>
  167. /deep/.u-cell__body {
  168. padding: 0;
  169. }
  170. ::v-deep .u-icon__icon {
  171. font-size: 30rpx !important;
  172. margin-bottom: 10rpx;
  173. left: 2rpx !important;
  174. top: 6rpx !important;
  175. }
  176. ::v-deep .u-upload__button__text {
  177. color: #B9C2D0 !important;
  178. font-size: 20rpx !important;
  179. }
  180. ::v-deep .u-cell__body {
  181. padding: 0;
  182. }
  183. .pages {
  184. background: #F9FAFC;
  185. .content {
  186. padding: 20rpx 30rpx;
  187. height: 100vh;
  188. .card {
  189. background: #fff;
  190. border-radius: 16rpx;
  191. padding: 30rpx;
  192. margin-bottom: 20rpx;
  193. display: flex;
  194. align-items: center;
  195. justify-content: space-between;
  196. &.c2 {
  197. display: block;
  198. }
  199. .label {
  200. font-size: 30rpx;
  201. }
  202. .tit {
  203. font-size: 30rpx;
  204. font-weight: bold;
  205. margin-bottom: 20rpx;
  206. }
  207. .upload {
  208. margin-top: 48rpx;
  209. width: 100%;
  210. height: 200rpx;
  211. border-radius: 16rpx;
  212. background-color: #F5F8FA;
  213. display: flex;
  214. align-items: center;
  215. text-align: center;
  216. .upload-one {
  217. margin: 0 245rpx;
  218. width: 200rpx;
  219. height: 200rpx;
  220. image {
  221. width: 100%;
  222. height: 100%;
  223. }
  224. }
  225. }
  226. }
  227. }
  228. .bottom {
  229. z-index: 99999;
  230. position: fixed;
  231. bottom: 0;
  232. background: #fff;
  233. width: 100%;
  234. padding: 20rpx 0 30rpx;
  235. box-sizing: border-box;
  236. z-index: 99999999;
  237. .btn {
  238. background: #33AFFC;
  239. color: white;
  240. text-align: center;
  241. height: 96rpx;
  242. margin: 0 auto;
  243. font-size: 34rpx;
  244. line-height: 96rpx;
  245. align-self: center;
  246. border-radius: 48rpx;
  247. width: 690rpx;
  248. }
  249. }
  250. }
  251. </style>