order.vue 15 KB

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