order.vue 11 KB

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