index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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" :key="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 v-if="item.store_avatar" :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. if(res.data.data.order_list.length< 10) {
  246. this.ispull = false;
  247. }
  248. res.data.data.order_list.forEach((item,index) => {
  249. item.goods.forEach(items => {
  250. let arr = items.goods_name.split(' ');
  251. items.desarray = arr[0];
  252. items.descire = items.goods_name.replace(arr[0], '');
  253. })
  254. })
  255. if(this.firstloading == 0) {
  256. this.loading = false;
  257. }
  258. this.firstloading = 1;
  259. this.order_list = this.order_list.concat(res.data.data.order_list);
  260. }
  261. })
  262. },
  263. gopay(e) {
  264. let store_id = e.store_id;
  265. let prices = e.order_amount;
  266. this.order_id = e.order_id;
  267. let order_id = e.order_id;
  268. let isform = 1;
  269. if(e.operate == '去付款') {
  270. uni.navigateTo({
  271. url:`/pages/myOrder/paymoment?order_id=${order_id}&prices=${prices}
  272. &isform=${isform}&store_id=${store_id}`
  273. })
  274. }else if(e.operate == '删除') {
  275. this.titles = '确认删除订单?'
  276. this.deleteorder = 1;
  277. this.orderCancel = true;
  278. }else if(e.operate == '催单') {
  279. let a = 1;
  280. uni.navigateTo({
  281. url:`/pages/myOrder/reminder?order_id=${order_id}&a=${a}`
  282. })
  283. }else if(e.operate == '确认收货') {
  284. this.deleteorder = 2;
  285. this.titles = '确认收货?'
  286. this.orderCancel = true;
  287. }else if(e.operate == '去评价') {
  288. uni.navigateTo({
  289. url:`/pages/myOrder/estimate?order_id=${order_id}`
  290. })
  291. }else if(e.operate == '联系酒店') {
  292. let a = 2;
  293. uni.navigateTo({
  294. url:`/pages/myOrder/reminder?order_id=${order_id}&a=${a}`
  295. })
  296. }
  297. },
  298. cancelDialog() {
  299. this.orderCancel = false;
  300. },
  301. confirmOrder() {
  302. // 删除订单 确认收货
  303. this.orderCancel = false;
  304. let url = this.deleteorder == 1?'/v2/order/drop':'/v2/order/confirm';
  305. this.request({
  306. url: url,
  307. method:'POST',
  308. data: {
  309. order_id: this.order_id
  310. },
  311. success: (res) => {
  312. this.order_list = [];
  313. this.page = 1;
  314. this.ispull = true;
  315. this.getlist();
  316. }
  317. })
  318. },
  319. goDetail(e) {
  320. let order_id = e;
  321. uni.navigateTo({
  322. url: `/pages/myOrder/order?id=${order_id}`
  323. });
  324. },
  325. goStore(e) {
  326. let id = e;
  327. uni.navigateTo({
  328. url: `/pages/index/hotel?id=${id}`
  329. });
  330. },
  331. upper(e) {
  332. },
  333. // 滚到底部
  334. lower(e) {
  335. if(this.ispull) {
  336. this.page += 1;
  337. this.getlist();
  338. }
  339. },
  340. // 滚动时触发
  341. scroll(e) {
  342. if(e.detail.scrollTop > 400) {
  343. this.isTop = true;
  344. }else{ //当距离小于500时显示回到顶部按钮
  345. this.isTop = false;
  346. }
  347. this.old.scrollTop = e.detail.scrollTop
  348. }
  349. }
  350. }
  351. </script>
  352. <style>
  353. page {
  354. background-color: #F5F5F5;
  355. }
  356. .cart-list {
  357. background-color: #fff;
  358. border-top: 12upx solid #F5F5F5;
  359. }
  360. .topTip {
  361. display: flex;
  362. align-items: center;
  363. justify-content: space-between;
  364. padding: 20upx 36upx;
  365. border-bottom: 1px solid #F5F5F5;
  366. }
  367. .changewidth {
  368. color: #303133;
  369. font-size: 32upx;
  370. font-weight: 100!important;
  371. }
  372. .van-card__desc {
  373. font-size: 25rpx;
  374. color: #999!important;
  375. padding-top: 10rpx;
  376. }
  377. .van-card {
  378. background-color: #fff!important;
  379. }
  380. .shoplist {
  381. display: flex;
  382. justify-content: space-between;
  383. align-items: center;
  384. }
  385. .deleChange {
  386. border: 1px solid #C0C4CC;
  387. padding: 8upx;
  388. }
  389. .van-tab {
  390. flex-basis: 20%!important;
  391. }
  392. </style>