orders.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <view class="content">
  3. <view class="nav flex">
  4. <view class="item" v-for="(item,index) in navList" :class="{action: current == index}" @click="changeCurrent(index)">
  5. {{item.tit}}
  6. </view>
  7. </view>
  8. <swiper :current="current" class="swiper-box" :style="{'height': height}">
  9. <swiper-item v-for="item in navList">
  10. <scroll-view scroll-y="true" :style="{'height': height}">
  11. <empty v-if="item.loaded === true && item.list.length === 0"></empty>
  12. <view class="order-item" v-for="items in item.list" >
  13. <view class="item-top flex">
  14. <view class="order-type">
  15. 预约订单
  16. </view>
  17. <view class="order-id">
  18. 订单编号:{{items.order_id}}
  19. </view>
  20. <view class="order-status">
  21. {{items.status == 0?'待服务':(items.status == 1?'进行中':'已完成')}}
  22. </view>
  23. </view>
  24. <view class="item-user flex">
  25. <image src="../../static/icon/where.png" mode="" class="where"></image>
  26. <view class="">
  27. <view class="">
  28. {{items.user_address}}
  29. </view>
  30. <view class="phone">
  31. {{items.real_name}}{{items.user_phone |geTel}}
  32. </view>
  33. </view>
  34. </view>
  35. <view class="item-user flex">
  36. <image src="../../static/icon/time.png" mode="" class="where"></image>
  37. <view class="">
  38. <view class="">
  39. {{items.subscribe_day}} {{items.subscribe_time}}
  40. </view>
  41. </view>
  42. </view>
  43. <view class="item-yg">
  44. <view class="">
  45. 服务类型:<text>{{items.type}}</text>
  46. </view>
  47. <!-- <view class="">
  48. 代理人:<text>李丹丹</text>
  49. </view> -->
  50. </view>
  51. <view class="item-btm flex">
  52. <view class="">
  53. 下单时间:{{items.add_time}}
  54. </view>
  55. <view class="u-btn" @click="cancelSubscribe(items.order_id)" v-if="items.status == 0">
  56. 取消预约
  57. </view>
  58. </view>
  59. </view>
  60. <uni-load-more :status="item.loading" v-if="!(item.loaded === true && item.list.length === 0)"></uni-load-more>
  61. </scroll-view>
  62. </swiper-item>
  63. </swiper>
  64. </view>
  65. </template>
  66. <script>
  67. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  68. import empty from '@/components/empty';
  69. import { subscribeList,cancelSubscribe} from '@/api/user.js'
  70. export default {
  71. components: {
  72. empty,
  73. uniLoadMore
  74. },
  75. data() {
  76. return {
  77. height: '',
  78. current: 0,
  79. navList: [
  80. {
  81. tit: '待服务',
  82. status: 0,
  83. list: [],
  84. loading: 'more',
  85. loaded: true,
  86. page: 1,
  87. limit: 10,
  88. },
  89. {
  90. tit: '进行中',
  91. status: 1,
  92. list: [],
  93. loading: 'more',
  94. loaded: false,
  95. page: 1,
  96. limit: 10,
  97. },
  98. // {
  99. // tit: '已完成',
  100. // status: 2,
  101. // list: [],
  102. // loading: 'more',
  103. // loaded: false,
  104. // page: 1,
  105. // limit: 10
  106. // }
  107. ]
  108. }
  109. },
  110. filters:{
  111. geTel(tel){
  112. var reg = /^(\d{3})\d{4}(\d{4})$/;
  113. return tel.replace(reg, "$1****$2");
  114. }
  115. },
  116. onLoad() {
  117. this.getOrderList()
  118. },
  119. onShow() {
  120. },
  121. onReachBottom() {
  122. },
  123. onReady(res) {
  124. var that = this;
  125. uni.getSystemInfo({
  126. success: resu => {
  127. const query = uni.createSelectorQuery();
  128. query.select('.swiper-box').boundingClientRect();
  129. query.exec(function(res) {
  130. that.height = resu.windowHeight - res[0].top + 'px';
  131. });
  132. },
  133. fail: res => {}
  134. });
  135. },
  136. methods: {
  137. cancelSubscribe(id) {
  138. cancelSubscribe({
  139. order_id:id
  140. }).then(res=> {
  141. uni.showToast({
  142. title: '取消成功',
  143. duration: 2000
  144. });
  145. this.getOrderList('re')
  146. })
  147. },
  148. changeCurrent(index) {
  149. if(index == this.current) return;
  150. this.current = index;
  151. this.getOrderList()
  152. },
  153. getOrderList(type) {
  154. let that = this;
  155. let item = that.navList[that.current];
  156. if(type == 're') {
  157. item.list = []
  158. item.page = 1
  159. item.loading = 'more'
  160. item.loaded = false
  161. }
  162. if(item.loading == 'noMore' || item.loading == 'loading') return;
  163. item.loading = 'more'
  164. subscribeList({
  165. page:item.page,
  166. limit:item.limit,
  167. status: item.status
  168. }).then(res => {
  169. console.log(res.data.data);
  170. let arr = res.data.data
  171. item.list = item.list.concat(arr)
  172. if(arr.length == item.limit) {
  173. item.loading = 'more'
  174. }else {
  175. item.loading = 'noMore'
  176. }
  177. item.loaded = true
  178. })
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .content {
  185. padding-top: 20rpx;
  186. }
  187. .nav {
  188. width: 690rpx;
  189. height: 64rpx;
  190. background: $base-color;
  191. border-radius: 30rpx;
  192. margin: auto;
  193. justify-content: space-around;
  194. margin-bottom: 30rpx;
  195. .item {
  196. width: 209rpx;
  197. line-height: 56rpx;
  198. border-radius: 28rpx;
  199. text-align: center;
  200. color: #FFFFFF;
  201. }
  202. .action {
  203. color: $base-color;
  204. background: #FFFFFF;
  205. // font-weight: bold;
  206. }
  207. }
  208. .swiper-box {
  209. }
  210. .order-item {
  211. padding:0 20rpx;
  212. background-color: #fff;
  213. width: 700rpx;
  214. margin: 0 auto 20rpx;
  215. border-radius: 20rpx;
  216. &:last-of-type {
  217. margin-bottom: 0;
  218. }
  219. .item-top {
  220. height: 92rpx;
  221. border-bottom: #f5f5f5 3rpx solid;
  222. font-weight: 500;
  223. .order-type {
  224. // padding: 10;
  225. padding: 8rpx 10rpx;
  226. background: #ffeae5;
  227. border-radius: 0rpx 10rpx 0rpx 10rpx;
  228. font-size: 20rpx;
  229. color: #FF4E00;
  230. }
  231. .order-id {
  232. flex-grow: 1;
  233. font-size: 22rpx;
  234. color: #A3A8BB;
  235. padding-left: 10rpx;
  236. }
  237. .order-status {
  238. font-size: 26rpx;
  239. color: #FF4E00;
  240. }
  241. }
  242. .item-yg {
  243. width: 660rpx;
  244. // height: 122rpx;
  245. background: #F5F5F5;
  246. font-size: 24rpx;
  247. color: #666666;
  248. padding: 25rpx 0 20rpx 20rpx;
  249. margin-bottom: 24rpx;
  250. text {
  251. font-weight: bold;
  252. color: #333333;
  253. }
  254. }
  255. .item-btm {
  256. height: 92rpx;
  257. font-size: 24rpx;
  258. color: #A3A8BB;
  259. border-top: #f5f5f5 3rpx solid;
  260. }
  261. .item-user {
  262. justify-content: flex-start;
  263. align-items: flex-start;
  264. font-weight: bold;
  265. font-size: 26rpx;
  266. color: #000000;
  267. margin: 30rpx 0;
  268. .where {
  269. width: 24rpx;
  270. height: 28rpx;
  271. margin-right: 23rpx;
  272. }
  273. .time {
  274. width: 24rpx;
  275. height: 24rpx;
  276. }
  277. image {
  278. flex-shrink: 0;
  279. margin-top:5rpx;
  280. }
  281. .phone {
  282. padding-top: 15rpx;
  283. font-size: 23rpx;
  284. color: #666666;
  285. }
  286. }
  287. }
  288. .u-btn {
  289. width: 144rpx;
  290. line-height: 55rpx;
  291. border-radius: 28rpx;
  292. border: 1px solid #FF4C4C;
  293. font-size: 26rpx;
  294. color: #FF4C4C;
  295. text-align: center;
  296. }
  297. </style>