index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <view>
  3. <uni-menubar title="文章列表" />
  4. <tm-search v-model="param.keyword" color="blue" @confirm="init"></tm-search>
  5. <tm-tabs color="blue" v-model="activeIndex" :list="allnav" range-key="name" align="left" @change="change">
  6. </tm-tabs>
  7. <view class='art-coin'>
  8. <block v-for="(item,index) in list" :key="index">
  9. <view class='art-act' @click="goDetail(item.id)">
  10. <view class="art-act-imgAndTitle">
  11. <image v-if="item.pic" class='art-act-l' mode='aspectFill' :src='item.pic'></image>
  12. <view class="art-act-titleAndTime">
  13. <view class='act-act-rname'>{{ item.title }}</view>
  14. <view class="art-act-time">{{item.create_time}}</view>
  15. </view>
  16. </view>
  17. <view class='act-art-rinfo'>
  18. <view class='act-act-rsort'>{{ item.name }}</view>
  19. <view class='act-act-rbrowsing'>
  20. <view class='act-act-rlook'>{{ item.show_views > 0 ? item.show_views : item.views }}查看
  21. </view>
  22. <view class='act-act-rrelay'>{{ item.track_count }}转发</view>
  23. </view>
  24. </view>
  25. </view>
  26. </block>
  27. </view>
  28. <tm-poup confirmColor="blue" position="bottom" height="70%" :round="0" v-if="addShow" v-model="addShow">
  29. <view class="pa-20">
  30. <view class="text-xl text-bold">文章编辑</view>
  31. <tm-pickers default-value="cate" btn-color="blue" :list="allnav" rang-key="name" @confirm="sureCate">
  32. <view class="flex flex-between">
  33. <view style="mr-20">文章分类</view>
  34. <view>
  35. <tm-input :margin="[0,0]"
  36. :value="formData.cate_id? allnav.find(v=>v.id == formData.cate_id)['name']:'请选择分类'">
  37. </tm-input>
  38. </view>
  39. </view>
  40. </tm-pickers>
  41. <view class="flex flex-between mt-20">
  42. <view class="mr-20">文章来源</view>
  43. <view>
  44. <tm-groupradio>
  45. <tm-radio dense size="20" v-model="sourceObj.obj1" color="bg-gradient-blue-accent"
  46. label="微信公众号"></tm-radio>
  47. <tm-radio dense size="20" v-model="sourceObj.obj2" color="bg-gradient-blue-accent"
  48. label="今日头条"></tm-radio>
  49. </tm-groupradio>
  50. </view>
  51. </view>
  52. <view class="mt-40 flex flex-between">
  53. <view class="mr-20">打开方式</view>
  54. <view>
  55. <tm-groupradio>
  56. <tm-radio dense size="20" v-model="openObj.obj1" color="bg-gradient-blue-accent"
  57. label="小程序内"></tm-radio>
  58. <tm-radio dense size="20" v-model="openObj.obj2" color="bg-gradient-blue-accent"
  59. label="微信公众号"></tm-radio>
  60. </tm-groupradio>
  61. </view>
  62. </view>
  63. <view class="pa-20 ma-20 text-size-xs bg-gray" v-if="openObj.obj2">
  64. <view>微信内打开,需要小程序关联到微信公众号</view>
  65. <view @click="copy">点击复制APPID:<text>wx3466c53d33b9dbdc</text>进行关联</view>
  66. </view>
  67. <view class="mt-40">文章地址</view>
  68. <tm-gap></tm-gap>
  69. <tm-input bg-color="grey-lighten-5" :padding="[0,0]" clear :height="120" :maxlength="1000"
  70. input-type="textarea" v-model="formData.url"></tm-input>
  71. <view class="px-24">
  72. <tm-button block @click="articleAdd">确定提交</tm-button>
  73. </view>
  74. </view>
  75. </tm-poup>
  76. <tm-flotbutton @click="addShow = true" label="添加" :show-text="true">
  77. </tm-flotbutton>
  78. </view>
  79. </template>
  80. <script>
  81. export default {
  82. data() {
  83. return {
  84. appIdShow: false,
  85. sourceObj: {
  86. obj1: true,
  87. obj2: false,
  88. },
  89. openObj: {
  90. obj1: true,
  91. obj2: false,
  92. },
  93. cate: "",
  94. pid: '',
  95. param: {
  96. page: 1,
  97. keyword: '',
  98. cate_id: '',
  99. cate_pid: '',
  100. },
  101. activeIndex: 0,
  102. nav: [],
  103. allnav: [{
  104. 'name': '全部',
  105. 'id': 0
  106. }],
  107. list: [],
  108. addShow: false,
  109. formData: {
  110. cate_id: "",
  111. is_make: "",
  112. link_type: "",
  113. url: ""
  114. }
  115. }
  116. },
  117. computed: {
  118. user() {
  119. return this.$tm.vx.state().user.userInfo || {}
  120. }
  121. },
  122. watch: {
  123. addShow(val) {
  124. if (val) {
  125. this.get()
  126. }
  127. }
  128. },
  129. onLoad() {
  130. uni.$tm.request.post('art/cate', this.pid).then(res => {
  131. this.nav = res.data
  132. this.allnav = [...this.allnav, ...this.nav]
  133. })
  134. this.init()
  135. },
  136. methods: {
  137. get() {
  138. uni.getClipboardData({
  139. success: (res) => {
  140. this.formData.url = res.data
  141. if (this.formData.url.indexOf("qq") != -1) {
  142. this.sourceObj.obj1 = true
  143. } else {
  144. this.sourceObj.obj2 = true
  145. }
  146. }
  147. });
  148. },
  149. copy() {
  150. uni.setClipboardData({
  151. data: "wx3466c53d33b9dbdc"
  152. });
  153. },
  154. radioChange(e) {
  155. if (e.checked == true) {
  156. this.appIdShow = true
  157. }
  158. },
  159. sureCate(e) {
  160. this.formData.cate_id = e[0].data.id
  161. },
  162. articleAdd() {
  163. this.formData.link_type = this.sourceObj.obj1 == true ? 1 : 2
  164. this.formData.is_make = this.openObj.obj1 == true ? 0 : 1
  165. this.$tm.request.post('art/fetchwxart', this.formData).then(res => {
  166. if (res.code == 200) {
  167. uni.showToast({
  168. title: "新增成功",
  169. icon: "success"
  170. })
  171. this.init()
  172. this.addShow = false
  173. this.formData = {
  174. cate_id: "",
  175. is_make: "",
  176. link_type: "",
  177. url: ""
  178. }
  179. } else {
  180. uni.showToast({
  181. title: res.message,
  182. icon: "none"
  183. })
  184. }
  185. })
  186. },
  187. init() {
  188. uni.$tm.request.post('art/list', this.param).then(res => {
  189. this.list = res.data
  190. })
  191. },
  192. change(e) {
  193. this.activeIndex = e
  194. this.param.cate_id = this.allnav[e].id
  195. this.init()
  196. },
  197. goDetail(id) {
  198. uni.navigateTo({
  199. url: '/pages/list/list?id=' + id + "&card_id=" + uni.getStorageSync('card_id')
  200. })
  201. }
  202. }
  203. }
  204. </script>
  205. <style lang="scss" scoped>
  206. /*去掉滚动条*/
  207. ::-webkit-scrollbar {
  208. width: 0;
  209. height: 0;
  210. color: transparent;
  211. }
  212. .top-bar {
  213. width: 100%;
  214. display: flex;
  215. align-items: center;
  216. justify-content: space-between;
  217. background-color: #fff;
  218. box-shadow: 2px 2px 5px #ccc;
  219. font-size: 28rpx;
  220. }
  221. .stick {
  222. position: fixed;
  223. right: 0;
  224. left: 0;
  225. background: #fff;
  226. box-shadow: 2px 2px 5px #ccc;
  227. font-size: 28rpx;
  228. }
  229. .contains-act {
  230. padding-top: 100rpx;
  231. }
  232. .scrolls {
  233. height: 100rpx;
  234. width: 98%;
  235. line-height: 100rpx;
  236. display: flex;
  237. align-items: center;
  238. justify-content: center;
  239. white-space: nowrap;
  240. }
  241. .scrolls .cure {
  242. width: 130rpx;
  243. display: inline-flex;
  244. justify-content: center;
  245. }
  246. .scrolls .active text {
  247. color: #f90;
  248. height: 96rpx;
  249. border-bottom: 4rpx solid #f90;
  250. }
  251. .scroll-more {
  252. flex: 1;
  253. display: flex;
  254. justify-content: center;
  255. }
  256. .scroll-more text {
  257. font-size: 50rpx;
  258. line-height: 50rpx;
  259. color: #3b3b3b;
  260. }
  261. .art-act {
  262. display: flex;
  263. flex-direction: column;
  264. justify-content: flex-start;
  265. margin: 1rem 20rpx 0 20rpx;
  266. box-shadow: 0px 1px 5px #EEEEEE;
  267. border-radius: 5px;
  268. background: #fff;
  269. }
  270. /* .art-act:last-child{
  271. border-bottom: 0;
  272. } */
  273. .art-act-time {
  274. font-size: 24rpx;
  275. color: #aaa;
  276. margin-top: 3vw;
  277. }
  278. .art-act-imgAndTitle {
  279. display: flex;
  280. flex-direction: row-reverse;
  281. align-items: center;
  282. justify-content: space-between;
  283. padding: 3vw 0;
  284. margin: 0 3vw;
  285. border-bottom: 1px solid #eee;
  286. }
  287. .art-act-titleAndTime {
  288. display: flex;
  289. flex-direction: column;
  290. flex: 1;
  291. justify-content: space-between;
  292. }
  293. .art-act-l {
  294. width: 250rpx;
  295. height: 150rpx;
  296. margin-left: 3vw;
  297. }
  298. .act-act-rname {
  299. font-size: 30rpx;
  300. font-weight: 530;
  301. display: -webkit-box;
  302. -webkit-box-orient: vertical;
  303. -webkit-line-clamp: 2;
  304. overflow: hidden;
  305. word-break: break-all;
  306. flex: 1;
  307. }
  308. .act-art-rinfo {
  309. display: flex;
  310. flex-direction: row-reverse;
  311. align-items: center;
  312. justify-content: space-between;
  313. font-size: 26rpx;
  314. color: #888888;
  315. padding: 4vw 0;
  316. margin: 0 3vw;
  317. }
  318. .act-act-rsort {
  319. /*color: #fff;
  320. padding: 6rpx 20rpx;
  321. background: #00a1e9;
  322. border-radius: 2px;*/
  323. }
  324. .act-act-rbrowsing {
  325. display: flex;
  326. align-items: center;
  327. }
  328. .act-act-rrelay {
  329. margin-left: 20rpx;
  330. }
  331. /*底部tabbar*/
  332. .blank {
  333. height: 126rpx;
  334. }
  335. .art-tabbar {
  336. width: 100%;
  337. height: 120rpx;
  338. position: fixed;
  339. bottom: 0;
  340. z-index: 99;
  341. display: flex;
  342. justify-content: center;
  343. }
  344. .art-tabbar view {
  345. width: 100rpx;
  346. height: 100rpx;
  347. border-radius: 50%;
  348. border: 1px solid #eeeeee;
  349. position: absolute;
  350. top: -34rpx;
  351. background-color: #ffffff;
  352. }
  353. .art-bar {
  354. position: fixed;
  355. display: flex;
  356. align-items: center;
  357. width: 100%;
  358. bottom: 0;
  359. border-top: 1px solid #eeeeee;
  360. z-index: 100;
  361. background-color: #ffffff;
  362. }
  363. .art-bar-act {
  364. flex: 1;
  365. display: flex;
  366. flex-flow: column;
  367. align-items: center;
  368. height: 120rpx;
  369. justify-content: flex-end;
  370. }
  371. /* .art-tabbar-on{
  372. color:#55b537;
  373. } */
  374. .art-bar-act text {
  375. font-size: 50rpx;
  376. line-height: 50rpx;
  377. }
  378. .art-bar-act view {
  379. font-size: 24rpx;
  380. margin: 10rpx 0;
  381. }
  382. .art-bar-among {
  383. flex: 1;
  384. height: 120rpx;
  385. display: flex;
  386. justify-content: center;
  387. position: relative;
  388. }
  389. .art-bar-pic {
  390. position: absolute;
  391. font-size: 100rpx;
  392. top: -30rpx;
  393. line-height: 100rpx;
  394. /* border:1px solid #eeeeee; */
  395. border-radius: 50%;
  396. background-color: #ffffff;
  397. }
  398. .art-bar-tit {
  399. font-size: 24rpx;
  400. position: absolute;
  401. bottom: 10rpx;
  402. }
  403. .art-bar-act image {
  404. width: 50rpx;
  405. }
  406. .art-bar-among image {
  407. position: absolute;
  408. width: 100rpx;
  409. height: 100rpx;
  410. border-radius: 50%;
  411. background-color: #ffffff;
  412. top: -26rpx;
  413. }
  414. </style>