creation.vue 7.9 KB

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