order.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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.orderStateDictValue}}</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 class="num-cont">
  25. <text class="price-num">{{row.payGold}}</text>
  26. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  27. </view>
  28. <view>X {{row.buyQty}}</view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="check-row">
  33. <view class="text-right">
  34. <text class="total-text">
  35. 共{{item.goodsNum}}件商品
  36. </text>
  37. <view class="num-cont" v-if="item.orderState=='WAIT_PAY'">
  38. <text class="money-total">应付</text>
  39. <text class="price-num">{{item.originalGold}}</text>
  40. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  41. </view>
  42. <view class="num-cont" v-else>
  43. <text class="money-total">实付</text>
  44. <text class="price-num">{{item.payGold}}</text>
  45. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="check-row">
  50. <view v-if="item.orderState=='WAIT_PAY'" class="text-right left-time">
  51. <text style="margin-right: 20upx;">
  52. 支付剩余
  53. </text>
  54. <u-count-down @end="getRow"
  55. style="margin-right: 20upx;" separator ="zh"
  56. :timestamp="item.leftTimeT" :show-days="false" :show-hours="false"></u-count-down>
  57. <u-button :custom-style="btnStyle" @click="toPay(item)" shape="circle" type="error" size="medium">去支付</u-button>
  58. </view>
  59. <view v-if="item.orderState=='WAIT_SEND'||item.orderState=='SEND_PART'" class="text-right">
  60. <u-button :custom-style="btnStyle" @click="showTip" shape="circle" size="medium">提醒发货</u-button>
  61. </view>
  62. <view v-if="item.orderState=='SEND_ALL'||item.orderState=='SEND_PART'" class="text-right">
  63. <u-button @click="showLog(item)" :custom-style="btnStyle"
  64. style="margin-right: 20upx;margin-left: 20upx;" shape="circle" size="medium">查看物流</u-button>
  65. <u-button :custom-style="btnStyle" @click="showLog(item)" shape="circle" type="primary" size="medium">确认收货</u-button>
  66. </view>
  67. <view v-if="item.orderState=='FINISH'" class="text-right">
  68. <u-button @click="showLog(item)" :custom-style="btnStyle" shape="circle" size="medium">查看物流</u-button>
  69. </view>
  70. </view>
  71. </view>
  72. <u-empty style="padding-top: 10vh;height: auto;" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'"
  73. mode="list"></u-empty>
  74. <view v-if="index==current" style="padding: 20upx;">
  75. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  76. </view>
  77. </scroll-view>
  78. </swiper-item>
  79. </swiper>
  80. </view>
  81. <!-- 提示用户设置支付密码 -->
  82. <u-modal v-model="showSetPswModal"
  83. content="请先设置支付密码,才能使用乐豆"
  84. show-cancel-button
  85. confirm-text="去设置"
  86. cancel-text="暂时放弃"
  87. @confirm="toSetPwd"
  88. @cancel="showSetPswModal=false"
  89. ></u-modal>
  90. <!-- 确认取消弹窗 -->
  91. <u-modal v-model="showLeavePsw"
  92. title="确认放弃支付吗?"
  93. content="您的订单在30分钟内未支付将被取消"
  94. show-cancel-button
  95. confirm-text="确认放弃"
  96. cancel-text="继续支付"
  97. @confirm="canclePay"
  98. @cancel="payAgain"
  99. ></u-modal>
  100. <!-- 确认支付弹窗 -->
  101. <u-popup mode="center" closeable @close="closePayModal" v-model="showInputPsw" width="500rpx" >
  102. <view class="slot-content">
  103. <view>确认支付</view>
  104. <view class="text-cont">
  105. <text class="num-big">{{totalPrice}}</text>
  106. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  107. </view>
  108. <view class="footer">
  109. <input v-model="password" maxlength="30"
  110. style="text-align: center;"
  111. type="password"
  112. placeholder="请输入支付密码"
  113. @confirm="toPayOrder"/>
  114. </view>
  115. <view class="fot-btn">
  116. <u-button @click="toPayOrder" type="error" >确认支付</u-button>
  117. </view>
  118. </view>
  119. </u-popup>
  120. </view>
  121. </template>
  122. <script>
  123. import {
  124. getLookUpDatas,
  125. listLookUp
  126. } from '@/api/data'
  127. import {
  128. getOrderList, signPay, existPayPwd
  129. } from '@/api/order.js'
  130. import moment from 'moment'
  131. export default {
  132. components: {},
  133. data() {
  134. return {
  135. btnStyle:{
  136. width: '180rpx',
  137. fontSize: '30rpx',
  138. },
  139. status: 'loadmore',
  140. noDataText: '暂无数据',
  141. tabList: [{
  142. dispName: '全部',
  143. typeId: 2,
  144. queryLabel: [] // tab参数
  145. },
  146. {
  147. dispName: '待支付',
  148. typeId: 1,
  149. queryLabel: ['WAIT_PAY'] // tab参数
  150. },
  151. {
  152. dispName: '待发货',
  153. typeId: 3,
  154. queryLabel: ['WAIT_SEND'] // tab参数
  155. },
  156. {
  157. dispName: '待收货',
  158. typeId: 3,
  159. queryLabel: ['SEND_ALL','SEND_PART'] // tab参数
  160. },
  161. {
  162. dispName: '已完成',
  163. typeId: 3,
  164. queryLabel: ['FINISH'] // tab参数
  165. },
  166. ],
  167. current: 0,
  168. swiperCurrent: 0,
  169. pageNo: 1,
  170. pageSize: 10,
  171. list: [],
  172. logData: { // 物流信息
  173. logName: '韵达快递',
  174. logNum: 12356544544
  175. },
  176. total: 0,
  177. totalPrice: 0, // 支付合计
  178. password: '', // 支付密码
  179. action: 'swiperChange', // 操作类型,上划分页,或左右滑动
  180. showSetPswModal: false, // 设置支付密码弹窗
  181. showInputPsw: false, // 打开输入密码弹窗
  182. showLeavePsw: false, // 打开确定放弃弹窗
  183. payFinish: false // 是否支付成功
  184. }
  185. },
  186. onLoad() {
  187. // 监听设置密码是否成功
  188. uni.$once('setPswSuccess', this.setPsw)
  189. // 监听页面刷新事件 在详情支付成功后或在物流确认收货后刷新列表
  190. uni.$on('refresh', this.handleRefresh)
  191. this.pageInit()
  192. },
  193. onUnload() {
  194. uni.$off('refresh', this.handleRefresh)
  195. },
  196. onShow() {
  197. this.getRow(1) // 解决安卓息屏后倒计时不走问题
  198. },
  199. // 下拉刷新
  200. onPullDownRefresh() {
  201. console.log('refresh')
  202. this.pageNo = 1
  203. this.getRow()
  204. setTimeout(function () {
  205. uni.stopPullDownRefresh()
  206. }, 200)
  207. },
  208. methods: {
  209. pageInit() {
  210. this.sortIndex = 1
  211. this.pageNo = 1
  212. this.getRow()
  213. },
  214. handleRefresh() {
  215. this.getRow()
  216. },
  217. // tabs通知swiper切换
  218. tabsChange(index) {
  219. this.swiperCurrent = index;
  220. },
  221. swiperChange(event) {
  222. this.action = 'swiperChange'
  223. this.status = 'loading'
  224. },
  225. // swiper-item左右移动,通知tabs的滑块跟随移动
  226. transition(e) {
  227. let dx = e.detail.dx;
  228. this.$refs.uTabs.setDx(dx);
  229. },
  230. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  231. // swiper滑动结束,分别设置tabs和swiper的状态
  232. animationfinish(e) {
  233. let current = e.detail.current;
  234. let isCurtab = this.current == current
  235. if (this.status != "nomore") {
  236. let loadData = this.action == 'swiperChange' ? !isCurtab : isCurtab;
  237. if (loadData) {
  238. this.$refs.uTabs.setFinishCurrent(current);
  239. this.swiperCurrent = current;
  240. this.current = current;
  241. this.resetPage();
  242. }
  243. }
  244. },
  245. // scroll-view到底部加载更多
  246. onreachBottom() {
  247. this.action = 'onreachBottom'
  248. if (this.list.length < this.total) {
  249. this.pageNo += 1
  250. this.getRow()
  251. } else {
  252. if(this.list.length) {
  253. uni.showToast({
  254. title: '已经到底了',
  255. icon: 'none'
  256. });
  257. }
  258. this.status = "nomore"
  259. }
  260. },
  261. // 查询列表
  262. getRow(pageNo) {
  263. this.status = "loadmore"
  264. if (pageNo) {
  265. this.pageNo = pageNo
  266. }
  267. let params = {
  268. pageNo: this.pageNo,
  269. pageSize: this.pageSize,
  270. orderStateList: this.tabList[this.current].queryLabel, // tab分类
  271. }
  272. this.noDataText = '暂无数据'
  273. this.status = "loading"
  274. getOrderList(params).then(res => {
  275. if (res.status == 200) {
  276. if (this.pageNo > 1) {
  277. this.list = this.list.concat(res.data.list || [])
  278. } else {
  279. this.list = res.data.list || []
  280. }
  281. const date1 = moment().toArray() // 当前时间 数组形式
  282. this.list.map(item=>{
  283. const date2 = moment(item.orderTime).toDate() // 下单时间 日期格式
  284. const date3 = moment(date2).toArray() // 下单时间 数组形式
  285. const tt = 1800 - moment(date1).diff(moment(date3), 'seconds')// 距离30分钟支付 当前剩余秒数 = 1800秒 - 计算相差的秒数(当前时间-支付时间)
  286. item.leftTimeT = tt > 0 ? tt : 0
  287. })
  288. this.total = res.data.count || 0
  289. } else {
  290. this.list = []
  291. this.total = 0
  292. this.noDataText = res.message
  293. }
  294. this.status = "loadmore"
  295. })
  296. },
  297. resetPage() {
  298. this.status = 'loading';
  299. // 上划分页
  300. if (this.action == 'onreachBottom') {
  301. this.getRow();
  302. }
  303. // 左右切换tab
  304. if (this.action == 'swiperChange') {
  305. this.list = [];
  306. this.getRow(1);
  307. }
  308. },
  309. // 获取查询参数 刷新列表
  310. refresh(params) {
  311. // console.log(params,'1111111111')
  312. this.searchParams = params
  313. this.getRow(1)
  314. },
  315. // 跳转到设置支付密码页
  316. toSetPwd () {
  317. uni.navigateTo({
  318. url:"/pages/userCenter/userInfo/smsVerification"
  319. })
  320. },
  321. // 设置密码成功, 打开输入密码弹窗
  322. setPsw (e) {
  323. if (e.success) {
  324. this.showInputPsw = true
  325. }
  326. },
  327. // 关闭输入密码弹窗
  328. closePayModal(){
  329. if(!this.payFinish) {
  330. this.showLeavePsw = true
  331. }
  332. },
  333. //确认放弃
  334. canclePay() {
  335. this.password = ''
  336. this.showLeavePsw = false
  337. this.showInputPsw = false
  338. },
  339. // 继续支付
  340. payAgain () {
  341. this.showLeavePsw = false
  342. this.showInputPsw = true
  343. },
  344. // 支付 判断用户是否设置过支付密码
  345. toPay(item) {
  346. this.orderId = item.id
  347. this.totalPrice = item.originalGold
  348. this.payFinish = false
  349. // 判断用户是否设置过支付密码
  350. existPayPwd().then(res=>{
  351. console.log(res,'rrrrrr')
  352. if(res.status == 200) {
  353. // 设置过支付密码,输入密码
  354. if(res.data) {
  355. this.showInputPsw = true
  356. } else {
  357. // 没设置过支付密码,提示设置密码
  358. this.showSetPswModal = true
  359. }
  360. } else {
  361. uni.showToast({
  362. title: res.message,
  363. icon: 'none'
  364. })
  365. }
  366. })
  367. },
  368. // 支付
  369. toPayOrder() {
  370. if (this.password === '') {
  371. uni.showToast({
  372. title: '请先输入支付密码',
  373. icon: 'none'
  374. })
  375. return false
  376. }
  377. let params = {
  378. payPwd: this.password,
  379. id: this.orderId
  380. }
  381. signPay(params).then(res=>{
  382. this.btnLoading = false
  383. if(res.status == 200) {
  384. // 关闭弹窗 刷新列表
  385. this.payFinish = true
  386. this.showInputPsw = false
  387. this.getRow()
  388. setTimeout(()=>{
  389. // 跳转到支付完成界面
  390. uni.navigateTo({
  391. url:"/pages/toOrder/payFinish?id=" + this.orderId
  392. })
  393. },500)
  394. } else{
  395. this.password = ''
  396. uni.showToast({
  397. title: res.message,
  398. icon: 'none'
  399. })
  400. }
  401. })
  402. },
  403. // 提醒发货
  404. showTip() {
  405. uni.showToast({
  406. title: '已提醒商家发货',
  407. icon: 'none'
  408. })
  409. },
  410. // 查看物流
  411. showLog(item) {
  412. console.log(item, '111111')
  413. uni.navigateTo({
  414. url: "/pages/order/LogList?orderNo=" + item.orderNo
  415. })
  416. },
  417. // 详细页
  418. viewRow(item) {
  419. // if (!this.$hasPermissions('M_backlog_detail_mobile')) {
  420. // return
  421. // }
  422. console.log(item, '111111')
  423. // 已完成的
  424. uni.navigateTo({
  425. url: "/pages/order/orderDetail?id=" + item.id
  426. })
  427. },
  428. }
  429. }
  430. </script>
  431. <style lang="scss">
  432. page {
  433. height: 100%;
  434. width: 100%;
  435. background: #F8F8F8;
  436. }
  437. .pagesCons {
  438. height: 100%;
  439. width: 100%;
  440. background: #F8F8F8;
  441. display: flex;
  442. flex-direction: column;
  443. .text-right {
  444. text-align: right;
  445. }
  446. .tab-body {
  447. flex: 1;
  448. display: flex;
  449. flex-direction: column;
  450. .uTabs {
  451. border-bottom: 1px solid #EEEEEE;
  452. box-shadow: 1px 1px 3px #eeeeee;
  453. }
  454. .check-list {
  455. flex: 1;
  456. overflow-y: scroll;
  457. .swiper-item {
  458. width: 100%;
  459. height: 100%;
  460. overflow: hidden;
  461. .scroll-view {
  462. width: 100%;
  463. height: 100%;
  464. overflow: auto;
  465. }
  466. }
  467. }
  468. // 列表样式
  469. .check-order-list {
  470. background: #ffffff;
  471. padding: 10upx 20upx;
  472. margin: 25upx;
  473. border-radius: 6upx;
  474. box-shadow: 1px 1px 3px #EEEEEE;
  475. font-size: 28upx;
  476. .check-row {
  477. display: flex;
  478. align-items: center;
  479. padding: 20upx 10upx;
  480. .icon-xian {
  481. text-align: right;
  482. width: 40upx;
  483. }
  484. &:first-child {
  485. border-bottom: 1px dashed #F8F8F8;
  486. .createDate {
  487. color: #666;
  488. font-size: 26upx;
  489. margin-left: 10upx;
  490. }
  491. }
  492. &:last-child {
  493. border-top: 1px dashed #F8F8F8;
  494. }
  495. >view {
  496. &:first-child {
  497. flex: 1;
  498. }
  499. }
  500. }
  501. // 订单中商品列表
  502. .bundle-list {
  503. display: flex;
  504. padding: 20upx 10upx;
  505. font-size: 28upx;
  506. border-bottom: 1px solid #F8F8F8;
  507. .img-cont {
  508. width: 158rpx;
  509. height: 140upx;
  510. border-radius: 15upx;
  511. overflow: hidden;
  512. >image {
  513. width: 100%;
  514. height: 100%;
  515. }
  516. }
  517. >view {
  518. &:last-child {
  519. flex: 1;
  520. padding: 10upx 0;
  521. margin-left: 20upx;
  522. display: flex;
  523. flex-direction: column;
  524. justify-content: space-between;
  525. }
  526. }
  527. .bundle-num {
  528. display: flex;
  529. justify-content: space-between;
  530. }
  531. }
  532. .btn-cont {
  533. width: 180upx;
  534. font-size: 30upx;
  535. }
  536. .price-text {
  537. font-size: 20upx;
  538. margin-left: 10upx;
  539. }
  540. .price-num {
  541. font-size: 32upx;
  542. font-weight: 600;
  543. color: red;
  544. margin-right: 6rpx;
  545. }
  546. .total-text {
  547. margin-right: 50upx;
  548. }
  549. .money-total {
  550. margin-right: 10upx;
  551. }
  552. }
  553. }
  554. // 乐豆数量
  555. .num-cont{
  556. display: flex;
  557. align-items: center;
  558. float: right;
  559. }
  560. // 支付密码弹窗
  561. .slot-content{
  562. padding: 30upx 0;
  563. display: flex;
  564. flex-direction: column;
  565. align-items: center;
  566. justify-content: space-between;
  567. .text-cont{
  568. width: 100%;
  569. padding: 60upx 0;
  570. display: flex;
  571. align-items: center;
  572. justify-content: center;
  573. .num-big{
  574. font-size: 40upx;
  575. color: red;
  576. font-weight: 600;
  577. margin-right: 6rpx;
  578. }
  579. }
  580. .footer{
  581. width: 80%;
  582. border-bottom: 1px solid #b1b1b1;
  583. margin-bottom: 30upx;
  584. }
  585. }
  586. }
  587. </style>