order.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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">
  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. @click="goDetail(itm)">
  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.deliveryCode"
  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. } from '@/api/order.js'
  82. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  83. export default {
  84. mixins: [MescrollMixin], // 使用mixin
  85. data() {
  86. return {
  87. status: '',
  88. orderList: [],
  89. tabList: [{
  90. name: "全部",
  91. status: ""
  92. },
  93. {
  94. name: "待支付",
  95. status: "1"
  96. },
  97. {
  98. name: "待发货",
  99. status: "2"
  100. },
  101. {
  102. name: "待收货",
  103. status: "3"
  104. },
  105. {
  106. name: "已完成",
  107. status: "4"
  108. },
  109. {
  110. name: "售后中",
  111. status: "-1"
  112. },
  113. {
  114. name: "退款成功",
  115. status: "-2"
  116. }
  117. ],
  118. // mescroll配置
  119. downOption: {
  120. use: true,
  121. auto: false // 是否在初始化后自动执行下拉回调
  122. },
  123. upOption: {
  124. use: true,
  125. auto: true, // 是否在初始化时自动执行上拉回调
  126. page: {
  127. num: 0, // 当前页码
  128. size: 10 // 每页数据条数
  129. },
  130. noMoreSize: 5, // 如果列表已无数据,可设置列表的总数量要大于等于5条才显示无更多数据
  131. empty: {
  132. icon: '/static/images/no_data.png', // 可配置空状态图片
  133. tip: '暂无订单数据' // 空状态提示文字
  134. }
  135. },
  136. mescroll: null // mescroll实例
  137. }
  138. },
  139. methods: {
  140. goDetail(item) {
  141. console.log("跳转", item)
  142. uni.navigateTo({
  143. url: './storeOrderDetail?id=' + item.orderId
  144. })
  145. },
  146. // mescroll初始化
  147. mescrollInit(mescroll) {
  148. this.mescroll = mescroll;
  149. },
  150. // 下拉刷新回调
  151. downCallback(mescroll) {
  152. // 重置列表数据
  153. this.orderList = [];
  154. mescroll.resetUpScroll();
  155. },
  156. // 上拉加载回调
  157. upCallback(mescroll) {
  158. const pageNum = mescroll.num;
  159. const pageSize = mescroll.size;
  160. let data = {
  161. pageSize: pageSize,
  162. pageNum: pageNum,
  163. status: this.status
  164. }
  165. liveOrderList(data).then(res => {
  166. if (res.code == 200) {
  167. // 请求成功,处理数据
  168. let curPageData = res.data.list || [];
  169. // let curPageData = res.rows || [];
  170. let curPageLen = curPageData.length;
  171. let totalSize = res.data.total || 0;
  172. // 如果是第一页,直接赋值
  173. if (pageNum === 1) {
  174. this.orderList = [];
  175. }
  176. // 追加新数据
  177. this.orderList = this.orderList.concat(curPageData);
  178. // 方法一(推荐): 后台返回有总数据量
  179. mescroll.endBySize(curPageLen, totalSize);
  180. } else {
  181. // 请求失败
  182. mescroll.endErr();
  183. uni.showToast({
  184. title: res.msg,
  185. icon: 'none'
  186. });
  187. }
  188. }).catch(err => {
  189. // 请求异常
  190. mescroll.endErr();
  191. console.log("请求异常:" + JSON.stringify(err));
  192. });
  193. },
  194. // 确认收货
  195. confirmReceipt(item) {
  196. var that = this;
  197. uni.showModal({
  198. title: '提示',
  199. content: '确认收到货了吗',
  200. success: function(res) {
  201. if (res.confirm) {
  202. var data = {
  203. orderId: item.orderId,
  204. };
  205. finishOrder(data).then(res => {
  206. if (res.code == 200) {
  207. uni.showToast({
  208. icon: 'success',
  209. title: "操作成功",
  210. });
  211. // 刷新列表
  212. that.mescroll.resetUpScroll();
  213. } else {
  214. uni.showToast({
  215. icon: 'none',
  216. title: res.msg,
  217. });
  218. }
  219. });
  220. }
  221. }
  222. });
  223. },
  224. // 取消订单
  225. cancel(item) {
  226. var that = this;
  227. uni.showModal({
  228. title: '提示',
  229. content: '确定取消订单吗',
  230. success: function(res) {
  231. if (res.confirm) {
  232. const data = {
  233. orderId: item.orderId,
  234. };
  235. console.log(data)
  236. cancelOrder(data).then(res => {
  237. if (res.code == 200) {
  238. uni.showToast({
  239. icon: 'success',
  240. title: "操作成功",
  241. });
  242. // 刷新列表
  243. that.mescroll.resetUpScroll();
  244. } else {
  245. uni.showToast({
  246. icon: 'none',
  247. title: res.msg,
  248. });
  249. }
  250. });
  251. }
  252. }
  253. });
  254. },
  255. // 申请售后
  256. refund(item) {
  257. uni.navigateTo({
  258. url: './refundOrderProduct?orderId=' + item.orderId
  259. })
  260. },
  261. // tab切换
  262. tabsClick(item) {
  263. this.status = item.status;
  264. // 切换tab时刷新列表
  265. this.mescroll.resetUpScroll();
  266. },
  267. // 查看物流
  268. showDelivery(item) {
  269. uni.navigateTo({
  270. url: `./storeOrderDelivery?orderId=${item.orderId}`
  271. })
  272. },
  273. // 支付
  274. pay(item) {
  275. console.log("去支付", item)
  276. uni.navigateTo({
  277. url: `./paymentOrder?orderList=${encodeURIComponent(JSON.stringify(item))}`
  278. })
  279. },
  280. // 评价
  281. evaluate(item) {
  282. // 评价逻辑
  283. }
  284. }
  285. }
  286. </script>
  287. <style lang="scss" scoped>
  288. :deep(.u-tabs) {
  289. background-color: #FFFFFF;
  290. }
  291. :deep(.u-tabs__wrapper__nav) {
  292. width: 100%;
  293. }
  294. .top-fixed {
  295. width: 100%;
  296. position: fixed;
  297. top: 0;
  298. left: 0;
  299. z-index: 10;
  300. }
  301. .pub-tab-box {
  302. box-sizing: border-box;
  303. width: 100%;
  304. padding: 0 60upx;
  305. background-color: #FFFFFF;
  306. .tab-inner {
  307. height: 88upx;
  308. line-height: 88upx;
  309. display: flex;
  310. align-items: center;
  311. justify-content: space-between;
  312. overflow-x: auto;
  313. }
  314. .item {
  315. font-size: 28upx;
  316. white-space: nowrap;
  317. line-height: 1;
  318. font-family: PingFang SC;
  319. font-weight: 500;
  320. color: #666666;
  321. margin-right: 60upx;
  322. display: flex;
  323. align-items: center;
  324. justify-content: center;
  325. &:last-child {
  326. margin-right: 0;
  327. }
  328. &.active {
  329. font-weight: bold;
  330. color: #333333;
  331. }
  332. .text {
  333. position: relative;
  334. z-index: 1;
  335. }
  336. .tab-bg {
  337. width: 72upx;
  338. height: 28upx;
  339. position: absolute;
  340. top: 17upx;
  341. left: 50%;
  342. transform: translateX(-36upx);
  343. z-index: -1;
  344. }
  345. }
  346. }
  347. .content {
  348. .order-list {
  349. margin-top: 80rpx;
  350. background: #F5F7FA;
  351. padding: 0 24rpx;
  352. .order-item {
  353. background: #FFFFFF;
  354. border-radius: 16rpx;
  355. padding: 30rpx 24rpx;
  356. margin-top: 24rpx;
  357. .order-num {
  358. display: flex;
  359. justify-content: space-between;
  360. font-size: 28rpx;
  361. color: #2BC7B9;
  362. .lable {
  363. color: #5a5a5a;
  364. font-size: 26rpx;
  365. }
  366. }
  367. .order-main {
  368. display: flex;
  369. margin: 26rpx 0 30rpx;
  370. .img-box {
  371. width: 180rpx;
  372. height: 180rpx;
  373. border-radius: 16rpx;
  374. flex-shrink: 0;
  375. overflow: hidden;
  376. margin-right: 26rpx;
  377. image {
  378. width: 100%;
  379. height: 100%;
  380. }
  381. }
  382. .order-text {
  383. .title {
  384. font-weight: 500;
  385. font-size: 28rpx;
  386. color: #222222;
  387. }
  388. .txt {
  389. font-size: 24rpx;
  390. color: #999999;
  391. margin: 8rpx 0 18rpx 0;
  392. }
  393. .num {
  394. display: flex;
  395. justify-content: space-between;
  396. font-size: 22rpx;
  397. color: #E69A22;
  398. .grey {
  399. margin-top: 12rpx;
  400. font-size: 24rpx;
  401. color: #999999;
  402. }
  403. }
  404. }
  405. }
  406. .order-bottom {
  407. display: flex;
  408. justify-content: space-between;
  409. align-items: center;
  410. .order-money {
  411. .title {
  412. font-size: 24rpx;
  413. color: #757575;
  414. }
  415. .num {
  416. font-weight: 600;
  417. font-size: 20rpx;
  418. color: #FF5C03;
  419. .bold {
  420. font-weight: bold;
  421. font-size: 36rpx;
  422. }
  423. }
  424. }
  425. .button-group {
  426. display: flex;
  427. align-items: center;
  428. .button {
  429. // margin-left: 10rpx;
  430. // padding: 10rpx 14rpx;
  431. // border-radius: 8rpx;
  432. // font-weight: 500;
  433. // font-size: 24rpx;
  434. width: 150upx;
  435. height: 64upx;
  436. line-height: 64upx;
  437. font-size: 26upx;
  438. font-family: PingFang SC;
  439. font-weight: 500;
  440. text-align: center;
  441. border-radius: 32upx;
  442. margin-left: 10upx;
  443. }
  444. .cancel {
  445. border: 1px solid #DDDDDD;
  446. color: #666666;
  447. }
  448. .pay {
  449. color: #FFFFFF;
  450. background-color: #2BC7B9;
  451. }
  452. }
  453. }
  454. }
  455. }
  456. }
  457. </style>