index.vue 11 KB

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