order.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <template>
  2. <view class="container">
  3. <view class="content">
  4. <view class="tabs2 tabw">
  5. <image
  6. class="tabs2_bk"
  7. style="width: 100%; height: 30px"
  8. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/knapsack/tabBk2.png'"
  9. mode=""
  10. ></image>
  11. <view class="tabs2_info">
  12. <view :class="['tabItem', tab2Active == 1 ? 'active' : '']" @click="tabs2Click(1)">待付款</view>
  13. <view :class="['tabItem', tab2Active == 2 ? 'active' : '']" @click="tabs2Click(2)">待发货</view>
  14. <view :class="['tabItem', tab2Active == 3 ? 'active' : '']" @click="tabs2Click(3)">待收货</view>
  15. <view :class="['tabItem', tab2Active == 4 ? 'active' : '']" @click="tabs2Click(4)">全部</view>
  16. </view>
  17. </view>
  18. <view class="list">
  19. <view class="card" style="position: relative" v-for="(item, index) in list2">
  20. <view class="row text" style="font-weight: 600">
  21. {{ item.order.addTime }}
  22. <view class="status2 type1" v-if="item.order.orderStatus == 101">待付款</view>
  23. <view class="status2 type5" v-if="item.order.orderStatus == 103">已取消</view>
  24. <view class="status2 type2" v-if="item.order.orderStatus == 201">待发货</view>
  25. <view class="status2 type3" v-if="item.order.orderStatus == 301">待收货</view>
  26. <view class="status2 type4" v-if="item.order.orderStatus == 401">已完成</view>
  27. </view>
  28. <view class="row text" style="font-size: 12px">订单ID:{{ item.order.orderSn }}</view>
  29. <view class="row" style="margin-top: 10px" v-for="(item2, index2) in item.prizeList">
  30. <view class="left">
  31. <image class="img2" :src="item2.prizeIcon" mode="aspectFill"></image>
  32. </view>
  33. <view class="right" style="font-size: 14px">
  34. <view class="row" style="font-size: 12px">
  35. {{ item2.prizeName }}
  36. </view>
  37. <view class="row" style="font-weight: 600; color: #ff2c43">
  38. ¥:9.9
  39. <span style="color: #000">× {{ item2.prizeNum }}</span>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="row button" style="font-size: 14px">
  44. <span></span>
  45. <span>
  46. 实付金额:
  47. <span style="font-weight: 600; color: #ff2c43">
  48. <span style="font-size: 18px">{{ item.order.actualPrice }}</span>
  49. </span>
  50. </span>
  51. </view>
  52. <view class="row cardButtons" v-if="item.order.orderStatus == 101">
  53. <view class="button button1" @click="cancelOrder(item)">取消订单</view>
  54. <view class="button button2" @click="reOrder(item)">去支付</view>
  55. </view>
  56. </view>
  57. <noData v-if="list2.length == 0" />
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import noData from '@/component/noData.vue'
  64. import {
  65. packagePrizeListApi,
  66. packageOrderListApi,
  67. prizerRecoverApi,
  68. cancelOrderApi,
  69. reOrderApi,
  70. } from '@/api/knapsack.js'
  71. export default {
  72. components: {
  73. noData,
  74. },
  75. data() {
  76. return {
  77. list: [],
  78. allCheck: false,
  79. params: {
  80. limit: 999,
  81. page: 1,
  82. status: 0,
  83. sort: null,
  84. },
  85. list2: [],
  86. params2: {
  87. limit: 999,
  88. page: 1,
  89. },
  90. selectIndex: [],
  91. sortList: [
  92. {
  93. value: 0,
  94. text: '按时间排序',
  95. },
  96. ],
  97. tab2Active: 4,
  98. }
  99. },
  100. onShow() {
  101. this.selectIndex = []
  102. },
  103. onReady() {},
  104. onLoad(option) {
  105. this.tabs2Click(option.type)
  106. },
  107. watch: {
  108. list: {
  109. deep: true,
  110. handler(newValue, oldValue) {
  111. // console.log(newValue, 'newValue')
  112. let bool = true
  113. for (var i = 0; i < newValue.length; i++) {
  114. if (!newValue[i].check) {
  115. bool = false
  116. }
  117. }
  118. this.allCheck = bool
  119. },
  120. },
  121. },
  122. methods: {
  123. tabs2Click(index) {
  124. this.tab2Active = index
  125. let type = null
  126. switch (index) {
  127. case 1:
  128. type = 101
  129. break
  130. case 2:
  131. type = 201
  132. break
  133. case 3:
  134. type = 301
  135. break
  136. case 4:
  137. type = null
  138. break
  139. }
  140. this.getList2(type)
  141. },
  142. getList2(type) {
  143. console.log(type)
  144. // 获取商城订单列表
  145. if (type) {
  146. this.params2.status = type
  147. } else {
  148. this.params2.status = ''
  149. }
  150. packageOrderListApi(this.params2).then(res => {
  151. console.log(res, '商城订单列表')
  152. this.list2 = res.data.list
  153. })
  154. },
  155. // 取消订单
  156. cancelOrder(item) {
  157. console.log(item, 'item')
  158. let _this = this
  159. wx.showModal({
  160. title: '取消订单',
  161. content: '确认取消此订单?',
  162. success(res) {
  163. if (res.confirm) {
  164. let params = {
  165. orderId: item.order.id,
  166. }
  167. cancelOrderApi(params).then(res => {
  168. console.log(res, 'res')
  169. _this.tabs2Click(_this.tab2Active)
  170. })
  171. }
  172. },
  173. })
  174. },
  175. reOrder(item) {
  176. console.log(item, 'item')
  177. // let prizeList = item.prizeList
  178. // let ids = []
  179. // for (var i = 0; i < prizeList.length; i++) {
  180. // ids.push(prizeList[i].id)
  181. // }
  182. // getApp().globalData.orderConfirmIds = ids
  183. // getApp().globalData.selectAddrss = null
  184. // this.$navigateTo('/pages/orderConfirm/orderConfirm')
  185. let params = {
  186. orderId: item.order.id,
  187. }
  188. reOrderApi(params).then(res => {
  189. console.log(res, 'res')
  190. // _this.tabs2Click(_this.tab2Active)
  191. this.wxPayment(res.data)
  192. })
  193. },
  194. wxPayment(data) {
  195. let _this = this
  196. wx.requestPayment({
  197. timeStamp: data.timeStamp,
  198. nonceStr: data.nonceStr,
  199. package: data.packageValue,
  200. signType: data.signType,
  201. paySign: data.paySign,
  202. success: function (res) {
  203. console.log(res, '支付过程成功')
  204. wx.showToast({
  205. title: '支付成功。',
  206. icon: 'success',
  207. })
  208. _this.tabs2Click(_this.tab2Active)
  209. },
  210. fail: function (res) {
  211. console.log('支付过程失败')
  212. // util.showErrorToast('支付失败');
  213. },
  214. complete: function (res) {
  215. console.log('支付过程结束')
  216. },
  217. })
  218. },
  219. },
  220. }
  221. </script>
  222. <style scoped lang="scss">
  223. .container {
  224. background: #9ec8f9;
  225. overflow: auto;
  226. .tabs {
  227. width: 240px;
  228. height: 44px;
  229. border-radius: 22px;
  230. background: rgba(255, 255, 255, 0.8);
  231. margin: 20px auto 10px auto;
  232. color: #005ecc;
  233. font-size: 14px;
  234. display: flex;
  235. position: relative;
  236. .tabsTransition {
  237. width: 50%;
  238. height: 44px;
  239. position: absolute;
  240. .tabsBk {
  241. width: 100%;
  242. height: 100%;
  243. }
  244. }
  245. .tab {
  246. width: 50%;
  247. height: 44px;
  248. text-align: center;
  249. line-height: 44px;
  250. z-index: 2;
  251. }
  252. .active {
  253. color: #fff;
  254. }
  255. }
  256. .tabs2 {
  257. width: 240px;
  258. margin: 0 auto;
  259. position: relative;
  260. .tabs2_bk {
  261. width: 100%;
  262. }
  263. .tabs2_info {
  264. position: absolute;
  265. top: 0;
  266. display: flex;
  267. align-items: center;
  268. justify-content: center;
  269. width: 100%;
  270. height: 100%;
  271. font-size: 12px;
  272. .text {
  273. color: #fff;
  274. }
  275. .select {
  276. width: 80px;
  277. }
  278. }
  279. }
  280. .tabw {
  281. width: calc(100% - 20px);
  282. margin: 0 auto;
  283. .tabs2_info {
  284. justify-content: space-around;
  285. .tabItem {
  286. color: #fff;
  287. padding: 5px 0;
  288. font-size: 13px;
  289. }
  290. .active {
  291. color: #8ef1ff !important;
  292. border-bottom: solid 2px #8ef1ff;
  293. }
  294. }
  295. }
  296. .list {
  297. padding: 10px;
  298. padding-bottom: 70px;
  299. .swipeLeft {
  300. display: flex;
  301. align-items: center;
  302. justify-content: center;
  303. width: 40px;
  304. .radio {
  305. transform: scale(0.8);
  306. }
  307. }
  308. .card {
  309. margin-bottom: 10px;
  310. border-radius: 8px;
  311. background: #fff;
  312. padding: 10px;
  313. .row {
  314. display: flex;
  315. justify-content: space-between;
  316. .status2 {
  317. position: absolute;
  318. right: 10px;
  319. width: 44px;
  320. height: 16px;
  321. font-size: 12px;
  322. border-radius: 2px;
  323. text-align: center;
  324. padding: 2px 5px;
  325. }
  326. .type1 {
  327. background: #ffe4e7;
  328. color: #ff2c43;
  329. }
  330. .type2 {
  331. background: #e2edfb;
  332. color: #005ecc;
  333. }
  334. .type3 {
  335. background: #00bcc8;
  336. color: #00c537;
  337. }
  338. .type4 {
  339. background: #def2e4;
  340. color: #00bcc8;
  341. }
  342. .type5 {
  343. background: #dedede;
  344. color: #999;
  345. }
  346. .left {
  347. display: flex;
  348. align-items: center;
  349. .photo {
  350. margin-right: 5px;
  351. width: 30px;
  352. height: 30px;
  353. border-radius: 50%;
  354. }
  355. .name {
  356. font-size: 14px;
  357. font-weight: 600;
  358. }
  359. .img {
  360. width: 100px;
  361. height: 100px;
  362. border-radius: 2px;
  363. margin-right: 10px;
  364. }
  365. .img2 {
  366. width: 75px;
  367. height: 75px;
  368. border-radius: 2px;
  369. margin-right: 10px;
  370. }
  371. }
  372. .right {
  373. flex: 1;
  374. .row {
  375. margin-bottom: 5px;
  376. }
  377. .title {
  378. font-size: 16px;
  379. font-weight: 600;
  380. }
  381. }
  382. .text1 {
  383. color: #666666;
  384. font-size: 12px;
  385. }
  386. }
  387. .cardButtons {
  388. padding-top: 10px;
  389. border-top: solid 1px #eaeaea;
  390. justify-content: flex-end;
  391. .button {
  392. font-size: 12px;
  393. margin-left: 10px;
  394. padding: 4px 0;
  395. width: 60px;
  396. text-align: center;
  397. border-radius: 5px;
  398. }
  399. .button1 {
  400. color: #ff7d12;
  401. border: solid 1px #ff7d12;
  402. }
  403. .button2 {
  404. color: #fff;
  405. background: linear-gradient(180deg, #ffad3d 0%, #ff740a 100%);
  406. }
  407. }
  408. }
  409. }
  410. .buttons {
  411. position: fixed;
  412. bottom: 0;
  413. display: flex;
  414. justify-content: space-around;
  415. width: 100%;
  416. padding: 10px 0;
  417. margin-bottom: 30px;
  418. image {
  419. height: 42px;
  420. }
  421. }
  422. .bottom {
  423. background: #fff;
  424. position: fixed;
  425. bottom: 0;
  426. display: flex;
  427. justify-content: space-between;
  428. width: calc(100% - 20px);
  429. padding: 10px;
  430. .left {
  431. display: flex;
  432. justify-content: center;
  433. align-items: center;
  434. .text {
  435. color: #999;
  436. font-size: 14px;
  437. margin-left: 10px;
  438. }
  439. .radio1 {
  440. width: 20px;
  441. height: 20px;
  442. }
  443. .radio2 {
  444. width: 18px;
  445. height: 18px;
  446. }
  447. }
  448. .right {
  449. display: flex;
  450. .button {
  451. height: 30px;
  452. padding: 0 20px;
  453. border-radius: 15px;
  454. font-size: 14px;
  455. line-height: 30px;
  456. margin-left: 15px;
  457. }
  458. .button1 {
  459. height: 28px;
  460. border: solid 1px #ff8015;
  461. color: #ff8015;
  462. }
  463. .button2 {
  464. // border: solid 1px #FF8015;
  465. background: linear-gradient(180deg, #ffad3d 0%, #ff740a 100%);
  466. color: #fff;
  467. }
  468. }
  469. }
  470. }
  471. </style>
  472. <style scoped>
  473. .tabs2_info >>> .uni-stat__select {
  474. background: none;
  475. }
  476. .tabs2_info >>> .uni-select {
  477. border: none !important;
  478. font-size: 12px;
  479. }
  480. .tabs2_info >>> .uni-icons {
  481. font-size: 20px !important;
  482. }
  483. .tabs2_info >>> .uni-select__input-text {
  484. color: #8ef1ff !important;
  485. }
  486. .tabs2_info >>> .uni-icons {
  487. color: #8ef1ff !important;
  488. }
  489. .tabs2_info >>> .uni-select__selector {
  490. width: 100px;
  491. }
  492. .tabs2_info >>> .uni-select__selector-item {
  493. font-size: 12px;
  494. }
  495. </style>