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

455 lines
9.0 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
7 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 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. disabled
  87. v-model="form.address"/>
  88. <uv-icon
  89. size="40rpx"
  90. name="map"></uv-icon>
  91. </view>
  92. <view class="title-input box"
  93. @click="$refs.pickerHospital.open()"
  94. v-if="categoryRole.includes('shop')">
  95. <input type="text"
  96. v-if="!form.shop"
  97. placeholder="关联店铺(选填)"/>
  98. <view class="shop-box"
  99. v-else>
  100. <view class="title">
  101. {{ form.shop.title }}
  102. </view>
  103. <view class="desc">
  104. {{ form.shop.address }}
  105. </view>
  106. </view>
  107. </view>
  108. <view class="configBtn"
  109. @click="$refs.configPopup.open()">
  110. 发布须知
  111. </view>
  112. <view class="uni-color-btn"
  113. @click="submit">
  114. 发布
  115. </view>
  116. <configPopup
  117. ref="configPopup"
  118. :text="headInfo.save_no && headInfo.save_no.keyDetails"
  119. />
  120. <pickerHospital
  121. mixinsListApi="getStorePage"
  122. descKeyName="address"
  123. keyName="title"
  124. searchKey="title"
  125. ref="pickerHospital"
  126. @select="selectShop"
  127. />
  128. </view>
  129. </template>
  130. <script>
  131. import { mapState } from 'vuex'
  132. import Position from '@/utils/position.js'
  133. import pickerHospital from '@/components/base/pickerHospital.vue'
  134. export default {
  135. components : {
  136. pickerHospital,
  137. },
  138. data() {
  139. return {
  140. form : {
  141. title : '',
  142. classId : 0,
  143. address : '',
  144. phone : '',
  145. shop : '',
  146. },
  147. id : 0,
  148. fileList : [],
  149. codeFileList : [],
  150. imageMax : 9,
  151. };
  152. },
  153. computed : {
  154. ...mapState(['cityList', 'category', 'headInfo']),
  155. categoryRole(){
  156. if(!this.form.classId){
  157. return []
  158. }
  159. for(let i = 0;i < this.category.length;i++){
  160. let c = this.category[i]
  161. if(c.id == this.form.classId){
  162. return c.linkType ? c.linkType.split(',') : []
  163. // return 'code,phone,address,shop'.split(',')
  164. }
  165. }
  166. return []
  167. },
  168. },
  169. onLoad(args) {
  170. this.id = args.id
  171. this.form.classId = this.category[0].id
  172. // this.form.address = this.cityList[0].name
  173. this.imageMax = args.imageMax || 9
  174. this.getDateil()
  175. },
  176. onShow() {
  177. this.$store.commit('getCategory')
  178. },
  179. methods : {
  180. clickCategory(item, index){
  181. this.form.classId = item.id
  182. },
  183. clickAddress(item, index){
  184. this.form.address = item.name
  185. },
  186. getDateil(){
  187. if(!this.id){
  188. return
  189. }
  190. let self = this
  191. this.$api('getPostDetail', {
  192. id : this.id
  193. }, res => {
  194. if (res.code == 200) {
  195. self.form.id = res.result.id
  196. self.form.title = res.result.title
  197. self.form.address = res.result.address || self.form.address
  198. self.form.classId = res.result.classId || self.form.classId
  199. self.form.latitude = res.result.latitude || self.form.latitude
  200. self.form.longitude = res.result.longitude || self.form.longitude
  201. self.form.shop = res.result.shop || self.form.shop
  202. self.form.shopId = res.result.shopId || self.form.shopId
  203. if(res.result.wxImage){
  204. self.codeFileList = [
  205. {
  206. url : res.result.wxImage
  207. }
  208. ]
  209. }
  210. if(res.result.image){
  211. res.result.image.split(',')
  212. .forEach(url => {
  213. self.fileList.push({
  214. url
  215. })
  216. })
  217. }
  218. }
  219. })
  220. },
  221. deleteImage(e){
  222. this[e.name].splice(e.index, 1)
  223. },
  224. afterRead(e){
  225. let self = this
  226. e.file.forEach(file => {
  227. self.$Oss.ossUpload(file.url).then(url => {
  228. self[e.name].push({
  229. url
  230. })
  231. })
  232. })
  233. },
  234. // 提交
  235. submit(){
  236. // if(this.fileList.length == 0){
  237. // return uni.showToast({
  238. // title: '请上传图片',
  239. // icon : 'none'
  240. // })
  241. // }
  242. if (this.$utils.verificationAll(this.form, {
  243. title: '说点什么吧',
  244. })) {
  245. return
  246. }
  247. if(this.categoryRole.includes('code') && this.codeFileList.length == 0){
  248. return uni.showToast({
  249. title: '请上传微信二维码',
  250. icon : 'none'
  251. })
  252. }
  253. delete this.form.shop
  254. this.form.image = this.fileList.map((item) => item.url).join(",")
  255. this.form.wxImage = this.codeFileList.map((item) => item.url).join(",")
  256. this.$api('publishPost', this.form, res => {
  257. if(res.code == 200){
  258. uni.showToast({
  259. title: '发布成功!',
  260. icon: 'none'
  261. })
  262. setTimeout(uni.navigateBack, 1000, -1)
  263. }
  264. })
  265. },
  266. //地图上选择地址
  267. selectAddr() {
  268. Position.selectAddress(success => {
  269. this.setAddress(success)
  270. })
  271. },
  272. //提取用户选择的地址信息复制给表单数据
  273. setAddress(res) {
  274. //经纬度信息
  275. this.form.latitude = res.latitude
  276. this.form.longitude = res.longitude
  277. if (res.name) { //用户直接选择城市的逻辑
  278. // if (!res.address && res.name) { //用户直接选择城市的逻辑
  279. return this.form.address = res.name
  280. }
  281. // if (res.address || res.name) {
  282. // return this.form.address = res.address + res.name
  283. // }
  284. this.form.address = '' //用户啥都没选就点击勾选
  285. this.form.latitude = ''
  286. this.form.longitude = ''
  287. },
  288. // 选择关联的店铺
  289. selectShop(shop){
  290. this.form.shop = shop
  291. this.form.shopId = shop.id
  292. this.$refs.pickerHospital.close()
  293. },
  294. }
  295. }
  296. </script>
  297. <style lang="scss" scoped>
  298. .publishPost{
  299. background-color: #fff;
  300. min-height: 100vh;
  301. font-size: 28rpx;
  302. padding-bottom: 150rpx;
  303. /deep/ .uv-textarea{
  304. background-color: transparent;
  305. border: none;
  306. }
  307. /deep/ .uv-textarea__count{
  308. background-color: transparent !important;
  309. }
  310. .box{
  311. padding: 0 20rpx;
  312. }
  313. .images{
  314. display: flex;
  315. flex-wrap: wrap;
  316. padding: 20rpx;
  317. }
  318. .title-input{
  319. margin: 10rpx;
  320. border-bottom: 1px solid #00000015;
  321. padding-bottom: 25rpx;
  322. margin-bottom: 15rpx;
  323. display: flex;
  324. align-items: center;
  325. justify-content: space-between;
  326. input{
  327. width: 100%;
  328. }
  329. .shop-box{
  330. .title{
  331. font-size: 28rpx;
  332. }
  333. .desc{
  334. margin-top: 10rpx;
  335. color: #888;
  336. font-size: 24rpx;
  337. }
  338. }
  339. }
  340. .content-input{
  341. min-height: 400rpx;
  342. /deep/ .uv-textarea{
  343. min-height: 400rpx;
  344. }
  345. }
  346. .upTop{
  347. .title{
  348. padding-top: 20rpx;
  349. padding-left: 20rpx;
  350. border-top: 1px solid #00000015;
  351. display: flex;
  352. align-items: center;
  353. }
  354. .list{
  355. padding-top: 30rpx;
  356. width: 100%;
  357. .item{
  358. display: flex;
  359. padding: 20rpx;
  360. padding-left: 80rpx;
  361. justify-content: space-between;
  362. width: 600rpx;
  363. border-bottom: 1px solid #00000015;
  364. align-items: center;
  365. }
  366. }
  367. }
  368. .configBtn{
  369. padding: 20rpx;
  370. color: #777;
  371. padding-top: 40rpx;
  372. font-size: 28rpx;
  373. }
  374. .confirmationPopup{
  375. display: flex;
  376. flex-direction: column;
  377. align-items: center;
  378. justify-content: center;
  379. width: 100%;
  380. height: 300rpx;
  381. image{
  382. margin-top: 40rpx;
  383. }
  384. .info{
  385. margin-top: 40rpx;
  386. font-size: 26rpx;
  387. }
  388. }
  389. }
  390. .category{
  391. padding: 20rpx;
  392. .title{
  393. // font-weight: 900;
  394. // font-size: 30rpx;
  395. }
  396. .tagList{
  397. display: flex;
  398. flex-wrap: wrap;
  399. padding: 10rpx 0;
  400. view{
  401. background: rgba($uni-color, 0.1);
  402. padding: 10rpx 20rpx;
  403. margin: 10rpx;
  404. border-radius: 10rpx;
  405. font-size: 26rpx;
  406. }
  407. .act{
  408. color: #fff;
  409. background: $uni-color;
  410. }
  411. }
  412. }
  413. </style>