order.vue 16 KB

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