knapsack.vue 20 KB

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