creat_news.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <template>
  2. <view class="real-name">
  3. <!-- <view class="history">
  4. 历史发布
  5. </view> -->
  6. <view class="item">
  7. <view class="label">
  8. <view class="star">
  9. *
  10. </view>
  11. 新闻标题
  12. </view>
  13. <view class="right" @click="goEdit('新闻标题', 1)">
  14. {{form.title ? form.title : '去填写'}}
  15. <u-icon name="arrow-right" size="20" margin-left="20"></u-icon>
  16. </view>
  17. </view>
  18. <view class="item">
  19. <view class="label">
  20. <view class="star">
  21. *
  22. </view>
  23. 封面图
  24. </view>
  25. <view class="right" @click="goEdit('封面图', 2)">
  26. {{form.cover ? '已上传' : '去上传(最佳尺寸比例:92*76)'}}
  27. <u-icon name="arrow-right" size="20" margin-left="20"></u-icon>
  28. </view>
  29. </view>
  30. <view class="item">
  31. <view class="label">
  32. <view class="star">
  33. *
  34. </view>
  35. 新闻内容
  36. </view>
  37. <view class="right" @click="goEdit('新闻内容',3)">
  38. {{form.body ? '已填写' : '点击填写'}}
  39. <u-icon name="arrow-right" size="20" margin-left="20"></u-icon>
  40. </view>
  41. </view>
  42. <view class="item">
  43. <view class="label">
  44. <view class="star">
  45. *
  46. </view>
  47. 新闻类型
  48. </view>
  49. <view class="right" @click="is_shape = true">
  50. {{form.category_id?form.category_id == 1?'新闻资讯':'校园风采':'请选择'}}
  51. <u-icon name="arrow-right" size="20" margin-left="20"></u-icon>
  52. </view>
  53. <u-picker v-model="is_shape" mode="selector" :range="selector" @confirm="shape_choose"></u-picker>
  54. </view>
  55. <view class="item">
  56. <view class="label">
  57. <view class="star">
  58. *
  59. </view>
  60. 新闻简介
  61. </view>
  62. <!-- <view class="right jianjie">
  63. <u-input v-model="form.short_description" input-align="right" style="display: inline-block;" placeholderStyle="color: #282828;"/>
  64. <u-icon class="icon" name="arrow-right" size="20"></u-icon>
  65. </view> -->
  66. </view>
  67. <view class="item item_j">
  68. <view class="right jianjie">
  69. <u-input v-model="form.short_description" :border="true" type="textarea" />
  70. </view>
  71. </view>
  72. <!-- <view class="item">
  73. <view class="label">
  74. <view class="star">
  75. *
  76. </view>
  77. 新闻标签
  78. </view>
  79. <view class="right">
  80. <u-input v-model="form.tags" input-align="right" style="display: inline-block;" placeholderStyle="color: #282828;"/>
  81. <u-icon class="icon" name="arrow-right" size="20"></u-icon>
  82. </view>
  83. </view> -->
  84. <view class="item">
  85. <view class="label">
  86. <view class="star">
  87. *
  88. </view>
  89. 新闻状态
  90. </view>
  91. <u-radio-group v-model="form.status" class="radio">
  92. <u-radio name="1">
  93. 正常
  94. </u-radio>
  95. <u-radio name="0">
  96. 暂停
  97. </u-radio>
  98. </u-radio-group>
  99. </view>
  100. <!-- <view class="item">
  101. <view class="label">
  102. 活动地点
  103. </view>
  104. <view class="right">
  105. {{form.class_address}}
  106. </view>
  107. </view> -->
  108. <u-popup v-model="show" mode="bottom" height="100%">
  109. <view class="form">
  110. <view class="back" @click="show=!show">
  111. <u-icon name="arrow-left" color="#2979ff" size="28"></u-icon>
  112. </view>
  113. <u-navbar :is-back="false" title="填写信息"></u-navbar>
  114. <view class="title">
  115. {{input_name}}
  116. </view>
  117. <!-- 富文本编辑 -->
  118. <view class="" v-if="item==3">
  119. <!-- <quill-editor class="editor" v-model="messages[index]" ref="myQuillEditor" @blur="onEditorBlur"
  120. @focus="onEditorFocus" @ready="onEditorReady">
  121. </quill-editor> -->
  122. <jinEdit placeholder="请输入内容..." @editOk="editOk" uploadFileUrl="/api/common/upload" :html="form.body">
  123. </jinEdit>
  124. <!-- <VueEditor class="edit" v-model="form.body" /> -->
  125. </view>
  126. <!-- 选择时间 -->
  127. <view class="input" v-if="item==4" @click="show1=!show1">
  128. {{form.published_at? form.published_at : '点击选择时间'}}
  129. <u-picker mode="time" v-model="show1" :params="params" @confirm="changeDate"></u-picker>
  130. </view>
  131. <!-- 上传图片 -->
  132. <view class="upload_image1" v-if="item==2&&image_edit==0">
  133. <!-- <u-upload ref="uUpload" :action="action" :auto-upload="true" :form-data='imageDate'
  134. :file-list="fileList" @on-success='uploadSuccess'></u-upload> -->
  135. <u-upload :action="action" max-count="1" :file-list="fileList" :form-data='imageDate'
  136. @on-success='uploadSuccess'></u-upload>
  137. <text>(最佳尺寸比例:92*76)</text>
  138. </view>
  139. <view class="upload_image" v-if="item==2 && image_edit==1">
  140. <u-image width="100%" height="300rpx" :src="uploadImage"></u-image>
  141. </view>
  142. <view class="input" v-if="item==1">
  143. <u-input :placeholder=' "请输入" + input_name' v-model="value" />
  144. </view>
  145. <view class="complate" v-if="item==2 && image_edit==1" @click="reload">
  146. 重新上传
  147. </view>
  148. <view class="complate1" v-if="item==2" @click="complate">
  149. 完成
  150. </view>
  151. <view class="complate" v-if="item!==2 && item!=3" @click="complate">
  152. 完成
  153. </view>
  154. </view>
  155. </u-popup>
  156. <view class="buttom" @click="release">
  157. 提交审核
  158. </view>
  159. </view>
  160. </template>
  161. <script>
  162. import jinEdit from '../../components/jin-edit/jin-edit.vue';
  163. export default {
  164. components: {
  165. jinEdit
  166. },
  167. data() {
  168. return {
  169. imageHeader: {
  170. file_type: 'img',
  171. type: 'news'
  172. },
  173. messages: [],
  174. index: 0,
  175. show: false,
  176. input_name: '',
  177. placeholder: '开始输入...',
  178. value: '',
  179. selector: [
  180. '新闻资讯', '校园风采'
  181. ],
  182. is_shape: false,
  183. form: {
  184. title: '',
  185. published_at: '',
  186. class_address: '', //上课地点
  187. status: 1,
  188. category_id: '',
  189. body: '',
  190. sort: 0,
  191. category_id: '',
  192. is_message: 0
  193. },
  194. params: {
  195. year: true,
  196. month: true,
  197. day: true,
  198. hour: true,
  199. minute: true,
  200. second: true
  201. },
  202. show1: false,
  203. item: '',
  204. action: '', //封面图上传地址
  205. imageDate: {
  206. file_type: 'img',
  207. type: 'news'
  208. }, //上传图片携带参数
  209. fileList: [],
  210. uploadImage: '',
  211. image_edit: 0,
  212. tab_name: ''
  213. }
  214. },
  215. onLoad(options) {
  216. // this.form.category_id = options.category_id
  217. // this.tab_name = options.tab_name
  218. },
  219. onShow() {
  220. this.action = '/api/common/upload'
  221. // this.category()
  222. },
  223. methods: {
  224. // 点击发布
  225. editOk(res) {
  226. console.log(res.html);
  227. this.form.body = res.html
  228. this.show = false
  229. },
  230. //选择picker中的值
  231. shape_choose(e) {
  232. this.form.category_id = e + 1
  233. console.log(this.from, '22')
  234. },
  235. // saveEditor(e) {
  236. // console.log(e, '保存富文本')
  237. // this.form.body = e.html
  238. // this.show = !this.show
  239. // },
  240. // hideEditor() {
  241. // this.form.body = ''
  242. // this.show = !this.show
  243. // },
  244. // uploadImg() {
  245. // this.action = '/api/common/upload'
  246. // },
  247. // onEditorReady() {
  248. // // #ifdef MP-BAIDU
  249. // this.editorCtx = requireDynamicLib('editorLib').createEditorContext('editorId');
  250. // // #endif
  251. // // #ifdef APP-PLUS || H5 ||MP-WEIXIN
  252. // uni.createSelectorQuery().select('#editor').context((res) => {
  253. // this.editorCtx = res.context
  254. // }).exec()
  255. // // #endif
  256. // },
  257. // undo() {
  258. // this.editorCtx.undo()
  259. // },
  260. //添加通知公告
  261. release() {
  262. if (!this.form.title) {
  263. uni.showToast({
  264. title: '请填写新闻标题',
  265. icon: 'none'
  266. })
  267. return
  268. }else if(!this.form.cover){
  269. uni.showToast({
  270. title: '请上传封面图',
  271. icon: 'none'
  272. })
  273. return
  274. }
  275. else if (!this.form.body) {
  276. uni.showToast({
  277. title: '请填写新闻内容',
  278. icon: 'none'
  279. })
  280. return
  281. } else if (!this.form.category_id) {
  282. uni.showToast({
  283. title: '请选择新闻类型',
  284. icon: 'none'
  285. })
  286. return
  287. } else if (!this.form.status) {
  288. uni.showToast({
  289. title: '请选择新闻状态',
  290. icon: 'none'
  291. })
  292. return
  293. }
  294. else if (!this.form.short_description) {
  295. uni.showToast({
  296. title: '请填写新闻简介',
  297. icon: 'none'
  298. })
  299. return
  300. }
  301. // else if (!this.form.tags) {
  302. // uni.showToast({
  303. // title: '请填写新闻标签',
  304. // icon: 'none'
  305. // })
  306. // return
  307. // }
  308. this.form.organization_id = this.vuex_user.organization_id
  309. this.$u.post('/page/organization-store-new', this.form).then(res => {
  310. console.log(res, '提及扫')
  311. if (res.code == 200) {
  312. uni.showToast({
  313. title: '添加成功',
  314. icon: 'none'
  315. })
  316. setTimeout(function() {
  317. uni.reLaunch({
  318. url: 'news_success'
  319. })
  320. }, 1500)
  321. }
  322. })
  323. },
  324. //获取配置项
  325. // category() {
  326. // this.$u.get('/base/setting-key', {
  327. // key: 'CLASS_ADDRESS'
  328. // }).then(res => {
  329. // console.log(res, 'ppp')
  330. // this.form.class_address = res.data.value
  331. // })
  332. // },
  333. //上传图片成功
  334. uploadSuccess(data) {
  335. console.log(data, 'ppp')
  336. this.form.cover = data.data.id
  337. this.uploadImage = data.data.url
  338. this.image_edit = 1
  339. },
  340. onRemove() {
  341. console.log('pooo')
  342. this.uploadImage = ''
  343. },
  344. changeDate(e) {
  345. let day = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second
  346. console.log(day)
  347. this.form.published_at = day
  348. },
  349. //重新上传
  350. reload() {
  351. this.image_edit = 0
  352. console.log('---------')
  353. this.fileList = [],
  354. this.uploadImage = ''
  355. },
  356. complate() {
  357. console.log('++++++++++')
  358. let item = this.item
  359. switch (item) {
  360. case 1:
  361. this.form.title = this.value
  362. break
  363. case 2:
  364. this.image_edit = 1
  365. break
  366. }
  367. console.log(this.title)
  368. this.show = !this.show
  369. },
  370. goEdit(name, item) {
  371. if (this.uploadImage) {
  372. this.fileList.push({
  373. url: this.uploadImage
  374. })
  375. }
  376. this.item = item
  377. console.log(item)
  378. this.show = true
  379. this.input_name = name
  380. this.textarea = ''
  381. this.value = ''
  382. },
  383. //发布
  384. // release() {
  385. // uni.navigateTo({
  386. // url: './success'
  387. // })
  388. // }
  389. }
  390. }
  391. </script>
  392. <style lang="scss" scoped>
  393. page{
  394. padding: 16px 0;
  395. background-color: #fff;
  396. }
  397. .container {
  398. padding: 10px;
  399. }
  400. #editor {
  401. width: 100%;
  402. height: 400px;
  403. background-color: #CCCCCC;
  404. }
  405. .edit {
  406. height: 400px;
  407. }
  408. button {
  409. margin-top: 10px;
  410. }
  411. .upload_image1 {
  412. // height: 100px;
  413. // width: 100px;
  414. // overflow: hidden;
  415. margin-left: 10px;
  416. text{
  417. // display: block;
  418. // text-align: center;
  419. // width: 100%;
  420. color: #606266;
  421. }
  422. }
  423. .upload_image {
  424. width: 90%;
  425. margin: 0 auto;
  426. }
  427. .complate,
  428. .complate1 {
  429. width: 50%;
  430. margin: 0 auto;
  431. margin-top: 20%;
  432. line-height: 44px;
  433. text-align: center;
  434. height: 44px;
  435. background: #79573D;
  436. opacity: 1;
  437. border-radius: 24px;
  438. font-size: 18px;
  439. font-family: PingFang SC;
  440. font-weight: 500;
  441. color: #FFFFFF;
  442. opacity: 1;
  443. }
  444. .complate1 {
  445. margin-top: 30px;
  446. }
  447. .real-name {
  448. padding: 0 16px;
  449. .history {
  450. font-size: 12px;
  451. font-family: PingFang SC;
  452. font-weight: 400;
  453. height: 30px;
  454. line-height: 30px;
  455. text-align: right;
  456. color: #282828;
  457. opacity: 1;
  458. }
  459. .item {
  460. display: flex;
  461. align-items: center;
  462. height: 46px;
  463. line-height: 46px;
  464. margin-left: 10px;
  465. position: relative;
  466. .label {
  467. flex: 0 0 30%;
  468. font-size: 16px;
  469. font-family: PingFang SC;
  470. font-weight: bold;
  471. line-height: 20px;
  472. color: #282828;
  473. opacity: 1;
  474. }
  475. .star {
  476. position: absolute;
  477. left: -10px;
  478. top: 16px;
  479. color: red;
  480. }
  481. .right {
  482. flex: 1;
  483. font-size: 13px;
  484. font-family: PingFang SC;
  485. font-weight: 400;
  486. line-height: 20px;
  487. color: #282828;
  488. opacity: 0.42;
  489. text-align: right;
  490. }
  491. .jianjie {
  492. display: flex;
  493. height: 100px;
  494. // align-items: center;
  495. .icon {
  496. margin-top: 3px !important;
  497. }
  498. }
  499. .radio {
  500. display: inline-block;
  501. text-align: right;
  502. width: 100%;
  503. }
  504. }
  505. .item_j{
  506. height: 100px;
  507. }
  508. .form {
  509. position: relative;
  510. .back {
  511. position: absolute;
  512. left: 10px;
  513. top: 0px;
  514. width: 30px;
  515. height: 44px;
  516. line-height: 44px;
  517. text-align: center;
  518. z-index: 9999;
  519. // background: #18B566;
  520. }
  521. .title {
  522. padding: 0 20px;
  523. height: 40px;
  524. line-height: 40px;
  525. font-size: 16px;
  526. font-weight: 550;
  527. }
  528. .input {
  529. margin: 0 20px;
  530. height: 40px;
  531. line-height: 40px;
  532. border-bottom: solid 1px rgba(175, 175, 175, .2);
  533. }
  534. .input1 {
  535. margin: 0 20px;
  536. height: 40px;
  537. line-height: 40px;
  538. border: solid 1px rgba(175, 175, 175, .2);
  539. }
  540. }
  541. .item1 {
  542. .dec {
  543. font-size: 13px;
  544. font-family: PingFang SC;
  545. font-weight: 400;
  546. line-height: 20px;
  547. color: #AFAFAF;
  548. opacity: 1;
  549. padding-bottom: 10px;
  550. border-bottom: solid 1px rgba(175, 175, 175, .2);
  551. }
  552. }
  553. .buttom {
  554. width: 229px;
  555. height: 56px;
  556. line-height: 56px;
  557. background: #79573D;
  558. text-align: center;
  559. border-radius: 28px;
  560. margin: 0 auto;
  561. margin-top: 40%;
  562. font-size: 18px;
  563. font-family: PingFang SC;
  564. font-weight: bold;
  565. color: #fff;
  566. opacity: 1;
  567. }
  568. }
  569. // .ql-container.ql-snow{
  570. // height: px2rem(100);
  571. // }
  572. // .ql-editor.ql-blank{
  573. // height: px2rem(50);
  574. // }
  575. </style>