index.vue 11 KB

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