faBuWenZhang.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <view class="body" style="background-color: #efefef">
  3. <u-navbar :autoBack="true" title="发布" bgColor="rgba(255,255,255,0)" :placeholder="true" titleStyle="font-weight:bold;color:#121212"></u-navbar>
  4. <view class="nav_fabu">
  5. <view class="nav_left">
  6. <view class="left_icon"></view>
  7. <text>发文章</text>
  8. </view>
  9. <view class="nav_right">
  10. <view class="right_icon"></view>
  11. <text>发文章</text>
  12. </view>
  13. </view>
  14. <!-- 上传发布组件 -->
  15. <view class="" style="margin-bottom: 20rpx">
  16. <u--input v-model="titleVal" customStyle="background-color: #ffffff;height: 105rpx;" placeholder="请填写标题" border="surround" clearable></u--input>
  17. </view>
  18. <view class="box">
  19. <view class="sc_box">
  20. <text class="sc_tp">请上传图片</text>
  21. <text class="sc_tp">{{ uploadNumber + '/' + 9 }}</text>
  22. </view>
  23. <view style="margin-left: 56rpx">
  24. <u-upload
  25. width="200rpx"
  26. height="200rpx"
  27. :maxCount="9"
  28. :deletable="true"
  29. :fileList="fileList1"
  30. @afterRead="afterRead"
  31. @delete="deletePic"
  32. name="1"
  33. multiple
  34. ></u-upload>
  35. </view>
  36. <view class="" style="background-color: #efefef; height: 20rpx; width: 100%"><!-- 分割背景 --></view>
  37. <view class="banxin" style="background-color: #ffffff; margin-top: 20rpx">
  38. <u--textarea v-model="textVal" placeholder="请输入内容"></u--textarea>
  39. </view>
  40. <!-- 分区 -->
  41. <u-popup :show="showTanCeng" mode="bottom" @close="close" bgColor="#efefef">
  42. <view class="show_box">
  43. <view class="" style="display: flex; justify-content: space-between">
  44. <text @click="showTanCeng = false">取消</text>
  45. <text class="box_ok">确认</text>
  46. </view>
  47. <view class="box_fenqu" @click="show = true">
  48. <text>分区</text>
  49. <view class="">
  50. <text style="color: #999999; font-size: 28rpx">生活 - 日常</text>
  51. <uni-icons color="#999999" type="forward" size="20"></uni-icons>
  52. </view>
  53. </view>
  54. <!-- 添加标签 -->
  55. <view class="box_tj">
  56. <text style="color: #999999; font-size: 28rpx">还可以添加 2 个标签</text>
  57. <view class="" style="display: flex">
  58. <u-tag
  59. v-for="item in tags"
  60. :key="item"
  61. @close.stop="closeBtn(item)"
  62. :show="closeTag"
  63. closable
  64. shape="circle"
  65. :text="item.label"
  66. :type="item.type"
  67. ></u-tag>
  68. <!-- <u-tag @close="close1 = false" closable shape="circle" text="标签" type="error"></u-tag> -->
  69. </view>
  70. <!-- 推荐标签 -->
  71. <view class="" style="margin-top: 20rpx">
  72. <view style="color: #000000; font-size: 30rpx">推荐标签</view>
  73. <view class="" style="display: flex; margin-top: 20rpx">
  74. <u-tag size="mini" shape="circle" text="标签" type="warning"></u-tag>
  75. <u-tag size="mini" shape="circle" text="标签" type="success"></u-tag>
  76. </view>
  77. </view>
  78. </view>
  79. <u-picker
  80. title="选择分区"
  81. :show="show"
  82. @close="show = false"
  83. ref="uPicker"
  84. @cancel="show = false"
  85. :closeOnClickOverlay="true"
  86. :columns="columns"
  87. @confirm="confirm"
  88. @change="changeHandler"
  89. ></u-picker>
  90. </view>
  91. </u-popup>
  92. <view class="" style="background-color: #efefef; height: 20rpx; width: 100%"><!-- 分割背景 --></view>
  93. <view class="fq_box" @click="fenquBtn">
  94. <text>分区和标签</text>
  95. <view class="bq_box">
  96. <u-tag size="mini" shape="circle" text="标签" type="warning"></u-tag>
  97. <u-tag size="mini" shape="circle" text="标签" type="success"></u-tag>
  98. <u-tag size="mini" shape="circle" text="标签" type="error"></u-tag>
  99. <u-icon name="arrow-right" color="#666666" size="16"></u-icon>
  100. </view>
  101. </view>
  102. <!-- 评论 -->
  103. <view class="" style="background-color: #efefef; height: 20rpx; width: 100%"><!-- 分割背景 --></view>
  104. <view class="pl_box">
  105. <text>开启评论</text>
  106. <u-switch activeColor="#5ac725" v-model="switchval" @change="change"></u-switch>
  107. </view>
  108. <view class="queren">确认发布</view>
  109. </view>
  110. </view>
  111. </template>
  112. <script>
  113. export default {
  114. data() {
  115. return {
  116. closeTag: true,
  117. tags: [
  118. { label: '标签1', type: 'primary', closable: true },
  119. { label: '标签2', type: 'warning ', closable: true },
  120. { label: '标签3', type: 'success', closable: true }
  121. ],
  122. showTanCeng: false,
  123. show: false,
  124. columns: [
  125. ['中国', '美国'],
  126. ['深圳', '厦门', '上海', '拉萨']
  127. ],
  128. columnData: [
  129. ['深圳', '厦门', '上海', '拉萨'],
  130. ['得州', '华盛顿', '纽约', '阿拉斯加']
  131. ],
  132. titleVal: '',
  133. textVal: '',
  134. switchval: '',
  135. fileList1: [
  136. {
  137. url: 'https://huli-app.wenlvti.net/app_static/minnanhun/image/shouyeTJ.png'
  138. },
  139. {
  140. url: 'https://huli-app.wenlvti.net/app_static/minnanhun/image/cs_shouye_tp.png'
  141. },
  142. {
  143. url: 'https://huli-app.wenlvti.net/app_static/minnanhun/image/shouyeBJ.png'
  144. },
  145. {
  146. url: 'https://huli-app.wenlvti.net/app_static/minnanhun/image/shouyeTJ.png'
  147. },
  148. {
  149. url: 'https://huli-app.wenlvti.net/app_static/minnanhun/image/cs_shouye_tp.png'
  150. },
  151. {
  152. url: 'https://huli-app.wenlvti.net/app_static/minnanhun/image/shouyeBJ.png'
  153. },
  154. {
  155. url: 'https://huli-app.wenlvti.net/app_static/minnanhun/image/shouyeTJ.png'
  156. },
  157. {
  158. url: 'https://huli-app.wenlvti.net/app_static/minnanhun/image/cs_shouye_tp.png'
  159. },
  160. {
  161. url: 'https://huli-app.wenlvti.net/app_static/minnanhun/image/shouyeBJ.png'
  162. }
  163. ]
  164. };
  165. },
  166. onLoad() {},
  167. computed: {
  168. uploadNumber() {
  169. return this.fileList1.length;
  170. }
  171. },
  172. methods: {
  173. fenquBtn() {
  174. // this.show = true;
  175. this.showTanCeng = true;
  176. },
  177. // 关闭标签
  178. closeBtn(item) {
  179. console.log(item);
  180. this.tags.splice(this.tags.indexOf(item), 1);
  181. },
  182. // 分区组件方法
  183. changeHandler(e) {
  184. const {
  185. columnIndex,
  186. value,
  187. values, // values为当前变化列的数组内容
  188. index,
  189. // 微信小程序无法将picker实例传出来,只能通过ref操作
  190. picker = this.$refs.uPicker
  191. } = e;
  192. // 当第一列值发生变化时,变化第二列(后一列)对应的选项
  193. if (columnIndex === 0) {
  194. // picker为选择器this实例,变化第二列对应的选项
  195. picker.setColumnValues(1, this.columnData[index]);
  196. }
  197. },
  198. //// 分区组件方法 回调参数为包含columnIndex、value、values
  199. confirm(e) {
  200. console.log('confirm', e);
  201. this.show = false;
  202. },
  203. change(e) {
  204. console.log('change', e);
  205. },
  206. // 删除图片
  207. deletePic(event) {
  208. console.log(event, 'event');
  209. this[`fileList${event.name}`].splice(event.index, 1);
  210. },
  211. // 新增图片
  212. async afterRead(event) {
  213. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  214. let lists = [].concat(event.file);
  215. let fileListLen = this[`fileList${event.name}`].length;
  216. lists.map((item) => {
  217. this[`fileList${event.name}`].push({
  218. ...item,
  219. status: 'uploading',
  220. message: '上传中'
  221. });
  222. });
  223. for (let i = 0; i < lists.length; i++) {
  224. const result = await this.uploadFilePromise(lists[i].url);
  225. let item = this[`fileList${event.name}`][fileListLen];
  226. this[`fileList${event.name}`].splice(
  227. fileListLen,
  228. 1,
  229. Object.assign(item, {
  230. status: 'success',
  231. message: '',
  232. url: result
  233. })
  234. );
  235. fileListLen++;
  236. }
  237. },
  238. uploadFilePromise(url) {
  239. return new Promise((resolve, reject) => {
  240. let a = uni.uploadFile({
  241. url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
  242. filePath: url,
  243. name: 'file',
  244. formData: {
  245. user: 'test'
  246. },
  247. success: (res) => {
  248. setTimeout(() => {
  249. resolve(res.data.data);
  250. }, 1000);
  251. }
  252. });
  253. });
  254. },
  255. close() {
  256. this.showTanCeng = false;
  257. // console.log('close');
  258. }
  259. }
  260. };
  261. </script>
  262. <style>
  263. .banxin {
  264. margin: 0 32rpx 0 32rpx;
  265. }
  266. .u-upload__button.data-v-69e2a36e {
  267. background-color: #efefef !important;
  268. }
  269. .u-upload__deletable.data-v-69e2a36e {
  270. width: 35rpx !important;
  271. height: 35rpx !important;
  272. }
  273. .u-transition {
  274. margin-right: 12rpx;
  275. }
  276. /* .u-icon__icon.data-v-2ee87dc9 {
  277. font-size: 25rpx !important;
  278. line-height: 26rpx !important;
  279. } */
  280. .nav_fabu {
  281. display: flex;
  282. justify-content: space-evenly;
  283. background-color: #ca5642;
  284. }
  285. .nav_left {
  286. display: flex;
  287. justify-content: start;
  288. align-items: center;
  289. width: 282rpx;
  290. height: 123rpx;
  291. font-size: 32rpx;
  292. background: #f4f4f9;
  293. border: 6px solid #ca5642;
  294. border-radius: 20rpx;
  295. }
  296. .left_icon {
  297. width: 50rpx;
  298. height: 50rpx;
  299. border-radius: 50%;
  300. margin-left: 50rpx;
  301. background-color: #ca5642;
  302. }
  303. .nav_right {
  304. display: flex;
  305. justify-content: start;
  306. align-items: center;
  307. width: 282rpx;
  308. height: 123rpx;
  309. font-size: 32rpx;
  310. background: #f4f4f9;
  311. border: 6px solid #ca5642;
  312. border-radius: 20rpx;
  313. }
  314. .right_icon {
  315. width: 50rpx;
  316. height: 50rpx;
  317. margin-left: 50rpx;
  318. border-radius: 50%;
  319. background-color: #4e7198;
  320. }
  321. .sc_box {
  322. display: flex;
  323. justify-content: space-between;
  324. margin: 0 55rpx 40rpx 55rpx;
  325. border-bottom: 1px #dedede solid;
  326. height: 60rpx;
  327. }
  328. .sc_tp {
  329. font-size: 30rpx;
  330. color: #000000;
  331. }
  332. .fq_box {
  333. display: flex;
  334. justify-content: space-between;
  335. margin: 0 32rpx 0 32rpx;
  336. height: 105rpx;
  337. align-items: center;
  338. }
  339. .box {
  340. background-color: #ffffff;
  341. padding-top: 20rpx;
  342. padding-bottom: 30rpx;
  343. }
  344. .bq_box {
  345. display: flex;
  346. align-items: center;
  347. }
  348. .pl_box {
  349. display: flex;
  350. justify-content: space-between;
  351. margin: 0 32rpx 0 32rpx;
  352. height: 105rpx;
  353. align-items: center;
  354. }
  355. .show_box {
  356. width: 100%;
  357. height: 500rpx;
  358. padding: 20rpx;
  359. }
  360. .queren {
  361. height: 70rpx;
  362. background-color: #ca5642;
  363. border-radius: 35rpx;
  364. font-size: 30rpx;
  365. color: #ffffff;
  366. text-align: center;
  367. line-height: 68rpx;
  368. margin: 0 32rpx 0 32rpx;
  369. }
  370. .box_ok {
  371. line-height: 50rpx;
  372. text-align: center;
  373. color: #ffffff;
  374. width: 93rpx;
  375. height: 52rpx;
  376. background: #ca5642;
  377. border-radius: 26rpx;
  378. }
  379. .box_fenqu {
  380. display: flex;
  381. justify-content: space-between;
  382. align-items: center;
  383. border-radius: 20rpx;
  384. margin-top: 20rpx;
  385. height: 105rpx;
  386. background-color: #ffffff;
  387. font-size: 30rpx;
  388. padding: 20rpx;
  389. }
  390. .box_tj {
  391. height: 300rpx;
  392. border-radius: 20rpx;
  393. background-color: #ffffff;
  394. margin-top: 20rpx;
  395. padding: 20rpx;
  396. }
  397. </style>