knapsack.vue 15 KB

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