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