release.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <view class="content">
  3. <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item"
  5. :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  6. </view>
  7. <swiper :current="tabCurrentIndex" :style="{ height: height }" class="swiper-box" duration="300"
  8. @change="changeTab">
  9. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  10. <scroll-view scroll-y="true" class="list-scroll-content" :class="{ yan: tabCurrentIndex == 0 }"
  11. @scrolltolower="loadData">
  12. <!-- 空白页 -->
  13. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  14. <view class="main" v-for="(item, index) in tabItem.orderList" :key="index" @click="navTo('/pages/share/myarticle?id=' + item.id + '&type=' + tabCurrentIndex)">
  15. <view class="main-userInfo">
  16. <view class="avatar">
  17. <image :src="item.author" mode=""></image>
  18. </view>
  19. <view class="main-user-info">
  20. <view class="main-userName">{{item.title}}</view>
  21. <view class="main-user-time">{{item.add_time}}</view>
  22. </view>
  23. <view class="fenxiang flex">
  24. <image class="img-lj" src="../../static/icon/lj.png"></image>
  25. <view class="wen-lj">{{item.visit}}</view>
  26. </view>
  27. </view>
  28. <view class="text">
  29. <view>{{item.content}}</view>
  30. </view>
  31. <view class="fh-im">
  32. <image v-for="item in item.share_images" class="fh-img" :src="item" mode=""></image>
  33. </view>
  34. <view class="bot flex">
  35. <image class="del" src="../../static/icon/del.png" mode=""></image>
  36. <view @click.stop="del(item.id)" class="sc">删除</view>
  37. </view>
  38. </view>
  39. <!-- 订单列表 -->
  40. <uni-load-more :status="tabItem.loadingType"
  41. v-if="!(tabItem.orderList.length == 0 && tabItem.loaded)"></uni-load-more>
  42. </scroll-view>
  43. </swiper-item>
  44. </swiper>
  45. <button class="rele" @click="navTo('/pages/share/myarticle')" >发布素材</button>
  46. </view>
  47. </template>
  48. <script>
  49. import empty from '@/components/empty';
  50. import {
  51. my_article,
  52. delete_article,
  53. } from '@/api/user.js';
  54. import {
  55. getTime
  56. } from '@/utils/rocessor.js'
  57. export default {
  58. components: {
  59. empty
  60. },
  61. data() {
  62. return {
  63. height: '',
  64. tabCurrentIndex: 0,
  65. navList: [{
  66. type: 0,
  67. state: -1,
  68. text: '草稿箱',
  69. loadingType: 'more',
  70. orderList: [],
  71. page: 1, //当前页数
  72. limit: 10 //每次信息条数
  73. },
  74. {
  75. type: 1,
  76. state: 1,
  77. text: '已审核',
  78. loadingType: 'more',
  79. orderList: [],
  80. page: 1, //当前页数
  81. limit: 10 //每次信息条数
  82. },
  83. {
  84. type: 1,
  85. state: 0,
  86. text: '审核中',
  87. loadingType: 'more',
  88. orderList: [],
  89. page: 1, //当前页数
  90. limit: 10 //每次信息条数
  91. }
  92. ]
  93. };
  94. },
  95. onLoad() {
  96. this.loadData();
  97. },
  98. onShow() {},
  99. onReady(res) {
  100. var _this = this;
  101. uni.getSystemInfo({
  102. success: resu => {
  103. const query = uni.createSelectorQuery();
  104. query.select('.swiper-box').boundingClientRect();
  105. query.exec(function(res) {
  106. _this.height = resu.windowHeight - res[0].top + 'px';
  107. console.log('打印页面的剩余高度', _this.height);
  108. });
  109. },
  110. fail: res => {}
  111. });
  112. },
  113. methods: {
  114. //顶部tab点击
  115. tabClick(index) {
  116. this.tabCurrentIndex = index;
  117. },
  118. //swiper 切换
  119. changeTab(e) {
  120. this.tabCurrentIndex = e.target.current;
  121. this.loadData('tabChange');
  122. },
  123. dele(id) {
  124. const obj = this;
  125. uni.showModal({
  126. title: '提示',
  127. content: '是否删除这个草稿',
  128. success: function(res) {
  129. if (res.confirm) {
  130. delete_article({}, id).then(({
  131. data
  132. }) => {
  133. obj.$api.msg('删除成功');
  134. obj.loadData('shua');
  135. });
  136. } else if (res.cancel) {
  137. console.log('用户点击取消');
  138. }
  139. }
  140. });
  141. },
  142. navTo(url) {
  143. uni.navigateTo({
  144. url
  145. });
  146. },
  147. async loadData(source) {
  148. let obj = this;
  149. //这里是将订单挂载到tab列表下
  150. let index = this.tabCurrentIndex;
  151. let navItem = this.navList[index];
  152. let state = navItem.state;
  153. let type = navItem.type;
  154. if (source === 'shua') {
  155. navItem.loadingType = 'more';
  156. navItem.page = 1;
  157. navItem.limit = 10;
  158. navItem.orderList = [];
  159. }
  160. if (source === 'tabChange' && navItem.loaded === true) {
  161. //tab切换只有第一次需要加载数据
  162. return;
  163. }
  164. if (navItem.loadingType === 'loading') {
  165. //防止重复加载
  166. return;
  167. }
  168. // 修改当前对象状态为加载中
  169. navItem.loadingType = 'loading';
  170. my_article({
  171. page: navItem.page,
  172. limit: navItem.limit,
  173. state: state
  174. }, type)
  175. .then(({
  176. data
  177. }) => {
  178. let arr = []
  179. data.list = data.list.map((e)=>{
  180. e.share_images = e.share_images.split(',');
  181. return e
  182. });
  183. if (state == -1) {
  184. arr = data.list
  185. }
  186. if (state == 0) {
  187. arr = data.list.filter(e => {
  188. return e.check_status == 0
  189. })
  190. }
  191. if (state == 1) {
  192. arr = data.list.filter(e => {
  193. return e.check_status != 0
  194. })
  195. }
  196. arr.forEach(e => {
  197. e.add_time = getTime(e.add_time)
  198. })
  199. console.log(arr);
  200. navItem.orderList = navItem.orderList.concat(arr);
  201. navItem.page++;
  202. if (navItem.limit == data.list.length) {
  203. navItem.loadingType = 'more';
  204. } else {
  205. navItem.loadingType = 'noMore';
  206. }
  207. obj.$set(navItem, 'loaded', true);
  208. })
  209. .catch(e => {
  210. console.log(e,'233');
  211. });
  212. }
  213. }
  214. };
  215. </script>
  216. <style lang="scss">
  217. page,
  218. .content {
  219. min-height: 100%;
  220. height: auto;
  221. }
  222. .navbar {
  223. display: flex;
  224. height: 88rpx;
  225. padding: 0 5px;
  226. background: #fff;
  227. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  228. position: relative;
  229. z-index: 10;
  230. .nav-item {
  231. flex: 1;
  232. display: flex;
  233. justify-content: center;
  234. align-items: center;
  235. height: 100%;
  236. font-size: 15px;
  237. color: #999999;
  238. position: relative;
  239. &.current {
  240. color: #000;
  241. &:after {
  242. content: '';
  243. position: absolute;
  244. left: 50%;
  245. bottom: 0;
  246. transform: translateX(-50%);
  247. width: 44px;
  248. height: 0;
  249. border-bottom: 2px solid #c54b4a;
  250. }
  251. }
  252. }
  253. }
  254. .main {
  255. margin: 20rpx;
  256. padding: 35rpx 20rpx 24rpx;
  257. background: #ffffff;
  258. width: 702rpx;
  259. border-radius: 30rpx;
  260. image {
  261. width: 100%;
  262. height: 100%;
  263. }
  264. .main-userInfo {
  265. display: flex;
  266. align-items: center;
  267. .avatar {
  268. width: 80rpx;
  269. height: 80rpx;
  270. background: #ffffff;
  271. border-radius: 50%;
  272. }
  273. .main-user-info {
  274. margin-left: 14rpx;
  275. line-height: 1;
  276. .main-userName {
  277. font-size: 28rpx;
  278. font-weight: bold;
  279. color: #000000;
  280. }
  281. .main-user-time {
  282. margin-top: 14rpx;
  283. font-size: 21rpx;
  284. font-family: PingFang SC;
  285. font-weight: 500;
  286. color: #666666;
  287. }
  288. }
  289. .fenxiang {
  290. padding-left: 310rpx;
  291. .img-lj {
  292. width: 28rpx;
  293. height: 28rpx;
  294. }
  295. .wen-lj {
  296. font-size: 28rpx;
  297. color: #FF6F0F;
  298. padding-left: 10rpx;
  299. }
  300. }
  301. }
  302. .text {
  303. word-wrap: break-word;
  304. word-break: normal;
  305. margin: 20rpx 0rpx;
  306. font-size: 28rpx;
  307. font-weight: 500;
  308. color: #666666;
  309. }
  310. .fh-im {
  311. .fh-img {
  312. // margin: auto 10rpx;
  313. margin: 10rpx 21rpx 0rpx 0rpx;
  314. width: 200rpx;
  315. height: 200rpx;
  316. // padding: 10rpx;
  317. }
  318. }
  319. .bot {
  320. .del {
  321. margin-left: 540rpx;
  322. width: 24rpx;
  323. height: 28rpx;
  324. }
  325. .sc {
  326. padding-right: 40rpx;
  327. font-size: 24rpx;
  328. font-weight: 500;
  329. color: #FF4C4C;
  330. }
  331. }
  332. }
  333. .rele {
  334. position: fixed;
  335. width: 750rpx;
  336. bottom: 0rpx;
  337. background-color: #FF6F0F;
  338. color: #ffffff;
  339. }
  340. .swiper-box {
  341. margin-top: 20rpx;
  342. .tab-content {
  343. position: relative;
  344. }
  345. }
  346. </style>