orders.vue 13 KB

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