order.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <template>
  2. <view>
  3. <view class="content">
  4. <!-- 使用mescroll-body包裹订单列表 -->
  5. <mescroll-body bottom="0" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  6. :down="downOption" :up="upOption">
  7. <!-- <u-tabs class="tabs" itemStyle="width:14%;height:100rpx;" :list="tabList" @click="tabsClick"
  8. lineColor="#FF5C03"></u-tabs> -->
  9. <view class="top-fixed">
  10. <view class="pub-tab-box">
  11. <scroll-view class="scroll-tabs" scroll-x="true" show-scrollbar="false">
  12. <view class="tab-inner">
  13. <view v-for="(item,index) in tabList" :key="index"
  14. :class="status == item.status?'item active':'item'" @click="tabsClick(item)">
  15. <view class="text">
  16. {{ item.name }}
  17. <image v-show="status == item.status" class="tab-bg"
  18. src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/tab_bg.png"
  19. mode=""></image>
  20. </view>
  21. </view>
  22. </view>
  23. </scroll-view>
  24. </view>
  25. <view class="search-cont">
  26. <view class="inner">
  27. <image class="icon-search"
  28. src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/search.png"
  29. mode=""></image>
  30. <input type="text" value="" placeholder="输入订单号" confirm-type="搜索" @confirm="goSearch"
  31. placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  32. </view>
  33. </view>
  34. </view>
  35. <view class="order-list">
  36. <view class="order-item" v-for="(item,index) in orderList" :key="index" @click="goDetail(item)">
  37. <view class="order-num">
  38. <text class="lable">订单号:{{item.orderCode}}</text>
  39. <text v-if="item.status==-1&&item.refundStatus==0">未退款</text>
  40. <text v-if="item.status==-1&&item.refundStatus==1">申请中</text>
  41. <text v-if="item.status==-1&&item.refundStatus==2">已退款</text>
  42. <text v-if="item.status==-1">申请售后</text>
  43. <text v-else-if="item.status==-2">退款成功</text>
  44. <text v-else-if="item.status==0">待支付</text>
  45. <text v-else-if="item.status==1">待发货</text>
  46. <text v-else-if="item.status==2">待收货</text>
  47. <text v-else-if="item.status==3">已完成</text>
  48. <text v-else-if="item.status==-3">已取消</text>
  49. </view>
  50. <!-- v-for="(itm,idx) in item.orderItemList" :key="idx" -->
  51. <!-- <view >{{JSON.parse(item.itemJson).description}}</view>
  52. <view >{{JSON.parse(item.itemJson).imgUrl}}</view> -->
  53. <view class="order-main">
  54. <view class="img-box">
  55. <image :src="JSON.parse(item.itemJson).image"></image>
  56. </view>
  57. <view class="order-text">
  58. <view class="title">{{JSON.parse(item.itemJson).productName}}</view>
  59. <!-- <view class="txt">适用于乏力、头晕等人群,通过问诊可明确诊断给予专业性指导意见。</view> -->
  60. <view class="num">
  61. <text>{{JSON.parse(item.itemJson).sales}} 人已购</text>
  62. <text class="grey">x{{item.totalNum}}</text>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="order-bottom">
  67. <view class="order-money">
  68. <text class="title">订单金额:</text>
  69. <text class="num">¥<text class="bold">{{item.payPrice}}</text></text>
  70. </view>
  71. <view class="button-group">
  72. <view v-if="item.status == 0" @click.stop="cancel(item)" class="button cancel ">取消订单
  73. </view>
  74. <view v-if="item.isAfterSales==1&&item.status!=-3&&item.status!=0&&item.status!=-2"
  75. @click.stop="refund(item)" class="button cancel">申请售后
  76. </view>
  77. <view v-if="item.status ==2 ||item.status ==3 ||item.deliverySn" class="button cancel"
  78. @click.stop="showDelivery(item)">查看物流</view>
  79. <view v-if="item.status == 0" @click.stop="pay(item)" class="button pay">去支付</view>
  80. <view v-if="item.status == 2" @click.stop="confirmReceipt(item)" class="button pay">确认收货
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </mescroll-body>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. import {
  92. cancelOrder, //取消订单
  93. liveOrderList, // 订单列表
  94. finishOrder, //确认收货
  95. getStoreAfterSalesList //获取售后列表
  96. } from '@/api/order.js'
  97. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  98. export default {
  99. mixins: [MescrollMixin], // 使用mixin
  100. data() {
  101. return {
  102. searchKey: '',
  103. status: '',
  104. orderList: [],
  105. tabList: [{
  106. name: "全部",
  107. status: ""
  108. },
  109. {
  110. name: "待支付",
  111. status: "0"
  112. },
  113. {
  114. name: "待发货",
  115. status: "1"
  116. },
  117. {
  118. name: "待收货",
  119. status: "2"
  120. },
  121. {
  122. name: "已完成",
  123. status: "3"
  124. },
  125. {
  126. name: "售后中",
  127. status: "-1"
  128. },
  129. {
  130. name: "退款成功",
  131. status: "-2"
  132. }
  133. ],
  134. // mescroll配置
  135. downOption: {
  136. use: true,
  137. auto: false // 是否在初始化后自动执行下拉回调
  138. },
  139. upOption: {
  140. use: true,
  141. auto: true, // 是否在初始化时自动执行上拉回调
  142. page: {
  143. num: 0, // 当前页码
  144. size: 10 // 每页数据条数
  145. },
  146. noMoreSize: 5, // 如果列表已无数据,可设置列表的总数量要大于等于5条才显示无更多数据
  147. empty: {
  148. icon: 'https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/no_data.png', // 可配置空状态图片
  149. tip: '暂无订单数据' // 空状态提示文字
  150. }
  151. },
  152. mescroll: null // mescroll实例
  153. }
  154. },
  155. methods: {
  156. goSearch(e) {
  157. this.searchKey = e.detail.value;
  158. this.mescroll.resetUpScroll()
  159. },
  160. goDetail(item) {
  161. console.log("跳转", item)
  162. if (item.status == -1) {
  163. uni.navigateTo({
  164. url: './refundOrderDetail?id=' + item.afterSaleId
  165. })
  166. } else {
  167. uni.navigateTo({
  168. url: './storeOrderDetail?orderId=' + item.orderId+'&liveId='+item.liveId
  169. })
  170. }
  171. },
  172. // mescroll初始化
  173. mescrollInit(mescroll) {
  174. this.mescroll = mescroll;
  175. },
  176. // 下拉刷新回调
  177. downCallback(mescroll) {
  178. // 重置列表数据
  179. this.orderList = [];
  180. mescroll.resetUpScroll();
  181. },
  182. // 上拉加载回调
  183. upCallback(mescroll) {
  184. const pageNum = mescroll.num;
  185. const pageSize = mescroll.size;
  186. let data = {
  187. keyword: this.searchKey,
  188. pageSize: pageSize,
  189. pageNum: pageNum,
  190. status: this.status
  191. }
  192. liveOrderList(data).then(res => {
  193. if (res.code == 200) {
  194. // 请求成功,处理数据
  195. let curPageData = res.data.list || [];
  196. // let curPageData = res.rows || [];
  197. let curPageLen = curPageData.length;
  198. let totalSize = res.data.total || 0;
  199. // 如果是第一页,直接赋值
  200. if (pageNum === 1) {
  201. this.orderList = [];
  202. }
  203. // 追加新数据
  204. this.orderList = this.orderList.concat(curPageData);
  205. // 方法一(推荐): 后台返回有总数据量
  206. mescroll.endBySize(curPageLen, totalSize);
  207. } else {
  208. // 请求失败
  209. mescroll.endErr();
  210. uni.showToast({
  211. title: res.msg,
  212. icon: 'none'
  213. });
  214. }
  215. }).catch(err => {
  216. // 请求异常
  217. mescroll.endErr();
  218. console.log("请求异常:" + JSON.stringify(err));
  219. });
  220. },
  221. // 确认收货
  222. confirmReceipt(item) {
  223. var that = this;
  224. uni.showModal({
  225. title: '提示',
  226. content: '确认收到货了吗',
  227. success: function(res) {
  228. if (res.confirm) {
  229. var data = {
  230. orderId: item.orderId,
  231. };
  232. finishOrder(data).then(res => {
  233. if (res.code == 200) {
  234. uni.showToast({
  235. icon: 'success',
  236. title: "操作成功",
  237. });
  238. // 刷新列表
  239. that.mescroll.resetUpScroll();
  240. } else {
  241. uni.showToast({
  242. icon: 'none',
  243. title: res.msg,
  244. });
  245. }
  246. });
  247. }
  248. }
  249. });
  250. },
  251. // 取消订单
  252. cancel(item) {
  253. var that = this;
  254. uni.showModal({
  255. title: '提示',
  256. content: '确定取消订单吗',
  257. success: function(res) {
  258. if (res.confirm) {
  259. const data = {
  260. orderId: item.orderId,
  261. };
  262. console.log(data)
  263. cancelOrder(data).then(res => {
  264. if (res.code == 200) {
  265. uni.showToast({
  266. icon: 'success',
  267. title: "操作成功",
  268. });
  269. // 刷新列表
  270. that.mescroll.resetUpScroll();
  271. } else {
  272. uni.showToast({
  273. icon: 'none',
  274. title: res.msg,
  275. });
  276. }
  277. });
  278. }
  279. }
  280. });
  281. },
  282. // 申请售后
  283. refund(item) {
  284. uni.navigateTo({
  285. url: './refundOrderProduct?orderId=' + item.orderId
  286. })
  287. },
  288. // tab切换
  289. tabsClick(item) {
  290. console.log("item", item)
  291. this.status = item.status;
  292. // 切换tab时刷新列表
  293. this.mescroll.resetUpScroll();
  294. },
  295. // 查看物流
  296. showDelivery(item) {
  297. uni.navigateTo({
  298. url: `./storeOrderDelivery?orderId=${item.orderId}`
  299. })
  300. },
  301. // 支付
  302. pay(item) {
  303. console.log("去支付", item)
  304. uni.navigateTo({
  305. url: `./paymentOrder?orderList=${encodeURIComponent(JSON.stringify(item))}`
  306. })
  307. },
  308. }
  309. }
  310. </script>
  311. <style lang="scss" scoped>
  312. :deep(.u-tabs) {
  313. background-color: #FFFFFF;
  314. }
  315. :deep(.u-tabs__wrapper__nav) {
  316. width: 100%;
  317. }
  318. .top-fixed {
  319. width: 100%;
  320. position: fixed;
  321. top: 0;
  322. left: 0;
  323. z-index: 10;
  324. }
  325. .pub-tab-box {
  326. width: 100%;
  327. background-color: #FFFFFF;
  328. }
  329. .scroll-tabs {
  330. width: 100%;
  331. white-space: nowrap;
  332. /* 隐藏滚动条 */
  333. ::-webkit-scrollbar {
  334. display: none;
  335. }
  336. /* 添加鼠标滚轮支持 */
  337. overflow-x: auto;
  338. -webkit-overflow-scrolling: touch;
  339. }
  340. /* 针对电脑环境添加特殊样式 */
  341. @media (min-width: 768px) {
  342. .scroll-tabs {
  343. /* 在电脑上显示滚动条 */
  344. ::-webkit-scrollbar {
  345. display: block;
  346. height: 4px;
  347. }
  348. ::-webkit-scrollbar-thumb {
  349. background: #ddd;
  350. border-radius: 2px;
  351. }
  352. }
  353. }
  354. .tab-inner {
  355. display: flex;
  356. align-items: center;
  357. height: 88upx;
  358. padding: 0 30upx;
  359. /* 给左右留一些空间 */
  360. }
  361. .item {
  362. font-size: 28upx;
  363. white-space: nowrap;
  364. line-height: 1;
  365. font-family: PingFang SC;
  366. font-weight: 500;
  367. color: #666666;
  368. margin-right: 60upx;
  369. display: flex;
  370. align-items: center;
  371. justify-content: center;
  372. flex-shrink: 0;
  373. position: relative;
  374. &:last-child {
  375. margin-right: 30upx;
  376. /* 最后一个也保持间距 */
  377. }
  378. &.active {
  379. font-weight: bold;
  380. color: #333333;
  381. }
  382. .text {
  383. position: relative;
  384. z-index: 1;
  385. }
  386. .tab-bg {
  387. width: 72upx;
  388. height: 28upx;
  389. position: absolute;
  390. top: 17upx;
  391. left: 50%;
  392. transform: translateX(-36upx);
  393. z-index: -1;
  394. }
  395. }
  396. .content {
  397. .search-cont {
  398. padding: 16upx 30upx;
  399. background-color: #FFFFFF;
  400. .inner {
  401. box-sizing: border-box;
  402. width: 100%;
  403. height: 72upx;
  404. background: #F7F7F7;
  405. border-radius: 36upx;
  406. display: flex;
  407. align-items: center;
  408. padding: 0 30upx;
  409. .icon-search {
  410. width: 28upx;
  411. height: 28upx;
  412. margin-right: 20upx;
  413. }
  414. input {
  415. height: 60upx;
  416. line-height: 60upx;
  417. flex: 1;
  418. }
  419. }
  420. }
  421. .order-list {
  422. margin-top: 220rpx;
  423. background: #F5F7FA;
  424. padding: 0 24rpx;
  425. .order-item {
  426. background: #FFFFFF;
  427. border-radius: 16rpx;
  428. padding: 30rpx 24rpx;
  429. margin-top: 24rpx;
  430. .order-num {
  431. display: flex;
  432. justify-content: space-between;
  433. font-size: 28rpx;
  434. color: #2BC7B9;
  435. .lable {
  436. color: #5a5a5a;
  437. font-size: 26rpx;
  438. }
  439. }
  440. .order-main {
  441. display: flex;
  442. margin: 26rpx 0 30rpx;
  443. .img-box {
  444. width: 180rpx;
  445. height: 180rpx;
  446. border-radius: 16rpx;
  447. flex-shrink: 0;
  448. overflow: hidden;
  449. margin-right: 26rpx;
  450. flex-shrink: 0;
  451. image {
  452. width: 100%;
  453. height: 100%;
  454. }
  455. }
  456. .order-text {
  457. flex: 1;
  458. .title {
  459. font-weight: 500;
  460. font-size: 28rpx;
  461. color: #222222;
  462. }
  463. .txt {
  464. font-size: 24rpx;
  465. color: #999999;
  466. margin: 8rpx 0 18rpx 0;
  467. }
  468. .num {
  469. margin-top: 60rpx;
  470. display: flex;
  471. justify-content: space-between;
  472. font-size: 22rpx;
  473. color: #E69A22;
  474. .grey {
  475. margin-top: 12rpx;
  476. font-size: 24rpx;
  477. color: #999999;
  478. }
  479. }
  480. }
  481. }
  482. .order-bottom {
  483. display: flex;
  484. justify-content: space-between;
  485. align-items: center;
  486. .order-money {
  487. .title {
  488. font-size: 24rpx;
  489. color: #757575;
  490. }
  491. .num {
  492. font-weight: 600;
  493. font-size: 20rpx;
  494. color: #FF5C03;
  495. .bold {
  496. font-weight: bold;
  497. font-size: 36rpx;
  498. }
  499. }
  500. }
  501. .button-group {
  502. display: flex;
  503. align-items: center;
  504. .button {
  505. // margin-left: 10rpx;
  506. // padding: 10rpx 14rpx;
  507. // border-radius: 8rpx;
  508. // font-weight: 500;
  509. // font-size: 24rpx;
  510. width: 150upx;
  511. height: 64upx;
  512. line-height: 64upx;
  513. font-size: 26upx;
  514. font-family: PingFang SC;
  515. font-weight: 500;
  516. text-align: center;
  517. border-radius: 32upx;
  518. margin-left: 10upx;
  519. }
  520. .cancel {
  521. border: 1px solid #DDDDDD;
  522. color: #666666;
  523. }
  524. .pay {
  525. color: #FFFFFF;
  526. background-color: #2BC7B9;
  527. }
  528. }
  529. }
  530. }
  531. }
  532. }
  533. </style>