orders.vue 11 KB

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