knapsack.vue 15 KB

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