index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view>
  3. <view class="order-box">
  4. <view v-for="(item,index) in list" :key="index" class="order-box-list" @click="goDetail(item.id)">
  5. <view class="order-box-header">
  6. <text class="order-box-title">{{item.name}}</text>
  7. <text class="order-box-desc" v-if="item.status == 1">已预约</text>
  8. <text class="order-box-desc" v-if="item.status == 2">已取消</text>
  9. </view>
  10. <view class="order-box-body">
  11. <view class="order-box-body-left">
  12. <image :src="item.goodsImg"></image>
  13. </view>
  14. <view class="order-box-body-right">
  15. <text class="order-box-body-desc">下单时间:{{item.createTime}}</text>
  16. <text class="order-box-body-cate" v-if="item.cate == 1">早餐</text>
  17. <text class="order-box-body-cate" v-if="item.cate == 2">午餐</text>
  18. <text class="order-box-body-cate" v-if="item.cate == 3">晚餐</text>
  19. <text class="order-box-body-cate" v-if="item.cate == 4">当日餐</text>
  20. </view>
  21. </view>
  22. </view>
  23. <view v-if="list.length == 0" class="no-data">
  24. <image src="../../images/no_data.png" mode=""></image>
  25. <view class="no-data-text">
  26. 空空如也~
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. var app = getApp();
  34. export default {
  35. data() {
  36. return {
  37. list: [],
  38. page: 1,
  39. size: 10,
  40. flag: 0
  41. }
  42. },
  43. onLoad() {
  44. },
  45. onShow(){
  46. var that = this;
  47. this.flag = 0;
  48. this.page = 1;
  49. this.getOrder();
  50. app.ajaxReadyCallback = res => { //各个接口统一回调方法
  51. var apiname = res.data.apiname;
  52. console.log(res);
  53. if(apiname == 'order'){
  54. that.list = res.data.data;
  55. if (that.list.length < that.size) {
  56. that.flag = 1;
  57. } else {
  58. that.page++;
  59. }
  60. }
  61. }
  62. },
  63. onPullDownRefresh() {
  64. this.flag = 0;
  65. this.page = 1;
  66. this.getOrder();
  67. },
  68. onReachBottom() { //上拉加载
  69. this.getOrder();
  70. },
  71. methods: {
  72. goDetail(id){
  73. uni.navigateTo({
  74. url: "/pages/order/detail?id=" + id
  75. });
  76. },
  77. getOrder(){
  78. if(this.flag == 1){
  79. return;
  80. }
  81. app.ajax({
  82. url: app.globalData.serverUrl + 'shopOrder/orderList',
  83. type: 'POST',
  84. apiname: 'order',
  85. data: {
  86. page: this.page,
  87. size: this.size
  88. }
  89. });
  90. },
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .order-box{
  96. padding-bottom: 30rpx;
  97. }
  98. .order-nodata{
  99. margin-top: 150rpx;
  100. text-align: center;
  101. font-size: 32rpx;
  102. color: #666666;
  103. }
  104. .order-box-list{
  105. width: 680rpx;
  106. height: auto;
  107. border-radius: 8rpx;
  108. margin: 15rpx auto;
  109. background-color: #FFFFFF;
  110. padding: 20rpx;
  111. overflow: hidden;
  112. }
  113. .order-box-header{
  114. width: 680rpx;
  115. height: 78rpx;
  116. line-height: 78rpx;
  117. border-bottom: 1rpx solid #F6F6F6;
  118. }
  119. .order-box-title{
  120. display: inline-block;
  121. width: 500rpx;
  122. height: 100%;
  123. font-size: 34rpx;
  124. font-weight: bold;
  125. }
  126. .order-box-desc{
  127. display: inline-block;
  128. width: 180rpx;
  129. text-align: right;
  130. height: 100%;
  131. color: #949494;
  132. font-size: 30rpx;
  133. }
  134. .order-box-body{
  135. padding: 20rpx 0 30rpx 0;
  136. }
  137. .order-box-body-left{
  138. display: inline-block;
  139. width: 88rpx;
  140. height: 88rpx;
  141. float: left;
  142. }
  143. .order-box-body-left image{
  144. width: 100%;
  145. height: 100%;
  146. border-radius: 10rpx;
  147. }
  148. .order-box-body-right{
  149. display: inline-block;
  150. width: 580rpx;
  151. float: right;
  152. }
  153. .order-box-body-desc{
  154. display: inline-block;
  155. width: 100%;
  156. font-size: 28rpx;
  157. color: #949494;
  158. }
  159. .order-box-body-cate{
  160. display: inline-block;
  161. width: 100%;
  162. font-size: 24rpx;
  163. color: $theme-color;
  164. }
  165. </style>