myColumnDetail.vue 10 KB

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