knapsack.vue 19 KB

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