123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617 |
- <template>
- <view class="container write-note">
- <view class="nav-bar-wrap" :style="{ height: navBarStyle.height, paddingTop: navBarStyle.paddingTop, paddingBottom: navBarStyle.paddingBottom }">
- <view class="content-box" :style="{ color: '#333' }">
- <text>发布新内容</text>
- <view class="arrow-left-icon">
- <van-icon name="arrow-left" size="20px" @click="goHandler" />
- </view>
- </view>
- </view>
- <view class="write-note-top">
- <view style="display: flex">
- <view @click="topLableHandler(item)" :class="['write-text', topLableActive == item.value && 'act-top-lable']" v-for="item in topLableList" :key="item.value"> {{ item.name }}</view>
- </view>
- <view class="write-note-button">
- <view class="draft" @click="draftBtnHandler"> 存草稿</view>
- <view class="release" @click="releaseBtnHandler"> 发布</view>
- </view>
- </view>
- <view class="write-note-content">
- <view class="title-note global_title"> <input v-model="articleTitle" placeholder="请输入标题" /></view>
- <view class="content-note" :style="{ height: editorHeight + 'rpx' }">
- <editor @focus="editorFocus" :adjust-position="false" id="editor" v-model="advice_content" placeholder="请输入正文(更轻松的创作,上传文档,请先登录查研观向网页版)" @input="contentChange" />
- <view class="new-lable" @click="showPopup = true">
- <view style="flex-shrink: 0">+ 标签(至少添加一个)</view>
- <view v-for="item in industryCompanyLable" :key="item" class="lable-li active">
- {{ item }}
- <van-icon name="cross" style="margin-left: 8rpx" />
- </view>
- </view>
- </view>
- </view>
- <view class="write-note-img">
- <robbyImageUpload v-model="fileList" :addImage="addImage" :delImage="delImage"></robbyImageUpload>
- </view>
- <van-popup :show="showPopup" position="bottom" custom-style="height: 85%;" round custom-class="lable-class-popup">
- <viwe class="add-lable-box">
- <view class="add-txt"> 添加标签 <view @click="addCompleteHandler"> 完成 </view></view>
- <view class="select-item">
- <view @click="industryOfCompanyHanler(item)" v-for="item in lableList" :key="item.value" :class="['item', lableActive == item.value && 'act-item']"> {{ item.name }}</view>
- </view>
- <view class="input-box">
- <icon type="search" size="15" class="sea_ico" />
- <input v-model="columnName" :placeholder="lableActive == 2 ? '搜索公司标签' : '搜索行业标签'" @input="searchHandle" />
- <view v-if="lableActive == 2" style="color: #376cbb" @click="addCompanyLableHandler">+ 创建</view>
- </view>
- <view class="text-box"> 已选标签 <view class="one-lable-text"> 至少添加一个标签 </view></view>
- <view class="lable-ul">
- <block v-if="lableActive == 1">
- <view :class="['lable-li', 'active']" v-for="item in selectedLableList" :key="item">
- {{ item }}
- <van-icon name="cross" style="margin-left: 8rpx" @click="selectedLableHandle(item)" />
- </view>
- </block>
- <block v-else>
- <view :class="['lable-li', 'active']" v-for="item in companySelectedLable" :key="item">
- {{ item }}
- <van-icon name="cross" style="margin-left: 8rpx" @click="selectedLableHandle(item)" />
- </view>
- </block>
- </view>
- <view class="text-box"> 标签</view>
- <view class="lable-ul lable-ul-two">
- <!-- 这里就不用计算属性了 不知道会不会有隐藏的问题 -->
- <block v-if="lableActive == 1">
- <view :class="['lable-li']" @click="industryLabelHandler(item)" v-for="item in industryLabel" :key="item">{{ item }}</view>
- </block>
- <block v-else>
- <block v-for="item in companyLable" :key="item">
- <view :class="['lable-li']" @click="industryLabelHandler(item)" v-if="!item.search">
- {{ item }}
- </view>
- </block>
- </block>
- </view>
- </viwe>
- </van-popup>
- <Loading />
- </view>
- </template>
- <script>
- import robbyImageUpload from "../components/imageUpload.vue";
- import { purchaserApi, uploadurl } from "@/config/api";
- export default {
- components: { robbyImageUpload },
- data() {
- return {
- navBarStyle: {
- height: 60 + "px",
- paddingTop: 40 + "px",
- paddingBottom: "4px",
- },
- showPopup: false,
- fileList: [],
- articleTitle: "", // 标题
- advice_content: "",
- columnName: "",
- industryCompanyLable: [], //添加的标签
- lableList: [
- { name: "行业标签", value: 1 },
- { name: "公司标签", value: 2 },
- ], // 公司或者行业标签
- lableActive: 1,
- topLableList: [
- { name: "笔记", value: 1 },
- { name: "观点", value: 2 },
- ], // 笔记或者观点的标签
- topLableActive: 1, // 笔记或者观点的选中
- industryLabel: [], // 行业标签
- selectedLableList: [], // 行业标签已选项
- companyLable: [], // 公司标签
- companySelectedLable: [], // 公司标签已选项
- detailId: 0,
- detailDataForm: {},
- editorCtx: null,
- editorHeight: 800,
- };
- },
- computed: {},
- methods: {
- // 初始获取导航栏
- initNavBar() {
- let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
- this.navBarStyle = {
- height: menuButtonInfo.height + menuButtonInfo.top + 8 + "px",
- paddingTop: menuButtonInfo.top - 4 + "px",
- paddingBottom: "4px",
- };
- },
- // 添加标签完成事件
- addCompleteHandler() {
- this.columnName = "";
- this.industryCompanyLable = [...this.selectedLableList, ...this.companySelectedLable];
- this.showPopup = false;
- },
- // 左上角的返回按钮
- goHandler() {
- let { Title, Content, ImgUrl, Tags } = this.detailDataForm;
- if (Title && (Title != this.articleTitle || this.advice_content != Content || this.fileList.join(",") != ImgUrl || this.industryCompanyLable.join(",") != Tags)) {
- this.savePromptHandler();
- return;
- } else if (Title) {
- uni.navigateBack();
- return;
- }
- if (this.articleTitle || this.advice_content || this.fileList > 0 || this.industryCompanyLable.length > 0) {
- this.savePromptHandler();
- } else {
- uni.navigateBack();
- }
- },
- // 创建标签公司Lable
- addCompanyLableHandler() {
- if (!this.columnName) return;
- if (this.companySelectedLable.includes(this.columnName.replace(/\s+/g, ""))) return this.$util.toast("标签已存在");
- this.companySelectedLable.push(this.columnName.replace(/\s+/g, ""));
- },
- // 行业公司标签的点击事件
- industryOfCompanyHanler(item) {
- this.lableActive = item.value;
- },
- // 内容输入框
- contentChange(e) {
- this.advice_content = e.detail.html;
- },
- // 头部 table 的点击事件
- topLableHandler(item) {
- this.topLableActive = item.value;
- },
- // 行业的标签点击事件
- industryLabelHandler(item) {
- if (this.lableActive == 1) {
- if (this.selectedLableList.includes(item)) {
- let index = this.selectedLableList.findIndex((key) => key == item);
- this.selectedLableList.splice(index, 1);
- } else {
- this.selectedLableList.push(item);
- }
- } else {
- if (this.companySelectedLable.includes(item)) {
- let index = this.companySelectedLable.findIndex((key) => key == item);
- this.companySelectedLable.splice(index, 1);
- } else {
- this.companySelectedLable.push(item);
- }
- }
- },
- // 点击取消标签的事件
- selectedLableHandle(item) {
- if (this.lableActive == 1) {
- let index = this.selectedLableList.findIndex((key) => key == item);
- this.selectedLableList.splice(index, 1);
- } else {
- let index = this.companySelectedLable.findIndex((key) => key == item);
- this.companySelectedLable.splice(index, 1);
- }
- },
- // 草稿箱
- async draftBtnHandler() {
- if (!this.articleTitle) return this.$util.toast("标题不能为空");
- const resSave = await purchaserApi.yanxuanSpecialSave({
- Content: this.advice_content,
- Title: this.articleTitle,
- Type: this.topLableActive,
- IndustryTags: this.selectedLableList.join(","),
- CompanyTags: this.companySelectedLable.join(","),
- ImgUrl: this.fileList.join(","),
- DoType: 1,
- Id: this.detailId,
- });
- if (resSave.Ret === 200) {
- this.$util.toast("已保存至草稿箱");
- setTimeout(() => {
- uni.navigateBack();
- }, 300);
- }
- },
- // 发布
- releaseBtnHandler() {
- if (!this.articleTitle || !this.advice_content || !this.industryCompanyLable.length > 0) {
- let str = !this.articleTitle ? "请输入标题" : !this.advice_content ? "请输入内容" : "请至少添加一个标签";
- return this.$util.toast(str);
- }
- uni.showModal({
- title: "确认发布",
- content: "内容将提交给管理员审核后发布,确定要提交审核吗?",
- confirmColor: "#376cbb",
- cancelColor: "#606266",
- success: async (res) => {
- if (res.confirm) {
- const resCheck = await purchaserApi.yanxuanSpecialCheck({
- Content: this.advice_content,
- ImgUrl: this.fileList,
- });
- if (resCheck.Ret === 200) {
- const resSave = await purchaserApi.yanxuanSpecialSave({
- Content: this.advice_content,
- Title: this.articleTitle,
- Type: this.topLableActive,
- IndustryTags: this.selectedLableList.join(","),
- CompanyTags: this.companySelectedLable.join(","),
- ImgUrl: this.fileList.join(","),
- DoType: 2,
- Id: this.detailId,
- });
- if (resSave.Ret === 200) {
- uni.showModal({
- content: "提交成功,审核结果将通过公众号消息提醒您,请留意【查研观向小助手】公众号",
- confirmText: "知道了",
- showCancel: false,
- confirmColor: "#376cbb",
- success: function (r) {
- if (r.confirm) {
- uni.navigateBack();
- }
- },
- });
- }
- }
- }
- },
- });
- },
- searchHandle() {
- this.lableActive == 1 ? this.getIndustryList() : this.getCompanySearch();
- },
- savePromptHandler() {
- uni.showModal({
- title: "是否保存当前修改",
- content: "保存的草稿可在【内容中心】查看",
- confirmColor: "#376cbb",
- cancelColor: "#606266",
- cancelText: "不保存",
- confirmText: "保存",
- success: async (res) => {
- if (res.confirm) {
- const resSave = await purchaserApi.yanxuanSpecialSave({
- Content: this.advice_content,
- Title: this.articleTitle,
- Type: this.topLableActive,
- IndustryTags: this.selectedLableList.join(","),
- CompanyTags: this.companySelectedLable.join(","),
- ImgUrl: this.fileList.join(","),
- DoType: 1,
- Id: this.detailId,
- });
- if (resSave.Ret === 200) {
- this.$util.toast("已保存至草稿箱");
- setTimeout(() => {
- uni.navigateBack();
- }, 300);
- }
- } else {
- uni.navigateBack();
- }
- },
- });
- },
- // 获取行业标签
- async getIndustryList() {
- const res = await purchaserApi.yanxuanSpecialIndustrySearch({
- Keyword: this.columnName.replace(/\s+/g, ""),
- });
- if (res.Ret === 200) {
- this.industryLabel = res.Data;
- }
- },
- // 获取公司标签
- async getCompanySearch() {
- const res = await purchaserApi.yanxuanSpecialCompanySearch({
- Keyword: this.columnName.replace(/\s+/g, ""),
- });
- if (res.Ret === 200) {
- this.companyLable = res.Data;
- }
- },
- delImage(done) {
- uni.showModal({
- content: "是否删除?",
- success: (res) => {
- if (res.confirm) {
- // 执行 done() 删除
- done();
- }
- },
- });
- },
- addImage(e) {
- this.$util.upload.Single(uploadurl, (res) => {
- let data = JSON.parse(res.data);
- if (data.Ret === 200) {
- this.fileList.push(data.Data.ResourceUrl);
- }
- },'camera');
- },
- // 获取专栏详情
- async getDetaliData() {
- const res = await purchaserApi.yanxuanSpecialDetail({
- Id: this.detailId,
- });
- if (res.Ret === 200) {
- this.detailDataForm = res.Data;
- this.articleTitle = this.detailDataForm.Title;
- this.advice_content = this.detailDataForm.Content;
- this.selectedLableList = this.detailDataForm.IndustryTags || [];
- this.companySelectedLable = this.detailDataForm.CompanyTags || [];
- setTimeout(() => {
- this.industryCompanyLable = [...this.selectedLableList, ...this.companySelectedLable];
- this.editorCtx.setContents({
- html: this.detailDataForm.Content, //this.EditGoodsDetail.content为赋值内容。
- });
- }, 200);
- this.fileList = this.detailDataForm.ImgUrl ? this.detailDataForm.ImgUrl.split(",") : [];
- }
- },
- editorFocus() {
- uni.pageScrollTo({
- scrollTop: 0,
- duration: 0,
- });
- },
- },
- onLoad(options) {
- uni
- .createSelectorQuery()
- .in(this)
- .select("#editor")
- .context((res2) => {
- this.editorCtx = res2.context;
- })
- .exec();
- this.detailId = Number(options.id) || 0;
- this.detailId > 0 && this.getDetaliData();
- this.initNavBar();
- this.getIndustryList();
- },
- };
- </script>
- <style lang="scss" scope>
- .write-note {
- padding-top: 200rpx;
- overflow: hidden;
- .nav-bar-wrap {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- display: flex;
- align-items: center;
- z-index: 999;
- background-color: #fff;
- .content-box {
- position: relative;
- display: flex;
- align-items: center;
- width: 100%;
- justify-content: center;
- color: #fff;
- font-size: 34rpx;
- .arrow-left-icon {
- position: absolute;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 40rpx;
- height: 40rpx;
- left: 39rpx;
- top: 50%;
- transform: translateY(-50%);
- z-index: 99;
- }
- }
- }
- background-color: $uni-bg-color;
- padding-bottom: 200rpx;
- .write-note-content {
- background-color: #fff;
- margin-top: 1rpx;
- padding: 30rpx;
- .title-note {
- width: 100%;
- height: 112rpx;
- display: flex;
- align-items: center;
- border-bottom: 2rpx solid $uni-bg-color;
- input {
- height: 100%;
- width: 100%;
- }
- }
- .content-note {
- width: 100%;
- height: 880rpx;
- padding-top: 20rpx;
- font-size: 32rpx;
- .ql-container {
- height: calc(100% - 80rpx);
- }
- .new-lable {
- margin-top: 20px;
- color: #376cbb;
- display: flex;
- width: 100%;
- overflow: hidden;
- overflow-x: auto;
- .lable-li {
- flex-shrink: 0;
- display: flex;
- align-items: center;
- margin: 0 20rpx 30rpx 0;
- height: 56rpx;
- padding: 0 24rpx;
- border-radius: 153rpx;
- background-color: #f8f8fa;
- }
- .active {
- background-color: #376cbb;
- color: #fff;
- }
- }
- }
- }
- .write-note-img {
- margin-top: 20rpx;
- background-color: #fff;
- width: 100%;
- padding: 20rpx;
- .image-add-upload {
- width: 100%;
- }
- }
- .write-note-button {
- display: flex;
- .draft {
- padding: 8rpx 18rpx;
- margin-right: 10rpx;
- color: #6698e1;
- }
- .release {
- padding: 8rpx 18rpx;
- color: #376cbb;
- }
- }
- .lable-class-popup {
- padding: 30rpx;
- }
- .add-lable-box {
- font-size: 28rpx;
- width: 100%;
- .add-txt {
- position: relative;
- height: 60rpx;
- line-height: 60rpx;
- font-weight: 600;
- font-size: 36rpx;
- color: #000;
- text-align: center;
- view {
- position: absolute;
- top: 0;
- right: 20rpx;
- color: #376cbb;
- font-size: 28rpx;
- }
- }
- .select-item {
- display: flex;
- margin: 20rpx 0;
- .item {
- width: 176rpx;
- height: 64rpx;
- border-radius: 100rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #f3f3f3;
- margin-right: 30rpx;
- }
- .act-item {
- color: #376cbb;
- background-color: #e5efff;
- }
- }
- .input-box {
- background-color: #f3f3f3;
- display: flex;
- align-items: center;
- height: 80rpx;
- width: 100%;
- position: relative;
- padding-left: 50rpx;
- padding-right: 20rpx;
- input {
- background-color: #f3f3f3;
- flex: 1;
- height: 80rpx;
- }
- .sea_ico {
- position: absolute;
- width: 31rpx;
- height: 31rpx;
- left: 10rpx;
- top: 50%;
- transform: translateY(-50%);
- }
- }
- .text-box {
- color: #333;
- font-size: 28rpx;
- font-weight: 600;
- display: flex;
- justify-content: space-between;
- margin: 30rpx 0;
- .one-lable-text {
- color: #999;
- font-size: 24rpx;
- font-weight: 400;
- }
- }
- .lable-ul {
- display: flex;
- flex-wrap: wrap;
- overflow: hidden;
- overflow-y: auto;
- .lable-li {
- flex-shrink: 0;
- display: flex;
- align-items: center;
- margin: 0 20rpx 30rpx 0;
- height: 56rpx;
- padding: 0 24rpx;
- border-radius: 153rpx;
- background-color: #f8f8fa;
- }
- .active {
- background-color: #376cbb;
- color: #fff;
- }
- }
- .lable-ul-two {
- height: 500rpx;
- }
- }
- .write-note-top {
- display: flex;
- justify-content: space-between;
- background-color: #fff;
- padding: 15rpx 35rpx;
- .write-text {
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 28rpx;
- width: 148rpx;
- height: 64rpx;
- padding: 10rpx 32rpx 10rpx 32rpx;
- border: 1rpx solid #e7e7e7;
- }
- view:nth-child(1) {
- border-radius: 6rpx 0rpx 0rpx 6rpx;
- }
- view:nth-child(2) {
- border-radius: 0rpx 6rpx 6rpx 0rpx;
- }
- .act-top-lable {
- background-color: #376cbb;
- color: #fff;
- border: none;
- }
- }
- }
- </style>
|