commodity.vue 7.7 KB

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