writeNote.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <view class="container write-note">
  3. <view class="nav-bar-wrap" :style="{ height: navBarStyle.height, paddingTop: navBarStyle.paddingTop, paddingBottom: navBarStyle.paddingBottom }">
  4. <view class="content-box" :style="{ color: '#333' }">
  5. <text>发布新内容</text>
  6. <view class="arrow-left-icon">
  7. <van-icon name="arrow-left" size="20px" @click="goHandler" />
  8. </view>
  9. </view>
  10. </view>
  11. <view class="write-note-top">
  12. <view @click="topLableHandler(item)" :class="['write-text', topLableActive == item.value && 'act-top-lable']" v-for="item in topLableList" :key="item.value"> {{ item.name }}</view>
  13. </view>
  14. <view class="write-note-content">
  15. <view class="title-note"> <input placeholder="请输入标题" /></view>
  16. <view class="content-note">
  17. <editor v-model="advice_content" placeholder="请输入正文(更轻松的创作,上传文档,请先登录查研观向网页版)" @input="contentChange" />
  18. <view class="new-lable" @click="showPopup = true">+ 标签(至少添加一个)</view>
  19. </view>
  20. </view>
  21. <view class="write-note-img">
  22. <robbyImageUpload class="image-add-upload" :value="fileList" :limit="6" />
  23. </view>
  24. <view class="write-note-button">
  25. <view class="write-note"> 草稿箱</view>
  26. <view class="write-note"> 发布</view>
  27. </view>
  28. <van-popup :show="showPopup" position="bottom" custom-style="height: 85%;" round custom-class="lable-class-popup">
  29. <viwe class="add-lable-box">
  30. <view class="add-txt"> 添加标签 <view> 完成 </view></view>
  31. <view class="select-item">
  32. <view @click="industryOfCompanyHanler(item)" v-for="item in lableList" :key="item.value" :class="['item', lableActive == item.value && 'act-item']"> {{ item.name }}</view>
  33. </view>
  34. <view class="input-box">
  35. <icon type="search" size="15" class="sea_ico" />
  36. <input v-model="columnName" placeholder="专栏名称" />
  37. <view v-if="lableActive == 2" style="color: #376cbb" @click="addCompanyLableHandler">+ &nbsp;创建</view>
  38. </view>
  39. <view class="text-box"> 已选标签 <view class="one-lable-text"> 至少添加一个标签 </view></view>
  40. <view class="lable-ul">
  41. <block v-if="lableActive == 1">
  42. <view :class="['lable-li', item.isActive && 'active']" v-for="item in selectedLableList" :key="item.name">
  43. {{ item.name }}
  44. <van-icon name="cross" style="margin-left: 8rpx" @click="selectedLableHandle(item)" />
  45. </view>
  46. </block>
  47. <block v-else>
  48. <view :class="['lable-li', item.isActive && 'active']" v-for="item in companySelectedLable" :key="item.name">
  49. {{ item.name }}
  50. <van-icon name="cross" style="margin-left: 8rpx" @click="selectedLableHandle(item)" />
  51. </view>
  52. </block>
  53. </view>
  54. <view class="text-box"> 标签</view>
  55. <view class="lable-ul">
  56. <!-- 这里就不用计算属性了 不知道会不会有隐藏的问题 -->
  57. <block v-if="lableActive == 1">
  58. <view :class="['lable-li', item.isActive && 'active']" @click="industryLabelHandler(item)" v-for="item in industryLabel" :key="item.name">{{ item.name }}</view>
  59. </block>
  60. <block v-else>
  61. <block v-for="item in companyLable" :key="item.name">
  62. <view :class="['lable-li', item.isActive && 'active']" @click="industryLabelHandler(item)" v-if="!item.search">
  63. {{ item.name }}
  64. </view>
  65. </block>
  66. </block>
  67. </view>
  68. </viwe>
  69. </van-popup>
  70. </view>
  71. </template>
  72. <script>
  73. import robbyImageUpload from "../components/imageUpload.vue";
  74. export default {
  75. components: { robbyImageUpload },
  76. data() {
  77. return {
  78. navBarStyle: {
  79. height: 60 + "px",
  80. paddingTop: 40 + "px",
  81. paddingBottom: "4px",
  82. },
  83. showPopup: false,
  84. fileList: [],
  85. advice_content: "",
  86. columnName: "",
  87. lableList: [
  88. { name: "行业标签", value: 1 },
  89. { name: "公司标签", value: 2 },
  90. ], // 公司或者行业标签
  91. lableActive: 1,
  92. topLableList: [
  93. { name: "笔记", value: 1 },
  94. { name: "观点", value: 2 },
  95. ], // 笔记或者观点的标签
  96. topLableActive: 1, // 笔记或者观点的选中
  97. industryLabel: [
  98. { name: "笔记1", value: 1 },
  99. { name: "笔记2", value: 2 },
  100. { name: "笔记3", value: 3 },
  101. { name: "笔记4", value: 4 },
  102. { name: "笔记5", value: 5 },
  103. ], // 行业标签
  104. selectedLableList: [], // 行业标签已选项
  105. companyLable: [
  106. { name: "笔记11", value: 1 },
  107. { name: "笔记22", value: 2 },
  108. { name: "笔记33", value: 3 },
  109. { name: "笔记44", value: 4 },
  110. { name: "笔记55", value: 5 },
  111. ], // 公司标签
  112. companySelectedLable: [], // 公司标签已选项
  113. };
  114. },
  115. methods: {
  116. initNavBar() {
  117. let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  118. this.navBarStyle = {
  119. height: menuButtonInfo.height + menuButtonInfo.top + 8 + "px",
  120. paddingTop: menuButtonInfo.top - 4 + "px",
  121. paddingBottom: "4px",
  122. };
  123. },
  124. // 创建标签公司Lable
  125. addCompanyLableHandler() {
  126. if (!this.columnName) return;
  127. this.companyLable.push({ name: this.columnName, value: this.companyLable.length + 1, search: true, isActive: true });
  128. this.companySelectedLable = this.companyLable.filter((key) => key.isActive);
  129. },
  130. // 行业公司标签的点击事件
  131. industryOfCompanyHanler(item) {
  132. this.lableActive = item.value;
  133. },
  134. // 内容输入框
  135. contentChange(e) {
  136. this.advice_content = e.detail.html;
  137. },
  138. // 头部 table 的点击事件
  139. topLableHandler(item) {
  140. this.topLableActive = item.value;
  141. },
  142. // 行业的标签点击事件
  143. industryLabelHandler(item) {
  144. this.$set(item, "isActive", !item.isActive);
  145. if (this.lableActive == 1) {
  146. this.selectedLableList = this.industryLabel.filter((key) => key.isActive);
  147. } else {
  148. this.companySelectedLable = this.companyLable.filter((key) => key.isActive);
  149. }
  150. },
  151. // 点击取消标签的事件
  152. selectedLableHandle(item) {
  153. if (this.lableActive == 1) {
  154. this.industryLabel.forEach((key) => {
  155. if (key.value === item.value) {
  156. item.isActive = !item.isActive;
  157. }
  158. });
  159. this.selectedLableList = this.industryLabel.filter((key) => key.isActive);
  160. } else {
  161. if (item.search) {
  162. let index = this.companyLable.findIndex((key) => key.value === item.value);
  163. this.companyLable.splice(index, 1);
  164. } else {
  165. this.companyLable.forEach((key) => {
  166. if (key.value === item.value) {
  167. item.isActive = !item.isActive;
  168. }
  169. });
  170. }
  171. this.companySelectedLable = this.companyLable.filter((key) => key.isActive);
  172. }
  173. },
  174. },
  175. onLoad() {
  176. this.initNavBar();
  177. },
  178. };
  179. </script>
  180. <style lang="scss" scope>
  181. .write-note {
  182. .nav-bar-wrap {
  183. width: 100%;
  184. display: flex;
  185. align-items: center;
  186. z-index: 99;
  187. background-color: #fff;
  188. .content-box {
  189. position: relative;
  190. display: flex;
  191. align-items: center;
  192. width: 100%;
  193. justify-content: center;
  194. color: #fff;
  195. font-size: 34rpx;
  196. .arrow-left-icon {
  197. position: absolute;
  198. display: flex;
  199. align-items: center;
  200. justify-content: center;
  201. width: 40rpx;
  202. height: 40rpx;
  203. left: 39rpx;
  204. top: 50%;
  205. transform: translateY(-50%);
  206. z-index: 99;
  207. }
  208. }
  209. }
  210. background-color: #f3f5f9;
  211. .write-note-content {
  212. background-color: #fff;
  213. margin-top: 1rpx;
  214. padding: 30rpx;
  215. .title-note {
  216. width: 100%;
  217. height: 112rpx;
  218. display: flex;
  219. align-items: center;
  220. border-bottom: 2rpx solid #f3f5f9;
  221. }
  222. .content-note {
  223. width: 100%;
  224. height: 880rpx;
  225. padding-top: 20rpx;
  226. .ql-container {
  227. height: calc(100% - 80rpx);
  228. }
  229. .new-lable {
  230. margin-top: 20px;
  231. color: #376cbb;
  232. }
  233. }
  234. }
  235. .write-note-img {
  236. margin-top: 20rpx;
  237. background-color: #fff;
  238. width: 100%;
  239. padding: 20rpx;
  240. .image-add-upload {
  241. width: 100%;
  242. }
  243. }
  244. .write-note-button {
  245. display: flex;
  246. }
  247. .lable-class-popup {
  248. padding: 30rpx;
  249. }
  250. .add-lable-box {
  251. font-size: 28rpx;
  252. width: 100%;
  253. .add-txt {
  254. position: relative;
  255. height: 60rpx;
  256. line-height: 60rpx;
  257. font-weight: 600;
  258. font-size: 36rpx;
  259. color: #000;
  260. text-align: center;
  261. view {
  262. position: absolute;
  263. top: 0;
  264. right: 20rpx;
  265. color: #376cbb;
  266. font-size: 28rpx;
  267. }
  268. }
  269. .select-item {
  270. display: flex;
  271. margin: 20rpx 0;
  272. .item {
  273. width: 176rpx;
  274. height: 64rpx;
  275. border-radius: 100rpx;
  276. display: flex;
  277. align-items: center;
  278. justify-content: center;
  279. background-color: #f3f3f3;
  280. margin-right: 30rpx;
  281. }
  282. .act-item {
  283. color: #376cbb;
  284. background-color: #e5efff;
  285. }
  286. }
  287. .input-box {
  288. background-color: #f3f3f3;
  289. display: flex;
  290. align-items: center;
  291. height: 80rpx;
  292. width: 100%;
  293. position: relative;
  294. padding-left: 50rpx;
  295. padding-right: 20rpx;
  296. input {
  297. background-color: #f3f3f3;
  298. flex: 1;
  299. height: 80rpx;
  300. }
  301. .sea_ico {
  302. position: absolute;
  303. width: 31rpx;
  304. height: 31rpx;
  305. left: 10rpx;
  306. top: 50%;
  307. transform: translateY(-50%);
  308. }
  309. }
  310. .text-box {
  311. color: #333;
  312. font-size: 28rpx;
  313. font-weight: 600;
  314. display: flex;
  315. justify-content: space-between;
  316. margin: 30rpx 0;
  317. .one-lable-text {
  318. color: #999;
  319. font-size: 24rpx;
  320. font-weight: 400;
  321. }
  322. }
  323. .lable-ul {
  324. display: flex;
  325. flex-wrap: wrap;
  326. .lable-li {
  327. flex-shrink: 0;
  328. display: flex;
  329. align-items: center;
  330. margin: 0 20rpx 30rpx 0;
  331. height: 56rpx;
  332. padding: 0 24rpx;
  333. border-radius: 153rpx;
  334. background-color: #f8f8fa;
  335. }
  336. .active {
  337. background-color: #376cbb;
  338. color: #fff;
  339. }
  340. }
  341. }
  342. .write-note-top {
  343. display: flex;
  344. background-color: #fff;
  345. padding: 15rpx 35rpx;
  346. .write-text {
  347. display: flex;
  348. align-items: center;
  349. justify-content: center;
  350. font-size: 28rpx;
  351. width: 148rpx;
  352. height: 64rpx;
  353. padding: 10rpx 32rpx 10rpx 32rpx;
  354. border-radius: 0rpx 6rpx 6rpx 0rpx;
  355. border: 1rpx solid #e7e7e7;
  356. }
  357. .act-top-lable {
  358. background-color: #376cbb;
  359. color: #fff;
  360. border: none;
  361. }
  362. }
  363. }
  364. </style>