creation.bak.vue 8.4 KB

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