index.vue 11 KB

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