index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <view>
  3. <van-tabs :active="active" @change="changeselect" >
  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. watch:{
  139. 'successlogion':function(val) {
  140. if(val) {
  141. this.active = 0;
  142. this.getlist();
  143. }else {
  144. uni.navigateTo({
  145. url: '/pages/myCenter/logion'
  146. })
  147. }
  148. },
  149. 'hasLogin':function(val) {
  150. if(val) {
  151. this.active = 0;
  152. this.getlist();
  153. }else {
  154. uni.navigateTo({
  155. url: '/pages/myCenter/logion'
  156. })
  157. }
  158. },
  159. },
  160. methods: {
  161. getop() {
  162. this.scrollTop = this.old.scrollTop
  163. this.$nextTick(function(){
  164. this.scrollTop=0;
  165. });
  166. this.isTop = false;
  167. },
  168. gotologion() {
  169. uni.navigateTo({
  170. url: '/pages/myCenter/logion'
  171. })
  172. },
  173. // 关闭弹窗
  174. // cancelDiaolog() {
  175. // this.showdialog = false;
  176. // },
  177. // // 确定
  178. // confirmDiaolog() {
  179. // this.showdialog = false;
  180. // this.getlist(); // 获取订单
  181. // },
  182. changeselect(e) {
  183. if(this.successlogion && this.hasLogin) {
  184. this.active = e.target.name;
  185. this.page = 1;
  186. this.ispull = true;
  187. this.order_list = [];
  188. if(e.target.name == 0) {
  189. this.state = 'all';
  190. this.getlist();
  191. }else if(e.target.name == 1) {
  192. this.state = 'waiting';
  193. this.getlist();
  194. }else if(e.target.name == 2) {
  195. this.state = 'payed';
  196. this.getlist();
  197. }else if(e.target.name == 3) {
  198. this.state = 'complete';
  199. this.getlist();
  200. }else if(e.target.name == 4) {
  201. this.state = 'cancel';
  202. this.getlist();
  203. }
  204. if(e.target.name == 5) {
  205. this.state = 'refund';
  206. //this.refund();
  207. }
  208. }else {
  209. uni.navigateTo({
  210. url: '/pages/myCenter/logion'
  211. })
  212. }
  213. },
  214. // 订单退款售后列表
  215. refund() {
  216. this.request({
  217. url: '/v3/order/refund_list',
  218. method: 'POST',
  219. data: {
  220. state: this.state,
  221. page: this.page,
  222. page_size: 10
  223. },
  224. success: (res) => {
  225. console.log(res.data.data.refund_list);
  226. if(res.data.data.refund_list.length< 10) {
  227. this.ispull = false;
  228. }
  229. res.data.data.refund_list.forEach((item,index) => {
  230. // item.goods.forEach(items => {
  231. let arr = item.goods_name.split(' ');
  232. item.desarray = arr[0];
  233. item.descire = item.goods_name.replace(arr[0], '');
  234. // })
  235. })
  236. this.order_list = this.order_list.concat(res.data.data.refund_list);
  237. }
  238. })
  239. },
  240. // 订单列表
  241. getlist() {
  242. this.request({
  243. url: '/v2/order/orders',
  244. method: 'POST',
  245. data: {
  246. state: this.state,
  247. page: this.page,
  248. page_size: 10
  249. },
  250. success: (res) => {
  251. if(res.data.data.order_list.length< 10) {
  252. this.ispull = false;
  253. }
  254. res.data.data.order_list.forEach((item,index) => {
  255. item.goods.forEach(items => {
  256. let arr = items.goods_name.split(' ');
  257. items.desarray = arr[0];
  258. items.descire = items.goods_name.replace(arr[0], '');
  259. })
  260. })
  261. // let arr = item.goods_name.split(' ');
  262. // item.desarray = arr[0];
  263. // item.descire = arr.replace(arr[0], '');
  264. this.order_list = this.order_list.concat(res.data.data.order_list);
  265. }
  266. })
  267. },
  268. gopay(e) {
  269. console.log(e);
  270. let prices = e.order_amount;
  271. this.order_id = e.order_id;
  272. let order_id = e.order_id;
  273. if(e.operate == '去付款') {
  274. uni.navigateTo({
  275. url:`/pages/myOrder/paymoment?order_id=${order_id}&prices=${prices}`
  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. console.log(e)
  336. console.log("顶部")
  337. },
  338. // 滚到底部
  339. lower(e) {
  340. if(this.ispull) {
  341. console.log("l;ll")
  342. this.page += 1;
  343. this.getlist();
  344. }
  345. },
  346. // 滚动时触发
  347. scroll(e) {
  348. if(e.detail.scrollTop > 400) {
  349. this.isTop = true;
  350. }else{ //当距离小于500时显示回到顶部按钮
  351. this.isTop = false;
  352. }
  353. this.old.scrollTop = e.detail.scrollTop
  354. }
  355. }
  356. }
  357. </script>
  358. <style>
  359. page {
  360. background-color: #F5F5F5;
  361. }
  362. .cart-list {
  363. background-color: #fff;
  364. border-top: 12upx solid #F5F5F5;
  365. }
  366. .topTip {
  367. display: flex;
  368. align-items: center;
  369. justify-content: space-between;
  370. padding: 20upx 36upx;
  371. border-bottom: 1px solid #F5F5F5;
  372. }
  373. .changewidth {
  374. color: #303133;
  375. font-size: 32upx;
  376. font-weight: 100!important;
  377. }
  378. .van-card__desc {
  379. font-size: 25rpx;
  380. color: #999!important;
  381. padding-top: 10rpx;
  382. }
  383. .van-card {
  384. background-color: #fff!important;
  385. }
  386. .shoplist {
  387. display: flex;
  388. justify-content: space-between;
  389. align-items: center;
  390. }
  391. .deleChange {
  392. border: 1px solid #C0C4CC;
  393. padding: 8upx;
  394. }
  395. </style>