publish.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. <template>
  2. <view class="publish">
  3. <statusBar :item="navBarData"></statusBar>
  4. <view class="" style="background-color: #ffffff;">
  5. <view class="pubTitle">
  6. <input class="title" style="" placeholder="活动标题" v-model="activitytitle" />
  7. </view>
  8. <view class="pubMid">
  9. <view class="mid">
  10. <view class="txt">
  11. <textarea class="txtClass" value="" placeholder="请输入内容" v-model="activityintro" />
  12. </view>
  13. <!-- <uni-file-picker :v-model="imageValue" fileMediatype="image" file-extname="png,jpg,jpeg"
  14. @select="select" @success="success" limit="1"> -->
  15. <!-- 上传图片 -->
  16. <view class="pic" @click="uploadPic">
  17. <view class="picCont">
  18. <image :src="pic" mode="aspectFill"></image>
  19. <view
  20. style="font-size: 24rpx;line-height: 40rpx;font-weight: 400;color: rgba(0, 0, 0, 0.6);">
  21. 添加图片
  22. </view>
  23. <view
  24. style="font-size: 20rpx;line-height: 36rpx;font-weight: 400;color: rgba(0, 0, 0, 0.4);">
  25. (0/1)
  26. </view>
  27. </view>
  28. <view class="pic_show" v-if="imageValue!==''">
  29. <image :src="imageValue" mode="aspectFill"></image>
  30. </view>
  31. </view>
  32. <!-- <view class="pic_show">
  33. <image :src="imageValue" mode="aspectFill"></image>
  34. </view> -->
  35. <!-- </uni-file-picker> -->
  36. <!-- <beUpload @getFile="getFile" :navName="'上传文件'" :accept="accept" :progress="progress"></beUpload> -->
  37. </view>
  38. </view>
  39. <view class="userOptionsBox">
  40. <view class="optionsItemBox">
  41. <picker mode="selector" :range="classifyList" @change="handelclassify">
  42. <view class="optionItem">
  43. <view class="option_left">
  44. <text class="option_text">
  45. 活动分类
  46. </text>
  47. </view>
  48. <view class="option_right">
  49. <view class="input_details">
  50. <view class="details">
  51. <view class="uni-input text">{{classify}}</view>
  52. </view>
  53. <view class="arrow">
  54. <image src="../../static/mine/arrow-right.png" mode="aspectFill"></image>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </picker>
  60. </view>
  61. </view>
  62. <view class="userOptionsBox">
  63. <view class="optionsItemBox">
  64. <picker mode="selector" :range="recruitmentList" @change="handelRecruitment">
  65. <view class="optionItem">
  66. <view class="option_left">
  67. <text class="option_text">
  68. 招募人数
  69. </text>
  70. </view>
  71. <view class="option_right">
  72. <view class="input_details">
  73. <view class="details">
  74. <view class="uni-input text">{{recruitment}}</view>
  75. </view>
  76. <view class="arrow">
  77. <image src="../../static/mine/arrow-right.png" mode="aspectFill"></image>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </picker>
  83. </view>
  84. </view>
  85. <view class="userOptionsBox">
  86. <view class="optionsItemBox">
  87. <picker mode="selector" :range="activityformList" @change="handelActivityform">
  88. <view class="optionItem">
  89. <view class="option_left">
  90. <text class="option_text">
  91. 活动形式
  92. </text>
  93. </view>
  94. <view class="option_right">
  95. <view class="input_details">
  96. <view class="details">
  97. <view class="uni-input text">{{activityform}}</view>
  98. </view>
  99. <view class="arrow">
  100. <image src="../../static/mine/arrow-right.png" mode="aspectFill"></image>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </picker>
  106. </view>
  107. </view>
  108. <view class="userOptionsBox">
  109. <view class="optionsItemBox">
  110. <picker mode="selector" :range="addressList" @change="handeladdress">
  111. <view class="optionItem">
  112. <view class="option_left">
  113. <text class="option_text">
  114. 活动地址
  115. </text>
  116. </view>
  117. <view class="option_right">
  118. <view class="input_details">
  119. <view class="details">
  120. <view class="uni-input text">{{address}}</view>
  121. </view>
  122. <view class="arrow">
  123. <image src="../../static/mine/arrow-right.png" mode="aspectFill"></image>
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. </picker>
  129. </view>
  130. </view>
  131. <view class="userOptionsBox">
  132. <view class="optionsItemBox">
  133. <picker mode="date" :value="activityDate" :start="startDate" :end="endDate"
  134. @change="activityDateChange">
  135. <view class="optionItem">
  136. <view class="option_left">
  137. <text class="option_text">
  138. 活动时间
  139. </text>
  140. </view>
  141. <view class="option_right">
  142. <view class="input_details">
  143. <view class="details">
  144. <view class="uni-input text">{{ activityDate }}</view>
  145. </view>
  146. <view class="arrow">
  147. <image src="../../static/mine/arrow-right.png" mode="aspectFill"></image>
  148. </view>
  149. </view>
  150. </view>
  151. </view>
  152. </picker>
  153. </view>
  154. </view>
  155. <view class="userOptionsBox">
  156. <view class="optionsItemBox">
  157. <picker mode="selector" :range="fundsList" @change="handelFunds">
  158. <view class="optionItem">
  159. <view class="option_left">
  160. <text class="option_text">
  161. 活动费用
  162. </text>
  163. </view>
  164. <view class="option_right">
  165. <view class="input_details">
  166. <view class="details">
  167. <view class="uni-input text">{{funds}}</view>
  168. </view>
  169. <view class="arrow">
  170. <image src="../../static/mine/arrow-right.png" mode="aspectFill"></image>
  171. </view>
  172. </view>
  173. </view>
  174. </view>
  175. </picker>
  176. </view>
  177. </view>
  178. <view class="userOptionsBox">
  179. <view class="optionsItemBox">
  180. <picker mode="date" :value="deadlineDate" :start="startDate" :end="endDate"
  181. @change="deadlineDateChange">
  182. <view class="optionItem">
  183. <view class="option_left">
  184. <text class="option_text">
  185. 报名截止
  186. </text>
  187. </view>
  188. <view class="option_right">
  189. <view class="input_details">
  190. <view class="details">
  191. <view class="uni-input text">{{ deadlineDate }}</view>
  192. </view>
  193. <view class="arrow">
  194. <image src="../../static/mine/arrow-right.png" mode="aspectFill"></image>
  195. </view>
  196. </view>
  197. </view>
  198. </view>
  199. </picker>
  200. </view>
  201. </view>
  202. </view>
  203. <view class="" style="height: 10vh;width: 750rpx;position: relative;">
  204. <view class="publish_now">
  205. <button class="btn" @click="submitForm">立即发布</button>
  206. </view>
  207. </view>
  208. <!-- 弹窗 -->
  209. <view>
  210. <view class="mask" v-show="showPopup" @click="closePopup"></view>
  211. <view class="popup-container" v-show="showPopup">
  212. <view class="popup">
  213. <view class="header">
  214. <text>确认发布</text>
  215. </view>
  216. <view class="footer">
  217. <button class="cancel-btn" @click="closePopup">取消</button>
  218. <button class="confirm-btn" @click="confirm">确认</button>
  219. </view>
  220. </view>
  221. </view>
  222. </view>
  223. <view>
  224. <view class="mask" v-show="showPopupConfirm" @click="closePopup"></view>
  225. <view class="popup-container" style="height: 175px;" v-show="showPopupConfirm">
  226. <view class="popup">
  227. <view class="header">
  228. <image src="../../static/gou1.png" mode="aspectFill"></image>
  229. <text style="margin-bottom: 24px;">发布成功</text>
  230. </view>
  231. <view class="footer">
  232. <button class="confirm-btn_2" @click="closePopup">确认</button>
  233. </view>
  234. </view>
  235. </view>
  236. </view>
  237. </view>
  238. </template>
  239. <script>
  240. export default {
  241. data() {
  242. const currentDate = this.getDate({
  243. format: true
  244. })
  245. return {
  246. navBarData: {
  247. title: '发布', //导航栏标题
  248. btn: 1 //是否显示返回按钮 0不显示 1 显示
  249. },
  250. showPopup: false,
  251. showPopupConfirm: false,
  252. // 标题
  253. activitytitle: '',
  254. // 内容
  255. activityintro: '',
  256. // 图片
  257. pic: '../../static/publish/photo.png',
  258. imageValue: '',
  259. // 分类
  260. classifyList: ['直播活动', '常规教研活动', '专题教研活动'],
  261. classify: '请选择',
  262. // 人数
  263. recruitmentList: Array.from({
  264. length: 100
  265. }, (_, index) => index + 1), //100人
  266. recruitment: '请选择',
  267. // 活动形式
  268. activityformList: ['户外活动', 'xxxx', 'xxxx'],
  269. activityform: '请选择',
  270. // 活动地址
  271. addressList: ['深圳xxxx大学', '深圳xxxx大学', '深圳xxxx大学'],
  272. address: '请选择',
  273. // 活动费用
  274. fundsList: Array.from({
  275. length: 30
  276. }, (_, index) => (index + 1) * 100).map(item => item),
  277. funds: '请选择',
  278. activityDate: currentDate,
  279. deadlineDate: currentDate,
  280. activeList: []
  281. };
  282. },
  283. computed: {
  284. startDate() {
  285. return this.getDate('start');
  286. },
  287. endDate() {
  288. return this.getDate('end');
  289. }
  290. },
  291. methods: {
  292. submitForm() {
  293. if (
  294. this.activitytitle.trim() === '' ||
  295. this.activityintro.trim() === '' ||
  296. this.imageValue == '' ||
  297. // this.classify == '请选择' ||
  298. this.recruitment.value === '请选择' ||
  299. // this.activityform.trim() === '请选择' ||
  300. this.address.trim() === '请选择' ||
  301. this.funds === '请选择'
  302. ) {
  303. // 弹出弹框或其他处理逻辑
  304. uni.showToast({
  305. title: '请填写完整的表单内容',
  306. icon: 'none'
  307. });
  308. return;
  309. }
  310. this.showPopup = true; //显示弹窗
  311. },
  312. closePopup() {
  313. // 取消操作
  314. this.showPopup = false;
  315. this.showPopupConfirm = false;
  316. },
  317. confirm() {
  318. // 确认操作
  319. if (this.classify == "直播活动") {
  320. this.classify = 0
  321. } else if (this.classify == "常规教研活动") {
  322. this.classify = 1
  323. } else {
  324. this.classify = 2
  325. }
  326. // 将文本框内容和图片链接存储在一个对象中
  327. const formData = {
  328. id: this.$store.state.user.openid,
  329. activitytitle: this.activitytitle,
  330. activityintro: this.activityintro,
  331. img: this.imageValue,
  332. classify: this.classify,
  333. recruitment: this.recruitment,
  334. activityform: this.activityform,
  335. address: this.address,
  336. funds: this.funds,
  337. activityDate: this.activityDate,
  338. deadlineDate: this.deadlineDate,
  339. // price: "188",
  340. // count: "6",
  341. };
  342. this.showPopup = false;
  343. this.showPopupConfirm = true
  344. // return console.log(formData);
  345. this.$request('/insertActive', 'POST', formData).then(res => {
  346. console.log(res.data);
  347. if (res.code == 200) {
  348. uni.switchTab({
  349. url: "/pages/activityPage/activityPage"
  350. })
  351. }
  352. })
  353. },
  354. handelclassify(e) {
  355. this.classify = this.classifyList[e.detail.value]
  356. console.log(this.classify);
  357. },
  358. handelRecruitment(e) {
  359. this.recruitment = this.recruitmentList[e.detail.value]
  360. console.log(this.imageValue);
  361. },
  362. handelActivityform(e) {
  363. this.activityform = this.activityformList[e.detail.value]
  364. },
  365. handeladdress(e) {
  366. this.address = this.addressList[e.detail.value]
  367. },
  368. handelFunds(e) {
  369. this.funds = this.fundsList[e.detail.value]
  370. },
  371. activityDateChange: function(e) {
  372. this.activityDate = e.detail.value
  373. },
  374. deadlineDateChange: function(e) {
  375. this.deadlineDate = e.detail.value
  376. },
  377. getDate(type) {
  378. const date = new Date();
  379. let year = date.getFullYear();
  380. let month = date.getMonth() + 1;
  381. let day = date.getDate();
  382. if (type === 'start') {
  383. year = year - 60;
  384. } else if (type === 'end') {
  385. year = year + 2;
  386. }
  387. month = month > 9 ? month : '0' + month;
  388. day = day > 9 ? day : '0' + day;
  389. return `${year}-${month}-${day}`;
  390. },
  391. // 上传图片
  392. uploadPic() {
  393. uni.chooseImage({
  394. count: 1, // 图片数量
  395. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  396. sourceType: ['album', 'camera'], //从相册选择或者拍照
  397. success: (res) => {
  398. const tempFilePaths = res.tempFilePaths[0];
  399. console.log(this);
  400. let that = this
  401. const uploadTask = uni.uploadFile({
  402. url: 'http://139.159.246.165:7006/img', // post请求地址
  403. // url: 'https://cxcy.ssti.net.cn/api/UploadFirmFile', // post请求地址
  404. // filePath: tempFilePaths,
  405. filePath: tempFilePaths,
  406. name: 'file', // 待确认
  407. header: {
  408. // 不要写这个不然报错
  409. // 'Content-Type': 'multipart/form-data',
  410. },
  411. success: function(res) {
  412. // console.log(res.data);
  413. that.imageValue = res.data
  414. // let url = JSON.parse(res.data)
  415. // console.log(url.data);
  416. },
  417. fail: function(uploadFileFail) {
  418. console.log('Error:', uploadFileFail.data);
  419. },
  420. complete: () => {
  421. // 接口调用结束的回调函数(调用成功、失败都会执行)
  422. // console.log('Complete:');
  423. }
  424. });
  425. }
  426. });
  427. },
  428. },
  429. }
  430. </script>
  431. <style lang="scss" scoped>
  432. .publish {
  433. .liu {
  434. //留白
  435. width: 750rpx;
  436. height: 68rpx;
  437. position: absolute;
  438. bottom: 0;
  439. background-color: #ffffff;
  440. }
  441. .pubTitle {
  442. width: 750rpx;
  443. height: 96rpx;
  444. padding: 24rpx 30rpx 0 30rpx;
  445. .title {
  446. font-size: 32rpx;
  447. line-height: 48rpx;
  448. font-weight: 500;
  449. }
  450. }
  451. .pubMid {
  452. width: 750rpx;
  453. // height: 504rpx;
  454. padding: 24rpx 30rpx 0 30rpx;
  455. // background-color: #8BBEFF;
  456. .mid {
  457. width: 690rpx;
  458. height: 440rpx;
  459. // background-color: #f2f2f2;
  460. .txt {
  461. width: 690rpx;
  462. height: 192rpx;
  463. .txtClass {
  464. width: 100%;
  465. height: 100%;
  466. font-size: 28rpx;
  467. font-weight: 400;
  468. line-height: 48rpx;
  469. }
  470. }
  471. .pic {
  472. width: 224rpx;
  473. height: 224rpx;
  474. background-color: rgba(242, 242, 242, 1);
  475. display: flex;
  476. position: relative;
  477. justify-content: center;
  478. align-items: center;
  479. .pic_show {
  480. position: absolute;
  481. top: 0;
  482. left: 0;
  483. width: 100%;
  484. height: 100%;
  485. z-index: 10;
  486. background-color: #8BBEFF;
  487. image {
  488. width: 100%;
  489. height: 100%;
  490. }
  491. }
  492. .picCont {
  493. display: flex;
  494. flex-direction: column;
  495. justify-content: center;
  496. align-items: center;
  497. image {
  498. width: 56rpx;
  499. height: 66rpx;
  500. }
  501. }
  502. }
  503. }
  504. }
  505. // background-color: #fff;
  506. height: 100vh;
  507. .textCont {
  508. padding: 16px;
  509. }
  510. .addPhoto {
  511. background-color: #f2f2f2;
  512. width: 224rpx;
  513. height: 224rpx;
  514. display: flex;
  515. color: #616161;
  516. flex-direction: column;
  517. align-items: center;
  518. justify-content: center;
  519. margin-left: 30rpx;
  520. image {
  521. width: 50px;
  522. height: 50px;
  523. // margin-left: 48px;
  524. }
  525. .photo {
  526. color: #000000A3;
  527. // padding-left: 44px;
  528. // font-size: 14px;
  529. }
  530. .num {
  531. color: #919191;
  532. // padding-left: 56px;
  533. // font-size: 14px;
  534. }
  535. }
  536. .userOptionsBox {
  537. width: 750rpx;
  538. height: 96rpx;
  539. display: flex;
  540. justify-content: center;
  541. align-items: center;
  542. .optionsItemBox {
  543. width: 690rpx;
  544. .optionItem {
  545. display: flex;
  546. justify-content: space-between;
  547. align-items: center;
  548. .option_left {
  549. display: flex;
  550. align-items: center;
  551. font-size: 28rpx;
  552. line-height: 48rpx;
  553. font-weight: 400;
  554. }
  555. .option_right {
  556. height: 40rpx;
  557. .input_details {
  558. display: flex;
  559. align-items: center;
  560. .details {
  561. display: flex;
  562. flex-direction: row;
  563. .text {
  564. font-size: 28rpx;
  565. color: rgb(153, 153, 153);
  566. }
  567. }
  568. .arrow {
  569. display: flex;
  570. image {
  571. width: 32rpx;
  572. height: 32rpx;
  573. }
  574. }
  575. }
  576. }
  577. }
  578. }
  579. }
  580. .publish_now {
  581. position: absolute;
  582. // bottom: 100rpx;
  583. display: flex;
  584. width: 750rpx;
  585. justify-content: center;
  586. padding-bottom: 50rpx;
  587. .btn {
  588. width: 432rpx;
  589. height: 88rpx;
  590. line-height: 88rpx;
  591. // background-color: #8BBEFF;
  592. background: rgba(0, 86, 168, 1);
  593. color: #fff;
  594. display: flex;
  595. flex-direction: column;
  596. align-items: center;
  597. margin-top: 20px;
  598. }
  599. }
  600. .mask {
  601. position: fixed;
  602. top: 0;
  603. left: 0;
  604. width: 100%;
  605. height: 100%;
  606. background-color: rgba(0, 0, 0, 0.3);
  607. z-index: 999;
  608. // display: none;
  609. }
  610. .popup-container {
  611. position: fixed;
  612. top: 50%;
  613. left: 50%;
  614. transform: translate(-50%, -50%);
  615. width: 520rpx;
  616. height: 260rpx;
  617. z-index: 1000;
  618. // display: none;
  619. .popup {
  620. width: 100%;
  621. height: 100%;
  622. display: flex;
  623. flex-direction: column;
  624. background-color: #fff;
  625. border-radius: 16rpx;
  626. .header {
  627. flex: 1;
  628. display: flex;
  629. justify-content: center;
  630. align-items: center;
  631. flex-direction: column;
  632. margin-top: 24px;
  633. font-size: 34rpx;
  634. font-weight: 600;
  635. image {
  636. width: 150rpx;
  637. height: 150rpx;
  638. margin-top: 15px;
  639. margin-bottom: 15px;
  640. }
  641. }
  642. .footer {
  643. flex: 1;
  644. display: flex;
  645. justify-content: space-around;
  646. align-items: end;
  647. padding-top: 17px;
  648. .cancel-btn {
  649. width: 259rpx;
  650. height: 100rpx;
  651. background-color: #F7F7F7;
  652. color: #000;
  653. font-size: 34rpx;
  654. text-align: center;
  655. border-radius: 0;
  656. border-bottom-left-radius: 16rpx;
  657. line-height: 50px;
  658. }
  659. .confirm-btn {
  660. width: 259rpx;
  661. height: 100rpx;
  662. background-color: #0081FE;
  663. color: #fff;
  664. font-size: 34rpx;
  665. text-align: center;
  666. border-radius: 0;
  667. border-bottom-right-radius: 16rpx;
  668. line-height: 50px;
  669. }
  670. .confirm-btn_2 {
  671. width: 518rpx;
  672. height: 100rpx;
  673. background-color: #F7F7F7;
  674. color: #000;
  675. font-size: 34rpx;
  676. text-align: center;
  677. border-radius: 0;
  678. border-bottom-left-radius: 16rpx;
  679. border-bottom-right-radius: 16rpx;
  680. line-height: 50px;
  681. }
  682. }
  683. }
  684. }
  685. }
  686. </style>