order.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <template>
  2. <view class="pagesCons">
  3. <view class="tab-body">
  4. <view class="uTabs">
  5. <u-tabs-swiper ref="uTabs" :list="tabList" name="dispName" :current="current" @change="tabsChange" :is-scroll="false"
  6. swiperWidth="750"></u-tabs-swiper>
  7. </view>
  8. <swiper class="check-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
  9. <swiper-item class="swiper-item" v-for="(tabs, index) in tabList" :key="index">
  10. <scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
  11. <view class="check-order-list" v-if="index==current" v-for="item in list" :key="item.id"
  12. @click="viewRow(item)">
  13. <view class="check-row">
  14. <view class="createDate">{{item.createDate}}</view>
  15. <view>{{item.orderState}}</view>
  16. </view>
  17. <view class="bundle-list" v-for="row in item.orderGoodsList" :key="row.id">
  18. <view class="img-cont">
  19. <image :src="row.goodsImages"></image>
  20. </view>
  21. <view>
  22. <view class="ellipsis-two">{{row.goodsName}}</view>
  23. <view class="bundle-num">
  24. <view><text class="price-num">{{row.payGold}}</text> <text class="price-text">乐豆</text></view>
  25. <view>X {{row.buyQty}}</view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="check-row">
  30. <view class="text-right">
  31. <text class="total-text">
  32. 共{{item.goodsNum}}件商品
  33. </text>
  34. <text v-if="item.orderState=='待支付'"><text class="money-total">应付</text><text class="price-num">{{item.originalGold}}</text>
  35. <text class="price-text">乐豆</text></text>
  36. <text v-else><text class="money-total">实付</text><text class="price-num">{{item.payGold}}</text> <text class="price-text">乐豆</text></text>
  37. </view>
  38. </view>
  39. <view class="check-row">
  40. <view v-if="item.orderState=='WAIT_PAY'" class="text-right">
  41. <text style="margin-right: 30upx;">支付剩余{{filterTime(item.orderTime)}}</text>
  42. <u-button class="btn-cont" @click="toPay(item)" shape="circle" type="error" size="medium">去支付</u-button>
  43. </view>
  44. <view v-if="item.orderState=='WAIT_SEND'" class="text-right">
  45. <u-button class="btn-cont" @click="showTip" shape="circle" size="medium">提醒发货</u-button>
  46. </view>
  47. <view v-if="item.orderState=='SEND_ALL'" class="text-right">
  48. <u-button @click="showLog(item)" class="btn-cont" style="margin-right: 20upx;" shape="circle" size="medium">查看物流</u-button>
  49. <u-button class="btn-cont" shape="circle" type="primary" size="medium">确认收货</u-button>
  50. </view>
  51. <view v-if="item.orderState=='FINISH'" class="text-right">
  52. <u-button @click="showLog(item)" class="btn-cont" shape="circle" size="medium">查看物流</u-button>
  53. </view>
  54. </view>
  55. </view>
  56. <u-empty style="padding-top: 10vh;height: auto;" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'"
  57. mode="list"></u-empty>
  58. <view v-if="index==current" style="padding: 20upx;">
  59. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  60. </view>
  61. </scroll-view>
  62. </swiper-item>
  63. </swiper>
  64. </view>
  65. <!-- 提示用户设置支付密码 -->
  66. <u-modal v-model="showSetPswModal"
  67. content="请先设置支付密码,才能使用乐豆"
  68. show-cancel-button
  69. confirm-text="去设置"
  70. cancel-text="暂时放弃"
  71. @confirm="toSetPwd"
  72. @cancel="showSetPswModal=false"
  73. ></u-modal>
  74. <!-- 确认取消弹窗 -->
  75. <u-modal v-model="showLeavePsw"
  76. title="确认放弃支付吗?"
  77. content="您的订单在30分钟内未支付将被取消"
  78. show-cancel-button
  79. confirm-text="确认放弃"
  80. cancel-text="继续支付"
  81. @confirm="canclePay"
  82. @cancel="payAgain"
  83. ></u-modal>
  84. <!-- 确认支付弹窗 -->
  85. <u-popup mode="center" closeable @close="showLeavePsw=true" v-model="showInputPsw" width="500rpx" >
  86. <view class="slot-content">
  87. <view>确认支付</view>
  88. <view class="text-cont">
  89. <text class="num-big">{{totalPrice}}</text>乐豆
  90. </view>
  91. <view class="footer">
  92. <u-input v-model="password" maxlength="30" input-align="center" type="password" placeholder="请输入支付密码" />
  93. </view>
  94. </view>
  95. </u-popup>
  96. </view>
  97. </template>
  98. <script>
  99. import {
  100. getLookUpDatas,
  101. listLookUp
  102. } from '@/api/data'
  103. import {
  104. getOrderList, signPay
  105. } from '@/api/order.js'
  106. export default {
  107. components: {},
  108. data() {
  109. return {
  110. status: 'loadmore',
  111. noDataText: '暂无数据',
  112. tabList: [{
  113. dispName: '全部',
  114. typeId: 2,
  115. queryLabel: [] // tab参数
  116. },
  117. {
  118. dispName: '待支付',
  119. typeId: 1,
  120. queryLabel: ['WAIT_PAY'] // tab参数
  121. },
  122. {
  123. dispName: '待发货',
  124. typeId: 3,
  125. queryLabel: ['WAIT_SEND', 'SEND_PART'] // tab参数
  126. },
  127. {
  128. dispName: '已发货',
  129. typeId: 3,
  130. queryLabel: ['SEND_ALL'] // tab参数
  131. },
  132. {
  133. dispName: '已完成',
  134. typeId: 3,
  135. queryLabel: ['FINISH'] // tab参数
  136. },
  137. ],
  138. current: 0,
  139. swiperCurrent: 0,
  140. pageNo: 1,
  141. pageSize: 10,
  142. list: [],
  143. logData: { // 物流信息
  144. logName: '韵达快递',
  145. logNum: 12356544544
  146. },
  147. total: 0,
  148. totalPrice: 0, // 支付合计
  149. action: 'swiperChange', // 操作类型,上划分页,或左右滑动
  150. showSetPswModal: false, // 设置支付密码弹窗
  151. showInputPsw: false, // 打开输入密码弹窗
  152. showLeavePsw: false, // 打开确定放弃弹窗
  153. }
  154. },
  155. onShow() {
  156. this.pageInit()
  157. },
  158. onLoad() {
  159. // 监听设置密码是否成功
  160. uni.$once('setPswSuccess', this.setPsw)
  161. },
  162. onUnload() {
  163. uni.$off('refreshBL', this.refresh)
  164. uni.$off('refreshBl-handle', this.handleRefresh)
  165. },
  166. methods: {
  167. pageInit() {
  168. this.sortIndex = 1
  169. this.pageNo = 1
  170. this.getRow()
  171. },
  172. handleRefresh() {
  173. this.getRow()
  174. },
  175. // tabs通知swiper切换
  176. tabsChange(index) {
  177. this.swiperCurrent = index;
  178. },
  179. swiperChange(event) {
  180. this.action = 'swiperChange'
  181. this.status = 'loading'
  182. },
  183. // swiper-item左右移动,通知tabs的滑块跟随移动
  184. transition(e) {
  185. let dx = e.detail.dx;
  186. this.$refs.uTabs.setDx(dx);
  187. },
  188. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  189. // swiper滑动结束,分别设置tabs和swiper的状态
  190. animationfinish(e) {
  191. let current = e.detail.current;
  192. let isCurtab = this.current == current
  193. if (this.status != "nomore") {
  194. let loadData = this.action == 'swiperChange' ? !isCurtab : isCurtab;
  195. if (loadData) {
  196. this.$refs.uTabs.setFinishCurrent(current);
  197. this.swiperCurrent = current;
  198. this.current = current;
  199. this.resetPage();
  200. }
  201. }
  202. },
  203. // scroll-view到底部加载更多
  204. onreachBottom() {
  205. this.action = 'onreachBottom'
  206. if (this.list.length < this.total) {
  207. this.pageNo += 1
  208. this.getRow()
  209. } else {
  210. uni.showToast({
  211. title: '已经到底了',
  212. icon: 'none'
  213. });
  214. this.status = "nomore"
  215. }
  216. },
  217. // 查询列表
  218. getRow(pageNo) {
  219. this.status = "loadmore"
  220. if (pageNo) {
  221. this.pageNo = pageNo
  222. }
  223. let params = {
  224. pageNo: this.pageNo,
  225. pageSize: this.pageSize,
  226. orderStateList: this.tabList[this.current].queryLabel, // tab分类
  227. }
  228. this.noDataText = '暂无数据'
  229. this.status = "loading"
  230. getOrderList(params).then(res => {
  231. if (res.status == 200) {
  232. if (this.pageNo > 1) {
  233. this.list = this.list.concat(res.data.list || [])
  234. } else {
  235. this.list = res.data.list || []
  236. }
  237. this.total = res.data.count || 0
  238. } else {
  239. this.list = []
  240. this.total = 0
  241. this.noDataText = res.message
  242. }
  243. this.status = "loadmore"
  244. })
  245. },
  246. resetPage() {
  247. this.status = 'loading';
  248. // 上划分页
  249. if (this.action == 'onreachBottom') {
  250. this.getRow();
  251. }
  252. // 左右切换tab
  253. if (this.action == 'swiperChange') {
  254. this.list = [];
  255. this.getRow(1);
  256. }
  257. },
  258. // 获取查询参数 刷新列表
  259. refresh(params) {
  260. // console.log(params,'1111111111')
  261. this.searchParams = params
  262. this.getRow(1)
  263. },
  264. // 支付剩余时间
  265. filterTime (time) {
  266. let nowT = new Date().valueOf() // 现在时间戳
  267. let orderT = new Date(time).valueOf() // 下单时间戳
  268. let tt = (1800 * 1000) - (nowT - orderT) // 距离30分钟支付 相差时间戳
  269. setInterval(()=>{
  270. if(tt>0) {
  271. tt = tt -1000
  272. } else {
  273. clearInterval()
  274. // this.getRow()
  275. }
  276. },1000)
  277. //计算相差分钟数
  278. var leave1 = tt % (3600 * 1000); //计算小时数后剩余的毫秒数
  279. var minutes = Math.floor(tt / (60 * 1000));
  280. //计算相差秒数
  281. var leave3 = leave1 % (60 * 1000); //计算分钟数后剩余的毫秒数
  282. var seconds = Math.round(leave3 / 1000);
  283. console.log(minutes + "天 " + seconds + "小时 ")
  284. // console.log(new Date(time).valueOf(),dt.valueOf(),'ttttttt')
  285. return minutes + "分 " + seconds + "秒"
  286. },
  287. // 跳转到设置支付密码页
  288. toSetPwd () {
  289. uni.navigateTo({
  290. url:"/pages/userCenter/userInfo/paymentPwd"
  291. })
  292. },
  293. // 设置密码成功, 打开输入密码弹窗
  294. setPsw (e) {
  295. if (e.success) {
  296. this.showInputPsw = true
  297. }
  298. },
  299. //确认放弃
  300. canclePay() {
  301. this.showLeavePsw = false
  302. this.showInputPsw = false
  303. },
  304. // 继续支付
  305. payAgain () {
  306. this.showLeavePsw = false
  307. this.showInputPsw = true
  308. },
  309. // 支付
  310. toPay(item) {
  311. // this.totalPrice = item.payGold
  312. // this.showSetPswModal = true
  313. // return
  314. signPay({id:item.id}).then(res=>{
  315. this.btnLoading = false
  316. if(res.status == 200) {
  317. // 跳转到支付完成界面
  318. uni.navigateTo({
  319. url:"/pages/toOrder/payFinish?id=" + this.orderId
  320. })
  321. } else{
  322. uni.showToast({
  323. title: res.message,
  324. icon: 'none'
  325. })
  326. }
  327. })
  328. },
  329. // 提醒发货
  330. showTip() {
  331. uni.showToast({
  332. title: '已提醒商家发货',
  333. icon: 'none'
  334. })
  335. },
  336. // 查看物流
  337. showLog(item) {
  338. console.log(item, '111111')
  339. uni.navigateTo({
  340. url: "/pages/order/LogList?id=" + item.id
  341. })
  342. },
  343. // 详细页
  344. viewRow(item) {
  345. // if (!this.$hasPermissions('M_backlog_detail_mobile')) {
  346. // return
  347. // }
  348. console.log(item, '111111')
  349. // 已完成的
  350. uni.navigateTo({
  351. url: "/pages/order/orderDetail?id=" + item.id
  352. })
  353. },
  354. }
  355. }
  356. </script>
  357. <style lang="scss">
  358. page {
  359. height: 100%;
  360. width: 100%;
  361. background: #F8F8F8;
  362. }
  363. .pagesCons {
  364. height: 100%;
  365. width: 100%;
  366. background: #F8F8F8;
  367. display: flex;
  368. flex-direction: column;
  369. .text-right {
  370. text-align: right;
  371. }
  372. .tab-body {
  373. flex: 1;
  374. display: flex;
  375. flex-direction: column;
  376. .uTabs {
  377. border-bottom: 1px solid #EEEEEE;
  378. box-shadow: 1px 1px 3px #eeeeee;
  379. }
  380. .check-list {
  381. flex: 1;
  382. overflow-y: scroll;
  383. .swiper-item {
  384. width: 100%;
  385. height: 100%;
  386. overflow: hidden;
  387. .scroll-view {
  388. width: 100%;
  389. height: 100%;
  390. overflow: auto;
  391. }
  392. }
  393. }
  394. // 列表样式
  395. .check-order-list {
  396. background: #ffffff;
  397. padding: 10upx 20upx;
  398. margin: 25upx;
  399. border-radius: 6upx;
  400. box-shadow: 1px 1px 3px #EEEEEE;
  401. font-size: 28upx;
  402. .check-row {
  403. display: flex;
  404. align-items: center;
  405. padding: 20upx 10upx;
  406. .icon-xian {
  407. text-align: right;
  408. width: 40upx;
  409. }
  410. &:first-child {
  411. border-bottom: 1px dashed #F8F8F8;
  412. .createDate {
  413. color: #666;
  414. font-size: 26upx;
  415. margin-left: 10upx;
  416. }
  417. }
  418. &:last-child {
  419. border-top: 1px dashed #F8F8F8;
  420. }
  421. >view {
  422. &:first-child {
  423. flex: 1;
  424. }
  425. }
  426. }
  427. // 订单中商品列表
  428. .bundle-list {
  429. display: flex;
  430. padding: 20upx 10upx;
  431. font-size: 28upx;
  432. border-bottom: 1px solid #F8F8F8;
  433. .img-cont {
  434. width: 158rpx;
  435. height: 140upx;
  436. border-radius: 15upx;
  437. overflow: hidden;
  438. >image {
  439. width: 100%;
  440. height: 100%;
  441. }
  442. }
  443. >view {
  444. &:last-child {
  445. flex: 1;
  446. margin-left: 20upx;
  447. display: flex;
  448. flex-direction: column;
  449. justify-content: space-between;
  450. }
  451. }
  452. .bundle-num {
  453. display: flex;
  454. justify-content: space-between;
  455. }
  456. }
  457. .btn-cont {
  458. width: 180upx;
  459. font-size: 30upx;
  460. }
  461. .price-text {
  462. font-size: 20upx;
  463. margin-left: 10upx;
  464. }
  465. .price-num {
  466. font-size: 32upx;
  467. color: red;
  468. }
  469. .total-text {
  470. margin-right: 50upx;
  471. }
  472. .money-total {
  473. margin-right: 10upx;
  474. }
  475. }
  476. }
  477. // 物流弹窗
  478. .slot-content {
  479. padding: 40upx 60upx;
  480. font-size: 28upx;
  481. >view {
  482. line-height: 60upx;
  483. }
  484. }
  485. }
  486. </style>