specialColumn.vue 9.3 KB

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