knapsack.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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 @click="decompose(item)" 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. prizerRecoverApi
  159. } from "@/api/knapsack.js"
  160. export default {
  161. data() {
  162. return {
  163. showCheck: false,
  164. activeIndex: 1,
  165. list: [],
  166. allCheck: false,
  167. params: {
  168. limit: 999,
  169. page: 1,
  170. status: 0,
  171. sort: null,
  172. },
  173. list2: [],
  174. params2: {
  175. limit: 999,
  176. page: 1,
  177. },
  178. selectIndex: [],
  179. sortList: [{
  180. value: 0,
  181. text: "按时间排序"
  182. }
  183. ],
  184. tab2Active: 4,
  185. }
  186. },
  187. onShow() {
  188. this.activeIndex = 1
  189. this.$refs.ani.init({
  190. duration: 100,
  191. timingFunction: 'linear',
  192. transformOrigin: '50% 50%',
  193. show: true,
  194. })
  195. this.$refs.ani.step({
  196. translateX: '0'
  197. })
  198. this.$refs.ani.run(() => {
  199. console.log('动画支持完毕')
  200. })
  201. // 获取背包数据
  202. this.getList()
  203. // 获取商城订单数据(全部)
  204. this.getList2()
  205. },
  206. onReady() {
  207. },
  208. onLoad() {
  209. },
  210. watch: {
  211. list: {
  212. deep: true,
  213. handler(newValue, oldValue) {
  214. // console.log(newValue, 'newValue')
  215. let bool = true
  216. for (var i = 0; i < newValue.length; i++) {
  217. if (!newValue[i].check) {
  218. bool = false
  219. }
  220. }
  221. this.allCheck = bool
  222. }
  223. }
  224. },
  225. methods: {
  226. tabs2Click(index) {
  227. this.tab2Active = index
  228. let type = null
  229. switch (index){
  230. case 1:
  231. type = 101
  232. break;
  233. case 2:
  234. type = 201
  235. break;
  236. case 3:
  237. type = 301
  238. break;
  239. case 4:
  240. type = null
  241. break;
  242. }
  243. this.getList2(type)
  244. },
  245. toConfirmConfirm() {
  246. if (this.selectIndex.length == 0) {
  247. wx.showToast({
  248. title: '请选则要发货卡牌。',
  249. icon: 'none',
  250. })
  251. return
  252. }
  253. getApp().globalData.orderConfirmIds = this.selectIndex
  254. getApp().globalData.selectAddrss = null
  255. this.$navigateTo('/pages/orderConfirm/orderConfirm')
  256. },
  257. // 取消下单
  258. cancelOrder() {
  259. this.showCheck = false
  260. this.selectIndex = []
  261. for (var i = 0; i < this.list.length; i++) {
  262. this.list[i].check = false
  263. }
  264. },
  265. clickCheckAll(bool) {
  266. this.selectIndex = []
  267. for (var i = 0; i < this.list.length; i++) {
  268. this.list[i].check = bool
  269. if (bool) {
  270. this.selectIndex.push(this.list[i].id)
  271. }
  272. }
  273. },
  274. checkClick(e, item) {
  275. console.log(item, 'item')
  276. item.check = !item.check
  277. let index = this.selectIndex.indexOf(item.id)
  278. if (item.check && index == -1) {
  279. this.selectIndex.push(item.id)
  280. } else if (!item.check && index != -1) {
  281. this.selectIndex.splice(index, 1)
  282. }
  283. console.log(this.selectIndex, 'this.selectIndex')
  284. },
  285. getList() {
  286. // 获取背包列表
  287. packagePrizeListApi(this.params).then(res => {
  288. console.log(res, '奖品背包')
  289. let list = res.data.list
  290. for (var i = 0; i < list.length; i++) {
  291. list[i].check = false
  292. }
  293. this.list = list
  294. })
  295. },
  296. getList2(type) {
  297. // 获取商城订单列表
  298. if(type) {
  299. this.params2.status = type
  300. }
  301. packageOrderListApi(this.params2).then(res => {
  302. console.log(res, '商城订单列表')
  303. this.list2 = res.data.list
  304. })
  305. },
  306. tabClick(index) {
  307. this.activeIndex = index
  308. if (index == 1) {
  309. this.$refs.ani.step({
  310. translateX: '0'
  311. })
  312. this.$refs.ani.run(() => {
  313. console.log('动画支持完毕')
  314. })
  315. }
  316. if (index == 2) {
  317. this.$refs.ani.step({
  318. translateX: '120px'
  319. })
  320. this.$refs.ani.run(() => {
  321. console.log('动画支持完毕')
  322. })
  323. }
  324. },
  325. decompose(value) {
  326. // 分解卡牌
  327. let _this = this
  328. let prizeIdList = []
  329. if (value.prizeName) {
  330. prizeIdList = [value.id]
  331. } else if (this.selectIndex.length > 0) {
  332. prizeIdList = this.selectIndex
  333. } else {
  334. wx.showToast({
  335. title: '请选则要分解卡牌。',
  336. icon: 'none',
  337. })
  338. return
  339. }
  340. wx.showModal({
  341. title: '确认分解卡牌?',
  342. content: '卡牌分解后将无法找回。',
  343. success: (res) => {
  344. if (res.confirm) {
  345. prizerRecoverApi(prizeIdList).then(res => {
  346. console.log(res, 'res')
  347. wx.showToast({
  348. title: '分解成功。',
  349. icon: 'none',
  350. })
  351. _this.getList()
  352. })
  353. } else if (res.cancel) {
  354. console.log('用户点击取消')
  355. }
  356. }
  357. })
  358. }
  359. }
  360. }
  361. </script>
  362. <style scoped lang="scss">
  363. .container {
  364. background: #9EC8F9;
  365. overflow: auto;
  366. .tabs {
  367. width: 240px;
  368. height: 44px;
  369. border-radius: 22px;
  370. background: rgba(255, 255, 255, 0.8);
  371. margin: 20px auto 10px auto;
  372. color: #005ECC;
  373. font-size: 14px;
  374. display: flex;
  375. position: relative;
  376. .tabsTransition {
  377. width: 50%;
  378. height: 44px;
  379. position: absolute;
  380. .tabsBk {
  381. width: 100%;
  382. height: 100%;
  383. }
  384. }
  385. .tab {
  386. width: 50%;
  387. height: 44px;
  388. text-align: center;
  389. line-height: 44px;
  390. z-index: 2;
  391. }
  392. .active {
  393. color: #fff;
  394. }
  395. }
  396. .tabs2 {
  397. width: 240px;
  398. margin: 0 auto;
  399. position: relative;
  400. .tabs2_bk {
  401. width: 100%;
  402. }
  403. .tabs2_info {
  404. position: absolute;
  405. top: 0;
  406. display: flex;
  407. align-items: center;
  408. justify-content: center;
  409. width: 100%;
  410. height: 100%;
  411. font-size: 12px;
  412. .text {
  413. color: #fff;
  414. }
  415. .select {
  416. width: 80px;
  417. }
  418. }
  419. }
  420. .tabw {
  421. width: calc(100% - 20px);
  422. margin: 0 auto;
  423. .tabs2_info {
  424. justify-content: space-around;
  425. .tabItem {
  426. color: #fff;
  427. padding: 5px 0;
  428. font-size: 13px;
  429. }
  430. .active {
  431. color: #8EF1FF !important;
  432. border-bottom: solid 2px #8EF1FF;
  433. }
  434. }
  435. }
  436. .list {
  437. padding: 10px;
  438. padding-bottom: 70px;
  439. .swipeLeft {
  440. display: flex;
  441. align-items: center;
  442. justify-content: center;
  443. width: 40px;
  444. .radio {
  445. transform: scale(0.8);
  446. }
  447. }
  448. .card {
  449. margin-bottom: 10px;
  450. border-radius: 8px;
  451. background: #fff;
  452. padding: 10px;
  453. .row {
  454. display: flex;
  455. justify-content: space-between;
  456. .status2 {
  457. position: absolute;
  458. right: 10px;
  459. width: 44px;
  460. height: 16px;
  461. font-size: 12px;
  462. border-radius: 2px;
  463. text-align: center;
  464. padding: 2px 5px;
  465. }
  466. .type1 {
  467. background: #FFE4E7;
  468. color: #FF2C43;
  469. }
  470. .type2 {
  471. background: #E2EDFB;
  472. color: #005ECC;
  473. }
  474. .type3 {
  475. background: #00BCC8;
  476. color: #00C537;
  477. }
  478. .type4 {
  479. background: #DEF2E4;
  480. color: #00BCC8;
  481. }
  482. .left {
  483. display: flex;
  484. align-items: center;
  485. .photo {
  486. margin-right: 5px;
  487. width: 30px;
  488. height: 30px;
  489. border-radius: 50%;
  490. }
  491. .name {
  492. font-size: 14px;
  493. font-weight: 600;
  494. }
  495. .img {
  496. width: 100px;
  497. height: 100px;
  498. border-radius: 2px;
  499. margin-right: 10px;
  500. }
  501. .img2 {
  502. width: 75px;
  503. height: 75px;
  504. border-radius: 2px;
  505. margin-right: 10px;
  506. }
  507. }
  508. .right {
  509. flex: 1;
  510. .row {
  511. margin-bottom: 5px;
  512. }
  513. .title {
  514. font-size: 16px;
  515. font-weight: 600;
  516. }
  517. }
  518. .text1 {
  519. color: #666666;
  520. font-size: 12px;
  521. }
  522. }
  523. }
  524. }
  525. .buttons {
  526. position: fixed;
  527. bottom: 0;
  528. display: flex;
  529. justify-content: space-around;
  530. width: 100%;
  531. padding: 10px 0;
  532. image {
  533. height: 42px;
  534. }
  535. }
  536. .bottom {
  537. background: #fff;
  538. position: fixed;
  539. bottom: 0;
  540. display: flex;
  541. justify-content: space-between;
  542. width: calc(100% - 20px);
  543. padding: 10px;
  544. .left {
  545. display: flex;
  546. justify-content: center;
  547. align-items: center;
  548. .text {
  549. color: #999;
  550. font-size: 14px;
  551. margin-left: 10px;
  552. }
  553. .radio1 {
  554. width: 20px;
  555. height: 20px;
  556. }
  557. .radio2 {
  558. width: 18px;
  559. height: 18px;
  560. }
  561. }
  562. .right {
  563. display: flex;
  564. .button {
  565. height: 30px;
  566. }
  567. }
  568. }
  569. }
  570. </style>
  571. <style scoped>
  572. .tabs2_info>>>.uni-stat__select {
  573. background: none;
  574. }
  575. .tabs2_info>>>.uni-select {
  576. border: none !important;
  577. font-size: 12px;
  578. }
  579. .tabs2_info>>>.uni-icons {
  580. font-size: 20px !important;
  581. }
  582. .tabs2_info>>>.uni-select__input-text {
  583. color: #8EF1FF !important;
  584. }
  585. .tabs2_info>>>.uni-icons {
  586. color: #8EF1FF !important;
  587. }
  588. .tabs2_info>>>.uni-select__selector {
  589. width: 100px;
  590. }
  591. .tabs2_info>>>.uni-select__selector-item {
  592. font-size: 12px;
  593. }
  594. </style>