瑶都万能墙
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.

400 lines
7.8 KiB

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