order.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  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. // 下拉刷新
  197. onPullDownRefresh() {
  198. console.log('refresh')
  199. this.pageNo = 1
  200. this.getRow()
  201. setTimeout(function () {
  202. uni.stopPullDownRefresh()
  203. }, 200)
  204. },
  205. methods: {
  206. pageInit() {
  207. this.sortIndex = 1
  208. this.pageNo = 1
  209. this.getRow()
  210. },
  211. handleRefresh() {
  212. this.getRow()
  213. },
  214. // tabs通知swiper切换
  215. tabsChange(index) {
  216. this.swiperCurrent = index;
  217. },
  218. swiperChange(event) {
  219. this.action = 'swiperChange'
  220. this.status = 'loading'
  221. },
  222. // swiper-item左右移动,通知tabs的滑块跟随移动
  223. transition(e) {
  224. let dx = e.detail.dx;
  225. this.$refs.uTabs.setDx(dx);
  226. },
  227. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  228. // swiper滑动结束,分别设置tabs和swiper的状态
  229. animationfinish(e) {
  230. let current = e.detail.current;
  231. let isCurtab = this.current == current
  232. if (this.status != "nomore") {
  233. let loadData = this.action == 'swiperChange' ? !isCurtab : isCurtab;
  234. if (loadData) {
  235. this.$refs.uTabs.setFinishCurrent(current);
  236. this.swiperCurrent = current;
  237. this.current = current;
  238. this.resetPage();
  239. }
  240. }
  241. },
  242. // scroll-view到底部加载更多
  243. onreachBottom() {
  244. this.action = 'onreachBottom'
  245. if (this.list.length < this.total) {
  246. this.pageNo += 1
  247. this.getRow()
  248. } else {
  249. if(this.list.length) {
  250. uni.showToast({
  251. title: '已经到底了',
  252. icon: 'none'
  253. });
  254. }
  255. this.status = "nomore"
  256. }
  257. },
  258. // 查询列表
  259. getRow(pageNo) {
  260. this.status = "loadmore"
  261. if (pageNo) {
  262. this.pageNo = pageNo
  263. }
  264. let params = {
  265. pageNo: this.pageNo,
  266. pageSize: this.pageSize,
  267. orderStateList: this.tabList[this.current].queryLabel, // tab分类
  268. }
  269. this.noDataText = '暂无数据'
  270. this.status = "loading"
  271. getOrderList(params).then(res => {
  272. if (res.status == 200) {
  273. if (this.pageNo > 1) {
  274. this.list = this.list.concat(res.data.list || [])
  275. } else {
  276. this.list = res.data.list || []
  277. }
  278. const date1 = moment().toArray() // 当前时间 数组形式
  279. this.list.map(item=>{
  280. const date2 = moment(item.orderTime).toDate() // 下单时间 日期格式
  281. const date3 = moment(date2).toArray() // 下单时间 数组形式
  282. const tt = 1800 - moment(date1).diff(moment(date3), 'seconds')// 距离30分钟支付 当前剩余秒数 = 1800秒 - 计算相差的秒数(当前时间-支付时间)
  283. item.leftTimeT = tt > 0 ? tt : 0
  284. })
  285. this.total = res.data.count || 0
  286. } else {
  287. this.list = []
  288. this.total = 0
  289. this.noDataText = res.message
  290. }
  291. this.status = "loadmore"
  292. })
  293. },
  294. resetPage() {
  295. this.status = 'loading';
  296. // 上划分页
  297. if (this.action == 'onreachBottom') {
  298. this.getRow();
  299. }
  300. // 左右切换tab
  301. if (this.action == 'swiperChange') {
  302. this.list = [];
  303. this.getRow(1);
  304. }
  305. },
  306. // 获取查询参数 刷新列表
  307. refresh(params) {
  308. // console.log(params,'1111111111')
  309. this.searchParams = params
  310. this.getRow(1)
  311. },
  312. // 跳转到设置支付密码页
  313. toSetPwd () {
  314. uni.navigateTo({
  315. url:"/pages/userCenter/userInfo/smsVerification"
  316. })
  317. },
  318. // 设置密码成功, 打开输入密码弹窗
  319. setPsw (e) {
  320. if (e.success) {
  321. this.showInputPsw = true
  322. }
  323. },
  324. // 关闭输入密码弹窗
  325. closePayModal(){
  326. if(!this.payFinish) {
  327. this.showLeavePsw = true
  328. }
  329. },
  330. //确认放弃
  331. canclePay() {
  332. this.password = ''
  333. this.showLeavePsw = false
  334. this.showInputPsw = false
  335. },
  336. // 继续支付
  337. payAgain () {
  338. this.showLeavePsw = false
  339. this.showInputPsw = true
  340. },
  341. // 支付 判断用户是否设置过支付密码
  342. toPay(item) {
  343. this.orderId = item.id
  344. this.totalPrice = item.originalGold
  345. this.payFinish = false
  346. // 判断用户是否设置过支付密码
  347. existPayPwd().then(res=>{
  348. console.log(res,'rrrrrr')
  349. if(res.status == 200) {
  350. // 设置过支付密码,输入密码
  351. if(res.data) {
  352. this.showInputPsw = true
  353. } else {
  354. // 没设置过支付密码,提示设置密码
  355. this.showSetPswModal = true
  356. }
  357. } else {
  358. uni.showToast({
  359. title: res.message,
  360. icon: 'none'
  361. })
  362. }
  363. })
  364. },
  365. // 支付
  366. toPayOrder() {
  367. if (this.password === '') {
  368. uni.showToast({
  369. title: '请先输入支付密码',
  370. icon: 'none'
  371. })
  372. return false
  373. }
  374. let params = {
  375. payPwd: this.password,
  376. id: this.orderId
  377. }
  378. signPay(params).then(res=>{
  379. this.btnLoading = false
  380. if(res.status == 200) {
  381. // 关闭弹窗 刷新列表
  382. this.payFinish = true
  383. this.showInputPsw = false
  384. this.getRow()
  385. setTimeout(()=>{
  386. // 跳转到支付完成界面
  387. uni.navigateTo({
  388. url:"/pages/toOrder/payFinish?id=" + this.orderId
  389. })
  390. },500)
  391. } else{
  392. this.password = ''
  393. uni.showToast({
  394. title: res.message,
  395. icon: 'none'
  396. })
  397. }
  398. })
  399. },
  400. // 提醒发货
  401. showTip() {
  402. uni.showToast({
  403. title: '已提醒商家发货',
  404. icon: 'none'
  405. })
  406. },
  407. // 查看物流
  408. showLog(item) {
  409. console.log(item, '111111')
  410. uni.navigateTo({
  411. url: "/pages/order/LogList?orderNo=" + item.orderNo
  412. })
  413. },
  414. // 详细页
  415. viewRow(item) {
  416. // if (!this.$hasPermissions('M_backlog_detail_mobile')) {
  417. // return
  418. // }
  419. console.log(item, '111111')
  420. // 已完成的
  421. uni.navigateTo({
  422. url: "/pages/order/orderDetail?id=" + item.id
  423. })
  424. },
  425. }
  426. }
  427. </script>
  428. <style lang="scss">
  429. page {
  430. height: 100%;
  431. width: 100%;
  432. background: #F8F8F8;
  433. }
  434. .pagesCons {
  435. height: 100%;
  436. width: 100%;
  437. background: #F8F8F8;
  438. display: flex;
  439. flex-direction: column;
  440. .text-right {
  441. text-align: right;
  442. }
  443. .tab-body {
  444. flex: 1;
  445. display: flex;
  446. flex-direction: column;
  447. .uTabs {
  448. border-bottom: 1px solid #EEEEEE;
  449. box-shadow: 1px 1px 3px #eeeeee;
  450. }
  451. .check-list {
  452. flex: 1;
  453. overflow-y: scroll;
  454. .swiper-item {
  455. width: 100%;
  456. height: 100%;
  457. overflow: hidden;
  458. .scroll-view {
  459. width: 100%;
  460. height: 100%;
  461. overflow: auto;
  462. }
  463. }
  464. }
  465. // 列表样式
  466. .check-order-list {
  467. background: #ffffff;
  468. padding: 10upx 20upx;
  469. margin: 25upx;
  470. border-radius: 6upx;
  471. box-shadow: 1px 1px 3px #EEEEEE;
  472. font-size: 28upx;
  473. .check-row {
  474. display: flex;
  475. align-items: center;
  476. padding: 20upx 10upx;
  477. .icon-xian {
  478. text-align: right;
  479. width: 40upx;
  480. }
  481. &:first-child {
  482. border-bottom: 1px dashed #F8F8F8;
  483. .createDate {
  484. color: #666;
  485. font-size: 26upx;
  486. margin-left: 10upx;
  487. }
  488. }
  489. &:last-child {
  490. border-top: 1px dashed #F8F8F8;
  491. }
  492. >view {
  493. &:first-child {
  494. flex: 1;
  495. }
  496. }
  497. }
  498. // 订单中商品列表
  499. .bundle-list {
  500. display: flex;
  501. padding: 20upx 10upx;
  502. font-size: 28upx;
  503. border-bottom: 1px solid #F8F8F8;
  504. .img-cont {
  505. width: 158rpx;
  506. height: 140upx;
  507. border-radius: 15upx;
  508. overflow: hidden;
  509. >image {
  510. width: 100%;
  511. height: 100%;
  512. }
  513. }
  514. >view {
  515. &:last-child {
  516. flex: 1;
  517. padding: 10upx 0;
  518. margin-left: 20upx;
  519. display: flex;
  520. flex-direction: column;
  521. justify-content: space-between;
  522. }
  523. }
  524. .bundle-num {
  525. display: flex;
  526. justify-content: space-between;
  527. }
  528. }
  529. .btn-cont {
  530. width: 180upx;
  531. font-size: 30upx;
  532. }
  533. .price-text {
  534. font-size: 20upx;
  535. margin-left: 10upx;
  536. }
  537. .price-num {
  538. font-size: 32upx;
  539. font-weight: 600;
  540. color: red;
  541. margin-right: 6rpx;
  542. }
  543. .total-text {
  544. margin-right: 50upx;
  545. }
  546. .money-total {
  547. margin-right: 10upx;
  548. }
  549. }
  550. }
  551. // 乐豆数量
  552. .num-cont{
  553. display: flex;
  554. align-items: center;
  555. float: right;
  556. }
  557. // 支付密码弹窗
  558. .slot-content{
  559. padding: 30upx 0;
  560. display: flex;
  561. flex-direction: column;
  562. align-items: center;
  563. justify-content: space-between;
  564. .text-cont{
  565. width: 100%;
  566. padding: 60upx 0;
  567. display: flex;
  568. align-items: center;
  569. justify-content: center;
  570. .num-big{
  571. font-size: 40upx;
  572. color: red;
  573. font-weight: 600;
  574. margin-right: 6rpx;
  575. }
  576. }
  577. .footer{
  578. width: 80%;
  579. border-bottom: 1px solid #b1b1b1;
  580. margin-bottom: 30upx;
  581. }
  582. }
  583. }
  584. </style>