knapsack.vue 17 KB

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