add.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <view class="real-name">
  3. <!-- <view class="history">
  4. 历史发布
  5. </view> -->
  6. <view class="item">
  7. <view class="label">
  8. 活动标题
  9. </view>
  10. <view class="right" @click="goEdit('活动标题', 1)">
  11. {{form.title ? form.title : '去填写'}}
  12. <u-icon name="arrow-right" size="20" margin-left="20"></u-icon>
  13. </view>
  14. </view>
  15. <view class="item">
  16. <view class="label">
  17. 封面图
  18. </view>
  19. <view class="right" @click="goEdit('封面图', 2)">
  20. {{form.cover ? '已上传' : '去上传'}}
  21. <u-icon name="arrow-right" size="20" margin-left="20"></u-icon>
  22. </view>
  23. </view>
  24. <view class="item">
  25. <view class="label">
  26. 活动内容
  27. </view>
  28. <view class="right" @click="goEdit('活动内容',3)">
  29. {{form.body ? '已填写' : '点击填写'}}
  30. <u-icon name="arrow-right" size="20" margin-left="20"></u-icon>
  31. </view>
  32. </view>
  33. <view class="item">
  34. <view class="label">
  35. 活动时间
  36. </view>
  37. <view class="right" @click="goEdit('活动时间',4)">
  38. {{form.published_at ? form.published_at : '去选择'}}
  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. 活动地点
  45. </view>
  46. <view class="right">
  47. {{form.class_address}}
  48. </view>
  49. </view> -->
  50. <u-popup v-model="show" mode="bottom" height="100%">
  51. <view class="form">
  52. <view class="back" @click="show=!show">
  53. <u-icon name="arrow-left" color="#2979ff" size="28"></u-icon>
  54. </view>
  55. <u-navbar :is-back="false" title="填写信息"></u-navbar>
  56. <view class="title">
  57. {{input_name}}
  58. </view>
  59. <!-- 富文本编辑 -->
  60. <view class="" v-if="item==3">
  61. <!-- <robin-editor class="editor" @cancel="hideEditor" @save="saveEditor" v-model="form.body"
  62. :imageUploader="uploadImg" :muiltImage="true">
  63. </robin-editor> -->
  64. <jinEdit placeholder="请输入内容..." @editOk="editOk" uploadFileUrl="/api/common/upload"
  65. :html="form.body"></jinEdit>
  66. </view>
  67. <!-- 选择时间 -->
  68. <view class="input" v-if="item==4" @click="show1=!show1">
  69. {{form.published_at? form.published_at : '点击选择时间'}}
  70. <u-picker mode="time" v-model="show1" :params="params" @confirm="changeDate"></u-picker>
  71. </view>
  72. <!-- 上传图片 -->
  73. <view class="upload_image1" v-if="item==2&&image_edit==0">
  74. <u-upload ref="uUpload" :action="action" :auto-upload="true" :form-data='imageDate'
  75. :file-list="fileList" @on-success='uploadSuccess' :on-progress='changeImage'></u-upload>
  76. </view>
  77. <view class="upload_image" v-if="item==2 && image_edit==1">
  78. <u-image width="100%" height="300rpx" :src="uploadImage"></u-image>
  79. </view>
  80. <view class="input" v-if="item==1">
  81. <u-input :placeholder=' "请输入" + input_name' v-model="value" />
  82. </view>
  83. <view class="complate" v-if="item==2 && image_edit==1" @click="reload">
  84. 重新上传
  85. </view>
  86. <view class="complate1" v-if="item==2" @click="complate">
  87. 完成
  88. </view>
  89. <view class="complate" v-if="item!==2 && item!=3" @click="complate">
  90. 完成
  91. </view>
  92. </view>
  93. </u-popup>
  94. <view class="buttom" @click="release">
  95. 提交审核
  96. </view>
  97. </view>
  98. </template>
  99. <script>
  100. import jinEdit from '../../components/jin-edit/jin-edit.vue';
  101. export default {
  102. components: {
  103. jinEdit
  104. },
  105. data() {
  106. return {
  107. show: false,
  108. input_name: '',
  109. placeholder: '开始输入...',
  110. value: '',
  111. form: {
  112. title: '',
  113. published_at: '',
  114. class_address: '', //上课地点
  115. status: 1,
  116. category_id: '',
  117. body: '',
  118. sort: 0,
  119. category_id: '',
  120. is_message: 0
  121. },
  122. params: {
  123. year: true,
  124. month: true,
  125. day: true,
  126. hour: true,
  127. minute: true,
  128. second: true
  129. },
  130. show1: false,
  131. item: '',
  132. action: '', //封面图上传地址
  133. imageDate: {
  134. file_type: 'img',
  135. type: 'article'
  136. }, //上传图片携带参数
  137. fileList: [],
  138. uploadImage: '',
  139. image_edit: 0,
  140. tab_name: ''
  141. }
  142. },
  143. onLoad(options) {
  144. this.form.category_id = options.category_id
  145. this.tab_name = options.tab_name
  146. },
  147. onShow() {
  148. if (this.is_weixin()) {
  149. this.navTitle()
  150. }
  151. this.action = '/api/base/common/upload'
  152. this.category()
  153. },
  154. methods: {
  155. //判断是否是微信
  156. is_weixin() {
  157. let ua = navigator.userAgent.toLowerCase();
  158. return ua.indexOf('micromessenger') != -1;
  159. },
  160. navTitle() {
  161. let navTitle = document.getElementsByTagName('uni-page-head');
  162. navTitle[0].style.display = 'none'
  163. },
  164. editOk(res) {
  165. console.log(res.html);
  166. console.log(this.form, '///////////////')
  167. this.form.body = res.html
  168. this.show = false
  169. },
  170. hideEditor() {
  171. this.form.body = ''
  172. this.show = !this.show
  173. },
  174. uploadImg() {
  175. this.action = '/api/base/common/upload'
  176. },
  177. onEditorReady() {
  178. // #ifdef MP-BAIDU
  179. this.editorCtx = requireDynamicLib('editorLib').createEditorContext('editorId');
  180. // #endif
  181. // #ifdef APP-PLUS || H5 ||MP-WEIXIN
  182. uni.createSelectorQuery().select('#editor').context((res) => {
  183. this.editorCtx = res.context
  184. }).exec()
  185. // #endif
  186. },
  187. undo() {
  188. this.editorCtx.undo()
  189. },
  190. //添加通知公告
  191. release() {
  192. if (!this.form.title) {
  193. uni.showToast({
  194. title: '请填写活动标题',
  195. icon: 'none'
  196. })
  197. return
  198. } else if (!this.form.body) {
  199. uni.showToast({
  200. title: '请填写活动内容',
  201. icon: 'none'
  202. })
  203. return
  204. }
  205. this.$u.post('/inform/information', this.form).then(res => {
  206. console.log(res, '提及扫')
  207. if (res.code == 200) {
  208. uni.showToast({
  209. title: '添加成功',
  210. icon: 'none'
  211. })
  212. setTimeout(function() {
  213. uni.reLaunch({
  214. url: './success'
  215. })
  216. }, 1500)
  217. }
  218. })
  219. },
  220. //获取配置项
  221. category() {
  222. this.$u.get('/base/setting-key', {
  223. key: 'CLASS_ADDRESS'
  224. }).then(res => {
  225. console.log(res, 'ppp')
  226. this.form.class_address = res.data.value
  227. })
  228. },
  229. //上传图片成功
  230. uploadSuccess(data) {
  231. console.log(data, 'ppp')
  232. this.form.cover = data.data.id
  233. this.uploadImage = data.data.url
  234. this.image_edit = 1
  235. },
  236. onRemove() {
  237. console.log('pooo')
  238. this.uploadImage = ''
  239. },
  240. changeDate(e) {
  241. let day = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second
  242. console.log(day)
  243. this.form.published_at = day
  244. },
  245. //重新上传
  246. reload() {
  247. this.image_edit = 0
  248. console.log('---------')
  249. this.fileList = [],
  250. this.uploadImage = ''
  251. },
  252. complate() {
  253. console.log('++++++++++')
  254. let item = this.item
  255. switch (item) {
  256. case 1:
  257. this.form.title = this.value
  258. break
  259. case 2:
  260. this.image_edit = 1
  261. break
  262. }
  263. console.log(this.title)
  264. this.show = !this.show
  265. },
  266. goEdit(name, item) {
  267. if (this.uploadImage) {
  268. this.fileList.push({
  269. url: this.uploadImage
  270. })
  271. }
  272. this.item = item
  273. console.log(item)
  274. this.show = true
  275. this.input_name = name
  276. this.textarea = ''
  277. this.value = ''
  278. },
  279. //发布
  280. // release() {
  281. // uni.navigateTo({
  282. // url: './success'
  283. // })
  284. // }
  285. // 点击发布
  286. }
  287. }
  288. </script>
  289. <style lang="scss" scoped>
  290. .container {
  291. padding: 10px;
  292. }
  293. #editor {
  294. width: 100%;
  295. height: 300px;
  296. background-color: #CCCCCC;
  297. }
  298. button {
  299. margin-top: 10px;
  300. }
  301. .upload_image1 {
  302. height: 100px;
  303. width: 100px;
  304. overflow: hidden;
  305. margin-left: 10px;
  306. }
  307. .upload_image {
  308. width: 90%;
  309. margin: 0 auto;
  310. }
  311. .complate,
  312. .complate1 {
  313. width: 50%;
  314. margin: 0 auto;
  315. margin-top: 20%;
  316. line-height: 44px;
  317. text-align: center;
  318. height: 44px;
  319. background: #3B7653;
  320. opacity: 1;
  321. border-radius: 24px;
  322. font-size: 18px;
  323. font-family: PingFang SC;
  324. font-weight: 500;
  325. color: #FFFFFF;
  326. opacity: 1;
  327. }
  328. .complate1 {
  329. margin-top: 30px;
  330. }
  331. .real-name {
  332. padding: 0 16px;
  333. .history {
  334. font-size: 12px;
  335. font-family: PingFang SC;
  336. font-weight: 400;
  337. height: 30px;
  338. line-height: 30px;
  339. text-align: right;
  340. color: #282828;
  341. opacity: 1;
  342. }
  343. .item {
  344. display: flex;
  345. align-items: center;
  346. height: 46px;
  347. line-height: 46px;
  348. .label {
  349. flex: 0 0 30%;
  350. font-size: 16px;
  351. font-family: PingFang SC;
  352. font-weight: bold;
  353. line-height: 20px;
  354. color: #282828;
  355. opacity: 1;
  356. }
  357. .right {
  358. flex: 1;
  359. font-size: 13px;
  360. font-family: PingFang SC;
  361. font-weight: 400;
  362. line-height: 20px;
  363. color: #282828;
  364. opacity: 0.42;
  365. text-align: right;
  366. }
  367. }
  368. .form {
  369. position: relative;
  370. .back {
  371. position: absolute;
  372. left: 10px;
  373. top: 0px;
  374. width: 30px;
  375. height: 44px;
  376. line-height: 44px;
  377. text-align: center;
  378. z-index: 9999;
  379. // background: #18B566;
  380. }
  381. .title {
  382. padding: 0 20px;
  383. height: 40px;
  384. line-height: 40px;
  385. font-size: 16px;
  386. font-weight: 550;
  387. }
  388. .input {
  389. margin: 0 20px;
  390. height: 40px;
  391. line-height: 40px;
  392. border-bottom: solid 1px rgba(175, 175, 175, .2);
  393. }
  394. .input1 {
  395. margin: 0 20px;
  396. height: 40px;
  397. line-height: 40px;
  398. border: solid 1px rgba(175, 175, 175, .2);
  399. }
  400. }
  401. .item1 {
  402. .dec {
  403. font-size: 13px;
  404. font-family: PingFang SC;
  405. font-weight: 400;
  406. line-height: 20px;
  407. color: #AFAFAF;
  408. opacity: 1;
  409. padding-bottom: 10px;
  410. border-bottom: solid 1px rgba(175, 175, 175, .2);
  411. }
  412. }
  413. .buttom {
  414. width: 229px;
  415. height: 56px;
  416. line-height: 56px;
  417. background: #D5D8DB;
  418. text-align: center;
  419. border-radius: 28px;
  420. margin: 0 auto;
  421. margin-top: 40%;
  422. font-size: 18px;
  423. font-family: PingFang SC;
  424. font-weight: bold;
  425. color: #282828;
  426. opacity: 1;
  427. }
  428. }
  429. </style>