order.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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. <!-- tab切换 -->
  11. <view class="pub-tab-box">
  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" src="/static/images/tab_bg.png"
  18. mode=""></image>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="order-list">
  25. <view class="order-item" v-for="(item,index) in orderList" :key="index" @click="goDetail(item)">
  26. <view class="order-num">
  27. <text class="lable">订单号:{{item.orderCode}}</text>
  28. <text v-if="item.status==-1&&item.refundStatus==0">未退款</text>
  29. <text v-if="item.status==-1&&item.refundStatus==1">申请中</text>
  30. <text v-if="item.status==-1&&item.refundStatus==2">已退款</text>
  31. <!-- <text v-if="item.status==-1">申请售后</text> -->
  32. <text v-else-if="item.status==-2">退款成功</text>
  33. <text v-else-if="item.status==1">待支付</text>
  34. <text v-else-if="item.status==2">待发货</text>
  35. <text v-else-if="item.status==3">待收货</text>
  36. <text v-else-if="item.status==4">已完成</text>
  37. <text v-else-if="item.status==-3">已取消</text>
  38. </view>
  39. <view class="order-main" v-for="(itm,idx) in item.orderItemList" :key="idx"
  40. >
  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="cancel(item)" class="button cancel ">取消订单</view>
  60. <view v-if="item.isAfterSales==1" @click="refund(item)" class="button cancel">申请售后
  61. </view>
  62. <view
  63. v-if="item.status ==3 ||item.status ==4 ||item.deliverySn"
  64. class="button cancel" @click.stop="showDelivery(item)">查看物流</view>
  65. <view v-if="item.status == 1" @click="pay(item)" class="button pay">去支付</view>
  66. <view v-if="item.status == 3" @click="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. evaluate(item) {
  292. // 评价逻辑
  293. }
  294. }
  295. }
  296. </script>
  297. <style lang="scss" scoped>
  298. :deep(.u-tabs) {
  299. background-color: #FFFFFF;
  300. }
  301. :deep(.u-tabs__wrapper__nav) {
  302. width: 100%;
  303. }
  304. .top-fixed {
  305. width: 100%;
  306. position: fixed;
  307. top: 0;
  308. left: 0;
  309. z-index: 10;
  310. }
  311. .pub-tab-box {
  312. box-sizing: border-box;
  313. width: 100%;
  314. padding: 0 60upx;
  315. background-color: #FFFFFF;
  316. .tab-inner {
  317. height: 88upx;
  318. line-height: 88upx;
  319. display: flex;
  320. align-items: center;
  321. justify-content: space-between;
  322. overflow-x: auto;
  323. }
  324. .item {
  325. font-size: 28upx;
  326. white-space: nowrap;
  327. line-height: 1;
  328. font-family: PingFang SC;
  329. font-weight: 500;
  330. color: #666666;
  331. margin-right: 60upx;
  332. display: flex;
  333. align-items: center;
  334. justify-content: center;
  335. &:last-child {
  336. margin-right: 0;
  337. }
  338. &.active {
  339. font-weight: bold;
  340. color: #333333;
  341. }
  342. .text {
  343. position: relative;
  344. z-index: 1;
  345. }
  346. .tab-bg {
  347. width: 72upx;
  348. height: 28upx;
  349. position: absolute;
  350. top: 17upx;
  351. left: 50%;
  352. transform: translateX(-36upx);
  353. z-index: -1;
  354. }
  355. }
  356. }
  357. .content {
  358. .order-list {
  359. margin-top: 80rpx;
  360. background: #F5F7FA;
  361. padding: 0 24rpx;
  362. .order-item {
  363. background: #FFFFFF;
  364. border-radius: 16rpx;
  365. padding: 30rpx 24rpx;
  366. margin-top: 24rpx;
  367. .order-num {
  368. display: flex;
  369. justify-content: space-between;
  370. font-size: 28rpx;
  371. color: #2BC7B9;
  372. .lable {
  373. color: #5a5a5a;
  374. font-size: 26rpx;
  375. }
  376. }
  377. .order-main {
  378. display: flex;
  379. margin: 26rpx 0 30rpx;
  380. .img-box {
  381. width: 180rpx;
  382. height: 180rpx;
  383. border-radius: 16rpx;
  384. flex-shrink: 0;
  385. overflow: hidden;
  386. margin-right: 26rpx;
  387. image {
  388. width: 100%;
  389. height: 100%;
  390. }
  391. }
  392. .order-text {
  393. .title {
  394. font-weight: 500;
  395. font-size: 28rpx;
  396. color: #222222;
  397. }
  398. .txt {
  399. font-size: 24rpx;
  400. color: #999999;
  401. margin: 8rpx 0 18rpx 0;
  402. }
  403. .num {
  404. display: flex;
  405. justify-content: space-between;
  406. font-size: 22rpx;
  407. color: #E69A22;
  408. .grey {
  409. margin-top: 12rpx;
  410. font-size: 24rpx;
  411. color: #999999;
  412. }
  413. }
  414. }
  415. }
  416. .order-bottom {
  417. display: flex;
  418. justify-content: space-between;
  419. align-items: center;
  420. .order-money {
  421. .title {
  422. font-size: 24rpx;
  423. color: #757575;
  424. }
  425. .num {
  426. font-weight: 600;
  427. font-size: 20rpx;
  428. color: #FF5C03;
  429. .bold {
  430. font-weight: bold;
  431. font-size: 36rpx;
  432. }
  433. }
  434. }
  435. .button-group {
  436. display: flex;
  437. align-items: center;
  438. .button {
  439. // margin-left: 10rpx;
  440. // padding: 10rpx 14rpx;
  441. // border-radius: 8rpx;
  442. // font-weight: 500;
  443. // font-size: 24rpx;
  444. width: 150upx;
  445. height: 64upx;
  446. line-height: 64upx;
  447. font-size: 26upx;
  448. font-family: PingFang SC;
  449. font-weight: 500;
  450. text-align: center;
  451. border-radius: 32upx;
  452. margin-left: 10upx;
  453. }
  454. .cancel {
  455. border: 1px solid #DDDDDD;
  456. color: #666666;
  457. }
  458. .pay {
  459. color: #FFFFFF;
  460. background-color: #2BC7B9;
  461. }
  462. }
  463. }
  464. }
  465. }
  466. }
  467. </style>