index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <view>
  3. <view id="box">
  4. <view class="box-nav">
  5. <view class="bn fx-r">
  6. <view v-for="(item,index) of navList" :key="index" class="bn-item" @click="navClick(index,item.value)">
  7. <view class="bni" :class="[navIndex == index ? 'select':'']">{{item.name}}</view>
  8. </view>
  9. </view>
  10. </view>
  11. <scroll-view scroll-y :style="'height:calc(100vh - ' + topViewHeight + 'px);' ">
  12. <view>
  13. <view class="order-box">
  14. <view v-for="(item,index) of orderList" :key="index" class="order-item">
  15. <view class="oi-top">
  16. <view class="oit-left fx-r fx-bc">
  17. <view class="l"></view>
  18. <text>订单编号:{{item.order_id}}</text>
  19. </view>
  20. <view class="oit-right">
  21. <text v-if="item.status == -1">订单已关闭</text>
  22. <text v-if="item.status == 0">未付款</text>
  23. <text v-if="item.status == 1">已付款/待商家发货</text>
  24. <text v-if="item.status == 2">待收货</text>
  25. <text v-if="item.status == 3">交易成功</text>
  26. </view>
  27. </view>
  28. <view @click="intoDetailClick(item.id)">
  29. <view class="pay-goods" v-for="(v,k) of item.info" :key="k">
  30. <view class="pg-left">
  31. <image :src="v.img" mode="aspectFill"></image>
  32. </view>
  33. <view class="pg-right">
  34. <view class="pgr-top">
  35. <text>{{v.title }}</text>
  36. </view>
  37. <view class="pro-tag" style="color: #AFAFAF;font-size: 12px;">{{v.sku_text}}</view>
  38. <view class="pgr-bot">
  39. <view class="pgrb-left">
  40. <view class="pgrbl-left">¥{{v.price}}</view>
  41. <view class="pgrbl-right">¥{{v.old_price}}</view>
  42. </view>
  43. <view class="pgrb-right">x{{v.count}}</view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view v-if="item.balance > 0" class="new-money fx-r fx-ae fx-bc">
  49. <view class="tag">提货积分(抵扣):</view>
  50. <view class="price">{{item.balance}}</view>
  51. </view>
  52. <view class="new-money fx-r fx-ae fx-bc">
  53. <view class="tag">实付</view>
  54. <view class="price"><text>¥</text>{{item.pay_money}}<text class="small">(免运费)</text></view>
  55. </view>
  56. <view class="oi-btn">
  57. <view class="fx-r" v-if="item.status == 0">
  58. <text style="font-size: 12px;">失效时间:</text>
  59. <countdown :startTime="utils.date('Y-m-d H:i:s')" :endTime="item.last_time" />
  60. </view>
  61. <view class="fx-g1"></view>
  62. <view class="oib-hui" v-if="item.status == 2" @click="flowClick(item.id,item.info[0].img)">查看物流</view>
  63. <view class="oib-hui" v-if="item.status == 3" @click="flowClick(item.id,item.info[0].img)">查看物流</view>
  64. <view class="oib-hui" v-if="item.status == 0" @click="tapCancel(item.id,index)">取消订单</view>
  65. <view class="oib-red" v-if="item.status == 2" @click="tapConfim(item.id,index)">确认收货</view>
  66. <view class="oib-red" v-if="item.status == 0" @click="toPayClick(item.order_id)">立即支付</view>
  67. <view class="oib-red" v-if="item.status == -1" @click="tapDel(item.id,index)">删除订单</view>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="loading fx-r fx-ac fx-bc" v-if="page.isFrite && !page.isFoot">
  72. <image src="/static/img/xloading.png"></image>
  73. <text>正在载入更多...</text>
  74. </view>
  75. <view class="loading complete" :hidden="!page.isFoot">已加载全部</view>
  76. </view>
  77. </scroll-view>
  78. </view>
  79. <ui-check-pay ref="checkpay"></ui-check-pay>
  80. </view>
  81. </template>
  82. <script>
  83. import uiCheckPay from '@/components/ui-pay/pay.vue';
  84. import {mapState,mapMutations } from 'vuex';
  85. import countdown from "@/components/cz-countdown/cz-countdown.vue"
  86. export default {
  87. computed: mapState(['user']),
  88. components: {
  89. uiCheckPay,
  90. countdown
  91. },
  92. data() {
  93. return {
  94. navList: [{
  95. name: "全部",
  96. value: "",
  97. type:""
  98. }, {
  99. name: "待发货",
  100. value: "payed",
  101. type:1
  102. }, {
  103. name: "待收货",
  104. value: "delivered",
  105. type:2
  106. }, {
  107. name: "已完成",
  108. value: "confirmed",
  109. type:3
  110. }],
  111. navIndex: 0,
  112. orderList: [],
  113. dClass:"",
  114. yPrice:"0.00",
  115. order_id:"",
  116. barHeight:0,
  117. topViewHeight:0,
  118. page:{
  119. isFirst:false,
  120. isLoad:false,
  121. isFoot:false,
  122. page:1
  123. }
  124. }
  125. },
  126. onLoad(option) {
  127. var type = option.type || '';
  128. if(type != '') {
  129. for(var i in this.navList) {
  130. if(type == this.navList[i].value) {
  131. this.navIndex = i;
  132. }
  133. }
  134. }
  135. uni.getSystemInfo({
  136. success:(res) => {
  137. this.barHeight = res.statusBarHeight;
  138. this.topViewHeight = this.barHeight + 50;
  139. // #ifdef H5
  140. this.topViewHeight += 46;
  141. // #endif
  142. }
  143. });
  144. //获取订单
  145. this.getData();
  146. },
  147. onReachBottom() {
  148. if(this.page.isFoot || this.page.isLoad) {
  149. return;
  150. }
  151. this.page.page ++;
  152. this.getData();
  153. },
  154. onUnload() {
  155. this.$refs.checkpay.hide();
  156. },
  157. methods: {
  158. // tab点击
  159. navClick(index, value) {
  160. this.navIndex = index;
  161. this.getData(true);
  162. },
  163. getData:function(isPull = false){
  164. if(this.page.isLoad) return;
  165. this.page.isLoad = true;
  166. if(isPull) {
  167. this.page.page = 1;
  168. this.page.isLoad = false;
  169. this.page.isFoot = false;
  170. }
  171. uni.showLoading({ title: '获取数据中..' });
  172. var post = {};
  173. post.page = this.page.page;
  174. post.type = this.navList[this.navIndex].type;
  175. this
  176. .request
  177. .post("userOrder",post)
  178. .then(res => {
  179. uni.hideLoading();
  180. this.page.isFirst = true;
  181. this.page.isLoad = false;
  182. if(isPull) {
  183. this.orderList = res.data.list;
  184. } else {
  185. this.orderList = this.orderList.concat(res.data.list);
  186. }
  187. //是否到底
  188. if(res.data.list.length != res.data.pageSize) {
  189. this.page.isFoot = true;
  190. }
  191. //that.CountDowm();
  192. })
  193. .catch(res=>{
  194. console.log(res);
  195. uni.hideLoading();
  196. uni.showModal({title: '系统提示',content: '加载失败,返回在尝试',showCancel: false});
  197. });
  198. },
  199. // 查看物流
  200. flowClick(id, path_img) {
  201. uni.navigateTo({
  202. url: `/pages/user/order/flow/flow?id=${id}&path_img=${path_img}`
  203. })
  204. },
  205. // 进入详情
  206. intoDetailClick(id) {
  207. uni.navigateTo({
  208. url: `/pages/user/order/detail/detail?id=${id}`
  209. })
  210. },
  211. /**
  212. * 支付操作
  213. */
  214. toPayClick:function(order_id){
  215. console.log(this.$refs);
  216. this.$refs.checkpay.show(order_id,()=>{
  217. this.$refs.checkpay.hide();
  218. });
  219. },
  220. /**
  221. * 取消订单
  222. * @param {Object} id
  223. * @param {Object} index
  224. */
  225. tapCancel(id, index) {
  226. this.utils.showModal("确认取消订单吗?",()=>{
  227. this
  228. .request
  229. .post("orderCancel",{id:id})
  230. .then(res=>{
  231. uni.hideLoading();
  232. if(res.code == 200) {
  233. this.utils.showAlert({title: "取消成功",mask: true,icon: "none"});
  234. this.orderList[index].status = -1;
  235. } else {
  236. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  237. }
  238. })
  239. .catch(res=>{
  240. console.log(res);
  241. uni.hideLoading();
  242. uni.showModal({title: '系统提示',content: '加载失败,返回在尝试',showCancel: false});
  243. });
  244. });
  245. },
  246. /**
  247. * 删除订单
  248. * @param {Object} id
  249. * @param {Object} index
  250. */
  251. tapDel(id, index) {
  252. this.utils.showModal("确认要删除订单吗?",()=>{
  253. this
  254. .request
  255. .post("orderDel",{id:id})
  256. .then(res=>{
  257. uni.hideLoading();
  258. if(res.code == 200) {
  259. this.utils.showAlert({title: "删除成功",mask: true,icon: "none"});
  260. this.$delete(this.orderList,index);
  261. } else {
  262. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  263. }
  264. })
  265. .catch(res=>{
  266. console.log(res);
  267. uni.hideLoading();
  268. uni.showModal({title: '系统提示',content: '加载失败,返回在尝试',showCancel: false});
  269. });
  270. });
  271. },
  272. tapConfim(id, index) {
  273. this.utils.showModal("确认收货?",()=>{
  274. this
  275. .request
  276. .post("orderConfim",{id:id})
  277. .then(res=>{
  278. uni.hideLoading();
  279. if(res.code == 200) {
  280. this.utils.showAlert({title: "收货成功",mask: true,icon: "none"});
  281. this.orderList[index].status = 3;
  282. } else {
  283. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  284. }
  285. })
  286. .catch(res=>{
  287. console.log(res);
  288. uni.hideLoading();
  289. uni.showModal({title: '系统提示',content: '加载失败,返回在尝试',showCancel: false});
  290. });
  291. });
  292. },
  293. // 退款联系客服
  294. refundClick() {
  295. uni.navigateTo({
  296. url: `/pages/user/customer/customer`
  297. })
  298. },
  299. }
  300. }
  301. </script>
  302. <style>
  303. page{background:#F5F5F5}
  304. .bg-top{position: absolute;top: 0;width: 100%;}
  305. .bg-top image{width: 100%;}
  306. .box-nav{width:100%;height:50px;background-color:#fff;border-top:1px #f5f5f5 solid;}
  307. .bn{align-items:center;height:50px}
  308. .bn-item{width:25%;text-align:center}
  309. .bni{color:#3F3E3E;font-size:14px;box-sizing:border-box;position:relative}
  310. .select{width:100%;color:#ef4034}
  311. .select::after{content:"";position:absolute;bottom:-5px;left:50%;transform:translate(-50%,-50%);background:#ef4034;width:24px;height:2px}
  312. .order-box{min-height: 300px;margin: 10px;}
  313. .order-item{background-color:#fff;padding:10px 15px;margin-bottom: 10px;border-radius: 10px;}
  314. .new-money{}
  315. .new-money .tag{color: #333;font-size: 12px;font-weight: 400;}
  316. .new-money .price{color: #333;font-size: 14px;font-weight: 400;margin-left: 1px;}
  317. .new-money .price text{color: #333;font-size: 12px;}
  318. .new-money .price .small{color: #333;font-size: 10px;}
  319. .zfen-view{height: 18px;}
  320. .zfen-view .zfen{
  321. overflow: hidden;
  322. text-overflow:ellipsis;
  323. white-space: nowrap;
  324. color: #ef4034;font-size: 10px;border: 1px solid #ef4034;padding: 0px 2px;display: inline-block;vertical-align:top;border-radius: 2px;}
  325. .zfen-view .zfen text{font-weight: bold;margin: 0px 1px;}
  326. .oi-top{display:flex;align-items:center}
  327. .oit-left{color:#AFAFAF;font-size:12px}
  328. .oit-left .l{background: #ef4034;width: 3px;height: 14px;border-radius: 6px;margin-right: 4px;}
  329. .oit-right{color:#ef4034;font-size:12px;margin-left:auto}
  330. .pay-goods{margin-top:10px;display:flex;align-items:center}
  331. .pg-left{width:90px;height:90px;margin-right:15px}
  332. .pg-left image{width:100%;height:100%;display:block;border-radius:10px}
  333. .pg-right{width:68%}
  334. .pgr-top{width:100%;color:#484747;font-size:14px;font-weight:500;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}
  335. .pgr-middle{margin-top:5px}
  336. .pgrm-vip{width:88px;height:20px;background-color:#F3D9C3;text-align:center;line-height:20px;color:#f1851e;font-size:10px;border-radius:4px}
  337. .pgrm-gui{color:#7E7E7E;font-size:10px}
  338. .pgr-bot{display:flex;align-items:center;margin-top:5px}
  339. .pgrb-left{display:flex;align-items:center;}
  340. .pgrb-left .aicao{width: 18px;height: 18px;}
  341. .pgrbl-left{color:#f1851e;font-size:18px;font-weight:500}
  342. .pgrbl-right{color:#7E7E7E;font-size:10px;text-decoration:line-through;margin-left:5px}
  343. .pgrb-right{margin-left:auto;color:#7E7E7E;font-size:10px}
  344. .oi-btn{display:flex;align-items:center;justify-content:flex-end;margin-top:15px}
  345. .oib-hui{width:80px;height:24px;text-align:center;line-height:24px;color: #545454;border:1px #EEEEEE solid;border-radius:100px;font-size:12px}
  346. .oib-red{width:80px;height:24px;text-align:center;line-height:24px;color:#fff;border:1px #ef4034 solid;border-radius:100px;font-size:13px;background-color:#ef4034;margin-left:10px}
  347. </style>