index.vue 9.1 KB

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