order.vue 14 KB

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