You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

535 lines
14 KiB

6 months ago
  1. <template>
  2. <view>
  3. <!-- 顶部导航 -->
  4. <view class="topTabBar" :style="{position:headerPosition,top:headerTop}">
  5. <view class="grid" v-for="(grid,tbIndex) in orderType" :key="tbIndex" @tap="showType(tbIndex)">
  6. <view class="text" :class="[tbIndex==tabbarIndex?'on':'']">{{grid}}</view>
  7. </view>
  8. </view>
  9. <!-- 考虑非APP端长列表和复杂的DOM使用scroll-view会卡顿所以漂浮顶部选项卡使用page本身的滑动 -->
  10. <view class="order-list">
  11. <view class="list">
  12. <empty v-if="list.length === 0"></empty>
  13. <view class="row" v-for="(row,index) in list" :key="index">
  14. <view class="listitem" v-if="row.orderlx==1">
  15. <view class="type">{{row.dh}}</view>
  16. <view class="type" v-if="row.order_zt>0">{{orderzttext[row.order_zt]}}</view>
  17. <view class="type" v-else>{{row.ztmiaos}}</view>
  18. </view>
  19. <view class="listitem" v-else>
  20. <view class="type">{{row.dh}}</view>
  21. <view class="type" v-if="row.order_zt>0">{{orderzttext2[row.order_zt]}}</view>
  22. <view class="type" v-else>{{row.ztmiaos}}</view>
  23. </view>
  24. <view class="listitem">
  25. <view class="itemtitle">下单日期</view>
  26. <view class="itemvaule">{{row.rq}}</view>
  27. </view>
  28. <view class="listitem">
  29. <view class="itemtitle">送货日期</view>
  30. <view class="itemvaule">{{row.dhrq}}</view>
  31. </view>
  32. <view class="listitem">
  33. <view class="itemtitle">商品金额</view>
  34. <view class="itemvaule">{{row.allmoney}}</view>
  35. </view>
  36. <view class="detail">
  37. <view class="number">{{row.goodnum}}件商品</view><view class="sum">合计<view class="price">{{row.total}}</view></view>
  38. <view class="nominal"><span v-if="row.yhjine>0" style="color: red;">(优惠券 -{{row.yhjine}})</span></view>
  39. </view>
  40. <view class="btns">
  41. <text style="margin: 0 auto;margin-left: 0px;color: #666; font-size: 28rpx;" v-if="row.orderlx==1">支付订单</text>
  42. <text style="margin: 0 auto;margin-left: 0px;color: #666; font-size: 28rpx;" v-else>普通订单</text>
  43. <!-- <block v-if="row.orderlx==0&&(row.zt==2||row.zt==1)&&row.sh==1">
  44. <view class="default">审核该订单</view>
  45. </block>
  46. <block v-else-if="row.orderlx==0&&(row.zt==2||row.zt==1)">
  47. <view class="default" @click="qutuanh(row.dhid,row.allmoney,0)">去退货</view>
  48. </block> -->
  49. <block v-if="row.orderlx==0&&row.zt==2">
  50. <!-- 取消订单 -->
  51. <view class="pay" @click="cancelorder(row.dhid)">取消订单</view>
  52. </block>
  53. <block v-if="row.jiad==1">
  54. <!-- 取消订单 -->
  55. <view class="pay" @click="jiad(row.dhid)">加减单</view>
  56. </block>
  57. <!-- <block v-if="row.orderlx==0&&(row.zt==2||row.zt==1)">
  58. <view class="default" @click="qutuanh(row.dhid,row.allmoney,0)">去退货</view>
  59. </block> -->
  60. <block v-if="row.orderlx==1&&row.is_pay==1&&row.zt!=3">
  61. <!-- 取消订单 -->
  62. <view class="pay" @click="cancelorder(row.dhid)">取消订单</view>
  63. <view class="pay" @tap="toPayment(row.dhid)">去付款</view>
  64. </block>
  65. <block v-if="row.orderlx==1&&row.is_pay==2&&row.order_zt!=2&&row.zt!=3">
  66. <view class="default" @click="sqtuik(row.dhid,row.allmoney,0)">申请退款</view>
  67. </block>
  68. <view class="default" v-if="row.goodnum>0" @click="showdetail(row.dhid)">订单明细</view>
  69. <view class="default" v-if="row.goodnum>0" @click="daochu(row.dhid)">导出</view>
  70. </view>
  71. <view class="btns" v-if="row.yszt==1">
  72. <view class="default" @click="toyans(row.dhid)">验收</view>
  73. <!-- <view class="default" >监督</view>
  74. <view class="default" >投诉</view>
  75. <view class="default" >评论</view> -->
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <uni-popup ref="popup" type="bottom" :maskClick="maskclose">
  81. <view class="dosure" @click="closeit">关闭</view>
  82. <view class="choosegood" :class="[product.istk?'tkgood':'']" v-for="(product,index) in detailgoodlist" :key="index">
  83. <view class="choosegoodimg" style="width: 15%;">
  84. <image class="uni-product-image" :src="product.img"></image>
  85. </view>
  86. <view class="desc">
  87. <view>{{product.mc}}&nbsp;{{product.price}}{{product.dw}}</view>
  88. <view class="price">规格{{product.gg}}</view>
  89. <view class="price">订货量{{product.dinghl}}{{product.dw}}</view>
  90. <view class="chukl">送货量{{product.songhl}}{{product.dw}}</view>
  91. </view>
  92. <view class="shisje">{{product.je}}</view>
  93. </view>
  94. </uni-popup>
  95. </view>
  96. </template>
  97. <script>
  98. import uniPopup from "@/components/uni-popup/uni-popup.vue";
  99. import * as XLSX from '@/static/excel.js';
  100. import empty from "@/components/empty";
  101. export default {
  102. data() {
  103. return {
  104. maskclose:true,
  105. headerPosition:"fixed",
  106. headerTop:"0px",
  107. typeText:['待付款','已付款','售后订单'],
  108. orderzttext:['','退款中','已退款','拒绝退款','部分退款中','部分已退款'],
  109. orderzttext2:['','退货中','已退货','拒绝退货','部分退货中','部分已退货'],
  110. orderType: ['全部','已确认','待确认','已取消'],
  111. fhtype:['待发货','已发货'],
  112. //订单列表 演示数据
  113. list:[],
  114. tabbarIndex:0,
  115. detailgoodlist:[],
  116. ispay:0,
  117. waitpayTime: 25,
  118. timerIdforgood: null,
  119. showcan:false
  120. };
  121. },
  122. onLoad(option) {
  123. //option为object类型,会序列化上个页面传递的参数
  124. //console.log("option: " + JSON.stringify(option));
  125. let tbIndex = parseInt(option.state);
  126. this.tabbarIndex = tbIndex;
  127. //兼容H5下排序栏位置
  128. // #ifdef H5
  129. let Timer = setInterval(()=>{
  130. let uniHead = document.getElementsByTagName('uni-page-head');
  131. if(uniHead.length>0){
  132. this.headerTop = uniHead[0].offsetHeight+'px';
  133. clearInterval(Timer);//清除定时器
  134. }
  135. },1);
  136. // #endif
  137. },
  138. onPageScroll(e){
  139. return;
  140. //兼容iOS端下拉时顶部漂移
  141. this.headerPosition = e.scrollTop>=0?"fixed":"absolute";
  142. },
  143. onShow(){
  144. this.orderlist(this.tabbarIndex);
  145. },
  146. onUnload(){
  147. uni.switchTab({
  148. url: '/pages/user/user'
  149. });
  150. },
  151. components: {uniPopup,empty},
  152. methods: {
  153. jiad(dhid){
  154. uni.removeStorageSync('cartlistjiad');//移除加单购物里面的商品
  155. uni.navigateTo({
  156. url:'../orderlist/orderjiad?dhid='+dhid
  157. })
  158. },
  159. toyans(dhid){
  160. uni.navigateTo({
  161. url:'../orderlist/orderyans?dhid='+dhid,
  162. })
  163. },
  164. cancelorder(dhid){
  165. var that=this;
  166. uni.showModal({
  167. title: '您确认要取消订单吗?',
  168. content: '',
  169. success: (res) => {
  170. if (res.confirm) {
  171. that.delorder(dhid);
  172. }
  173. }
  174. });
  175. },
  176. async delorder(dhid){
  177. let userinfo=uni.getStorageSync('userinfo');
  178. let redata=await this.$api.cancelOrder({action:'cancelOrder',userid:userinfo.uid,name:userinfo.name,dhid:dhid});
  179. if(redata.code==1){
  180. this.orderlist(this.tabbarIndex);
  181. }else{
  182. uni.showToast({
  183. title:redata.msg,icon:'none'
  184. })
  185. }
  186. uni.hideLoading();
  187. },
  188. async orderlist(type){
  189. uni.showLoading({
  190. title:'加载中...'
  191. })
  192. this.list=[];
  193. let userinfo=uni.getStorageSync('userinfo');
  194. let redata=await this.$api.orderlist2({action:'orderlist',userid:userinfo.uid,type:type});
  195. if(redata.code==1){
  196. this.list = redata.data;
  197. //console.log('订单列表',redata.data);
  198. }else{
  199. // uni.showToast({
  200. // title:'暂无数据',icon:'none'
  201. // })
  202. }
  203. uni.hideLoading();
  204. //console.log(redata.data,'返回订单列表')
  205. },
  206. async excel_dh(dhid)
  207. {
  208. let redata=await this.$api.daochu({action:'daochu',dhid:dhid});
  209. if(redata.code==1)
  210. {
  211. const fileName=redata.data.filename;
  212. const header = redata.data.header;
  213. const headerName = redata.data.headerName;
  214. const ExcelData = redata.data.data;
  215. XLSX.excel_exprot(ExcelData, header, headerName,fileName);
  216. }else
  217. {
  218. uni.showToast({
  219. title:'暂无数据',icon:'none'
  220. })
  221. }
  222. },
  223. async orderdetail(id,type){
  224. // let redata=await this.$api.orderdetail({action:'orderdetail',dhid:id});
  225. // if(redata.code==1){
  226. // this.detailgoodlist = redata.data;
  227. // console.log('订单详情',redata);
  228. // if(redata.data.length>0){
  229. // if(this.detailgoodlist.length>0){
  230. // this.$refs.popup.open()
  231. // }
  232. // }
  233. // }else{
  234. // uni.showToast({
  235. // title:'暂无数据',icon:'none'
  236. // })
  237. // }
  238. let redata=await this.$api.orderdetail({action:'orderdetail',dhid:id});
  239. if(redata.code==1){
  240. this.detailgoodlist = redata.data;
  241. if(redata.data.length>0){
  242. if(this.detailgoodlist.length>0){
  243. if(type==1){
  244. //去再次支付
  245. let tmpList=[];
  246. let len = this.detailgoodlist.length;
  247. for(let i=0;i<len;i++){
  248. tmpList.push(this.detailgoodlist[i]);
  249. }
  250. if(tmpList.length<1){
  251. uni.showToast({
  252. title:'请选择商品结算',
  253. icon:'none'
  254. });
  255. return ;
  256. }
  257. //把优惠券id和金额传过去二次支付页面进行显示,但不能进行选择优惠券,否则导致支付金额跟第一次不符合支付失败
  258. let yid=tmpList[0].yid;
  259. let yhjine=tmpList[0].yhjine
  260. uni.setStorage({
  261. key:'buylist',
  262. data:tmpList,
  263. success: () => {
  264. uni.navigateTo({
  265. url:'../orderconfirmation/orderconfirmation_twopay?dhid='+id+'&yid='+yid+"&yhjine="+yhjine
  266. })
  267. }
  268. })
  269. }else{
  270. this.$refs.popup.open()
  271. }
  272. }
  273. }
  274. }else{
  275. uni.showToast({
  276. title:'暂无数据',icon:'none'
  277. })
  278. }
  279. },
  280. showType(tbIndex){
  281. this.tabbarIndex = tbIndex;
  282. this.orderlist(tbIndex);
  283. },
  284. showdetail(id){
  285. this.orderdetail(id,0)
  286. },
  287. closeit(){
  288. this.$refs.popup.close()
  289. },
  290. //取消订单
  291. cancelOrder(dhid){
  292. let t=this;
  293. uni.showModal({
  294. title: '温馨提示',
  295. content: '是否删除该订单?',
  296. success: function (res) {
  297. if (res.confirm) {
  298. uni.showLoading({
  299. title:'正在删除...'
  300. })
  301. t.cancelorder(dhid)
  302. } else if (res.cancel) {
  303. //用户点击取消
  304. }
  305. }
  306. });
  307. },
  308. toPayment(dhid){
  309. //本地模拟订单提交UI效果
  310. this.orderdetail(dhid,1);
  311. },
  312. sqtuik(dhid,allmoney,tktype){
  313. //tktype 0-未发货前申请退款,1-已发货申请售后
  314. uni.navigateTo({
  315. url:'../refund/refund?dhid='+dhid+'&index='+this.tabbarIndex+'&allmoney='+allmoney+'&tktype='+tktype
  316. })
  317. },
  318. qutuanh(dhid,allmoney,tktype){
  319. //tktype 0-未发货前申请退款,1-已发货申请售后
  320. uni.navigateTo({
  321. url:'../refund/refund2?dhid='+dhid+'&index='+this.tabbarIndex+'&allmoney='+allmoney+'&tktype='+tktype
  322. })
  323. },
  324. wuliu(dhid){
  325. uni.showToast({
  326. title:'暂无物流',icon:'none'
  327. })
  328. // uni.navigateTo({
  329. // url:'./wuliu?dhid='+dhid
  330. // })
  331. },
  332. daochu(dhid)
  333. {
  334. this.excel_dh(dhid);
  335. }
  336. }
  337. }
  338. </script>
  339. <style lang="scss">
  340. page{
  341. background-color: #f3f3f3;
  342. }
  343. .kfbt{
  344. width: 100%;
  345. background-color: #ffffff;
  346. border-radius: 65rpx;
  347. font-size: 22rpx;
  348. button::after{ border: none; }
  349. border: solid 1upx #ccc;
  350. color: #666;
  351. padding: 0rpx 20rpx;
  352. }
  353. .topTabBar{
  354. width: 100%;
  355. position: fixed;
  356. top: 0;
  357. z-index: 10;
  358. background-color: #f8f8f8;
  359. height: 80upx;
  360. display: flex;
  361. justify-content: space-around;
  362. .grid{
  363. width: 20%;
  364. height: 80upx;
  365. display: flex;
  366. justify-content: center;
  367. align-items: center;
  368. color: #444;
  369. font-size: 28upx;
  370. .text{
  371. height: 76upx;
  372. display: flex;
  373. align-items: center;
  374. &.on{
  375. color: #f06c7a;
  376. border-bottom: solid 4upx #f06c7a;
  377. }
  378. }
  379. }
  380. }
  381. .order-list{
  382. margin-top: 80upx;
  383. padding-top: 20upx;
  384. width: 100%;
  385. .list{
  386. width: 94%;
  387. margin: 0 auto;
  388. .onorder{
  389. width: 100%;
  390. height: 50vw;
  391. display: flex;
  392. justify-content: center;
  393. align-content: center;
  394. flex-wrap: wrap;
  395. image{
  396. width: 20vw;
  397. height: 20vw;
  398. border-radius: 100%;
  399. }
  400. .text{
  401. width: 100%;
  402. height: 60upx;
  403. font-size: 28upx;
  404. color: #444;
  405. display: flex;
  406. justify-content: center;
  407. align-items: center;
  408. }
  409. }
  410. .row{
  411. padding: 10upx 40upx;
  412. border-radius: 10upx;
  413. background-color: #fff;
  414. margin-bottom: 20upx;
  415. .type{
  416. font-size: 26upx;
  417. color: #ec652f;
  418. height: 50upx;
  419. display: flex;
  420. align-items: center;
  421. }
  422. .listitem{
  423. display: flex;
  424. justify-content: space-between;
  425. .itemtitle{
  426. font-size: 25upx;
  427. color: #A7A7A7;
  428. }
  429. .itemvaule{
  430. font-size: 28upx;
  431. color: #5A5A5A;
  432. }
  433. .itemvaule_mx{
  434. font-size: 25upx;
  435. color: #A7A7A7;
  436. }
  437. }
  438. .detail{
  439. display: flex;
  440. justify-content: flex-end;
  441. align-items: flex-end;
  442. height: 60upx;
  443. font-size: 24upx;
  444. .sum{
  445. padding: 0 8upx;
  446. display: flex;
  447. align-items: flex-end;
  448. .price{
  449. font-size: 30upx;
  450. }
  451. }
  452. }
  453. .btns{
  454. height: 80upx;
  455. display: flex;
  456. align-items: center;
  457. justify-content: flex-end;
  458. view{
  459. min-width: 120upx;
  460. height: 50upx;
  461. padding: 0 2upx;
  462. border-radius: 50upx;
  463. display: flex;
  464. justify-content: center;
  465. align-items: center;
  466. font-size: 26upx;
  467. margin-left: 20upx;
  468. }
  469. .default{
  470. border: solid 1upx #ccc;
  471. color: #666;
  472. }
  473. .pay{
  474. border: solid 1upx #ec652f;
  475. color: #ec652f;
  476. }
  477. }
  478. }
  479. }
  480. }
  481. .tip{
  482. color: #008001;
  483. margin-bottom: 15rpx;
  484. }
  485. .tkgood{
  486. filter: grayscale(90%);
  487. }
  488. .choosegood{
  489. display: flex;
  490. justify-content: space-between;
  491. align-items: center;
  492. margin: 20rpx 1px;
  493. padding-bottom: 15upx;
  494. border-bottom: 1upx solid #E8E8E8;
  495. }
  496. .desc{
  497. font-size: 25upx;
  498. width: 45%;
  499. }
  500. .price{
  501. color: #7E7E7C;
  502. padding-top: 20rpx;
  503. }
  504. .chukl{
  505. color: #6C9850;
  506. padding-top: 20rpx;
  507. }
  508. .istk{
  509. color: #C1C1C1;
  510. padding-top: 20rpx;
  511. }
  512. .shisje{
  513. color: #DB2C21;
  514. padding-top: 20rpx;
  515. }
  516. .choosegoodimg image{
  517. width: 150rpx;
  518. height: 150rpx;
  519. }
  520. .dosure{
  521. position: absolute;
  522. right: 25upx;
  523. top: 20upx;
  524. }
  525. </style>