order.vue 10 KB

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