order.vue 14 KB

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