send.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <view class="container">
  3. <!-- 页面标题区域 -->
  4. <view v-if="!headerType" class="header" :style="{ height: customBarH * 2 + 'rpx', paddingTop: statusBarH * 2 + 'rpx' }">
  5. <img src="../../static/index/left2.png" :style="{ paddingTop: statusBarH * 2 + 'rpx' }" @click="handleBack" />
  6. <view class="header_text">发推文</view>
  7. </view>
  8. <view v-else class="header2" :style="{ height: customBarH * 2 + 'rpx', paddingTop: statusBarH * 2 + 'rpx' }">
  9. <img src="../../static/index/left2.png" :style="{ paddingTop: statusBarH * 2 + 'rpx' }" @click="handleBack" />
  10. <view class="header_text">发推文</view>
  11. </view>
  12. <!-- 图片视频上传展示区域 -->
  13. <view class="upload" :style="{ paddingTop: statusBarH * 2 + customBarH * 2 + 'rpx' }">
  14. <view class="upload_img" @click="handleImage">
  15. <img src="../../static/index/upload-img.png" />
  16. 添加图片
  17. </view>
  18. <view class="upload_video" @click="handleVideo">
  19. <img src="../../static/index/upload-video.png" />
  20. 添加视频
  21. </view>
  22. </view>
  23. <!-- 标题输入区域 -->
  24. <view class="title">
  25. <input class="input" type="text" placeholder-style="color:#B3B3B3" placeholder="请输入标题" v-model="titleValue" />
  26. </view>
  27. <!-- 推文内容输入区域 -->
  28. <view class="content">
  29. <textarea class="textarea" placeholder-style="color:#B3B3B3" maxlength="3000" placeholder="请分享你的故事吧~" v-model="contentValue"></textarea>
  30. <!-- 内容长度 -->
  31. <view class="textarea_length">{{ contentValue.length }}/3000</view>
  32. </view>
  33. <!-- 添加地点区域 -->
  34. <view class="add_place" @click="handleGoPage('/pages/addPlace/addPlace')">
  35. <img class="img" src="../../static/index/send-address.png" />
  36. 添加地点
  37. <img class="img2" src="../../static/index/send-right.png" />
  38. </view>
  39. <!-- 关联民宿区域 -->
  40. <view class="and">
  41. <img class="img" src="../../static/index/send-binding.png" />
  42. 关联民宿
  43. </view>
  44. <!-- 关联民宿列表区域 -->
  45. <view class="and_list">
  46. <!-- 每一个民宿区域 -->
  47. <view class="and_box" :class="{ active: item.is_collect_hotel }" v-for="item in andList" :key="item.id" @click="handleChange(item)">{{ item.hotel_name }}</view>
  48. </view>
  49. <!-- 发布按钮区域 -->
  50. <view class="sub_btn" @click="handleClickSub">发布</view>
  51. <!-- 状态弹窗区域 -->
  52. <uni-popup ref="popup" :is-mask-click="false" type="center">
  53. <view class="popup_body">
  54. <img src="../../static/index/success.png" />
  55. <view class="msg">发布成功</view>
  56. <view class="btn" @click="handleClickLook">查看推文</view>
  57. </view>
  58. </uni-popup>
  59. </view>
  60. </template>
  61. <script>
  62. export default {
  63. data() {
  64. return {
  65. // 顶部页面标题栏显示隐藏控制
  66. headerType: false,
  67. // 状态栏高度
  68. statusBarH: 0,
  69. // 胶囊按钮栏高度
  70. customBarH: 0,
  71. // 标题数据
  72. titleValue: '',
  73. // 推文内容区域
  74. contentValue: '',
  75. // activeIndex: null,
  76. // 关联民宿列表
  77. andList: []
  78. }
  79. },
  80. created() {
  81. // 获取系统信息
  82. uni.getSystemInfo({
  83. success: (e) => {
  84. // 获取状态栏高度
  85. this.statusBarH = e.statusBarHeight + 10
  86. // // 获取菜单按钮栏高度
  87. let custom = uni.getMenuButtonBoundingClientRect()
  88. this.customBarH = custom.height + 10
  89. }
  90. })
  91. },
  92. onLoad() {
  93. uni.$on('add', this.add)
  94. },
  95. onPageScroll(e) {
  96. if (e.scrollTop > 50) {
  97. this.headerType = true
  98. } else {
  99. this.headerType = false
  100. }
  101. },
  102. methods: {
  103. // 切换关联民宿回调
  104. handleChange(item) {
  105. item.is_collect_hotel = !item.is_collect_hotel
  106. // this.activeIndex = index
  107. },
  108. // 点击添加图片回调
  109. handleImage() {
  110. uni.chooseMedia({
  111. count: 9,
  112. mediaType: ['image'],
  113. success: (res) => {
  114. console.log(res.tempFiles)
  115. }
  116. })
  117. },
  118. // 点击添加视频回调
  119. handleVideo() {
  120. uni.chooseMedia({
  121. count: 9,
  122. mediaType: ['video'],
  123. success: (res) => {
  124. console.log(res.tempFiles)
  125. }
  126. })
  127. },
  128. // 点击添加地点回调
  129. handleGoPage(url) {
  130. uni.navigateTo({
  131. url
  132. })
  133. },
  134. // 全局自定义事件
  135. add(e) {
  136. this.andList = e.list
  137. },
  138. // 点击发布按钮回调
  139. handleClickSub() {
  140. console.log(this.andList)
  141. let temList = this.andList.filter((ele) => ele.is_collect_hotel)
  142. console.log(temList)
  143. this.$refs.popup.open()
  144. },
  145. // 点击弹窗查看推文按钮回调
  146. handleClickLook() {
  147. this.$refs.popup.close()
  148. },
  149. handleBack() {
  150. uni.navigateBack(1)
  151. }
  152. }
  153. }
  154. </script>
  155. <style lang="scss">
  156. .container {
  157. padding-bottom: 80rpx;
  158. min-height: 100vh;
  159. background-color: #fff;
  160. .header {
  161. position: fixed;
  162. top: 0;
  163. left: 0;
  164. right: 0;
  165. display: flex;
  166. justify-content: center;
  167. // position: relative;
  168. background-color: #fff;
  169. img {
  170. position: absolute;
  171. top: 0;
  172. left: 0;
  173. width: 47rpx;
  174. height: 47rpx;
  175. }
  176. .header_text {
  177. font-size: 34rpx;
  178. }
  179. }
  180. .header2 {
  181. position: fixed;
  182. top: 0;
  183. left: 0;
  184. right: 0;
  185. display: flex;
  186. justify-content: center;
  187. background-color: #fff;
  188. img {
  189. position: absolute;
  190. top: 0;
  191. left: 0;
  192. width: 47rpx;
  193. height: 47rpx;
  194. }
  195. .header_text {
  196. font-size: 34rpx;
  197. }
  198. }
  199. .upload {
  200. margin-top: 30rpx;
  201. padding-bottom: 10rpx;
  202. display: flex;
  203. .upload_img {
  204. display: flex;
  205. flex-direction: column;
  206. justify-content: center;
  207. align-items: center;
  208. margin-left: 20rpx;
  209. width: 186rpx;
  210. height: 283rpx;
  211. color: #999999;
  212. font-size: 28rpx;
  213. border-radius: 8rpx;
  214. background-color: #e6e6e6;
  215. img {
  216. margin-top: 10rpx;
  217. width: 68rpx;
  218. height: 68rpx;
  219. }
  220. }
  221. .upload_video {
  222. display: flex;
  223. flex-direction: column;
  224. justify-content: center;
  225. align-items: center;
  226. margin-left: 26rpx;
  227. width: 186rpx;
  228. height: 283rpx;
  229. color: #999999;
  230. font-size: 28rpx;
  231. border-radius: 8rpx;
  232. background-color: #e6e6e6;
  233. img {
  234. margin-top: 12rpx;
  235. width: 68rpx;
  236. height: 68rpx;
  237. }
  238. }
  239. }
  240. .title {
  241. margin: auto;
  242. width: 710rpx;
  243. height: 100rpx;
  244. border-bottom: 1rpx solid #e5e5e5;
  245. .input {
  246. box-sizing: border-box;
  247. padding-right: 20rpx;
  248. width: 100%;
  249. height: 100%;
  250. font-size: 32rpx;
  251. }
  252. }
  253. .content {
  254. margin: auto;
  255. width: 710rpx;
  256. height: 290rpx;
  257. font-size: 28rpx;
  258. color: #b3b3b3;
  259. border-bottom: 1rpx solid #e5e5e5;
  260. .textarea {
  261. margin-top: 25rpx;
  262. width: 100%;
  263. height: 240rpx;
  264. }
  265. .textarea_length {
  266. margin-top: 5rpx;
  267. text-align: end;
  268. }
  269. }
  270. .add_place {
  271. display: flex;
  272. align-items: center;
  273. margin: auto;
  274. width: 710rpx;
  275. height: 100rpx;
  276. font-size: 28rpx;
  277. border-bottom: 1rpx solid #e5e5e5;
  278. .img {
  279. margin-right: 10rpx;
  280. width: 55rpx;
  281. height: 55rpx;
  282. }
  283. .img2 {
  284. margin-left: auto;
  285. width: 40rpx;
  286. height: 40rpx;
  287. }
  288. }
  289. .and {
  290. display: flex;
  291. align-items: center;
  292. margin: auto;
  293. width: 710rpx;
  294. height: 88rpx;
  295. font-size: 28rpx;
  296. .img {
  297. margin-left: 10rpx;
  298. margin-right: 8rpx;
  299. width: 42rpx;
  300. height: 42rpx;
  301. }
  302. }
  303. .and_list {
  304. display: flex;
  305. flex-wrap: wrap;
  306. margin: auto;
  307. width: 710rpx;
  308. .and_box {
  309. margin-bottom: 20rpx;
  310. margin-right: 16rpx;
  311. padding: 0 44rpx;
  312. display: flex;
  313. justify-content: center;
  314. align-items: center;
  315. height: 55rpx;
  316. color: #999999;
  317. font-size: 24rpx;
  318. border-radius: 66rpx;
  319. background-color: #f2f2f2;
  320. }
  321. .active {
  322. color: #fff;
  323. background-color: #096562;
  324. }
  325. }
  326. .sub_btn {
  327. display: flex;
  328. justify-content: center;
  329. align-items: center;
  330. margin: 310rpx auto 0;
  331. width: 710rpx;
  332. height: 100rpx;
  333. color: #fff;
  334. font-size: 32rpx;
  335. border-radius: 64rpx;
  336. background-color: #096562;
  337. }
  338. .popup_body {
  339. display: flex;
  340. flex-direction: column;
  341. justify-content: space-evenly;
  342. align-items: center;
  343. width: 481rpx;
  344. height: 404rpx;
  345. border-radius: 23rpx;
  346. background-color: #fff;
  347. img {
  348. width: 112rpx;
  349. height: 112rpx;
  350. }
  351. .msg {
  352. color: #0f194d;
  353. font-size: 28rpx;
  354. }
  355. .btn {
  356. display: flex;
  357. justify-content: center;
  358. align-items: center;
  359. width: 396rpx;
  360. height: 76rpx;
  361. font-size: 26rpx;
  362. color: #fff;
  363. border-radius: 43rpx;
  364. background: linear-gradient(90deg, rgba(11, 193, 150, 1) 0%, rgba(9, 101, 98, 1) 100%);
  365. }
  366. }
  367. }
  368. </style>