index.vue 11 KB

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