compileCommodity.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <view class="content">
  3. <view class="status_bar"><!-- 这里是状态栏 --></view>
  4. <view class="content-money">
  5. <view class="money-box">
  6. <view class="goback-box" @click="toBack"><image class="goback" src="../../static/img/back.png" mode=""></image></view>
  7. <view class="header">商品管理</view>
  8. <view class="bianj" @click="nav('/pages/merchant/commodity')">完成</view>
  9. </view>
  10. </view>
  11. <view class="navbar">
  12. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  13. </view>
  14. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  15. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  16. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  17. <!-- 空白页 -->
  18. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  19. <!-- 已上架 -->
  20. <view class="commodity-box">
  21. <view class="goodsList-item flex" v-for="(lss, ind) in tabItem.orderList" @click="check('item', ind, tabIndex)">
  22. <view class="iconfont iconroundcheckfill checkbox" :class="{ checked: lss.checked }"></view>
  23. <view class="img"><image :src="lss.image" mode="scaleToFill"></image></view>
  24. <view class="text">
  25. <view class="spname">{{ lss.store_name }}</view>
  26. <view class="price">
  27. <text>¥</text>
  28. {{ lss.price }}
  29. </view>
  30. </view>
  31. <view class="yishou">已售{{ lss.sales }}</view>
  32. </view>
  33. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  34. </view>
  35. </scroll-view>
  36. </swiper-item>
  37. </swiper>
  38. <view class="btn flex">
  39. <view class="checkAllbox" @click="check('all')">
  40. <view class="iconfont iconroundcheckfill checkalls" :class="{ checked: allChecked }"></view>
  41. <view class="quanxuan">全选</view>
  42. </view>
  43. <view class="btn-box flex"><view class="button" style="margin-left: 20rpx;" @click="submit()">下架</view></view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  49. export default {
  50. data() {
  51. return {
  52. tabCurrentIndex: 0,
  53. allChecked: false,
  54. navList: [
  55. {
  56. state: 0,
  57. text: '全部',
  58. orderList: [],
  59. loadingType: 'more',
  60. page: 1, //当前页面
  61. limit: 10 //每次信息条数
  62. },
  63. {
  64. state: 0,
  65. text: '已上架',
  66. loadingType: 'more',
  67. orderList: [],
  68. page: 1, //当前页面
  69. limit: 10 //每次信息条数
  70. },
  71. {
  72. state: 0,
  73. text: '已下架',
  74. loadingType: 'more',
  75. orderList: [],
  76. page: 1, //当前页面
  77. limit: 10 //每次信息条数
  78. }
  79. ]
  80. };
  81. },
  82. onLoad() {
  83. this.loadData();
  84. },
  85. methods: {
  86. //顶部tab点击
  87. tabClick(index) {
  88. this.tabCurrentIndex = index;
  89. },
  90. changeTab(index) {
  91. this.tabCurrentIndex = index.detail.current;
  92. const obj = this;
  93. // obj.getDataList(obj.indexList[obj.classIndex], 'tabChange');
  94. obj.allChecked = true;
  95. if (obj.indexList[obj.classIndex].dataList.length > 0) {
  96. let list = obj.indexList[obj.classIndex].dataList;
  97. for (let i = 0; i < list.length; i++) {
  98. if (!list[i].checked) {
  99. obj.allChecked = false;
  100. break;
  101. }
  102. }
  103. } else {
  104. obj.allChecked = false;
  105. }
  106. },
  107. loadData() {
  108. },
  109. // 点击返回 我的页面
  110. toBack() {
  111. uni.navigateBack({});
  112. },
  113. choose() {
  114. this.isBian = !this.isBian;
  115. },
  116. nav(url) {
  117. uni.navigateTo({
  118. url
  119. });
  120. },
  121. check(type, index, erindex) {
  122. const obj = this;
  123. if (type === 'item') {
  124. const list = obj.indexList[erindex].dataList;
  125. list[index].checked = !list[index].checked;
  126. if (list[index].checked) {
  127. if (!obj.chose.includes(list[index].id)) {
  128. obj.chose.push(list[index].id);
  129. }
  130. } else {
  131. if (obj.chose.includes(list[index].id)) {
  132. // console.log(list[index].id);
  133. let aid = list[index];
  134. console.log(aid);
  135. let index = obj.chose.indexOf(aid);
  136. obj.chose.splice(index, 1);
  137. }
  138. }
  139. this.allChecked = true;
  140. for (let i = 0; i < list.length; i++) {
  141. if (!list[i].checked) {
  142. this.allChecked = false;
  143. }
  144. }
  145. } else {
  146. const checked = !obj.allChecked;
  147. const list = obj.indexList[obj.classIndex].dataList;
  148. list.forEach(item => {
  149. item.checked = checked;
  150. });
  151. obj.allChecked = checked;
  152. if (obj.allChecked) {
  153. list.forEach(item => {
  154. if (!obj.chose.includes(item.id)) {
  155. obj.chose.push(item.id);
  156. }
  157. });
  158. } else {
  159. list.forEach(item => {
  160. if (obj.chose.includes(item.id)) {
  161. let index = obj.chose.indexOf(item.id);
  162. obj.chose.splice(index, 1);
  163. }
  164. });
  165. }
  166. }
  167. }
  168. }
  169. };
  170. </script>
  171. <style lang="scss">
  172. page,
  173. .content {
  174. background: $page-color-base;
  175. height: 100%;
  176. }
  177. .swiper-box {
  178. height: calc(100% - 40px);
  179. }
  180. .list-scroll-content {
  181. height: 100%;
  182. }
  183. .status_bar {
  184. height: var(--status-bar-height);
  185. width: 100%;
  186. background: #ffffff;
  187. }
  188. .money-box {
  189. height: 80rpx;
  190. color: #000000;
  191. text-align: center;
  192. font-size: 35rpx;
  193. position: relative;
  194. background-color: #ffffff;
  195. .header {
  196. position: absolute;
  197. left: 0;
  198. top: 0;
  199. width: 100%;
  200. height: 80rpx;
  201. font-size: 32rpx;
  202. font-weight: 700;
  203. z-index: 99;
  204. display: flex;
  205. justify-content: center;
  206. align-items: center;
  207. }
  208. .bianj {
  209. position: absolute;
  210. right: 28rpx;
  211. height: 80rpx;
  212. font-size: 28rpx;
  213. font-family: PingFangSC;
  214. font-weight: 400;
  215. color: #333333;
  216. z-index: 99;
  217. display: flex;
  218. justify-content: center;
  219. align-items: center;
  220. }
  221. .goback-box {
  222. position: absolute;
  223. left: 24rpx;
  224. top: 0;
  225. height: 80rpx;
  226. display: flex;
  227. align-items: center;
  228. }
  229. .goback {
  230. z-index: 100;
  231. width: 20rpx;
  232. height: 34rpx;
  233. }
  234. }
  235. .commodity-box {
  236. width: 750rpx;
  237. .goodsList-item {
  238. position: relative;
  239. justify-content: flex-start;
  240. width: 100%;
  241. padding: 30rpx;
  242. .checkbox {
  243. display: flex;
  244. flex-shrink: 0;
  245. font-size: 32rpx;
  246. color: #eeeeee;
  247. background: #eeeeee;
  248. border-radius: 50px;
  249. }
  250. .img {
  251. margin-left: 28rpx;
  252. width: 146rpx;
  253. height: 146rpx;
  254. background: #f0f0f0;
  255. border-radius: 10px;
  256. image {
  257. width: 146rpx;
  258. height: 146rpx;
  259. }
  260. }
  261. .text {
  262. position: relative;
  263. padding-left: 35rpx;
  264. height: 146rpx;
  265. text-overflow: ellipsis;
  266. overflow: hidden;
  267. white-space: nowrap;
  268. .spname {
  269. font-size: 28rpx;
  270. font-family: PingFang SC;
  271. font-weight: bold;
  272. color: #333333;
  273. text-overflow: ellipsis;
  274. overflow: hidden;
  275. }
  276. .earning {
  277. width: 275rpx;
  278. padding: 7rpx;
  279. margin-top: 12rpx;
  280. background: #fee1d7;
  281. border-radius: 5rpx;
  282. text-align: center;
  283. font-size: 20rpx;
  284. font-family: PingFang SC;
  285. font-weight: 500;
  286. color: #fc4141;
  287. line-height: 1;
  288. }
  289. .price {
  290. margin-top: 19rpx;
  291. font-family: PingFang SC;
  292. font-weight: bold;
  293. color: #ff0000;
  294. font-size: 36rpx;
  295. text {
  296. font-size: 24rpx;
  297. }
  298. }
  299. }
  300. .yishou {
  301. position: absolute;
  302. right: 29rpx;
  303. bottom: 40rpx;
  304. }
  305. }
  306. }
  307. .navbar {
  308. display: flex;
  309. height: 40px;
  310. padding: 0 5px;
  311. background: #fff;
  312. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  313. position: relative;
  314. z-index: 10;
  315. .nav-item {
  316. flex: 1;
  317. display: flex;
  318. justify-content: center;
  319. align-items: center;
  320. height: 100%;
  321. font-size: 12px;
  322. color: $font-color-dark;
  323. position: relative;
  324. &.current {
  325. color: $base-color;
  326. &:after {
  327. content: '';
  328. position: absolute;
  329. left: 50%;
  330. bottom: 0;
  331. transform: translateX(-50%);
  332. width: 44px;
  333. height: 0;
  334. border-bottom: 2px solid $base-color;
  335. }
  336. }
  337. }
  338. }
  339. .input {
  340. position: fixed;
  341. bottom: 38rpx;
  342. left: 30rpx;
  343. text-align: center;
  344. width: 674rpx;
  345. height: 88rpx;
  346. background: #52c696;
  347. border-radius: 44rpx;
  348. font-size: 36rpx;
  349. font-family: PingFang SC;
  350. font-weight: 500;
  351. line-height: 88rpx;
  352. color: #ffffff;
  353. }
  354. .btn {
  355. position: fixed;
  356. bottom: 0;
  357. width: 100%;
  358. height: 100rpx;
  359. justify-content: space-between;
  360. padding: 0 39rpx 0 54rpx;
  361. line-height: 1;
  362. border-top: 1rpx solid #f0f0f0;
  363. .checkAllbox {
  364. display: flex;
  365. .checkalls {
  366. font-size: 32rpx;
  367. color: #eeeeee;
  368. background: #eeeeee;
  369. border-radius: 50px;
  370. }
  371. .quanxuan {
  372. margin-left: 16rpx;
  373. font-size: 30rpx;
  374. font-family: PingFang SC;
  375. font-weight: 400;
  376. color: #1d2023;
  377. }
  378. }
  379. .button {
  380. width: 160rpx;
  381. height: 64rpx;
  382. background: #52c696;
  383. border-radius: 32rpx;
  384. color: #ffffff;
  385. text-align: center;
  386. line-height: 64rpx;
  387. font-size: 30rpx;
  388. font-family: PingFang SC;
  389. font-weight: bold;
  390. }
  391. }
  392. </style>