order.vue 16 KB

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