specialColumn.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <view class="container special-column">
  3. <view class="tab-content" v-if="isAuthor">
  4. <view class="item" v-for="item in tabList" :key="item.value" @click="tabClickHandler(item)">
  5. {{ item.name }}
  6. <view class="line-active" v-if="tabActive == item.value"> </view>
  7. </view>
  8. </view>
  9. <view class="item-ul" v-if="tabActive == 1">
  10. <view class="item-li" v-for="item in specialList" :key="item.Id" @click="goDetailPages(item)">
  11. <view class="item-title"> {{ item.SpecialName }}</view>
  12. <view class="item-name-time">
  13. <view class="name">
  14. <image :src="item.HeadImg"></image>
  15. <text> {{ item.NickName }}</text>
  16. </view>
  17. <view class="time"> {{ item.LatestPublishDate }}</view>
  18. </view>
  19. <view class="item-content"> 专栏介绍: {{ item.Introduction }} </view>
  20. </view>
  21. </view>
  22. <view class="set-up-info" v-if="tabActive == 2">
  23. <block v-if="(authorDetail.NickName || authorDetail.SpecialName) && isEditInfo">
  24. <info-card :authorDetail="authorDetail" pagesType="专栏详情" @editColumnHandler="editColumnHandler" />
  25. <view class="column-list-content">
  26. <column-list-content :authorDetail="authorDetail" :mySpecialList="mySpecialList" @upDateCollectHandler="upDateCollectHandler" />
  27. </view>
  28. <view class="write-note-button">
  29. <view class="draft" @click="goContentPage"> 内容中心</view>
  30. <view class="release" @click="goReleaseContent"> 发布新内容</view>
  31. </view>
  32. </block>
  33. <block v-else>
  34. <view class="info-name info-box">
  35. <block v-if="isEditInfo">
  36. <text class="seting-txt">首次进入我的专栏</text>
  37. <text class="seting-txt">请设置您的专栏信息</text>
  38. </block>
  39. <text class="seting-txt" v-else>编辑专栏</text>
  40. <input v-model="columnName" placeholder="请输入专栏名称(最多12个字)" />
  41. <input v-model="columnNickname" placeholder="请输入昵称(最多12个字)" />
  42. </view>
  43. <view class="set-up-lable info-box">
  44. <view class="top-box">
  45. <view class="lable-txt">
  46. 专栏标签
  47. <text>(选填)</text>
  48. </view>
  49. <view v-if="columnLableList.length < 6" class="new-lable" @click="addlableShow = true">+ 新建标签</view>
  50. </view>
  51. <view class="column-lable">
  52. <view class="lable-item" v-for="(item, index) in columnLableList" :key="index">
  53. <text>{{ item }}</text>
  54. <van-icon name="cross" @click="deleteLablehandle(index)" />
  55. </view>
  56. </view>
  57. </view>
  58. <view class="set-up-info info-box" style="height: 480rpx">
  59. <view class="lable-txt"> 专栏介绍 </view>
  60. <u-input :maxlength="30" v-model="columnIntroduce" type="textarea" :clearable="false" placeholder="请输入专栏介绍 " height="300" class="ipt" />
  61. </view>
  62. <view class="my-btn" @click="infoDetermineHandler"> {{ isEditInfo ? "进入我的专栏" : "保存" }} </view>
  63. </block>
  64. </view>
  65. <u-modal
  66. v-model="addlableShow"
  67. :show-title="false"
  68. show-cancel-button
  69. confirm-text="确定"
  70. cancel-text="取消"
  71. :content-style="{ fontSize: '32rpx' }"
  72. :cancel-style="{ borderRight: '1rpx solid #EBEBEB' }"
  73. :confirm-style="{ fontWeight: '700' }"
  74. @confirm="confirmModal"
  75. @cancel="cancelModal"
  76. >
  77. <view class="slot-content slot-content-text">
  78. <text class="add-lable-txt">新建标签</text>
  79. <input v-model="addLableName" placeholder="请输入标签名称(最多8个字)" />
  80. </view>
  81. </u-modal>
  82. <Loading />
  83. </view>
  84. </template>
  85. <script>
  86. import ColumnListContent from "../components/columnListContent.vue";
  87. import infoCard from "../components/infoCard.vue";
  88. import { purchaserApi } from "@/config/api";
  89. export default {
  90. components: { infoCard, ColumnListContent },
  91. data() {
  92. return {
  93. tabList: [
  94. { name: "专栏列表", value: "1" },
  95. { name: "我的专栏", value: "2" },
  96. ],
  97. specialList: [], // 专栏列表
  98. mySpecialList: [], // 专栏列表
  99. isAuthor: false, // 是否是作者
  100. authorDetail: {}, // 作者的详情信息
  101. tabActive: "1",
  102. addlableShow: false,
  103. columnName: "",
  104. columnNickname: "",
  105. columnIntroduce: "",
  106. columnLableList: [],
  107. addLableName: "",
  108. isEditInfo: true,
  109. };
  110. },
  111. methods: {
  112. // top标签点击事件
  113. tabClickHandler(item) {
  114. this.tabActive = item.value;
  115. },
  116. // 添加标签的确认事件
  117. confirmModal() {
  118. if (!this.addLableName) return this.$util.toast("未添加标签");
  119. this.columnLableList.push(this.addLableName.slice(0, 8));
  120. this.addLableName = "";
  121. },
  122. // 添加标签的取消事件
  123. cancelModal() {
  124. this.addLableName = "";
  125. },
  126. // 信息填写完成 进入我的专栏
  127. async infoDetermineHandler() {
  128. if (this.columnName && this.columnNickname && this.columnIntroduce) {
  129. const res = await purchaserApi.yanxuanSpecialAuthorSave({
  130. SpecialName: this.columnName.slice(0, 12),
  131. NickName: this.columnNickname.slice(0, 12),
  132. Introduction: this.columnIntroduce,
  133. Label: this.columnLableList.join(","),
  134. UserId: this.authorDetail.UserId,
  135. });
  136. if (res.Ret === 200) {
  137. this.getAuthorDetail();
  138. this.isEditInfo = true;
  139. }
  140. } else {
  141. let str = !this.columnName ? "专栏名称" : !this.columnNickname ? "专栏昵称" : !this.columnIntroduce ? "专栏介绍" : "";
  142. this.$util.toast("请输入" + str);
  143. }
  144. },
  145. // 删除新建标签
  146. deleteLablehandle(index) {
  147. this.columnLableList.splice(index, 1);
  148. },
  149. async getColumnList() {
  150. const res = await purchaserApi.yanxuanSpecialAuthorList();
  151. if (res.Ret === 200) {
  152. this.specialList = res.Data.List || [];
  153. this.isAuthor = res.Data.IsAuthor;
  154. this.isAuthor && this.getAuthorDetail();
  155. }
  156. },
  157. async getAuthorDetail() {
  158. const res = await purchaserApi.yanxuanSpecialAuthorDetail();
  159. if (res.Ret === 200) {
  160. this.authorDetail = res.Data || {};
  161. const myRes = await purchaserApi.yanxuanSpecialList({
  162. UserId: this.authorDetail.UserId,
  163. });
  164. if (myRes.Ret === 200) {
  165. this.mySpecialList = myRes.Data.List || [];
  166. }
  167. }
  168. },
  169. // 去往专栏详情
  170. goDetailPages(item) {
  171. uni.navigateTo({ url: "/pages-purchaser/columnDetail/columnDetail?id=" + item.UserId });
  172. },
  173. // 去往内容中心
  174. goContentPage() {
  175. uni.navigateTo({ url: "/pages-purchaser/contentAllPage/contentAllPage" });
  176. },
  177. // 去发布新内容
  178. goReleaseContent() {
  179. uni.navigateTo({ url: "/pages-purchaser/writeNote/writeNote" });
  180. },
  181. // 编辑专栏
  182. editColumnHandler() {
  183. this.columnName = this.authorDetail.SpecialName;
  184. this.columnNickname = this.authorDetail.NickName;
  185. this.columnIntroduce = this.authorDetail.Introduction;
  186. this.columnLableList = this.authorDetail.Label ? this.authorDetail.Label.split(",") : [];
  187. this.isEditInfo = false;
  188. },
  189. // 更新收藏
  190. upDateCollectHandler(item) {
  191. this.mySpecialList.forEach((key) => {
  192. if (key.Id === item.Id) {
  193. key.CollectNum = item.IsCollect == 1 ? item.CollectNum - 1 : item.CollectNum + 1;
  194. key.IsCollect = item.IsCollect == 1 ? 0 : 1;
  195. }
  196. });
  197. },
  198. },
  199. onShow() {
  200. this.getColumnList();
  201. },
  202. /** 用户点击分享 */
  203. onShareAppMessage: function (res) {
  204. return {
  205. title: "研选专栏",
  206. path: "/pages-purchaser/specialColumn/specialColumn",
  207. };
  208. },
  209. };
  210. </script>
  211. <style lang="scss" scope>
  212. .special-column {
  213. background-color: #f3f5f9;
  214. input {
  215. height: 72rpx;
  216. background-color: #f0f1f3;
  217. padding-left: 24rpx;
  218. border-radius: 12rpx;
  219. }
  220. .tab-content {
  221. position: sticky;
  222. top: 0;
  223. left: 0;
  224. z-index: 99;
  225. margin-top: 1rpx;
  226. background-color: #fff;
  227. height: 96rpx;
  228. display: flex;
  229. view {
  230. flex: 1;
  231. text-align: center;
  232. line-height: 96rpx;
  233. border-bottom: 2rpx solid #e7e7e7;
  234. }
  235. .item {
  236. position: relative;
  237. .line-active {
  238. position: absolute;
  239. left: 50%;
  240. bottom: 0rpx;
  241. width: 32rpx;
  242. height: 6rpx;
  243. border-radius: 6rpx;
  244. background-color: #376cbb;
  245. transform: translateX(-50%);
  246. }
  247. }
  248. }
  249. .item-ul {
  250. padding: 30rpx;
  251. .item-li {
  252. padding: 0 30rpx 30rpx;
  253. background-color: white;
  254. border-radius: 16rpx;
  255. border-top: 10rpx solid #8fa4c4;
  256. margin-bottom: 20rpx;
  257. .item-title {
  258. margin-top: 20rpx;
  259. font-size: 34rpx;
  260. font-weight: 500;
  261. }
  262. .item-name-time {
  263. display: flex;
  264. justify-content: space-between;
  265. align-items: center;
  266. height: 80rpx;
  267. font-size: 28rpx;
  268. color: #999;
  269. .name {
  270. display: flex;
  271. align-items: center;
  272. image {
  273. width: 48rpx;
  274. height: 48rpx;
  275. border-radius: 50%;
  276. margin-right: 10rpx;
  277. }
  278. }
  279. }
  280. .item-content {
  281. text-overflow: -o-ellipsis-lastline;
  282. overflow: hidden;
  283. text-overflow: ellipsis;
  284. display: -webkit-box;
  285. -webkit-line-clamp: 4;
  286. line-clamp: 4;
  287. -webkit-box-orient: vertical;
  288. }
  289. }
  290. }
  291. .set-up-info {
  292. padding: 30rpx;
  293. overflow: hidden;
  294. .info-name {
  295. width: 100%;
  296. padding: 40rpx;
  297. border-radius: 16rpx;
  298. color: #333;
  299. background-color: #fff;
  300. .seting-txt {
  301. text-align: center;
  302. font-size: 36rpx;
  303. font-weight: 500;
  304. line-height: 50rpx;
  305. }
  306. .item-txt {
  307. margin-top: 40rpx;
  308. margin-bottom: 5rpx;
  309. font-size: 28rpx;
  310. font-weight: 500;
  311. line-height: 40rpx;
  312. }
  313. input {
  314. margin-top: 40rpx;
  315. }
  316. }
  317. .set-up-lable {
  318. .top-box {
  319. display: flex;
  320. background-color: #fff;
  321. justify-content: space-between;
  322. .new-lable {
  323. color: #376cbb;
  324. }
  325. }
  326. }
  327. .lable-txt {
  328. font-size: 28rpx;
  329. font-weight: 500;
  330. line-height: 40rpx;
  331. display: flex;
  332. text {
  333. color: #999;
  334. flex-wrap: 400;
  335. }
  336. }
  337. .info-box {
  338. padding: 40rpx;
  339. border-radius: 16rpx;
  340. color: #333;
  341. background-color: #fff;
  342. margin-bottom: 30rpx;
  343. }
  344. .ipt {
  345. height: 300rpx;
  346. }
  347. }
  348. .u-input {
  349. margin-top: 10rpx;
  350. background-color: #f0f1f3;
  351. }
  352. .u-input__textarea {
  353. padding: 20rpx !important;
  354. }
  355. .my-btn {
  356. margin: 50rpx 0;
  357. width: 100%;
  358. height: 72rpx;
  359. padding: 18rpx 30rpx 18rpx 30rpx;
  360. border-radius: 9rpx;
  361. background: #376cbb;
  362. color: #fff;
  363. display: flex;
  364. align-items: center;
  365. justify-content: center;
  366. }
  367. .add-lable-txt {
  368. color: #000;
  369. font-size: 36rpx;
  370. flex-wrap: 600;
  371. margin-bottom: 20rpx;
  372. width: 100%;
  373. text-align: center;
  374. }
  375. .column-lable {
  376. display: flex;
  377. flex-wrap: wrap;
  378. .lable-item {
  379. display: flex;
  380. color: #fff;
  381. font-size: 28rpx;
  382. padding: 10rpx 24rpx;
  383. background-color: #376cbb;
  384. border-radius: 153px;
  385. margin: 20rpx 20rpx 0 0;
  386. text {
  387. margin-right: 12rpx;
  388. }
  389. }
  390. }
  391. .slot-content-text {
  392. text-align: left;
  393. }
  394. .write-note-button {
  395. position: fixed;
  396. width: 100%;
  397. bottom: 10rpx;
  398. left: 0rpx;
  399. z-index: 99;
  400. display: flex;
  401. padding: 0 35rpx;
  402. padding-bottom: constant(safe-area-inset-bottom);
  403. padding-bottom: env(safe-area-inset-bottom);
  404. .draft {
  405. margin-right: 20rpx;
  406. display: flex;
  407. align-items: center;
  408. justify-content: center;
  409. width: 216rpx;
  410. height: 72rpx;
  411. color: #376cbb;
  412. background-color: #e5efff;
  413. border-radius: 9rpx;
  414. }
  415. .release {
  416. flex: 1;
  417. display: flex;
  418. align-items: center;
  419. justify-content: center;
  420. height: 72rpx;
  421. border-radius: 9rpx;
  422. color: #ffff;
  423. background-color: #376cbb;
  424. }
  425. }
  426. .column-list-content {
  427. margin-top: 20rpx;
  428. }
  429. }
  430. </style>