order.vue 12 KB

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