order.vue 14 KB

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