index.vue 11 KB

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