specialColumn.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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. refresh:false
  110. };
  111. },
  112. methods: {
  113. // top标签点击事件
  114. tabClickHandler(item) {
  115. this.tabActive = item.value;
  116. },
  117. // 添加标签的确认事件
  118. confirmModal() {
  119. if (!this.addLableName) return this.$util.toast("未添加标签");
  120. this.columnLableList.push(this.addLableName.slice(0, 8));
  121. this.addLableName = "";
  122. },
  123. // 添加标签的取消事件
  124. cancelModal() {
  125. this.addLableName = "";
  126. },
  127. // 信息填写完成 进入我的专栏
  128. async infoDetermineHandler() {
  129. if (this.columnName && this.columnNickname && this.columnIntroduce) {
  130. const res = await purchaserApi.yanxuanSpecialAuthorSave({
  131. SpecialName: this.columnName.slice(0, 12),
  132. NickName: this.columnNickname.slice(0, 12),
  133. Introduction: this.columnIntroduce,
  134. Label: this.columnLableList.join(","),
  135. UserId: this.authorDetail.UserId,
  136. });
  137. if (res.Ret === 200) {
  138. this.getAuthorDetail();
  139. this.isEditInfo = true;
  140. }
  141. } else {
  142. let str = !this.columnName ? "专栏名称" : !this.columnNickname ? "专栏昵称" : !this.columnIntroduce ? "专栏介绍" : "";
  143. this.$util.toast("请输入" + str);
  144. }
  145. },
  146. // 删除新建标签
  147. deleteLablehandle(index) {
  148. this.columnLableList.splice(index, 1);
  149. },
  150. async getColumnList() {
  151. const res = await purchaserApi.yanxuanSpecialAuthorList();
  152. if (res.Ret === 200) {
  153. this.specialList = res.Data.List || [];
  154. this.isAuthor = res.Data.IsAuthor;
  155. this.isAuthor && this.getAuthorDetail();
  156. if (this.refresh) {
  157. uni.stopPullDownRefresh();
  158. this.refresh = false;
  159. }
  160. }
  161. },
  162. async getAuthorDetail() {
  163. const res = await purchaserApi.yanxuanSpecialAuthorDetail();
  164. if (res.Ret === 200) {
  165. this.authorDetail = res.Data || {};
  166. const myRes = await purchaserApi.yanxuanSpecialList({
  167. UserId: this.authorDetail.UserId,
  168. });
  169. if (myRes.Ret === 200) {
  170. this.mySpecialList = myRes.Data.List || [];
  171. }
  172. }
  173. },
  174. // 去往专栏详情
  175. goDetailPages(item) {
  176. uni.navigateTo({ url: "/pages-purchaser/columnDetail/columnDetail?id=" + item.UserId });
  177. },
  178. // 去往内容中心
  179. goContentPage() {
  180. uni.navigateTo({ url: "/pages-purchaser/contentAllPage/contentAllPage" });
  181. },
  182. // 去发布新内容
  183. goReleaseContent() {
  184. uni.navigateTo({ url: "/pages-purchaser/writeNote/writeNote" });
  185. },
  186. // 编辑专栏
  187. editColumnHandler() {
  188. this.columnName = this.authorDetail.SpecialName;
  189. this.columnNickname = this.authorDetail.NickName;
  190. this.columnIntroduce = this.authorDetail.Introduction;
  191. this.columnLableList = this.authorDetail.Label ? this.authorDetail.Label.split(",") : [];
  192. this.isEditInfo = false;
  193. },
  194. // 更新收藏
  195. upDateCollectHandler(item) {
  196. this.mySpecialList.forEach((key) => {
  197. if (key.Id === item.Id) {
  198. key.CollectNum = item.IsCollect == 1 ? item.CollectNum - 1 : item.CollectNum + 1;
  199. key.IsCollect = item.IsCollect == 1 ? 0 : 1;
  200. }
  201. });
  202. },
  203. },
  204. onShow() {
  205. this.getColumnList();
  206. },
  207. /** 用户点击分享 */
  208. onShareAppMessage: function (res) {
  209. return {
  210. title: "研选专栏",
  211. path: "/pages-purchaser/specialColumn/specialColumn",
  212. };
  213. },
  214. /* 下拉刷新 */
  215. onPullDownRefresh() {
  216. this.refresh = true;
  217. this.getColumnList();
  218. },
  219. };
  220. </script>
  221. <style lang="scss" scope>
  222. .special-column {
  223. background-color: $uni-bg-color;
  224. input {
  225. height: 72rpx;
  226. background-color: #f0f1f3;
  227. padding-left: 24rpx;
  228. border-radius: 12rpx;
  229. }
  230. .tab-content {
  231. position: sticky;
  232. top: 0;
  233. left: 0;
  234. z-index: 99;
  235. margin-top: 1rpx;
  236. background-color: #fff;
  237. height: 96rpx;
  238. display: flex;
  239. view {
  240. flex: 1;
  241. text-align: center;
  242. line-height: 96rpx;
  243. border-bottom: 2rpx solid #e7e7e7;
  244. }
  245. .item {
  246. position: relative;
  247. .line-active {
  248. position: absolute;
  249. left: 50%;
  250. bottom: 0rpx;
  251. width: 32rpx;
  252. height: 6rpx;
  253. border-radius: 6rpx;
  254. background-color: #376cbb;
  255. transform: translateX(-50%);
  256. }
  257. }
  258. }
  259. .item-ul {
  260. padding: 30rpx;
  261. .item-li {
  262. padding: 0 30rpx 30rpx;
  263. background-color: white;
  264. border-radius: 16rpx;
  265. border-top: 10rpx solid #8fa4c4;
  266. margin-bottom: 20rpx;
  267. .item-title {
  268. margin-top: 20rpx;
  269. font-size: 34rpx;
  270. font-weight: 500;
  271. }
  272. .item-name-time {
  273. display: flex;
  274. justify-content: space-between;
  275. align-items: center;
  276. height: 80rpx;
  277. font-size: 28rpx;
  278. color: #999;
  279. .name {
  280. display: flex;
  281. align-items: center;
  282. image {
  283. width: 48rpx;
  284. height: 48rpx;
  285. border-radius: 50%;
  286. margin-right: 10rpx;
  287. }
  288. }
  289. }
  290. .item-content {
  291. text-overflow: -o-ellipsis-lastline;
  292. overflow: hidden;
  293. text-overflow: ellipsis;
  294. display: -webkit-box;
  295. -webkit-line-clamp: 4;
  296. line-clamp: 4;
  297. -webkit-box-orient: vertical;
  298. }
  299. }
  300. }
  301. .set-up-info {
  302. padding: 30rpx;
  303. overflow: hidden;
  304. .info-name {
  305. width: 100%;
  306. padding: 40rpx;
  307. border-radius: 16rpx;
  308. color: #333;
  309. background-color: #fff;
  310. .seting-txt {
  311. text-align: center;
  312. font-size: 36rpx;
  313. font-weight: 500;
  314. line-height: 50rpx;
  315. }
  316. .item-txt {
  317. margin-top: 40rpx;
  318. margin-bottom: 5rpx;
  319. font-size: 28rpx;
  320. font-weight: 500;
  321. line-height: 40rpx;
  322. }
  323. input {
  324. margin-top: 40rpx;
  325. }
  326. }
  327. .set-up-lable {
  328. .top-box {
  329. display: flex;
  330. background-color: #fff;
  331. justify-content: space-between;
  332. .new-lable {
  333. color: #376cbb;
  334. }
  335. }
  336. }
  337. .lable-txt {
  338. font-size: 28rpx;
  339. font-weight: 500;
  340. line-height: 40rpx;
  341. display: flex;
  342. text {
  343. color: #999;
  344. flex-wrap: 400;
  345. }
  346. }
  347. .info-box {
  348. padding: 40rpx;
  349. border-radius: 16rpx;
  350. color: #333;
  351. background-color: #fff;
  352. margin-bottom: 30rpx;
  353. }
  354. .ipt {
  355. height: 300rpx;
  356. }
  357. }
  358. .u-input {
  359. margin-top: 10rpx;
  360. background-color: #f0f1f3;
  361. }
  362. .u-input__textarea {
  363. padding: 20rpx !important;
  364. }
  365. .my-btn {
  366. margin: 50rpx 0;
  367. width: 100%;
  368. height: 72rpx;
  369. padding: 18rpx 30rpx 18rpx 30rpx;
  370. border-radius: 9rpx;
  371. background: #376cbb;
  372. color: #fff;
  373. display: flex;
  374. align-items: center;
  375. justify-content: center;
  376. }
  377. .add-lable-txt {
  378. color: #000;
  379. font-size: 36rpx;
  380. flex-wrap: 600;
  381. margin-bottom: 20rpx;
  382. width: 100%;
  383. text-align: center;
  384. }
  385. .column-lable {
  386. display: flex;
  387. flex-wrap: wrap;
  388. .lable-item {
  389. display: flex;
  390. color: #fff;
  391. font-size: 28rpx;
  392. padding: 10rpx 24rpx;
  393. background-color: #376cbb;
  394. border-radius: 153px;
  395. margin: 20rpx 20rpx 0 0;
  396. text {
  397. margin-right: 12rpx;
  398. }
  399. }
  400. }
  401. .slot-content-text {
  402. text-align: left;
  403. }
  404. .write-note-button {
  405. position: fixed;
  406. width: 100%;
  407. bottom: 10rpx;
  408. left: 0rpx;
  409. z-index: 99;
  410. display: flex;
  411. padding: 0 35rpx;
  412. padding-bottom: constant(safe-area-inset-bottom);
  413. padding-bottom: env(safe-area-inset-bottom);
  414. .draft {
  415. margin-right: 20rpx;
  416. display: flex;
  417. align-items: center;
  418. justify-content: center;
  419. width: 216rpx;
  420. height: 72rpx;
  421. color: #376cbb;
  422. background-color: #e5efff;
  423. border-radius: 9rpx;
  424. }
  425. .release {
  426. flex: 1;
  427. display: flex;
  428. align-items: center;
  429. justify-content: center;
  430. height: 72rpx;
  431. border-radius: 9rpx;
  432. color: #ffff;
  433. background-color: #376cbb;
  434. }
  435. }
  436. .column-list-content {
  437. margin-top: 20rpx;
  438. }
  439. }
  440. </style>