瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

392 lines
7.5 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. <template>
  2. <view class="publishPost">
  3. <navbar
  4. leftClick
  5. @leftClick="$utils.navigateBack"
  6. title="发布动态"/>
  7. <!-- <view class="title-input box">
  8. <input type="text" placeholder="取个吸引人的标题吧" v-model="form.title"/>
  9. </view> -->
  10. <view class="content-input">
  11. <uv-textarea
  12. v-model="form.title"
  13. :maxlength="200"
  14. autoHeight
  15. count
  16. style="min-height: 400rpx;"
  17. placeholder="说点什么吧"></uv-textarea>
  18. </view>
  19. <view class="images box">
  20. <uv-upload
  21. :fileList="fileList"
  22. :maxCount="imageMax"
  23. multiple
  24. width="150rpx"
  25. height="150rpx"
  26. @delete="deleteImage"
  27. @afterRead="afterRead"
  28. :previewFullImage="true"></uv-upload>
  29. </view>
  30. <view class="category">
  31. <view class="title">
  32. 选择分类
  33. </view>
  34. <view class="tagList">
  35. <view
  36. :class="{act : t.id == form.classId}"
  37. @click="clickCategory(t, i)"
  38. v-for="(t, i) in category"
  39. :key="i">
  40. {{ t.title }}
  41. </view>
  42. </view>
  43. </view>
  44. <!-- <view class="category">
  45. <view class="title">
  46. 选择地区
  47. </view>
  48. <view class="tagList">
  49. <view
  50. :class="{act : t.name == form.address}"
  51. @click="clickAddress(t, i)"
  52. v-for="(t, i) in cityList"
  53. :key="i">
  54. {{ t.name }}
  55. </view>
  56. </view>
  57. </view> -->
  58. <view class="title-input box">
  59. <input type="text" placeholder="手机号码(选填)" v-model="form.phone"/>
  60. </view>
  61. <view class="title-input box"
  62. @click="selectAddr">
  63. <input type="text"
  64. placeholder="选择位置(选填)"
  65. v-model="form.address"/>
  66. <uv-icon
  67. size="40rpx"
  68. name="map"></uv-icon>
  69. </view>
  70. <!-- <view class="upTop"
  71. >
  72. <view class="title">
  73. <uv-icon name="pushpin-fill"></uv-icon>
  74. 是否置顶
  75. </view>
  76. <uv-radio-group v-model="form.topId">
  77. <view class="list">
  78. <view class="item">
  79. <view class="left">
  80. 不需要置顶
  81. </view>
  82. <view class="right">
  83. <uv-radio
  84. size="35rpx"
  85. icon-size="35rpx"
  86. :disabled="!!id"
  87. :name="0">
  88. </uv-radio>
  89. </view>
  90. </view>
  91. <view class="item"
  92. v-for="(item, index) in upTopList"
  93. :key="index">
  94. <view class="left">
  95. 置顶{{ item.day }}{{ item.money }}
  96. </view>
  97. <view class="right">
  98. <uv-radio
  99. size="35rpx"
  100. :disabled="!!id"
  101. icon-size="35rpx"
  102. :name="item.id">
  103. </uv-radio>
  104. </view>
  105. </view>
  106. </view>
  107. </uv-radio-group>
  108. </view> -->
  109. <view class="configBtn"
  110. @click="$refs.configPopup.open('getPublishPostNotice')">
  111. 发布须知
  112. </view>
  113. <view class="uni-color-btn"
  114. @click="submit">
  115. 发布
  116. </view>
  117. <configPopup
  118. ref="configPopup"
  119. />
  120. </view>
  121. </template>
  122. <script>
  123. import { mapState } from 'vuex'
  124. import Position from '@/utils/position.js'
  125. export default {
  126. components : {
  127. },
  128. data() {
  129. return {
  130. form : {
  131. title : '',
  132. classId : 0,
  133. address : '',
  134. phone : '',
  135. },
  136. id : 0,
  137. fileList : [],
  138. imageMax : 9,
  139. };
  140. },
  141. computed : {
  142. ...mapState(['cityList', 'category']),
  143. },
  144. onLoad(args) {
  145. this.id = args.id
  146. this.form.classId = this.category[0].id
  147. // this.form.address = this.cityList[0].name
  148. this.imageMax = args.imageMax || 9
  149. this.getDateil()
  150. },
  151. onShow() {
  152. this.$store.commit('getCategory')
  153. },
  154. methods : {
  155. clickCategory(item, index){
  156. this.form.classId = item.id
  157. },
  158. clickAddress(item, index){
  159. this.form.address = item.name
  160. },
  161. getDateil(){
  162. if(!this.id){
  163. return
  164. }
  165. let self = this
  166. this.$api('getPostDetail', {
  167. id : this.id
  168. }, res => {
  169. if (res.code == 200) {
  170. self.form.id = res.result.id
  171. self.form.title = res.result.title
  172. self.form.address = res.result.address || self.form.address
  173. self.form.classId = res.result.classId || self.form.classId
  174. self.form.latitude = res.result.latitude || self.form.latitude
  175. self.form.longitude = res.result.longitude || self.form.longitude
  176. if(res.result.image){
  177. res.result.image.split(',')
  178. .forEach(url => {
  179. self.fileList.push({
  180. url
  181. })
  182. })
  183. }
  184. }
  185. })
  186. },
  187. deleteImage(e){
  188. this.fileList.splice(e.index, 1)
  189. },
  190. afterRead(e){
  191. let self = this
  192. e.file.forEach(file => {
  193. self.$Oss.ossUpload(file.url).then(url => {
  194. self.fileList.push({
  195. url
  196. })
  197. })
  198. })
  199. },
  200. // 提交
  201. submit(){
  202. // if(this.fileList.length == 0){
  203. // return uni.showToast({
  204. // title: '请上传图片',
  205. // icon : 'none'
  206. // })
  207. // }
  208. if (this.$utils.verificationAll(this.form, {
  209. title: '说点什么吧',
  210. })) {
  211. return
  212. }
  213. this.form.image = this.fileList.map((item) => item.url).join(",")
  214. this.$api('publishPost', this.form, res => {
  215. if(res.code == 200){
  216. uni.showToast({
  217. title: '发布成功!',
  218. icon: 'none'
  219. })
  220. setTimeout(uni.navigateBack, 1000, -1)
  221. }
  222. })
  223. },
  224. //地图上选择地址
  225. selectAddr() {
  226. Position.selectAddress(success => {
  227. this.setAddress(success)
  228. })
  229. },
  230. //提取用户选择的地址信息复制给表单数据
  231. setAddress(res) {
  232. //经纬度信息
  233. this.form.latitude = res.latitude
  234. this.form.longitude = res.longitude
  235. if (res.name) { //用户直接选择城市的逻辑
  236. // if (!res.address && res.name) { //用户直接选择城市的逻辑
  237. return this.form.address = res.name
  238. }
  239. // if (res.address || res.name) {
  240. // return this.form.address = res.address + res.name
  241. // }
  242. this.form.address = '' //用户啥都没选就点击勾选
  243. this.form.latitude = ''
  244. this.form.longitude = ''
  245. },
  246. preview(){},
  247. draft(){},
  248. }
  249. }
  250. </script>
  251. <style lang="scss" scoped>
  252. .publishPost{
  253. background-color: #fff;
  254. min-height: 100vh;
  255. font-size: 28rpx;
  256. padding-bottom: 150rpx;
  257. /deep/ .uv-textarea{
  258. background-color: transparent;
  259. border: none;
  260. }
  261. /deep/ .uv-textarea__count{
  262. background-color: transparent !important;
  263. }
  264. .box{
  265. padding: 0 20rpx;
  266. }
  267. .images{
  268. display: flex;
  269. flex-wrap: wrap;
  270. padding: 20rpx;
  271. }
  272. .title-input{
  273. margin: 10rpx;
  274. border-bottom: 1px solid #00000015;
  275. padding-bottom: 25rpx;
  276. margin-bottom: 15rpx;
  277. display: flex;
  278. align-items: center;
  279. justify-content: space-between;
  280. input{
  281. width: 100%;
  282. }
  283. }
  284. .content-input{
  285. min-height: 400rpx;
  286. /deep/ .uv-textarea{
  287. min-height: 400rpx;
  288. }
  289. }
  290. .upTop{
  291. .title{
  292. padding-top: 20rpx;
  293. padding-left: 20rpx;
  294. border-top: 1px solid #00000015;
  295. display: flex;
  296. align-items: center;
  297. }
  298. .list{
  299. padding-top: 30rpx;
  300. width: 100%;
  301. .item{
  302. display: flex;
  303. padding: 20rpx;
  304. padding-left: 80rpx;
  305. justify-content: space-between;
  306. width: 600rpx;
  307. border-bottom: 1px solid #00000015;
  308. align-items: center;
  309. }
  310. }
  311. }
  312. .configBtn{
  313. padding: 20rpx;
  314. color: #777;
  315. padding-top: 40rpx;
  316. font-size: 28rpx;
  317. }
  318. .confirmationPopup{
  319. display: flex;
  320. flex-direction: column;
  321. align-items: center;
  322. justify-content: center;
  323. width: 100%;
  324. height: 300rpx;
  325. image{
  326. margin-top: 40rpx;
  327. }
  328. .info{
  329. margin-top: 40rpx;
  330. font-size: 26rpx;
  331. }
  332. }
  333. }
  334. .category{
  335. padding: 20rpx;
  336. .title{
  337. // font-weight: 900;
  338. // font-size: 30rpx;
  339. }
  340. .tagList{
  341. display: flex;
  342. flex-wrap: wrap;
  343. padding: 10rpx 0;
  344. view{
  345. background: rgba($uni-color, 0.1);
  346. padding: 10rpx 20rpx;
  347. margin: 10rpx;
  348. border-radius: 10rpx;
  349. font-size: 26rpx;
  350. }
  351. .act{
  352. color: #fff;
  353. background: $uni-color;
  354. }
  355. }
  356. }
  357. </style>