index.vue 11 KB

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