order.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <view class="content">
  3. <view class="tab-menu">
  4. <view :class="orderState==0?'tab-item active':'tab-item'" @click="orderStatus(0)">全部</view>
  5. <view :class="orderState==2?'tab-item active':'tab-item'" @click="orderStatus(2)">待使用</view>
  6. <view :class="orderState==3?'tab-item active':'tab-item'" @click="orderStatus(3)">已完成</view>
  7. <view :class="orderState==4?'tab-item active':'tab-item'" @click="orderStatus(4)">已退款</view>
  8. <view :class="orderState==8?'tab-item active':'tab-item'" @click="orderStatus(8)">履约中</view>
  9. </view>
  10. <scroll-view class="order-body" scroll-y scroll-with-animation @scrolltoupper="scrolltoupper" @scrolltolower="scrolltolower" upper-threshold="80">
  11. <view class="order-list" v-if="orderList.length == 0 && orderData.loading">
  12. <view class="order-item" v-for="(item,indx) in 3" :key="indx">
  13. <view class="item-header">
  14. <view class="item-store" style="flex: 1;"><view class="skeleton-line animate"></view></view>
  15. </view>
  16. <view class="item-goods">
  17. <view class="image">
  18. <view class="skeleton-line animate"></view>
  19. </view>
  20. <view class="info">
  21. <view class="title">
  22. <view class="skeleton-line animate"></view>
  23. </view>
  24. <view class="tags">
  25. <view class="skeleton-line animate"></view>
  26. </view>
  27. <view class="tags">
  28. <view class="skeleton-line animate"></view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="mt15">
  33. <view class="skeleton-line animate"></view>
  34. </view>
  35. <view class="item-footer mt15">
  36. <view class="footer-left" style="width: 30%;">
  37. <view class="skeleton-line animate"></view>
  38. </view>
  39. <view class="footer-group-btn" style="width: 30%;">
  40. <view class="skeleton-line animate"></view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="order-list" v-else>
  46. <view class="empty-body" v-if="orderList.length == 0">
  47. <view class="imgs">
  48. <image src="/static/image/empty.png" mode="widthFix"></image>
  49. <view class="tip">没有更多数据啦~</view>
  50. <view class="re-btn" @click="toLogin" v-if="!isLogin">立即登录</view>
  51. </view>
  52. </view>
  53. <view class="order-item" v-for="(item,indx) in orderList" :key="item.id" v-else>
  54. <view class="item-header" @click="toDetail(item.out_order_no)">
  55. <view class="item-store">
  56. <image src="/static/image/store.svg"></image>
  57. <text>{{item.poi.poi_name}}</text>
  58. </view>
  59. <view class="item-status danger" v-if="item.status == 1">待使用</view>
  60. <view class="item-status success" v-if="item.status == 2">已完成</view>
  61. <view class="item-status fail" v-if="item.status == 3">已退款</view>
  62. <view class="item-status warn" v-if="item.status == 4">退款中</view>
  63. <view class="item-status fail" v-if="item.status == 5">已关闭</view>
  64. <view class="item-status warn" v-if="item.status == 6">部分退款</view>
  65. <view class="item-status success" v-if="item.status == 7">履约中</view>
  66. </view>
  67. <view class="item-goods" @click="toDetail(item.out_order_no)">
  68. <view class="image">
  69. <image :src="item.img"></image>
  70. </view>
  71. <view class="info">
  72. <view class="title">
  73. <view class="name" v-if="item.product.is_new == 1">{{item.product.price}}元代{{item.product.line_price}}元商场权益券{{ item.product.product_name }}</view>
  74. <view class="name" v-else>{{ item.product.product_name }}</view>
  75. <view class="num">x{{ item.number }}</view>
  76. </view>
  77. <view class="tags">
  78. {{item.sku_name?item.sku_name:'默认'}}
  79. <view class="price">{{ $dialog.formatMoney(item.price,true) }}</view>
  80. </view>
  81. </view>
  82. </view>
  83. <view class="item-time">
  84. <view class="time-list">订单编号:{{ item.order_sn }}</view>
  85. <view class="time-list">下单时间:{{item.create_at}}</view>
  86. </view>
  87. <view class="item-footer" @click="toDetail(item.out_order_no)">
  88. <view class="footer-left">实付 <text>{{ $dialog.formatMoney(item.pay_money,true) }}</text></view>
  89. <view class="footer-group-btn">
  90. <view :class="indx%2==0?'button border':'button warn'">继续支付</view>
  91. <view class="button fail">申请退款</view>
  92. </view>
  93. </view>
  94. </view>
  95. <uni-load-more status="loading" v-if="orderData.loading"></uni-load-more>
  96. <uni-load-more status="noMore" v-if="orderList.length > 0 && orderData.isDone"></uni-load-more>
  97. </view>
  98. <view class="line-height"></view>
  99. </scroll-view>
  100. <halfLogin ref="loginCom" @success="loginSuccess"></halfLogin>
  101. </view>
  102. </template>
  103. <script>
  104. var app;
  105. const pageSize = 20;
  106. export default {
  107. data() {
  108. return {
  109. orderState:0,
  110. orderData:{
  111. size:pageSize,
  112. page:1,
  113. loading:false,
  114. isDone:false
  115. },
  116. orderList:[],
  117. isLogin:true
  118. }
  119. },
  120. onLoad() {
  121. app = this;
  122. app.getOrder()
  123. },
  124. methods: {
  125. scrolltoupper(){},
  126. scrolltolower(e){
  127. if (app.orderData.isDone || app.orderList.length == 0) return ;
  128. app.getOrder()
  129. },
  130. toDetail(order){
  131. uni.navigateTo({
  132. url:"/pages/order/detail?order="+order
  133. })
  134. },
  135. loginSuccess(){
  136. app.getOrder()
  137. },
  138. toLogin(){
  139. app.$refs.loginCom.open();
  140. },
  141. orderStatus(state) {
  142. app.orderState = state
  143. app.orderList = [];
  144. app.orderData = {
  145. size:pageSize,
  146. page:1,
  147. loading:false,
  148. isDone:false
  149. };
  150. app.getOrder()
  151. },
  152. async getOrder(){
  153. app.orderData.loading = true;
  154. var formData = {};
  155. const tokenPoi = uni.getStorageSync("contact");
  156. formData.poi = tokenPoi.poi_id;
  157. formData.page = app.orderData.page;
  158. formData.size = app.orderData.size;
  159. formData.status = app.orderState;
  160. var resp = await app.$api.order.list.get(formData)
  161. app.orderData.loading = false;
  162. if (resp.code == 401) {
  163. app.isLogin = false;
  164. return ;
  165. }
  166. if (resp.code == 0) {
  167. return app.$dialog.showSuccess(resp.msg)
  168. }
  169. app.isLogin = true;
  170. if (resp.data.rows.length > 0) {
  171. app.orderData.page ++;
  172. app.orderList = [...app.orderList,...resp.data.rows];
  173. } else {
  174. app.orderData.isDone = true;
  175. }
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="scss" scoped>
  181. .content{
  182. position: fixed;
  183. z-index: 1;
  184. top: 0;
  185. left: 0;
  186. bottom: 0;
  187. right: 0;
  188. background-color: #ededed;
  189. display: flex;
  190. flex-direction: column;
  191. .line-height{
  192. height: 40rpx;
  193. width: 100%;
  194. }
  195. }
  196. .empty-body{
  197. display: flex;align-items: center;justify-content: center;flex-direction: column;height: calc(100vh - 100upx);
  198. .imgs{
  199. text-align: center;font-size: 28upx;color: #666;
  200. image{height: 160upx;width: 160upx;}
  201. .tip{margin-top: 20upx;}
  202. }
  203. .re-btn{
  204. width: 180upx;
  205. height: 80upx;
  206. line-height: 80upx;
  207. text-align: center;
  208. font-size: 28upx;
  209. color: #fff;
  210. background-color: $main-color;
  211. border-radius: 10upx;
  212. margin-top: 60upx;
  213. }
  214. }
  215. .tab-menu{
  216. height: 80rpx;
  217. line-height: 80rpx;
  218. background-color: #fff;
  219. display: flex;
  220. align-items: center;
  221. font-size: 28rpx;
  222. color: #666;
  223. justify-content: space-around;
  224. .tab-item{
  225. position: relative;
  226. color: $main-text-color;
  227. &.active{
  228. color: $main-color;
  229. font-weight: 700;
  230. &::after{
  231. position: absolute;
  232. content: "";
  233. width: 30%;
  234. left: 35%;
  235. height: 4rpx;
  236. bottom: 0;
  237. background-color: $main-color;
  238. }
  239. }
  240. }
  241. }
  242. .order-body{
  243. height: 0;
  244. flex: 1;
  245. .order-list{
  246. .order-item{
  247. width: 95%;
  248. margin: 0 auto;
  249. background-color: #fff;
  250. padding: 20rpx;
  251. margin-top: 20rpx;
  252. border-radius: 10rpx;
  253. .item-footer{
  254. display: flex;
  255. align-items: center;
  256. justify-content: space-between;
  257. color: $main-text-color;
  258. font-size: 28rpx;
  259. .footer-left{
  260. text {
  261. font-size: 30rpx;
  262. font-weight: bold;
  263. color: $main-color;
  264. }
  265. }
  266. .footer-group-btn{
  267. display: flex;
  268. align-items: center;
  269. gap: 20rpx;
  270. .button{
  271. font-size: 24rpx;
  272. padding: 10rpx 20rpx;
  273. border-radius: 40rpx;
  274. display: flex;
  275. align-items: center;
  276. &.border{
  277. background-color: #fff;
  278. border: 2rpx solid #fed7aa;
  279. color: #f26428;
  280. }
  281. &.success{
  282. background-color: #d1fae5;
  283. color: #059669;
  284. }
  285. &.fail{
  286. background-color: #f1f5f9;
  287. color: #64748b;
  288. }
  289. &.danger{
  290. background-color: #fef3c7;
  291. color: #b45309;
  292. }
  293. &.warn{
  294. background-color: #fef3c7;
  295. color: #b45309;
  296. }
  297. }
  298. }
  299. }
  300. .item-time{
  301. background-color: #fff8f1;
  302. border-radius: 10rpx;
  303. margin: 20rpx 0;
  304. padding: 20rpx;
  305. .time-list{
  306. line-height: 48rpx;
  307. font-size: 24rpx;
  308. color: #64748b;
  309. }
  310. }
  311. .item-goods{
  312. display: flex;
  313. align-items: center;
  314. gap: 20rpx;
  315. background-color: #fff;
  316. margin-top: 20rpx;
  317. border-radius: 20rpx;
  318. .stock{
  319. text-align: right;
  320. }
  321. .image {
  322. height: 180rpx;
  323. overflow: hidden;display: flex;align-items: center;min-width: 180rpx;
  324. position: relative;
  325. image {
  326. width: 180rpx;
  327. border-radius: 10upx;
  328. height: 100%;
  329. }
  330. }
  331. .info{
  332. flex: 1 1 0%;
  333. overflow: hidden;
  334. .title{
  335. display: flex;
  336. align-items: center;
  337. justify-content: space-between;
  338. .name {
  339. overflow: hidden;
  340. text-overflow: ellipsis;
  341. font-size: 32rpx;
  342. display: -webkit-box;
  343. -webkit-line-clamp: 2;
  344. -webkit-box-orient: vertical;
  345. color: #333;
  346. font-weight: 900;
  347. }
  348. }
  349. .tags {
  350. color: #94a3b8;
  351. font-size: 24rpx;
  352. margin: 10rpx 0;
  353. display: flex;
  354. align-items: center;
  355. justify-content: space-between;
  356. .price {
  357. font-size: 28rpx;
  358. color: $main-text-color;
  359. font-weight: 600;
  360. }
  361. }
  362. }
  363. }
  364. .item-header{
  365. display: flex;
  366. align-items: center;
  367. justify-content: space-between;
  368. border-bottom: 2rpx solid #fff7ed;
  369. padding-bottom: 10rpx;
  370. .item-status{
  371. font-size: 24rpx;
  372. padding: 10rpx 20rpx;
  373. border-radius: 30rpx;
  374. &.success{
  375. background-color: #d1fae5;
  376. color: #059669;
  377. }
  378. &.fail{
  379. background-color: #f1f5f9;
  380. color: #64748b;
  381. }
  382. &.danger{
  383. background-color: #fef3c7;
  384. color: #b45309;
  385. }
  386. &.warn{
  387. background-color: #ffedd5;
  388. color: #e95b22;
  389. }
  390. }
  391. .item-store{
  392. display: flex;
  393. align-items: center;
  394. gap: 15rpx;
  395. image {
  396. width: 40rpx;
  397. height: 40rpx;
  398. }
  399. }
  400. }
  401. }
  402. }
  403. }
  404. </style>