index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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. <!-- <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 logionDialog from '@/component/loginDialog.vue'
  72. export default{
  73. components: {
  74. Dialog,
  75. logionDialog
  76. },
  77. data() {
  78. return {
  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. {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. // 我的跳掉订单
  119. uni.$on('getstate', (e) => {
  120. console.log(e);
  121. console.log("ss")
  122. })
  123. // 完成支付
  124. uni.$on(" finshlist",()=>{
  125. this.page = 1;
  126. this.order_list = [];
  127. this.getlist();
  128. })
  129. // 完成评价
  130. uni.$on("finshesitmate",()=>{
  131. this.page = 1;
  132. this.order_list = [];
  133. this.getlist();
  134. })
  135. if(this.successlogion && this.hasLogin) {
  136. this.getlist(); // 获取订单
  137. }else {
  138. uni.navigateTo({
  139. url: '/pages/myCenter/logion'
  140. })
  141. }
  142. },
  143. watch:{
  144. 'successlogion':function(val) {
  145. if(val) {
  146. this.active = 0;
  147. this.getlist();
  148. }else {
  149. uni.navigateTo({
  150. url: '/pages/myCenter/logion'
  151. })
  152. }
  153. },
  154. 'hasLogin':function(val) {
  155. if(val) {
  156. this.active = 0;
  157. this.getlist();
  158. }else {
  159. uni.navigateTo({
  160. url: '/pages/myCenter/logion'
  161. })
  162. }
  163. },
  164. },
  165. methods: {
  166. gotologion() {
  167. uni.navigateTo({
  168. url: '/pages/myCenter/logion'
  169. })
  170. },
  171. // 关闭弹窗
  172. // cancelDiaolog() {
  173. // this.showdialog = false;
  174. // },
  175. // // 确定
  176. // confirmDiaolog() {
  177. // this.showdialog = false;
  178. // this.getlist(); // 获取订单
  179. // },
  180. changeselect(e) {
  181. if(this.successlogion && this.hasLogin) {
  182. console.log(e);
  183. this.active = e.target.name;
  184. this.page = 1;
  185. this.order_list = [];
  186. if(e.target.name == 0) {
  187. this.state = 'all';
  188. }else if(e.target.name == 1) {
  189. this.state = 'waiting';
  190. }else if(e.target.name == 2) {
  191. this.state = 'payed';
  192. }else if(e.target.name == 3) {
  193. this.state = 'complete';
  194. }else if(e.target.name == 4) {
  195. this.state = 'cancel';
  196. }else if(e.target.name == 5) {
  197. this.state = 'refund';
  198. }
  199. this.getlist();
  200. }else {
  201. uni.navigateTo({
  202. url: '/pages/myCenter/logion'
  203. })
  204. }
  205. },
  206. getlist() {
  207. this.request({
  208. url: '/v2/order/orders',
  209. method: 'POST',
  210. data: {
  211. state: this.state,
  212. page: this.page,
  213. page_size: 10
  214. },
  215. success: (res) => {
  216. if(res.data.data.order_list.length< 10) {
  217. this.ispull = false;
  218. }
  219. res.data.data.order_list.forEach((item,index) => {
  220. item.goods.forEach(items => {
  221. let arr = items.goods_name.split(' ');
  222. items.desarray = arr[0];
  223. items.descire = items.goods_name.replace(arr[0], '');
  224. })
  225. })
  226. // let arr = item.goods_name.split(' ');
  227. // item.desarray = arr[0];
  228. // item.descire = arr.replace(arr[0], '');
  229. this.order_list = this.order_list.concat(res.data.data.order_list);
  230. }
  231. })
  232. },
  233. gopay(e) {
  234. console.log(e);
  235. let prices = e.order_amount;
  236. this.order_id = e.order_id;
  237. let order_id = e.order_id;
  238. if(e.operate == '去付款') {
  239. uni.navigateTo({
  240. url:`/pages/myOrder/paymoment?order_id=${order_id}&prices=${prices}`
  241. })
  242. }else if(e.operate == '删除') {
  243. this.titles = '确认删除订单?'
  244. this.deleteorder = 1;
  245. this.orderCancel = true;
  246. }else if(e.operate == '催单') {
  247. let a = 1;
  248. uni.navigateTo({
  249. url:`/pages/myOrder/reminder?order_id=${order_id}&a=${a}`
  250. })
  251. }else if(e.operate == '确认收货') {
  252. this.deleteorder = 2;
  253. this.titles = '确认收货?'
  254. this.orderCancel = true;
  255. }else if(e.operate == '去评价') {
  256. uni.navigateTo({
  257. url:`/pages/myOrder/estimate?order_id=${order_id}`
  258. })
  259. }else if(e.operate == '联系酒店') {
  260. let a = 2;
  261. uni.navigateTo({
  262. url:`/pages/myOrder/reminder?order_id=${order_id}&a=${a}`
  263. })
  264. }
  265. },
  266. cancelDialog() {
  267. this.orderCancel = false;
  268. },
  269. confirmOrder() {
  270. // 删除订单 确认收货
  271. this.orderCancel = false;
  272. let url = this.deleteorder == 1?'/v2/order/drop':'/v2/order/confirm';
  273. this.request({
  274. url: url,
  275. method:'POST',
  276. data: {
  277. order_id: this.order_id
  278. },
  279. success: (res) => {
  280. this.order_list = [];
  281. this.page = 1;
  282. this.ispull = true;
  283. this.getlist();
  284. }
  285. })
  286. },
  287. goDetail(e) {
  288. let order_id = e;
  289. uni.navigateTo({
  290. url: `/pages/myOrder/order?id=${order_id}`
  291. });
  292. },
  293. upper(e) {
  294. console.log(e)
  295. console.log("顶部")
  296. },
  297. // 滚到底部
  298. lower(e) {
  299. if(this.ispull) {
  300. console.log("l;ll")
  301. this.page += 1;
  302. this.getlist();
  303. }
  304. },
  305. // 滚动时触发
  306. scroll(e) {
  307. this.old.scrollTop = e.detail.scrollTop
  308. }
  309. }
  310. }
  311. </script>
  312. <style>
  313. page {
  314. background-color: #F5F5F5;
  315. }
  316. .cart-list {
  317. background-color: #fff;
  318. border-top: 12upx solid #F5F5F5;
  319. }
  320. .topTip {
  321. display: flex;
  322. align-items: center;
  323. justify-content: space-between;
  324. padding: 20upx 36upx;
  325. border-bottom: 1px solid #F5F5F5;
  326. }
  327. .changewidth {
  328. color: #303133;
  329. font-size: 32upx;
  330. font-weight: 100!important;
  331. }
  332. .priceClass {
  333. color:#303133!important;
  334. font-weight: 100!important;
  335. font-size: 36upx;
  336. }
  337. .van-card {
  338. background-color: #fff!important;
  339. }
  340. .shoplist {
  341. display: flex;
  342. justify-content: space-between;
  343. align-items: center;
  344. }
  345. .deleChange {
  346. border: 1px solid #C0C4CC;
  347. padding: 8upx;
  348. }
  349. </style>