order.vue 13 KB

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