order.vue 16 KB

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