orders.vue 16 KB

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