index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <template>
  2. <view>
  3. <view class='my-order'>
  4. <view class='header bg-color'>
  5. <view class='picTxt acea-row row-between-wrapper'>
  6. <view class='text'>
  7. <view class='name'>订单信息</view>
  8. <!-- <view>总金额:¥{{orderData.total || 0}} 总子订单数:{{orderData.subOrder || 0}}</view> -->
  9. </view>
  10. <view class='pictrue'>
  11. <image src='../../../static/images/orderTime.png'></image>
  12. </view>
  13. </view>
  14. </view>
  15. <view class='nav acea-row row-around'>
  16. <view class='item' :class='orderType==0 ? "on": ""' @click="statusClick(0)">
  17. <view>待支付</view>
  18. <view class='num'>{{orderData.unpaid || 0}}</view>
  19. </view>
  20. <view class='item' :class='orderType==1 ? "on": ""' @click="statusClick(1)">
  21. <view>打单中</view>
  22. <view class='num'>{{orderData.inorder || 0}}</view>
  23. </view>
  24. <view class='item' :class='orderType==2 ? "on": ""' @click="statusClick(2)">
  25. <view>已出单</view>
  26. <view class='num '>{{orderData.sendOrder || 0}}</view>
  27. </view>
  28. <view class='item' :class='orderType==9 ? "on": ""' @click="statusClick(9)">
  29. <view>异常</view>
  30. <view class='num'>{{orderData.abnormalOrder || 0}}</view>
  31. </view>
  32. <view class='item' :class='orderType==-2 ? "on": ""' @click="statusClick(-2)">
  33. <view>退货</view>
  34. <view class='num'>{{orderData.refundOrder || 0}}</view>
  35. </view>
  36. </view>
  37. <view class='list'>
  38. <view class='item' v-for="(item,index) in orderList" :key="index">
  39. <view class='title acea-row row-between-wrapper'>
  40. <view class="acea-row row-middle">
  41. <view>{{item.time}}</view>
  42. </view>
  43. <view v-if="item.status == 0" class='font-color'>未支付</view>
  44. <view v-if="item.status == 1" class='font-color'>打单中</view>
  45. <view v-if="item.status == 2" class='font-color'>已出单</view>
  46. <view v-if="item.status == 9" class='font-color'>异常</view>
  47. <view v-if="item.status == -2" class='font-color'>已退款</view>
  48. </view>
  49. <view class='item-info acea-row row-between row-top'>
  50. <view class='pictrue'>
  51. <image :src='item.pro_img'></image>
  52. </view>
  53. <view class='text acea-row row-between'>
  54. <view class='name line2'>{{item.pro_title}}</view>
  55. <view class='money'>
  56. <view>{{item.platfrom_name}}</view>
  57. <view>x{{item.order_count}}</view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class='totalPrice'>付款金额
  62. <text class='money font-color'>¥{{item.all_price}}</text>
  63. </view>
  64. <view class='bottom acea-row row-right row-middle'>
  65. <view class='bnt bg-color' v-if="item.status == 0" @click='pay(item.order_id)'>支付</view>
  66. <view class='bnt cancelBnt' v-if="item.status == 0" @click='cancel(index,item.id)'>取消</view>
  67. <view :class='item.status == 0 ? "bnt cancelBnt" : "bnt bg-color"' @click='detail(item.id)'>查看</view>
  68. </view>
  69. </view>
  70. </view>
  71. <view class='loadingicon acea-row row-center-wrapper' v-if="orderList.length>0">
  72. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  73. </view>
  74. <view v-if="orderList.length == 0">
  75. <emptyPage title="暂无订单~"></emptyPage>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. import {
  82. mapGetters
  83. } from "vuex";
  84. import {
  85. toLogin
  86. } from '@/libs/login.js';
  87. import {
  88. getOrder,
  89. getOrderList,
  90. balancePay,
  91. cancelOrder
  92. } from '@/api/api.js';
  93. import emptyPage from '@/components/emptyPage.vue';
  94. export default {
  95. components: {
  96. emptyPage
  97. },
  98. data() {
  99. return {
  100. loading: false, //是否加载中
  101. loadend: false, //是否加载完毕
  102. loadTitle: '加载更多', //提示语
  103. orderList: [], //订单数组
  104. orderData: {}, //订单详细统计
  105. orderType: '0', //订单状态
  106. page: 1,
  107. limit: 20
  108. };
  109. },
  110. computed: mapGetters(['isLogin']),
  111. onLoad: function(options) {
  112. if (options.status) this.orderType = options.status;
  113. if (this.isLogin) {
  114. this.getOrderData();
  115. this.getOrderList();
  116. } else {
  117. toLogin();
  118. }
  119. },
  120. methods: {
  121. //获取订单统计数据
  122. getOrderData: function() {
  123. let that = this;
  124. getOrder().then(res => {
  125. that.$set(that, 'orderData', res.data);
  126. })
  127. },
  128. //切换类型
  129. statusClick: function(status) {
  130. if (status == this.orderType) return;
  131. this.orderType = status;
  132. this.loadend = false;
  133. this.page = 1;
  134. this.$set(this, 'orderList', []);
  135. this.getOrderList();
  136. },
  137. //获取订单列表
  138. getOrderList: function() {
  139. let that = this;
  140. if (that.loadend) return;
  141. if (that.loading) return;
  142. that.loading = true;
  143. that.loadTitle = "加载更多";
  144. getOrderList({
  145. orderType: that.orderType,
  146. page: that.page,
  147. limit: that.limit,
  148. }).then(res => {
  149. let list = res.data.list || [];
  150. let loadend = list.length < that.limit;
  151. that.orderList = that.$util.SplitArray(list, that.orderList);
  152. that.$set(that, 'orderList', that.orderList);
  153. that.loadend = loadend;
  154. that.loading = false;
  155. that.loadTitle = loadend ? "没有更多了" : '加载更多';
  156. that.page = that.page + 1;
  157. }).catch(err => {
  158. that.loading = false;
  159. that.loadTitle = "加载更多";
  160. })
  161. },
  162. pay: function(order_id) {
  163. let that = this;
  164. balancePay({'order_id':order_id}).then(res => {
  165. return that.$util.Tips({
  166. title: res.data.msg,
  167. icon: 'success'
  168. }, () => {
  169. this.loadend = false;
  170. this.page = 1;
  171. this.$set(this, 'orderList', []);
  172. this.getOrderData();
  173. this.getOrderList();
  174. });
  175. }).catch(err => {
  176. that.$util.Tips({
  177. title: err
  178. });
  179. });
  180. },
  181. cancel: function(index, id) {
  182. let that = this;
  183. if (!id) return that.$util.Tips({
  184. title: '缺少订单号无法取消订单'
  185. });
  186. cancelOrder({'id':id}).then(res => {
  187. return that.$util.Tips({
  188. title: res.data.msg,
  189. icon: 'success'
  190. }, function() {
  191. that.orderList.splice(index, 1);
  192. that.getOrderData();
  193. });
  194. }).catch(err => {
  195. return that.$util.Tips({
  196. title: err
  197. });
  198. });
  199. },
  200. detail: function(id) {
  201. uni.navigateTo({
  202. url: '/pages/users/order/detail?id='+id
  203. })
  204. }
  205. },
  206. onReachBottom: function() {
  207. this.getOrderList();
  208. }
  209. }
  210. </script>
  211. <style scoped lang="scss">
  212. .bg-color {
  213. background-color: #ff5c00!important;
  214. }
  215. .my-order .header {
  216. height: 260rpx;
  217. padding: 0 30rpx;
  218. }
  219. .my-order .header .picTxt {
  220. height: 190rpx;
  221. }
  222. .my-order .header .picTxt .text {
  223. color: rgba(255, 255, 255, 0.8);
  224. font-size: 26rpx;
  225. font-family: 'Guildford Pro';
  226. }
  227. .my-order .header .picTxt .text .name {
  228. font-size: 34rpx;
  229. font-weight: bold;
  230. color: #fff;
  231. margin-bottom: 20rpx;
  232. }
  233. .my-order .header .picTxt .pictrue {
  234. width: 122rpx;
  235. height: 109rpx;
  236. }
  237. .my-order .header .picTxt .pictrue image {
  238. width: 100%;
  239. height: 100%;
  240. }
  241. .my-order .nav {
  242. background-color: #fff;
  243. width: 690rpx;
  244. height: 140rpx;
  245. border-radius: 6rpx;
  246. margin: -73rpx auto 0 auto;
  247. }
  248. .my-order .nav .item {
  249. text-align: center;
  250. font-size: 26rpx;
  251. color: #282828;
  252. padding: 29rpx 0;
  253. }
  254. .my-order .nav .item.on {
  255. font-weight: bold;
  256. border-bottom: 5rpx solid #ff5c00;
  257. }
  258. .my-order .nav .item .num {
  259. margin-top: 18rpx;
  260. }
  261. .my-order .list {
  262. width: 690rpx;
  263. margin: 14rpx auto 0 auto;
  264. }
  265. .my-order .list .item {
  266. background-color: #fff;
  267. border-radius: 6rpx;
  268. margin-bottom: 14rpx;
  269. }
  270. .my-order .list .item .title {
  271. height: 84rpx;
  272. padding: 0 30rpx;
  273. border-bottom: 1rpx solid #eee;
  274. font-size: 28rpx;
  275. color: #282828;
  276. }
  277. .my-order .list .item .title .sign {
  278. font-size: 24rpx;
  279. padding: 0 7rpx;
  280. height: 36rpx;
  281. margin-right: 15rpx;
  282. }
  283. .my-order .list .item .item-info {
  284. padding: 0 30rpx;
  285. margin-top: 22rpx;
  286. }
  287. .my-order .list .item .item-info .pictrue {
  288. width: 120rpx;
  289. height: 120rpx;
  290. }
  291. .my-order .list .item .item-info .pictrue image {
  292. width: 100%;
  293. height: 100%;
  294. border-radius: 6rpx;
  295. }
  296. .my-order .list .item .item-info .text {
  297. width: 486rpx;
  298. font-size: 28rpx;
  299. color: #999;
  300. margin-top: 6rpx;
  301. }
  302. .my-order .list .item .item-info .text .name {
  303. width: 306rpx;
  304. color: #282828;
  305. }
  306. .my-order .list .item .item-info .text .money {
  307. text-align: right;
  308. }
  309. .my-order .list .item .totalPrice {
  310. font-size: 26rpx;
  311. color: #282828;
  312. text-align: right;
  313. margin: 27rpx 0 0 30rpx;
  314. padding: 0 30rpx 30rpx 0;
  315. border-bottom: 1rpx solid #eee;
  316. }
  317. .my-order .list .item .totalPrice .money {
  318. font-size: 28rpx;
  319. font-weight: bold;
  320. }
  321. .my-order .list .item .bottom {
  322. height: 107rpx;
  323. padding: 0 30rpx;
  324. }
  325. .my-order .list .item .bottom .bnt {
  326. width: 176rpx;
  327. height: 60rpx;
  328. text-align: center;
  329. line-height: 60rpx;
  330. color: #fff;
  331. border-radius: 50rpx;
  332. font-size: 27rpx;
  333. }
  334. .my-order .list .item .bottom .bnt.cancelBnt {
  335. border: 1rpx solid #ddd;
  336. color: #aaa;
  337. }
  338. .my-order .list .item .bottom .bnt{
  339. width: 80px;
  340. }
  341. .my-order .list .item .bottom .bnt~.bnt {
  342. margin-left: 17rpx;
  343. }
  344. .noCart {
  345. margin-top: 171rpx;
  346. padding-top: 0.1rpx;
  347. }
  348. .noCart .pictrue {
  349. width: 414rpx;
  350. height: 336rpx;
  351. margin: 78rpx auto 56rpx auto;
  352. }
  353. .noCart .pictrue image {
  354. width: 100%;
  355. height: 100%;
  356. }
  357. </style>