orders.vue 14 KB

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