total.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <view class="PanKuContainer">
  3. <view class="all">
  4. <view class="num">
  5. 库存:总共
  6. <text class="spec">
  7. {{ infoList.reduce((a, b) => a + Number(b.total), 0) }}
  8. </text>
  9. </view>
  10. </view>
  11. <view
  12. class="goodList"
  13. >
  14. <view
  15. v-for="(item, i) in infoList"
  16. :key="i"
  17. class="goodItem"
  18. >
  19. <view class="top">
  20. <view
  21. class="avatar"
  22. :style="{ backgroundImage: `url(${item.imgurl})` }"
  23. />
  24. <view class="info">
  25. <view class="name">{{ item.name }}</view>
  26. <view class="fixed">一年零一天不满意退钱</view>
  27. </view>
  28. </view>
  29. <view class="skuContainer">
  30. <view
  31. class="header"
  32. :class="item.toggle ? 'open' : ''"
  33. @click="item.toggle = !item.toggle"
  34. >
  35. <view class="icon"></view>
  36. <view class="name">{{ item.attr }}</view>
  37. </view>
  38. <view v-if="item.toggle" class="skuList">
  39. <view class="skuHeader">
  40. <view class="type">规格</view>
  41. <view class="size">尺码</view>
  42. <view class="num">数量</view>
  43. </view>
  44. <view
  45. v-for="(btem, bi) in item.spec"
  46. :key="bi"
  47. class="skuItem"
  48. >
  49. <view class="type">{{ btem.sex ? '男款' : '女款' }}</view>
  50. <view class="size">{{ btem.size }}</view>
  51. <view class="num">{{ btem.num }}</view>
  52. </view>
  53. </view>
  54. <view class="dataAll">
  55. <view class="sex">
  56. 男款:{{ item.men }}套
  57. /
  58. 女款:{{ item.women }}套
  59. </view>
  60. <view class="num">
  61. 合计:<text class="spec">{{ item.total }}套</text>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import { allStock } from "@/apis/stock.js"
  71. export default {
  72. data() {
  73. return {
  74. infoList: []
  75. }
  76. },
  77. onLoad() {
  78. let _this = this
  79. uni.showLoading()
  80. allStock().then(res => {
  81. uni.hideLoading()
  82. if (res.code === 200) {
  83. Object.keys(res.data).forEach(k => {
  84. if(res.data[k].spec.length > 0) {
  85. res.data[k].toggle = false
  86. res.data[k].attr = _this.changeKey(k)
  87. res.data[k].men = res.data[k].spec.filter(({ sex }) => sex).reduce((a, b) => a + Number(b.num), 0)
  88. res.data[k].women = res.data[k].spec.filter(({ sex }) => !sex).reduce((a, b) => a + Number(b.num), 0)
  89. res.data[k].total = res.data[k].spec.reduce((a, b) => a + Number(b.num), 0)
  90. _this.infoList.push(res.data[k])
  91. }
  92. })
  93. } else {
  94. uni.showModal({
  95. content: res.message || "获取详情失败",
  96. showCancel: false
  97. })
  98. }
  99. }).catch(() => {
  100. uni.hideLoading()
  101. uni.showModal({
  102. content: "获取详情失败",
  103. showCancel: false
  104. })
  105. })
  106. },
  107. methods: {
  108. changeKey(k) {
  109. let out = ''
  110. switch(k) {
  111. case 'hard':
  112. out = '精装版'
  113. break;
  114. case 'new_old':
  115. out = '纯棉版'
  116. break;
  117. case 'old':
  118. out = '高腰版'
  119. break;
  120. case 'simple':
  121. out = '简约版'
  122. break;
  123. case 'youth':
  124. out = '青春版'
  125. break;
  126. default:
  127. out = '简约版'
  128. break
  129. }
  130. return out
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. page{
  137. display: flex;
  138. flex-direction: column;
  139. }
  140. .PanKuContainer {
  141. width: 100%;
  142. flex: 1;
  143. background-color: #F9F9FB;
  144. padding: 30rpx;
  145. .btn {
  146. width: 140rpx;
  147. height: 56rpx;
  148. border-radius: 8rpx;
  149. background-color: #EA4A41;
  150. color: #FFFFFF;
  151. font-size: 28rpx;
  152. line-height: 56rpx;
  153. text-align: center;
  154. text-align: center;
  155. }
  156. .all {
  157. width: 100%;
  158. display: flex;
  159. align-items: center;
  160. justify-content: space-between;
  161. margin-bottom: 30rpx;
  162. .num {
  163. color: #333333;
  164. font-size: 36rpx;
  165. line-height: 50rpx;
  166. font-weight: bold;
  167. .spec {
  168. color: #EA4A41 !important;
  169. }
  170. }
  171. }
  172. .reviseBtn {
  173. position: fixed;
  174. bottom: 0;
  175. left: 0;
  176. right: 0;
  177. height: 100rpx;
  178. display: flex;
  179. align-items: center;
  180. justify-content: space-between;
  181. background: #FFFFFF;
  182. color: #FFFFFF;
  183. font-size: 32rpx;
  184. padding: 0 30rpx;
  185. .type {
  186. color: #999999;
  187. font-size: 28rpx;
  188. margin-right: 10rpx;
  189. }
  190. .all {
  191. color: #333333;
  192. font-size: 28rpx;
  193. }
  194. .num {
  195. font-size: 40rpx;
  196. color: #EA4A41;
  197. }
  198. .unit {
  199. font-size: 28rpx;
  200. color: #EA4A41;
  201. }
  202. .submitBtn {
  203. width: 192rpx;
  204. height: 68rpx;
  205. line-height: 68rpx;
  206. text-align: center;
  207. border-radius: 68rpx;
  208. background: linear-gradient(to right, #F97C55, #F44545);
  209. color: #FFFFFF;
  210. font-size: 28rpx;
  211. }
  212. }
  213. .goodList {
  214. width: 100%;
  215. .goodItem {
  216. width: 100%;
  217. margin-bottom: 30rpx;
  218. box-sizing: border-box;
  219. .top {
  220. width: 100%;
  221. display: flex;
  222. align-items: stretch;
  223. justify-content: space-between;
  224. margin-bottom: 40rpx;
  225. .avatar {
  226. width: 180rpx;
  227. height: 144rpx;
  228. background-color: #eeeeee;
  229. background-position: center;
  230. background-size: cover;
  231. background-repeat: no-repeat;
  232. border-radius: 8rpx;
  233. }
  234. .info {
  235. display: flex;
  236. justify-content: center;
  237. flex-direction: column;
  238. flex: 1;
  239. overflow: hidden;
  240. margin-left: 20rpx;
  241. .name {
  242. color: #333333;
  243. font-size: 32rpx;
  244. line-height: 44rpx;
  245. margin-bottom: 20rpx;
  246. }
  247. .fixed {
  248. color: #F76454;
  249. font-size: 28rpx;
  250. height: 40rpx;
  251. line-height: 40rpx;
  252. border: 1px solid #F76454;
  253. box-sizing: border-box;
  254. width: 328rpx;
  255. border-radius: 40rpx;
  256. color: #F76454;
  257. text-align: center;
  258. }
  259. }
  260. }
  261. .skuContainer {
  262. width: 100%;
  263. background-color: #ffffff;
  264. box-sizing: border-box;
  265. border-radius: 24rpx;
  266. overflow: hidden;
  267. .header {
  268. width: 100%;
  269. height: 104rpx;
  270. padding: 0 30rpx;
  271. box-sizing: border-box;
  272. display: flex;
  273. align-items: center;
  274. justify-content: flex-start;
  275. border-bottom: 1px solid #EEEEEE;
  276. .icon {
  277. width: 30rpx;
  278. height: 30rpx;
  279. border-radius: 50%;
  280. background-color: rgba(234, 74, 65, 0.36);
  281. margin-right: 10rpx;
  282. display: flex;
  283. align-items: center;
  284. justify-content: center;
  285. &::before {
  286. content: "";
  287. display: block;
  288. width: 18rpx;
  289. height: 18rpx;
  290. border-radius: 50%;
  291. background-color: #EA4A41;
  292. }
  293. }
  294. .name {
  295. color: #333333;
  296. font-size: 32rpx;
  297. line-height: 44rpx;
  298. }
  299. &::after {
  300. display: block;
  301. content: "";
  302. margin-left: auto;
  303. width: 30rpx;
  304. height: 30rpx;
  305. background-image: url(../../static/new_my/arrow.png);
  306. background-position: center;
  307. background-size: cover;
  308. background-repeat: no-repeat;
  309. }
  310. &.open {
  311. &::after {
  312. transform: rotate(90deg) !important;
  313. }
  314. }
  315. }
  316. .skuList{
  317. width: 100%;
  318. .skuHeader, .skuItem {
  319. width: 100%;
  320. height: 100rpx;
  321. padding: 0 30rpx;
  322. box-sizing: border-box;
  323. display: flex;
  324. align-items: center;
  325. justify-content: space-between;
  326. border-bottom: 1px solid #EEEEEE;
  327. .type, .size, .num {
  328. flex: 1;
  329. overflow: hidden;
  330. display: flex;
  331. align-items: center;
  332. justify-content: center;
  333. }
  334. .type {
  335. justify-content: flex-start;
  336. }
  337. .size{
  338. justify-content: center;
  339. }
  340. .num {
  341. justify-content: flex-end;
  342. }
  343. }
  344. .skuHeader {
  345. color: #999999;
  346. font-size: 28rpx;
  347. line-height: 40rpx;
  348. }
  349. }
  350. .dataAll {
  351. width: 100%;
  352. height: 116rpx;
  353. padding: 0 30rpx;
  354. box-sizing: border-box;
  355. display: flex;
  356. align-items: center;
  357. justify-content: space-between;
  358. .sex {
  359. color: #333333;
  360. font-size: 28rpx;
  361. }
  362. .num {
  363. color: #999999;
  364. font-size: 28rpx;
  365. .spec {
  366. color: #EA4A41 !important;
  367. font-size: 40rpx !important;
  368. font-weight: bolder;
  369. }
  370. }
  371. }
  372. }
  373. }
  374. }
  375. }
  376. </style>