orders.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. <template>
  2. <view class="orders">
  3. <view class="nav">
  4. <!-- 搜索栏 -->
  5. <view class="navbox">
  6. <view class="search">
  7. <u-input placeholderStyle='color:#999' placeholder="搜索" border='none' v-model='search' @input="searchText">
  8. <template slot="suffix" style='margin-right:40rpx;'>
  9. <u-image :showLoading="true" :showError='true' src="/static/icon/search.png" width="40rpx"
  10. height="32rpx"></u-image>
  11. </template>
  12. </u-input>
  13. </view>
  14. </view>
  15. <!-- 分段器 -->
  16. <view class="segmented">
  17. <view class="tab_nav">
  18. <view class="navTitle" v-for="(item,index) in items" :key="index">
  19. <view :class="{'active':isActive == index}" @click="checked(index)">
  20. {{item}}
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 占位 -->
  27. <view style="width: 100%;height: 220rpx;"></view>
  28. <view class="msg-null" v-if="orderList.length == 0 ">
  29. <image src="https://t9.9026.com/imgs/dataNull.png" style="width: 394rpx;height: 396rpx;" mode=""></image>
  30. <view class="msg-null-text">
  31. <text>暂无数据</text>
  32. </view>
  33. </view>
  34. <view style="background-color: #f9f9f9;" v-if="orderList.length > 0 ">
  35. <view class="card" v-for="(item,index) in orderList" :key="index" @click="goOrderDetail(item.id,item.status)">
  36. <view class="toptitle">
  37. <view>订单号:{{item.order_no}}</view>
  38. <view v-if="item.status == 1 && item.is_virtual == 0">待兑换</view>
  39. <view v-if="item.status == 2 && item.is_virtual == 0 && item.express_type == 1">待发货</view>
  40. <view v-if="item.status == 2 && item.is_virtual == 0 && item.express_type == 2">待核销</view>
  41. <view v-if="item.status == 3 && item.is_virtual == 0 && item.express_type == 1">待收货</view>
  42. <view v-if="item.status == 3 && item.is_virtual == 1">待核销</view>
  43. <view v-if="item.status == 3 && item.is_virtual == 0 && item.express_type == 2">待核销</view>
  44. <view v-if="item.status == 4 && item.is_virtual == 0 && item.express_type == 1">已完成</view>
  45. <view v-if="item.status == 4 && item.is_virtual == 1">已核销</view>
  46. <view v-if="item.status == 4 && item.is_virtual == 0 && item.express_type == 2">已核销</view>
  47. </view>
  48. <view class="shopCard">
  49. <image v-if="item.product_type != 3 " :src="JSON.parse(item.img_urls)[0]"></image>
  50. <image v-if="item.product_type == 3 " :src="item.img_urls"></image>
  51. <view style="margin-left: 24rpx;">
  52. <text class="name">{{item.product_name}}</text>
  53. <text class="tag" v-if="item.source_type == 3">{{item.attr_text}} {{item.integral}}积分</text>
  54. </view>
  55. </view>
  56. <view class="points">
  57. <text class="totalName" style="margin-right: 50rpx;">共{{item.product_num}}件</text>
  58. <text class="totalName" v-if="item.source_type == 3">共计:</text>
  59. <text class="totalContent" v-if="item.source_type == 3">{{item.integral}}积分</text>
  60. </view>
  61. <view class="btn">
  62. <view class="btnitem" @click.stop="openVFcode(item.check_qrcode)"
  63. v-if="item.status == 3 && item.is_virtual == 1">
  64. <text>核销码</text>
  65. </view>
  66. <view class="btnitem" @click.stop="openVFcode(item.check_qrcode)"
  67. v-if="item.status == 3 && item.is_virtual == 0&&item.express_type == 2">
  68. <text>核销码</text>
  69. </view>
  70. <view class="btnitem" @click.stop="openVFcode(item.check_qrcode)"
  71. v-if="item.status ==2 && item.is_virtual == 0&&item.express_type == 2">
  72. <text>核销码</text>
  73. </view>
  74. <!-- <view class="btnitem" v-if="item.status == 1">
  75. <text>取消</text>
  76. </view> -->
  77. <view class="btnitem" v-if="item.status == 1" @click.stop="exchangePrize(item.draw_record_id,item.is_virtual)">
  78. <text>兑换</text>
  79. </view>
  80. <view @click.stop="takeOver(item.id)" class="btnitem"
  81. v-if="item.status == 3 && item.is_virtual == 0 && item.express_type == 1">
  82. <text>确认收货</text>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 已经到底啦 -->
  88. <view style="margin-top: 88rpx;padding-bottom: 60rpx;" v-if="orderList.length > 0 ">
  89. <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText" />
  90. </view>
  91. <!-- 弹出层/核销码 -->
  92. <uni-popup ref="popup" type="center">
  93. <view class="pop">
  94. <view class="title"><text>核销码</text></view>
  95. <view style="margin-left:30rpx;width: 580rpx;height: 2rpx;background: #F0F0F0;"></view>
  96. <view class="img">
  97. <image :src="check_qrcode"></image>
  98. </view>
  99. <view class="btn">
  100. <view class="cancel" @click="closeVFcode"><text>取消</text></view>
  101. <view class="download" @click="handleDownImg"><text>保存图片</text></view>
  102. </view>
  103. </view>
  104. </uni-popup>
  105. </view>
  106. </template>
  107. <script>
  108. import util from './../../../utils/util.js'
  109. export default {
  110. data() {
  111. return {
  112. //兑换是否过期
  113. isEnd:'',
  114. //核销码
  115. check_qrcode: '', //二维码内容(扫码识别后需要访问的网址)
  116. // 搜索
  117. search: '',
  118. // 分段器标题
  119. items: ['全部', '待兑换', '待发货', '待收货', '已完成'],
  120. isActive: 0,
  121. contentText: {
  122. contentdown: '查看更多',
  123. contentrefresh: '加载中',
  124. contentnomore: '—— 已经到底啦 ——'
  125. },
  126. // 订单列表
  127. orderList: [],
  128. // 分页
  129. page: 1,
  130. pagesize: 15,
  131. totalElements: '',
  132. allListItem: '',
  133. // 组件uni-load-more
  134. status: 'noMore',
  135. }
  136. },
  137. onLoad(o) {
  138. if (o.isActive) {
  139. this.isActive = o.isActive
  140. this.getMyOrder(o.isActive)
  141. } else {
  142. this.getMyOrder()
  143. }
  144. uni.$on('refreshPrizeData',()=>{
  145. this.isActive = 3
  146. this.getMyOrder(this.isActive )
  147. })
  148. },
  149. onUnload() {
  150. uni.$emit('refreshOrderNum');
  151. },
  152. // 触底加载
  153. onReachBottom() {
  154. // 触底的时候请求数据,即为上拉加载更多
  155. var allTotal = this.page * this.pagesize
  156. console.log(allTotal,'----allTotal');
  157. //this.page为加载次数,this.pagesize为每一次加载的数据条数
  158. if (allTotal < this.totalElements) {
  159. //this.totalElements为请求数据的总条数。只要现有条数小于总条数就就执行一下代码
  160. this.allListItem = false;
  161. this.page++;
  162. //加载次数递加
  163. this.status = "loading"
  164. this.$api.orders.getOrderList({ //请求更多数据列表
  165. page: this.page,
  166. status:this.isActive,
  167. keyword:this.search
  168. }).then(res => {
  169. let ret = [...this.orderList, ...res.data.data]
  170. this.orderList = ret
  171. console.log(ret)
  172. })
  173. } else {
  174. this.allListItem = true;
  175. console.log('已加载全部数据')
  176. this.status = "noMore"
  177. }
  178. },
  179. methods: {
  180. //确定收货
  181. takeOver(id) {
  182. uni.showLoading({
  183. title: '加载中'
  184. })
  185. this.$api.orders.confirmReceipt({
  186. order_id: id
  187. }).then(res => {
  188. if (res.code === 0) {
  189. uni.hideLoading()
  190. uni.showToast({
  191. icon: "none",
  192. title: '收货成功'
  193. })
  194. //重新拉数据
  195. this.getMyOrder(this.isActive)
  196. } else {
  197. uni.showToast({
  198. icon: "none",
  199. title: res.msg
  200. })
  201. }
  202. })
  203. },
  204. //判断兑换是否过期
  205. cancelTime(i, j) {
  206. let nowtime = new Date() //获取当前时间
  207. let endtime = new Date(j); //活动结束时间
  208. let lefttime = endtime.getTime() - nowtime.getTime() //距离结束时间的毫秒数
  209. if (lefttime < 0) {
  210. //兑换过期
  211. this.isEnd = true
  212. }
  213. },
  214. // 获取订单列表
  215. getMyOrder(type) {
  216. this.$api.orders.getOrderList({
  217. page: 0,
  218. status: type || '',
  219. keyword: this.search
  220. }).then(res => {
  221. if (res.code == 0) {
  222. this.orderList = res.data.data
  223. this.totalElements = res.data.total
  224. this.pagesize = res.data.per_page
  225. }
  226. })
  227. },
  228. //菜单index切换
  229. checked(index) {
  230. this.page = 1
  231. this.isActive = index
  232. this.getMyOrder(index)
  233. },
  234. // 搜索防抖
  235. searchText: util.debounce(function() {
  236. this.goSearch()
  237. }, 1000),
  238. // 搜索
  239. goSearch() {
  240. this.$api.orders.getOrderList({
  241. status: this.isActive,
  242. page: 1,
  243. keyword: this.search
  244. }).then(res => {
  245. console.log(res, "搜索活动项目列表")
  246. if (res.code == 0) {
  247. this.orderList = res.data.data
  248. this.totalElements = res.data.total
  249. this.pagesize = res.data.per_page
  250. }
  251. })
  252. },
  253. // 跳转订单详情
  254. goOrderDetail(id,status) {
  255. if(status == 1){
  256. console.log('待兑换');
  257. }else{
  258. uni.navigateTo({
  259. url: '/pages/my/myorders/orderDetail?id=' + id
  260. })
  261. }
  262. },
  263. //跳转奖品兑换
  264. exchangePrize(id,is_virtual){
  265. let isPhy = ''
  266. if(is_virtual == 0){
  267. isPhy = 1
  268. uni.navigateTo({
  269. url:`/pages/my/prize/exchangePrize?id=${id}&isPhy=${isPhy}`
  270. })
  271. }else{
  272. isPhy = 2
  273. uni.navigateTo({
  274. url:`/pages/my/prize/exchangePrize?id=${id}&isPhy=${isPhy}`
  275. })
  276. }
  277. },
  278. // // 跳转积分兑换
  279. // goIntegralExchange() {
  280. // uni.navigateTo({
  281. // url: '/pages/my/integral/integralOrder'
  282. // })
  283. // },
  284. // 打开弹出层
  285. openVFcode(check_qrcode) {
  286. console.log(check_qrcode, '----->check_qrcode');
  287. this.check_qrcode = check_qrcode
  288. this.$refs.popup.open()
  289. },
  290. // 关闭弹出层
  291. closeVFcode() {
  292. this.$refs.popup.close()
  293. this.getMyOrder(this.isActive )
  294. },
  295. // 保存图片
  296. handleDownImg() {
  297. uni.showLoading({
  298. title: "保存中..."
  299. })
  300. const that = this;
  301. uni.downloadFile({
  302. url: that.check_qrcode,
  303. success: res => {
  304. if (res.statusCode === 200) {
  305. uni.hideLoading()
  306. uni.saveImageToPhotosAlbum({
  307. filePath: res.tempFilePath,
  308. success: function() {
  309. uni.showToast({
  310. title: '已保存到相册',
  311. icon: 'success',
  312. duration: 2000
  313. })
  314. that.$refs.popup.close()
  315. },
  316. fail: function() {
  317. uni.showToast({
  318. title: '保存失败,请稍后重试',
  319. icon: 'none',
  320. duration: 2000
  321. })
  322. }
  323. });
  324. } else {
  325. uni.hideLoading()
  326. uni.showToast({
  327. title: '下载失败',
  328. icon: 'none',
  329. duration: 2000
  330. })
  331. }
  332. }
  333. });
  334. },
  335. }
  336. }
  337. </script>
  338. <style lang="scss" scoped>
  339. $pageColor:#F9F9F9;
  340. $bgColor:#FFFFFF;
  341. // flex布局居中对齐
  342. @mixin flexlayout {
  343. display: flex;
  344. align-items: center;
  345. justify-content: center;
  346. }
  347. .orders {
  348. height: 100%;
  349. background: $pageColor;
  350. }
  351. .home-bottom {
  352. padding-top: 80rpx;
  353. background-color: #f9f9f9;
  354. }
  355. .msg-null {
  356. padding-top: 60rpx;
  357. display: flex;
  358. flex-direction: column;
  359. align-items: center;
  360. justify-content: center;
  361. .msg-null-text {
  362. margin-top: 40rpx;
  363. font-size: 28rpx;
  364. color: #333;
  365. }
  366. }
  367. ::v-deep .segmented-control__text {
  368. font-size: 32rpx !important;
  369. font-family: PingFang-SC-Heavy, PingFang-SC;
  370. font-weight: 500 !important;
  371. color: #666666 !important;
  372. }
  373. ::v-deep .segmented-control__item--text {
  374. font-size: 32rpx !important;
  375. font-family: PingFang-SC-Heavy, PingFang-SC;
  376. font-weight: 800 !important;
  377. padding: 10rpx 0 !important;
  378. color: #D9A94D !important;
  379. border-radius: 4rpx !important;
  380. }
  381. .nav {
  382. position: fixed;
  383. top: 0;
  384. z-index: 999;
  385. height: 220rpx;
  386. width: 750rpx;
  387. background: $bgColor;
  388. .navbox {
  389. display: flex;
  390. align-items: center;
  391. justify-content: space-between;
  392. padding: 0 30rpx;
  393. box-sizing: border-box;
  394. // 搜索
  395. .search {
  396. height: 124rpx;
  397. width: 690px;
  398. background-color: $bgColor;
  399. @include flexlayout;
  400. ::v-deep .u-input {
  401. width: 690rpx !important;
  402. height: 68rpx !important;
  403. background: #F1F1F1;
  404. border-radius: 74rpx;
  405. }
  406. ::v-deep .u-input__content__field-wrapper {
  407. padding-left: 36rpx;
  408. }
  409. ::v-deep .u-input__content__field-wrapper__field {
  410. color: #999999 !important;
  411. font-size: 28rpx !important;
  412. }
  413. }
  414. }
  415. .segmented {
  416. margin-top: 18rpx;
  417. width: 750rpx;
  418. border-radius: 0rpx 0rpx 16rpx 16rpx;
  419. padding: 0 30rpx;
  420. box-sizing: border-box;
  421. //菜单切换
  422. .tab_nav {
  423. width: 690rpx;
  424. display: flex;
  425. justify-content: space-between;
  426. align-items: center;
  427. font-family: PingFang-SC-Heavy, PingFang-SC;
  428. }
  429. .tab_nav .navTitle {
  430. width: 128rpx;
  431. flex: none;
  432. height: 28rpx;
  433. font-size: 32rpx;
  434. color: #666;
  435. display: flex;
  436. align-items: center;
  437. justify-content: space-around;
  438. position: relative;
  439. }
  440. .active {
  441. color: #D9A94D;
  442. font-weight: bold;
  443. &::after {
  444. display: inline-block;
  445. content: '';
  446. width: 48rpx;
  447. height: 12rpx;
  448. background: linear-gradient(90deg, #F3D69F 0%, #D9A94D 100%);
  449. border-radius: 6px;
  450. position: absolute;
  451. bottom: -30rpx;
  452. left: 40rpx;
  453. }
  454. }
  455. }
  456. }
  457. .card {
  458. margin-top: 24rpx;
  459. background: $bgColor;
  460. border-radius: 16rpx;
  461. padding: 32rpx 28rpx 24rpx 28rpx;
  462. box-sizing: border-box;
  463. .toptitle {
  464. display: flex;
  465. justify-content: space-between;
  466. align-items: center;
  467. font-size: 28rpx;
  468. font-family: PingFang-SC-Bold, PingFang-SC;
  469. font-weight: bold;
  470. color: #080F18;
  471. }
  472. .shopCard {
  473. margin-top: 28rpx;
  474. width: 694rpx;
  475. height: 164rpx;
  476. background: #F4F5F6;
  477. border-radius: 10rpx;
  478. display: flex;
  479. align-items: center;
  480. image {
  481. width: 132rpx;
  482. height: 132rpx;
  483. margin-left: 16rpx;
  484. display: inline-block;
  485. border-radius: 12rpx;
  486. }
  487. .name {
  488. font-size: 28rpx;
  489. font-family: PingFangSC-Medium, PingFang SC;
  490. font-weight: 500;
  491. color: #080F18;
  492. display: block;
  493. }
  494. .tag {
  495. font-size: 24rpx;
  496. font-family: PingFang-SC-Medium, PingFang-SC;
  497. font-weight: 500;
  498. color: #666666;
  499. }
  500. }
  501. .points {
  502. display: flex;
  503. justify-content: flex-end;
  504. align-items: center;
  505. margin-top: 30rpx;
  506. .totalName {
  507. font-size: 22rpx;
  508. font-family: PingFang-SC-Medium, PingFang-SC;
  509. font-weight: 500;
  510. color: #080F18;
  511. margin-right: 10rpx;
  512. }
  513. .totalContent {
  514. font-size: 30rpx;
  515. font-family: PingFang-SC-Heavy, PingFang-SC;
  516. font-weight: 800;
  517. color: #080F18;
  518. }
  519. }
  520. .btn {
  521. margin-top: 30rpx;
  522. display: flex;
  523. justify-content: flex-end;
  524. .btnitem {
  525. margin-left: 16rpx;
  526. width: 170rpx;
  527. height: 60rpx;
  528. background: #FFFFFF;
  529. border-radius: 30rpx;
  530. border: 2rpx solid #D0D0D0;
  531. @include flexlayout() text {
  532. font-size: 26rpx;
  533. font-family: PingFang-SC-Medium, PingFang-SC;
  534. font-weight: 500;
  535. color: #080F18;
  536. }
  537. }
  538. }
  539. }
  540. .pop {
  541. width: 640rpx;
  542. height: 764rpx;
  543. background: $bgColor;
  544. border-radius: 20rpx;
  545. padding-top: 64rpx;
  546. box-sizing: border-box;
  547. .title {
  548. @include flexlayout();
  549. margin-bottom: 24rpx;
  550. text {
  551. font-size: 34rpx;
  552. font-family: PingFangSC-Medium, PingFang SC;
  553. font-weight: 500;
  554. color: #333333;
  555. }
  556. }
  557. .img {
  558. margin-top: 10rpx;
  559. margin-left: 48rpx;
  560. width: 544rpx;
  561. height: 468rpx;
  562. background: $bgColor;
  563. border-radius: 2rpx;
  564. @include flexlayout();
  565. image {
  566. width: 392rpx;
  567. height: 390rpx;
  568. }
  569. }
  570. .btn {
  571. margin-top: 40rpx;
  572. width: 100%;
  573. height: 110rpx;
  574. display: flex;
  575. align-items: center;
  576. .cancel {
  577. @include flexlayout();
  578. width: 50%;
  579. height: 100%;
  580. border-top: #E5E5E5 solid 1rpx;
  581. border-right: #E5E5E5 solid 1rpx;
  582. text {
  583. font-size: 32rpx;
  584. font-family: PingFangSC-Medium, PingFang SC;
  585. font-weight: 500;
  586. color: #666666;
  587. }
  588. }
  589. .download {
  590. border-top: #E5E5E5 solid 1rpx;
  591. // border-left:#E5E5E5 solid 0.3rpx;
  592. @include flexlayout();
  593. height: 100%;
  594. width: 50%;
  595. text {
  596. font-size: 32rpx;
  597. font-family: PingFangSC-Medium, PingFang SC;
  598. font-weight: 500;
  599. color: #FF7119;
  600. }
  601. }
  602. }
  603. }
  604. </style>