index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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.order_list = [];
  195. if(e.target.name == 0) {
  196. this.state = 'all';
  197. }else if(e.target.name == 1) {
  198. this.state = 'waiting';
  199. }else if(e.target.name == 2) {
  200. this.state = 'payed';
  201. }else if(e.target.name == 3) {
  202. this.state = 'complete';
  203. }else if(e.target.name == 4) {
  204. this.state = 'cancel';
  205. }else if(e.target.name == 5) {
  206. this.state = 'refund';
  207. }
  208. this.getlist();
  209. }else {
  210. uni.navigateTo({
  211. url: '/pages/myCenter/logion'
  212. })
  213. }
  214. },
  215. getlist() {
  216. this.request({
  217. url: '/v2/order/orders',
  218. method: 'POST',
  219. data: {
  220. state: this.state,
  221. page: this.page,
  222. page_size: 10
  223. },
  224. success: (res) => {
  225. if(res.data.data.order_list.length< 10) {
  226. this.ispull = false;
  227. }
  228. res.data.data.order_list.forEach((item,index) => {
  229. item.goods.forEach(items => {
  230. let arr = items.goods_name.split(' ');
  231. items.desarray = arr[0];
  232. items.descire = items.goods_name.replace(arr[0], '');
  233. })
  234. })
  235. // let arr = item.goods_name.split(' ');
  236. // item.desarray = arr[0];
  237. // item.descire = arr.replace(arr[0], '');
  238. this.order_list = this.order_list.concat(res.data.data.order_list);
  239. }
  240. })
  241. },
  242. gopay(e) {
  243. console.log(e);
  244. let prices = e.order_amount;
  245. this.order_id = e.order_id;
  246. let order_id = e.order_id;
  247. if(e.operate == '去付款') {
  248. uni.navigateTo({
  249. url:`/pages/myOrder/paymoment?order_id=${order_id}&prices=${prices}`
  250. })
  251. }else if(e.operate == '删除') {
  252. this.titles = '确认删除订单?'
  253. this.deleteorder = 1;
  254. this.orderCancel = true;
  255. }else if(e.operate == '催单') {
  256. let a = 1;
  257. uni.navigateTo({
  258. url:`/pages/myOrder/reminder?order_id=${order_id}&a=${a}`
  259. })
  260. }else if(e.operate == '确认收货') {
  261. this.deleteorder = 2;
  262. this.titles = '确认收货?'
  263. this.orderCancel = true;
  264. }else if(e.operate == '去评价') {
  265. uni.navigateTo({
  266. url:`/pages/myOrder/estimate?order_id=${order_id}`
  267. })
  268. }else if(e.operate == '联系酒店') {
  269. let a = 2;
  270. uni.navigateTo({
  271. url:`/pages/myOrder/reminder?order_id=${order_id}&a=${a}`
  272. })
  273. }
  274. },
  275. cancelDialog() {
  276. this.orderCancel = false;
  277. },
  278. confirmOrder() {
  279. // 删除订单 确认收货
  280. this.orderCancel = false;
  281. let url = this.deleteorder == 1?'/v2/order/drop':'/v2/order/confirm';
  282. this.request({
  283. url: url,
  284. method:'POST',
  285. data: {
  286. order_id: this.order_id
  287. },
  288. success: (res) => {
  289. this.order_list = [];
  290. this.page = 1;
  291. this.ispull = true;
  292. this.getlist();
  293. }
  294. })
  295. },
  296. goDetail(e) {
  297. let order_id = e;
  298. uni.navigateTo({
  299. url: `/pages/myOrder/order?id=${order_id}`
  300. });
  301. },
  302. upper(e) {
  303. console.log(e)
  304. console.log("顶部")
  305. },
  306. // 滚到底部
  307. lower(e) {
  308. if(this.ispull) {
  309. console.log("l;ll")
  310. this.page += 1;
  311. this.getlist();
  312. }
  313. },
  314. // 滚动时触发
  315. scroll(e) {
  316. if(e.detail.scrollTop > 400) {
  317. this.isTop = true;
  318. }else{ //当距离小于500时显示回到顶部按钮
  319. this.isTop = false;
  320. }
  321. this.old.scrollTop = e.detail.scrollTop
  322. }
  323. }
  324. }
  325. </script>
  326. <style>
  327. page {
  328. background-color: #F5F5F5;
  329. }
  330. .cart-list {
  331. background-color: #fff;
  332. border-top: 12upx solid #F5F5F5;
  333. }
  334. .topTip {
  335. display: flex;
  336. align-items: center;
  337. justify-content: space-between;
  338. padding: 20upx 36upx;
  339. border-bottom: 1px solid #F5F5F5;
  340. }
  341. .changewidth {
  342. color: #303133;
  343. font-size: 32upx;
  344. font-weight: 100!important;
  345. }
  346. .van-card__desc {
  347. font-size: 25rpx;
  348. color: #999!important;
  349. padding-top: 10rpx;
  350. }
  351. .priceClass {
  352. color:#303133!important;
  353. font-size: 36upx;
  354. font-weight: normal!important;
  355. }
  356. .van-card {
  357. background-color: #fff!important;
  358. }
  359. .shoplist {
  360. display: flex;
  361. justify-content: space-between;
  362. align-items: center;
  363. }
  364. .deleChange {
  365. border: 1px solid #C0C4CC;
  366. padding: 8upx;
  367. }
  368. </style>