orders.vue 15 KB

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