knapsack.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <template>
  2. <view class="container">
  3. <view class="tabs">
  4. <uni-transition ref="ani" class="tabsTransition" :styles="styles" :show="true">
  5. <image class="tabsBk" src="@/static/img/knapsack/tabBk.png" mode="widthFix"></image>
  6. </uni-transition>
  7. <view :class="['tab', activeIndex == 1 ? 'active' : '']" @click="tabClick(1)">
  8. 现货奖品
  9. </view>
  10. <view :class="['tab', activeIndex == 2 ? 'active' : '']" @click="tabClick(2)">
  11. 商城订单
  12. </view>
  13. </view>
  14. <view class="content" v-if="activeIndex == 1">
  15. <view class="tabs2">
  16. <image class="tabs2_bk" src="@/static/img/knapsack/tabBk2.png" mode="widthFix"></image>
  17. <view class="tabs2_info">
  18. <span class="text">选择排序方式:</span>
  19. <uni-data-select class="select" v-model="params.sort" :localdata="sortList"></uni-data-select>
  20. </view>
  21. </view>
  22. <view class="list">
  23. <uni-swipe-action :autoClose="false">
  24. <uni-swipe-action-item v-for="(item, index) in list" :key="index" :show="showCheck ? 'left':'none'"
  25. :disabled="true">
  26. <template v-slot:left>
  27. <view class="swipeLeft">
  28. <radio class="radio" :checked="item.check == true" @click="checkClick($event, item)" />
  29. </view>
  30. </template>
  31. <view class="card">
  32. <view class="row" style="margin-top: 10px;">
  33. <view class="left">
  34. <image class="img" src="@/static/img/ka.jpeg" mode="aspectFill"></image>
  35. </view>
  36. <view class="right" style="font-size: 14px;">
  37. <view class="row title">
  38. {{item.prizeName}}
  39. </view>
  40. <view class="row text">
  41. 获得时间:{{ item.creatTime }}
  42. </view>
  43. <view class="row" style="color: #FF2C43;">
  44. 回收积分:{{ item.integral }}
  45. <span class="status">{{ item.prizeStatus }}</span>
  46. </view>
  47. <view class="row button">
  48. <span></span>
  49. <span>
  50. <image style="width: 44px;" src="@/static/img/knapsack/button5.png"
  51. mode="widthFix"></image>
  52. </span>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </uni-swipe-action-item>
  58. </uni-swipe-action>
  59. </view>
  60. <view class="buttons" v-if="!showCheck">
  61. <image class="button" src="@/static/img/knapsack/button3.png" mode="heightFix"></image>
  62. <image class="button" @click="showCheck = true" src="@/static/img/knapsack/button4.png"
  63. mode="heightFix">
  64. </image>
  65. </view>
  66. <view class="bottom" v-if="showCheck">
  67. <view class="left">
  68. <image class="radio1" @click="clickCheckAll(true)" v-if="!allCheck"
  69. src="@/static/img/knapsack/check.png" mode="widthFix"></image>
  70. <image class="radio2" @click="clickCheckAll(false)" v-else
  71. src="@/static/img/knapsack/checkActive.png" mode="widthFix"></image>
  72. <view class="text" style="color: #000;">
  73. 全选
  74. </view>
  75. <view class="text">
  76. 已选 (<span style="color: #000;">{{selectIndex.length}}</span>)
  77. </view>
  78. </view>
  79. <view class="right">
  80. <image class="button" @click="cancelOrder" style="margin-right: 5px;"
  81. src="@/static/img/knapsack/button2.png" mode="heightFix"></image>
  82. <image class="button" @click="toConfirmConfirm" src="@/static/img/knapsack/button1.png"
  83. mode="heightFix"></image>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="content " v-if="activeIndex == 2">
  88. <view class="tabs2 tabw">
  89. <image class="tabs2_bk" style="width: 100%; height: 30px;" src="@/static/img/knapsack/tabBk2.png"
  90. mode=""></image>
  91. <view class="tabs2_info">
  92. <view :class="['tabItem', tab2Active == 1 ? 'active': '']" @click="tabs2Click(1)">
  93. 代付款
  94. </view>
  95. <view :class="['tabItem', tab2Active == 2 ? 'active': '']" @click="tabs2Click(2)">
  96. 待发货
  97. </view>
  98. <view :class="['tabItem', tab2Active == 3 ? 'active': '']" @click="tabs2Click(3)">
  99. 待收货
  100. </view>
  101. <view :class="['tabItem', tab2Active == 4 ? 'active': '']" @click="tabs2Click(4)">
  102. 全部
  103. </view>
  104. </view>
  105. </view>
  106. <view class="list">
  107. <view class="card" style="position: relative;" v-for="(item, index) in list2">
  108. <view class="row text" style="font-weight: 600;">
  109. {{ item.order.addTime }}
  110. <view class="status2 type1" v-if="item.order.orderStatus == 101">
  111. 待付款
  112. </view>
  113. <view class="status2 type2" v-if="item.order.orderStatus == 201">
  114. 待发货
  115. </view>
  116. <view class="status2 type3" v-if="item.order.orderStatus == 301">
  117. 待收货
  118. </view>
  119. <view class="status2 type4" v-if="item.order.orderStatus == 401">
  120. 已完成
  121. </view>
  122. </view>
  123. <view class="row text" style="font-size: 12px;">
  124. 订单ID:{{item.order.orderSn}}
  125. </view>
  126. <view class="row" style="margin-top: 10px;" v-for="(item2, index2) in item.prizeList">
  127. <view class="left">
  128. <image class="img2" :src="item2.prizeIcon" mode="aspectFill"></image>
  129. </view>
  130. <view class="right" style="font-size: 14px;">
  131. <view class="row" style="font-size: 12px;">
  132. {{item2.prizeName}}
  133. </view>
  134. <view class="row" style="font-weight: 600;color: #FF2C43;">
  135. ¥:9.9
  136. <span style="color: #000;"> × {{item2.prizeNum}}</span>
  137. </view>
  138. </view>
  139. </view>
  140. <view class="row button" style="font-size: 14px;">
  141. <span></span>
  142. <span>
  143. 实付金额:
  144. <span style="font-weight: 600;color: #FF2C43;">
  145. ¥<span style="font-size: 18px;">{{item.order.actualPrice}}</span>
  146. </span>
  147. </span>
  148. </view>
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. </template>
  154. <script>
  155. import {
  156. packagePrizeListApi,
  157. packageOrderListApi
  158. } from "@/api/knapsack.js"
  159. export default {
  160. data() {
  161. return {
  162. showCheck: false,
  163. activeIndex: 1,
  164. list: [],
  165. allCheck: false,
  166. params: {
  167. limit: 999,
  168. page: 1,
  169. status: 0,
  170. sort: null,
  171. },
  172. list2: [],
  173. params2: {
  174. limit: 999,
  175. page: 1,
  176. },
  177. selectIndex: [],
  178. sortList: [{
  179. value: 0,
  180. text: "按时间排序"
  181. },
  182. {
  183. value: 1,
  184. text: "按价格排序"
  185. },
  186. ],
  187. tab2Active: 4,
  188. }
  189. },
  190. onShow() {
  191. this.activeIndex = 1
  192. this.$refs.ani.init({
  193. duration: 100,
  194. timingFunction: 'linear',
  195. transformOrigin: '50% 50%',
  196. show: true,
  197. })
  198. this.$refs.ani.step({
  199. translateX: '0'
  200. })
  201. this.$refs.ani.run(() => {
  202. console.log('动画支持完毕')
  203. })
  204. // 获取背包数据
  205. this.getList()
  206. // 获取商城订单数据(全部)
  207. this.getList2()
  208. },
  209. onReady() {
  210. },
  211. onLoad() {
  212. },
  213. watch: {
  214. list: {
  215. deep: true,
  216. handler(newValue, oldValue) {
  217. // console.log(newValue, 'newValue')
  218. let bool = true
  219. for (var i = 0; i < newValue.length; i++) {
  220. if (!newValue[i].check) {
  221. bool = false
  222. }
  223. }
  224. this.allCheck = bool
  225. }
  226. }
  227. },
  228. methods: {
  229. tabs2Click(index) {
  230. this.tab2Active = index
  231. let type = null
  232. switch (index){
  233. case 1:
  234. type = 101
  235. break;
  236. case 2:
  237. type = 201
  238. break;
  239. case 3:
  240. type = 301
  241. break;
  242. case 4:
  243. type = null
  244. break;
  245. }
  246. this.getList2(type)
  247. },
  248. toConfirmConfirm() {
  249. if (this.selectIndex.length == 0) {
  250. wx.showToast({
  251. title: '请选则要发货卡牌。',
  252. icon: 'none',
  253. })
  254. return
  255. }
  256. getApp().globalData.orderConfirmIds = this.selectIndex
  257. getApp().globalData.selectAddrss = null
  258. this.$navigateTo('/pages/orderConfirm/orderConfirm')
  259. },
  260. // 取消下单
  261. cancelOrder() {
  262. this.showCheck = false
  263. this.selectIndex = []
  264. for (var i = 0; i < this.list.length; i++) {
  265. this.list[i].check = false
  266. }
  267. },
  268. clickCheckAll(bool) {
  269. this.selectIndex = []
  270. for (var i = 0; i < this.list.length; i++) {
  271. this.list[i].check = bool
  272. if (bool) {
  273. this.selectIndex.push(this.list[i].id)
  274. }
  275. }
  276. },
  277. checkClick(e, item) {
  278. console.log(item, 'item')
  279. item.check = !item.check
  280. let index = this.selectIndex.indexOf(item.id)
  281. if (item.check && index == -1) {
  282. this.selectIndex.push(item.id)
  283. } else if (!item.check && index != -1) {
  284. this.selectIndex.splice(index, 1)
  285. }
  286. console.log(this.selectIndex, 'this.selectIndex')
  287. },
  288. getList() {
  289. // 获取背包列表
  290. packagePrizeListApi(this.params).then(res => {
  291. console.log(res, '奖品背包')
  292. let list = res.data.list
  293. for (var i = 0; i < list.length; i++) {
  294. list[i].check = false
  295. }
  296. this.list = list
  297. })
  298. },
  299. getList2(type) {
  300. // 获取商城订单列表
  301. if(type) {
  302. this.params2.status = type
  303. }
  304. packageOrderListApi(this.params2).then(res => {
  305. console.log(res, '商城订单列表')
  306. this.list2 = res.data.list
  307. })
  308. },
  309. tabClick(index) {
  310. this.activeIndex = index
  311. if (index == 1) {
  312. this.$refs.ani.step({
  313. translateX: '0'
  314. })
  315. this.$refs.ani.run(() => {
  316. console.log('动画支持完毕')
  317. })
  318. }
  319. if (index == 2) {
  320. this.$refs.ani.step({
  321. translateX: '120px'
  322. })
  323. this.$refs.ani.run(() => {
  324. console.log('动画支持完毕')
  325. })
  326. }
  327. }
  328. }
  329. }
  330. </script>
  331. <style scoped lang="scss">
  332. .container {
  333. background: #9EC8F9;
  334. overflow: auto;
  335. .tabs {
  336. width: 240px;
  337. height: 44px;
  338. border-radius: 22px;
  339. background: rgba(255, 255, 255, 0.8);
  340. margin: 20px auto 10px auto;
  341. color: #005ECC;
  342. font-size: 14px;
  343. display: flex;
  344. position: relative;
  345. .tabsTransition {
  346. width: 50%;
  347. height: 44px;
  348. position: absolute;
  349. .tabsBk {
  350. width: 100%;
  351. height: 100%;
  352. }
  353. }
  354. .tab {
  355. width: 50%;
  356. height: 44px;
  357. text-align: center;
  358. line-height: 44px;
  359. z-index: 2;
  360. }
  361. .active {
  362. color: #fff;
  363. }
  364. }
  365. .tabs2 {
  366. width: 240px;
  367. margin: 0 auto;
  368. position: relative;
  369. .tabs2_bk {
  370. width: 100%;
  371. }
  372. .tabs2_info {
  373. position: absolute;
  374. top: 0;
  375. display: flex;
  376. align-items: center;
  377. justify-content: center;
  378. width: 100%;
  379. height: 100%;
  380. font-size: 12px;
  381. .text {
  382. color: #fff;
  383. }
  384. .select {
  385. width: 80px;
  386. }
  387. }
  388. }
  389. .tabw {
  390. width: calc(100% - 20px);
  391. margin: 0 auto;
  392. .tabs2_info {
  393. justify-content: space-around;
  394. .tabItem {
  395. color: #fff;
  396. padding: 5px 0;
  397. font-size: 13px;
  398. }
  399. .active {
  400. color: #8EF1FF !important;
  401. border-bottom: solid 2px #8EF1FF;
  402. }
  403. }
  404. }
  405. .list {
  406. padding: 10px;
  407. padding-bottom: 70px;
  408. .swipeLeft {
  409. display: flex;
  410. align-items: center;
  411. justify-content: center;
  412. width: 40px;
  413. .radio {
  414. transform: scale(0.8);
  415. }
  416. }
  417. .card {
  418. margin-bottom: 10px;
  419. border-radius: 8px;
  420. background: #fff;
  421. padding: 10px;
  422. .row {
  423. display: flex;
  424. justify-content: space-between;
  425. .status2 {
  426. position: absolute;
  427. right: 10px;
  428. width: 44px;
  429. height: 16px;
  430. font-size: 12px;
  431. border-radius: 2px;
  432. text-align: center;
  433. padding: 2px 5px;
  434. }
  435. .type1 {
  436. background: #FFE4E7;
  437. color: #FF2C43;
  438. }
  439. .type2 {
  440. background: #E2EDFB;
  441. color: #005ECC;
  442. }
  443. .type3 {
  444. background: #00BCC8;
  445. color: #00C537;
  446. }
  447. .type4 {
  448. background: #DEF2E4;
  449. color: #00BCC8;
  450. }
  451. .left {
  452. display: flex;
  453. align-items: center;
  454. .photo {
  455. margin-right: 5px;
  456. width: 30px;
  457. height: 30px;
  458. border-radius: 50%;
  459. }
  460. .name {
  461. font-size: 14px;
  462. font-weight: 600;
  463. }
  464. .img {
  465. width: 100px;
  466. height: 100px;
  467. border-radius: 2px;
  468. margin-right: 10px;
  469. }
  470. .img2 {
  471. width: 75px;
  472. height: 75px;
  473. border-radius: 2px;
  474. margin-right: 10px;
  475. }
  476. }
  477. .right {
  478. flex: 1;
  479. .row {
  480. margin-bottom: 5px;
  481. }
  482. .title {
  483. font-size: 16px;
  484. font-weight: 600;
  485. }
  486. }
  487. .text1 {
  488. color: #666666;
  489. font-size: 12px;
  490. }
  491. }
  492. }
  493. }
  494. .buttons {
  495. position: fixed;
  496. bottom: 0;
  497. display: flex;
  498. justify-content: space-around;
  499. width: 100%;
  500. padding: 10px 0;
  501. image {
  502. height: 42px;
  503. }
  504. }
  505. .bottom {
  506. background: #fff;
  507. position: fixed;
  508. bottom: 0;
  509. display: flex;
  510. justify-content: space-between;
  511. width: calc(100% - 20px);
  512. padding: 10px;
  513. .left {
  514. display: flex;
  515. justify-content: center;
  516. align-items: center;
  517. .text {
  518. color: #999;
  519. font-size: 14px;
  520. margin-left: 10px;
  521. }
  522. .radio1 {
  523. width: 20px;
  524. height: 20px;
  525. }
  526. .radio2 {
  527. width: 18px;
  528. height: 18px;
  529. }
  530. }
  531. .right {
  532. display: flex;
  533. .button {
  534. height: 30px;
  535. }
  536. }
  537. }
  538. }
  539. </style>
  540. <style scoped>
  541. .tabs2_info>>>.uni-stat__select {
  542. background: none;
  543. }
  544. .tabs2_info>>>.uni-select {
  545. border: none !important;
  546. font-size: 12px;
  547. }
  548. .tabs2_info>>>.uni-icons {
  549. font-size: 20px !important;
  550. }
  551. .tabs2_info>>>.uni-select__input-text {
  552. color: #8EF1FF !important;
  553. }
  554. .tabs2_info>>>.uni-icons {
  555. color: #8EF1FF !important;
  556. }
  557. .tabs2_info>>>.uni-select__selector {
  558. width: 100px;
  559. }
  560. .tabs2_info>>>.uni-select__selector-item {
  561. font-size: 12px;
  562. }
  563. </style>