order.vue 15 KB

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