index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <view>
  3. <view class="header">
  4. <van-tabs :active="active" @change="changeselect">
  5. <!-- <view v-for="(item, index) in menu" :key="index">
  6. <van-tab v-if="num.waiting_count>0&&index==1" :name="index" :info="num.waiting_count" :title="item.name"></van-tab>
  7. <van-tab v-if="num.payed_count>0&&index==2" :name="index" :info="num.payed_count" :title="item.name"></van-tab> -->
  8. <van-tab v-for="(item, index) in menu" :key="index" :name="index" :info="num[index]" :title="item.name"></van-tab>
  9. <!-- </view> -->
  10. </van-tabs>
  11. </view>
  12. <van-skeleton :loading="loading">
  13. <scroll-view
  14. v-if="order_list.length > 0"
  15. style="height:100vh;margin-top: 88upx;"
  16. class="floor-list"
  17. :scroll-top="scrollTop"
  18. scroll-y="true"
  19. @scroll="scroll"
  20. @scrolltoupper="upper"
  21. @scrolltolower="lower"
  22. :refresher-enabled="false"
  23. >
  24. <view v-for="(item, index) in order_list" :key="index" class="cart-list">
  25. <view class="topTip" @click="goStore(item.store_id)">
  26. <view>
  27. <image
  28. v-if="item.store_avatar"
  29. :src="pictureUrl + '/uploads/home/store/' + item.store_id + '/' + item.store_avatar"
  30. style="border-radius: 50%;
  31. width: 50upx;height: 50upx;vertical-align: middle;"
  32. ></image>
  33. <span style="padding-left: 16upx;">{{ item.store_name }}</span>
  34. </view>
  35. <view style="color: #D9332E;font-size: 24upx;">{{ item.status }}</view>
  36. </view>
  37. <view @click="goDetail(item.order_id)" v-for="(items, indexs) in item.goods" :key="indexs" class="shoplist" style="background-color: #fff;">
  38. <view>
  39. <van-card
  40. title-class="changewidth"
  41. price-class="priceClass"
  42. :price="items.goods_pay_price"
  43. :desc="items.descire + 'X' + items.goods_num"
  44. :title="items.desarray"
  45. :thumb="pictureUrl + '/uploads/home/store/goods/' + items.goods_image.substr(0, items.goods_image.indexOf('\_')) + '/' + items.goods_image"
  46. ></van-card>
  47. </view>
  48. </view>
  49. <view class="topTip">
  50. <view style="font-size: 28upx;">合计:{{ item.order_amount }}</view>
  51. <view class="deleChange" @click="gopay(item)" v-if="item.order_state == 10">去付款</view>
  52. <view class="deleChange" @click="gopay(item)" v-if="item.order_state == 20 && item.shipping_type == 0">催单</view>
  53. <view class="deleChange" @click="gopay(item)" v-if="item.order_state == 20 && item.shipping_type != 0">联系酒店</view>
  54. <view class="deleChange" @click="gopay(item)" v-if="item.order_state == 30">确认收货</view>
  55. <view class="deleChange" @click="gopay(item)" v-if="item.order_state == 40 && item.evaluation_state == 0">去评价</view>
  56. </view>
  57. </view>
  58. <view v-if="ispull" class="fontcenter">加载中...</view>
  59. <view v-if="!ispull" style="padding: 20upx 0;" class="fontcenter">只有这么多订单啦</view>
  60. </scroll-view>
  61. </van-skeleton>
  62. <view v-if="order_list.length == 0 && successlogion && hasLogin">
  63. <view style="margin: 160upx auto;text-align: center;">
  64. <van-icon size="160rpx" color="#909399" name="description" />
  65. <view style="text-align: center;color: #909399;">去买点什么</view>
  66. </view>
  67. </view>
  68. <view v-if="(order_list.length == 0 && !successlogion) || (order_list.length == 0 && !hasLogin)">
  69. <view style="margin: 160upx auto;text-align: center;">
  70. <van-icon size="160rpx" color="#909399" name="description" />
  71. <view style="text-align: center;color: #909399;"><span style="color: #F76260;" @click="gotologion">请先登录</span></view>
  72. </view>
  73. </view>
  74. <!-- 催单 -->
  75. <Dialog :orderCancel="orderCancel" :titles="titles" @colseDialog="cancelDialog" @confirmPay="confirmOrder" />
  76. <Gobacktop @getop="getop" v-if="isTop" />
  77. </view>
  78. </template>
  79. <script>
  80. import { mapMutations, mapState } from 'vuex';
  81. import Dialog from '@/component/Dialog.vue';
  82. import Gobacktop from '@/component/Gobacktop.vue';
  83. export default {
  84. components: {
  85. Dialog,
  86. Gobacktop
  87. },
  88. data() {
  89. return {
  90. firstloading: 0,
  91. loading: true,
  92. isTop: false,
  93. ispull: true,
  94. showdialog: false,
  95. orderCancel: false,
  96. titles: '',
  97. pictureUrl: this.pictureUrl,
  98. menu: [
  99. { name: '全部' },
  100. { name: '待支付' },
  101. { name: '处理中' },
  102. { name: '已收货' },
  103. { name: '已取消' }
  104. // s{name:'退款售后'}
  105. ],
  106. deleteorder: 0, // 判断删除订单还是确认收货
  107. // 要查找的订单状态 all-全部 waiting-待支付 payed-处理中 complete-已收货 cancel-已取消 refund-退款售后
  108. active: 0,
  109. scrollTop: 0,
  110. old: {
  111. scrollTop: 0
  112. },
  113. order_id: '',
  114. page: 1,
  115. page_size: 10,
  116. state: 'all',
  117. order_list: [],
  118. num:[],
  119. };
  120. },
  121. computed: {
  122. ...mapState(['hasLogin', 'userInfo', 'successlogion'])
  123. },
  124. onLoad(a) {
  125. uni.$on('refehlist', () => {
  126. this.order_list = [];
  127. this.getlist();
  128. });
  129. uni.$on('finshlist', () => {
  130. this.page = 1;
  131. this.order_list = [];
  132. this.getlist();
  133. });
  134. // 完成评价
  135. uni.$on('finshesitmate', () => {
  136. this.page = 1;
  137. this.order_list = [];
  138. this.getlist();
  139. });
  140. if (this.successlogion && this.hasLogin) {
  141. this.getlist(); // 获取订单
  142. } else {
  143. uni.navigateTo({
  144. url: '/pages/myCenter/logion'
  145. });
  146. }
  147. },
  148. onUnload() {
  149. uni.$off();
  150. },
  151. onShow(){
  152. this.getNum();
  153. },
  154. watch: {
  155. successlogion: function(val) {
  156. if (val) {
  157. this.active = 0;
  158. this.getlist();
  159. } else {
  160. uni.navigateTo({
  161. url: '/pages/myCenter/logion'
  162. });
  163. }
  164. },
  165. hasLogin: function(val) {
  166. if (val) {
  167. this.active = 0;
  168. this.getlist();
  169. } else {
  170. uni.navigateTo({
  171. url: '/pages/myCenter/logion'
  172. });
  173. }
  174. }
  175. },
  176. methods: {
  177. getNum(){
  178. this.request({
  179. url:'/v1/order/statistics',
  180. method:'GET',
  181. success: (res)=>{
  182. this.$nextTick(function(){
  183. var data=res.data.data;
  184. var waiting_count=data.waiting_count>0? data.waiting_count:null;
  185. var payed_count=data.payed_count>0? data.payed_count:null;
  186. this.num=[null,waiting_count,payed_count,null,null];
  187. })
  188. }
  189. })
  190. },
  191. getop() {
  192. this.scrollTop = this.old.scrollTop;
  193. this.$nextTick(function() {
  194. this.scrollTop = 0;
  195. });
  196. this.isTop = false;
  197. },
  198. gotologion() {
  199. uni.navigateTo({
  200. url: '/pages/myCenter/logion'
  201. });
  202. },
  203. changeselect(e) {
  204. if (this.successlogion && this.hasLogin) {
  205. this.active = e.target.name;
  206. this.page = 1;
  207. this.ispull = true;
  208. this.order_list = [];
  209. if (e.target.name == 0) {
  210. this.state = 'all';
  211. this.getlist();
  212. } else if (e.target.name == 1) {
  213. this.state = 'waiting';
  214. this.getlist();
  215. } else if (e.target.name == 2) {
  216. this.state = 'payed';
  217. this.getlist();
  218. } else if (e.target.name == 3) {
  219. this.state = 'complete';
  220. this.getlist();
  221. } else if (e.target.name == 4) {
  222. this.state = 'cancel';
  223. this.getlist();
  224. }
  225. if (e.target.name == 5) {
  226. this.state = 'refund';
  227. }
  228. } else {
  229. uni.navigateTo({
  230. url: '/pages/myCenter/logion'
  231. });
  232. }
  233. },
  234. // 订单退款售后列表
  235. refund() {
  236. this.request({
  237. url: '/v3/order/refund_list',
  238. method: 'POST',
  239. data: {
  240. state: this.state,
  241. page: this.page,
  242. page_size: 10
  243. },
  244. success: res => {
  245. if (res.data.data.refund_list.length < 10) {
  246. this.ispull = false;
  247. }
  248. res.data.data.refund_list.forEach((item, index) => {
  249. let arr = item.goods_name.split(' ');
  250. item.desarray = arr[0];
  251. item.descire = item.goods_name.replace(arr[0], '');
  252. });
  253. this.order_list = this.order_list.concat(res.data.data.refund_list);
  254. }
  255. });
  256. },
  257. // 订单列表
  258. getlist() {
  259. this.request({
  260. url: '/v2/order/orders',
  261. method: 'POST',
  262. data: {
  263. state: this.state,
  264. page: this.page,
  265. page_size: 10
  266. },
  267. success: res => {
  268. if (res.data.data.order_list.length < 10) {
  269. this.ispull = false;
  270. }
  271. res.data.data.order_list.forEach((item, index) => {
  272. item.goods.forEach(items => {
  273. let arr = items.goods_name.split(' ');
  274. items.desarray = arr[0];
  275. items.descire = items.goods_name.replace(arr[0], '');
  276. });
  277. });
  278. if (this.firstloading == 0) {
  279. this.loading = false;
  280. }
  281. this.firstloading = 1;
  282. this.order_list = this.order_list.concat(res.data.data.order_list);
  283. }
  284. });
  285. },
  286. gopay(e) {
  287. let store_id = e.store_id;
  288. let prices = e.order_amount;
  289. this.order_id = e.order_id;
  290. let order_id = e.order_id;
  291. let isform = 1;
  292. if (e.operate == '去付款') {
  293. uni.navigateTo({
  294. url: `/pages/myOrder/paymoment?order_id=${order_id}&prices=${prices}
  295. &isform=${isform}&store_id=${store_id}`
  296. });
  297. } else if (e.operate == '删除') {
  298. this.titles = '确认删除订单?';
  299. this.deleteorder = 1;
  300. this.orderCancel = true;
  301. } else if (e.operate == '催单') {
  302. let a = 1;
  303. uni.navigateTo({
  304. url: `/pages/myOrder/reminder?order_id=${order_id}&a=${a}`
  305. });
  306. } else if (e.operate == '确认收货') {
  307. this.deleteorder = 2;
  308. this.titles = '确认收货?';
  309. this.orderCancel = true;
  310. } else if (e.operate == '去评价') {
  311. uni.navigateTo({
  312. url: `/pages/myOrder/estimate?order_id=${order_id}`
  313. });
  314. } else if (e.operate == '联系酒店') {
  315. let a = 2;
  316. uni.navigateTo({
  317. url: `/pages/myOrder/reminder?order_id=${order_id}&a=${a}`
  318. });
  319. }
  320. },
  321. cancelDialog() {
  322. this.orderCancel = false;
  323. },
  324. confirmOrder() {
  325. // 删除订单 确认收货
  326. this.orderCancel = false;
  327. let url = this.deleteorder == 1 ? '/v2/order/drop' : '/v2/order/confirm';
  328. this.request({
  329. url: url,
  330. method: 'POST',
  331. data: {
  332. order_id: this.order_id
  333. },
  334. success: res => {
  335. this.order_list = [];
  336. this.page = 1;
  337. this.ispull = true;
  338. this.getlist();
  339. }
  340. });
  341. },
  342. goDetail(e) {
  343. let order_id = e;
  344. uni.navigateTo({
  345. url: `/pages/myOrder/order?id=${order_id}`
  346. });
  347. },
  348. goStore(e) {
  349. let id = e;
  350. uni.navigateTo({
  351. url: `/pages/index/hotel?id=${id}`
  352. });
  353. },
  354. upper(e) {},
  355. // 滚到底部
  356. lower(e) {
  357. if (this.ispull) {
  358. this.page += 1;
  359. this.getlist();
  360. }
  361. },
  362. // 滚动时触发
  363. scroll(e) {
  364. if (e.detail.scrollTop > 400) {
  365. this.isTop = true;
  366. } else {
  367. //当距离小于500时显示回到顶部按钮
  368. this.isTop = false;
  369. }
  370. this.old.scrollTop = e.detail.scrollTop;
  371. }
  372. }
  373. };
  374. </script>
  375. <style>
  376. .header{
  377. position: fixed;
  378. top: 0;
  379. left: 0;
  380. right: 0;
  381. z-index: 999;
  382. background-color: #fff;
  383. }
  384. page {
  385. background-color: #f5f5f5;
  386. }
  387. .cart-list {
  388. background-color: #fff;
  389. border-top: 12upx solid #f5f5f5;
  390. }
  391. .topTip {
  392. display: flex;
  393. align-items: center;
  394. justify-content: space-between;
  395. padding: 20upx 36upx;
  396. border-bottom: 1px solid #f5f5f5;
  397. }
  398. .changewidth {
  399. color: #303133;
  400. font-size: 32upx;
  401. font-weight: 100 !important;
  402. }
  403. .van-card__desc {
  404. font-size: 25rpx;
  405. color: #999 !important;
  406. padding-top: 10rpx;
  407. }
  408. .van-card {
  409. background-color: #fff !important;
  410. }
  411. .shoplist {
  412. display: flex;
  413. justify-content: space-between;
  414. align-items: center;
  415. }
  416. .deleChange {
  417. border: 1px solid #c0c4cc;
  418. padding: 8upx;
  419. }
  420. .van-tab {
  421. flex-basis: 20% !important;
  422. padding: 0 2px !important;
  423. }
  424. </style>