order.vue 12 KB

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