order.vue 15 KB

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