order.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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://kntobs.jnmyunl.com/shop/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://kntobs.jnmyunl.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://kntobs.jnmyunl.com/shop/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. if (item.status == -1) {
  162. uni.navigateTo({
  163. url: './refundOrderDetail?id=' + item.afterSalesId
  164. })
  165. } else {
  166. uni.navigateTo({
  167. url: './storeOrderDetail?orderId=' + item.orderId+'&liveId='+item.liveId
  168. })
  169. }
  170. },
  171. // mescroll初始化
  172. mescrollInit(mescroll) {
  173. this.mescroll = mescroll;
  174. },
  175. // 下拉刷新回调
  176. downCallback(mescroll) {
  177. // 重置列表数据
  178. this.orderList = [];
  179. mescroll.resetUpScroll();
  180. },
  181. // 上拉加载回调
  182. upCallback(mescroll) {
  183. const pageNum = mescroll.num;
  184. const pageSize = mescroll.size;
  185. let data = {
  186. keyword: this.searchKey,
  187. pageSize: pageSize,
  188. pageNum: pageNum,
  189. status: this.status
  190. }
  191. liveOrderList(data).then(res => {
  192. if (res.code == 200) {
  193. // 请求成功,处理数据
  194. let curPageData = res.data.list || [];
  195. // let curPageData = res.rows || [];
  196. let curPageLen = curPageData.length;
  197. let totalSize = res.data.total || 0;
  198. // 如果是第一页,直接赋值
  199. if (pageNum === 1) {
  200. this.orderList = [];
  201. }
  202. // 追加新数据
  203. this.orderList = this.orderList.concat(curPageData);
  204. // 方法一(推荐): 后台返回有总数据量
  205. mescroll.endBySize(curPageLen, totalSize);
  206. } else {
  207. // 请求失败
  208. mescroll.endErr();
  209. uni.showToast({
  210. title: res.msg,
  211. icon: 'none'
  212. });
  213. }
  214. }).catch(err => {
  215. // 请求异常
  216. mescroll.endErr();
  217. console.log("请求异常:" + JSON.stringify(err));
  218. });
  219. },
  220. // 确认收货
  221. confirmReceipt(item) {
  222. var that = this;
  223. uni.showModal({
  224. title: '提示',
  225. content: '确认收到货了吗',
  226. success: function(res) {
  227. if (res.confirm) {
  228. var data = {
  229. orderId: item.orderId,
  230. };
  231. finishOrder(data).then(res => {
  232. if (res.code == 200) {
  233. uni.showToast({
  234. icon: 'success',
  235. title: "操作成功",
  236. });
  237. // 刷新列表
  238. that.mescroll.resetUpScroll();
  239. } else {
  240. uni.showToast({
  241. icon: 'none',
  242. title: res.msg,
  243. });
  244. }
  245. });
  246. }
  247. }
  248. });
  249. },
  250. // 取消订单
  251. cancel(item) {
  252. var that = this;
  253. uni.showModal({
  254. title: '提示',
  255. content: '确定取消订单吗',
  256. success: function(res) {
  257. if (res.confirm) {
  258. const data = {
  259. orderId: item.orderId,
  260. };
  261. console.log(data)
  262. cancelOrder(data).then(res => {
  263. if (res.code == 200) {
  264. uni.showToast({
  265. icon: 'success',
  266. title: "操作成功",
  267. });
  268. // 刷新列表
  269. that.mescroll.resetUpScroll();
  270. } else {
  271. uni.showToast({
  272. icon: 'none',
  273. title: res.msg,
  274. });
  275. }
  276. });
  277. }
  278. }
  279. });
  280. },
  281. // 申请售后
  282. refund(item) {
  283. uni.navigateTo({
  284. url: './refundOrderProduct?orderId=' + item.orderId
  285. })
  286. },
  287. // tab切换
  288. tabsClick(item) {
  289. console.log("item", item)
  290. this.status = item.status;
  291. // 切换tab时刷新列表
  292. this.mescroll.resetUpScroll();
  293. },
  294. // 查看物流
  295. showDelivery(item) {
  296. uni.navigateTo({
  297. url: `./storeOrderDelivery?orderId=${item.orderId}`
  298. })
  299. },
  300. // 支付
  301. pay(item) {
  302. console.log("去支付", item)
  303. uni.navigateTo({
  304. url: `./paymentOrder?orderList=${encodeURIComponent(JSON.stringify(item))}`
  305. })
  306. },
  307. }
  308. }
  309. </script>
  310. <style lang="scss" scoped>
  311. :deep(.u-tabs) {
  312. background-color: #FFFFFF;
  313. }
  314. :deep(.u-tabs__wrapper__nav) {
  315. width: 100%;
  316. }
  317. .top-fixed {
  318. width: 100%;
  319. position: fixed;
  320. top: 0;
  321. left: 0;
  322. z-index: 10;
  323. }
  324. .pub-tab-box {
  325. width: 100%;
  326. background-color: #FFFFFF;
  327. }
  328. .scroll-tabs {
  329. width: 100%;
  330. white-space: nowrap;
  331. /* 隐藏滚动条 */
  332. ::-webkit-scrollbar {
  333. display: none;
  334. }
  335. /* 添加鼠标滚轮支持 */
  336. overflow-x: auto;
  337. -webkit-overflow-scrolling: touch;
  338. }
  339. /* 针对电脑环境添加特殊样式 */
  340. @media (min-width: 768px) {
  341. .scroll-tabs {
  342. /* 在电脑上显示滚动条 */
  343. ::-webkit-scrollbar {
  344. display: block;
  345. height: 4px;
  346. }
  347. ::-webkit-scrollbar-thumb {
  348. background: #ddd;
  349. border-radius: 2px;
  350. }
  351. }
  352. }
  353. .tab-inner {
  354. display: flex;
  355. align-items: center;
  356. height: 88upx;
  357. padding: 0 30upx;
  358. /* 给左右留一些空间 */
  359. }
  360. .item {
  361. font-size: 28upx;
  362. white-space: nowrap;
  363. line-height: 1;
  364. font-family: PingFang SC;
  365. font-weight: 500;
  366. color: #666666;
  367. margin-right: 60upx;
  368. display: flex;
  369. align-items: center;
  370. justify-content: center;
  371. flex-shrink: 0;
  372. position: relative;
  373. &:last-child {
  374. margin-right: 30upx;
  375. /* 最后一个也保持间距 */
  376. }
  377. &.active {
  378. font-weight: bold;
  379. color: #333333;
  380. }
  381. .text {
  382. position: relative;
  383. z-index: 1;
  384. }
  385. .tab-bg {
  386. width: 72upx;
  387. height: 28upx;
  388. position: absolute;
  389. top: 17upx;
  390. left: 50%;
  391. transform: translateX(-36upx);
  392. z-index: -1;
  393. }
  394. }
  395. .content {
  396. .search-cont {
  397. padding: 16upx 30upx;
  398. background-color: #FFFFFF;
  399. .inner {
  400. box-sizing: border-box;
  401. width: 100%;
  402. height: 72upx;
  403. background: #F7F7F7;
  404. border-radius: 36upx;
  405. display: flex;
  406. align-items: center;
  407. padding: 0 30upx;
  408. .icon-search {
  409. width: 28upx;
  410. height: 28upx;
  411. margin-right: 20upx;
  412. }
  413. input {
  414. height: 60upx;
  415. line-height: 60upx;
  416. flex: 1;
  417. }
  418. }
  419. }
  420. .order-list {
  421. margin-top: 220rpx;
  422. background: #F5F7FA;
  423. padding: 0 24rpx;
  424. .order-item {
  425. background: #FFFFFF;
  426. border-radius: 16rpx;
  427. padding: 30rpx 24rpx;
  428. margin-top: 24rpx;
  429. .order-num {
  430. display: flex;
  431. justify-content: space-between;
  432. font-size: 28rpx;
  433. color: #2BC7B9;
  434. .lable {
  435. color: #5a5a5a;
  436. font-size: 26rpx;
  437. }
  438. }
  439. .order-main {
  440. display: flex;
  441. margin: 26rpx 0 30rpx;
  442. .img-box {
  443. width: 180rpx;
  444. height: 180rpx;
  445. border-radius: 16rpx;
  446. flex-shrink: 0;
  447. overflow: hidden;
  448. margin-right: 26rpx;
  449. flex-shrink: 0;
  450. image {
  451. width: 100%;
  452. height: 100%;
  453. }
  454. }
  455. .order-text {
  456. flex: 1;
  457. .title {
  458. font-weight: 500;
  459. font-size: 28rpx;
  460. color: #222222;
  461. }
  462. .txt {
  463. font-size: 24rpx;
  464. color: #999999;
  465. margin: 8rpx 0 18rpx 0;
  466. }
  467. .num {
  468. margin-top: 60rpx;
  469. display: flex;
  470. justify-content: space-between;
  471. font-size: 22rpx;
  472. color: #E69A22;
  473. .grey {
  474. margin-top: 12rpx;
  475. font-size: 24rpx;
  476. color: #999999;
  477. }
  478. }
  479. }
  480. }
  481. .order-bottom {
  482. display: flex;
  483. justify-content: space-between;
  484. align-items: center;
  485. .order-money {
  486. .title {
  487. font-size: 24rpx;
  488. color: #757575;
  489. }
  490. .num {
  491. font-weight: 600;
  492. font-size: 20rpx;
  493. color: #FF5C03;
  494. .bold {
  495. font-weight: bold;
  496. font-size: 36rpx;
  497. }
  498. }
  499. }
  500. .button-group {
  501. display: flex;
  502. align-items: center;
  503. .button {
  504. // margin-left: 10rpx;
  505. // padding: 10rpx 14rpx;
  506. // border-radius: 8rpx;
  507. // font-weight: 500;
  508. // font-size: 24rpx;
  509. width: 150upx;
  510. height: 64upx;
  511. line-height: 64upx;
  512. font-size: 26upx;
  513. font-family: PingFang SC;
  514. font-weight: 500;
  515. text-align: center;
  516. border-radius: 32upx;
  517. margin-left: 10upx;
  518. }
  519. .cancel {
  520. border: 1px solid #DDDDDD;
  521. color: #666666;
  522. }
  523. .pay {
  524. color: #FFFFFF;
  525. background-color: #2BC7B9;
  526. }
  527. }
  528. }
  529. }
  530. }
  531. }
  532. </style>