index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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.goods_name.split(' ')[1]+'X'+items.goods_num"
  26. :title="items.goods_name.split(' ')[0]"
  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 && 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 && !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. <Dialog :orderCancel="orderCancel"
  58. :titles="titles"
  59. @colseDialog="cancelDialog"
  60. @confirmPay="confirmOrder"
  61. />
  62. <!-- <logionDialog @confirmDiaolog="confirmDiaolog" :ishow="false" @cancelDiaolog="cancelDiaolog" :showdialog="showdialog"/> -->
  63. </view>
  64. </template>
  65. <script>
  66. import {
  67. mapMutations,mapState
  68. } from 'vuex'
  69. import Dialog from '@/component/Dialog.vue'
  70. import logionDialog from '@/component/loginDialog.vue'
  71. export default{
  72. components: {
  73. Dialog,
  74. logionDialog
  75. },
  76. data() {
  77. return {
  78. ispull: true,
  79. showdialog: false,
  80. orderCancel: false,
  81. titles:'',
  82. pictureUrl: this.pictureUrl,
  83. menu:[
  84. {name:'全部'},
  85. {name:'待支付'},
  86. {name:'处理中'},
  87. {name:'已收货'},
  88. {name:'已取消'},
  89. {name:'退款售后'}
  90. ],
  91. // 要查找的订单状态 all-全部 waiting-待支付 payed-处理中 complete-已收货 cancel-已取消 refund-退款售后
  92. active: 0,
  93. scrollTop: 0,
  94. old: {
  95. scrollTop: 0
  96. },
  97. order_id:'',
  98. page: 1,
  99. page_size: 10,
  100. state: 'all',
  101. order_list:[]
  102. }
  103. },
  104. computed:{
  105. ...mapState([
  106. 'hasLogin',
  107. 'userInfo'
  108. ]),
  109. },
  110. onLoad(a) {
  111. uni.$emit("refehlist",()=>{
  112. this.getlist();
  113. })
  114. if(this.hasLogin) {
  115. console.log(a);
  116. this.getlist(); // 获取订单
  117. }else {
  118. uni.navigateTo({
  119. url: '/pages/myCenter/logion'
  120. })
  121. //this.showdialog = true;
  122. }
  123. },
  124. watch:{
  125. 'hasLogin':function(val) {
  126. if(val) {
  127. this.active = 0;
  128. this.getlist();
  129. }else {
  130. uni.navigateTo({
  131. url: '/pages/myCenter/logion'
  132. })
  133. }
  134. },
  135. },
  136. methods: {
  137. gotologion() {
  138. uni.navigateTo({
  139. url: '/pages/myCenter/logion'
  140. })
  141. },
  142. // 关闭弹窗
  143. // cancelDiaolog() {
  144. // this.showdialog = false;
  145. // },
  146. // // 确定
  147. // confirmDiaolog() {
  148. // this.showdialog = false;
  149. // this.getlist(); // 获取订单
  150. // },
  151. changeselect(e) {
  152. if(this.hasLogin) {
  153. console.log(e);
  154. this.active = e.target.name;
  155. this.page = 1;
  156. if(e.target.name == 0) {
  157. this.state = 'all';
  158. }else if(e.target.name == 1) {
  159. this.state = 'waiting';
  160. }else if(e.target.name == 2) {
  161. this.state = 'payed';
  162. }else if(e.target.name == 3) {
  163. this.state = 'complete';
  164. }else if(e.target.name == 4) {
  165. this.state = 'cancel';
  166. }else if(e.target.name == 5) {
  167. this.state = 'refund';
  168. }
  169. this.getlist();
  170. }else {
  171. uni.navigateTo({
  172. url: '/pages/myCenter/logion'
  173. })
  174. }
  175. },
  176. getlist() {
  177. this.request({
  178. url: '/v2/order/orders',
  179. method: 'POST',
  180. data: {
  181. state: this.state,
  182. page: this.page,
  183. page_size: 10
  184. },
  185. success: (res) => {
  186. if(res.data.data.order_list.length< 10) {
  187. this.ispull = false;
  188. }
  189. this.order_list = this.order_list.concat(res.data.data.order_list);
  190. }
  191. })
  192. },
  193. gopay(e) {
  194. console.log(e);
  195. let prices = e.order_amount;
  196. this.order_id = e.order_id;
  197. let order_id = e.order_id;
  198. if(e.operate == '去付款') {
  199. uni.navigateTo({
  200. url:`/pages/myOrder/paymoment?order_id=${order_id}&prices=${prices}`
  201. })
  202. }else if(e.operate == '删除') {
  203. this.titles = '确认删除订单?'
  204. this.orderCancel = true;
  205. }
  206. },
  207. cancelDialog() {
  208. this.orderCancel = false;
  209. },
  210. confirmOrder() {
  211. this.orderCancel = false;
  212. this.request({
  213. url:'/v2/order/drop',
  214. method:'POST',
  215. data: {
  216. order_id: this.order_id
  217. },
  218. success: (res) => {
  219. this.getlist();
  220. }
  221. })
  222. },
  223. goDetail(e) {
  224. let order_id = e;
  225. uni.navigateTo({
  226. url: `/pages/myOrder/order?id=${order_id}`
  227. });
  228. },
  229. upper(e) {
  230. console.log(e)
  231. console.log("顶部")
  232. },
  233. // 滚到底部
  234. lower(e) {
  235. console.log("底部")
  236. if(this.ispull) {
  237. this.page += 1;
  238. this.getlist();
  239. }
  240. },
  241. // 滚动时触发
  242. scroll(e) {
  243. this.old.scrollTop = e.detail.scrollTop
  244. }
  245. }
  246. }
  247. </script>
  248. <style>
  249. page {
  250. background-color: #F5F5F5;
  251. }
  252. .cart-list {
  253. background-color: #fff;
  254. border-top: 12upx solid #F5F5F5;
  255. }
  256. .topTip {
  257. display: flex;
  258. align-items: center;
  259. justify-content: space-between;
  260. padding: 20upx 36upx;
  261. border-bottom: 1px solid #F5F5F5;
  262. }
  263. .changewidth {
  264. color: #303133;
  265. font-size: 32upx;
  266. font-weight: 100!important;
  267. }
  268. .priceClass {
  269. color:#303133!important;
  270. font-weight: 100!important;
  271. font-size: 36upx;
  272. }
  273. .van-card {
  274. background-color: #fff!important;
  275. }
  276. .shoplist {
  277. display: flex;
  278. justify-content: space-between;
  279. align-items: center;
  280. }
  281. .deleChange {
  282. border: 1px solid #C0C4CC;
  283. padding: 8upx;
  284. }
  285. </style>