order.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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. uni.showToast({
  227. title: '已经到底了',
  228. icon: 'none'
  229. });
  230. this.status = "nomore"
  231. }
  232. },
  233. // 查询列表
  234. getRow(pageNo) {
  235. this.status = "loadmore"
  236. if (pageNo) {
  237. this.pageNo = pageNo
  238. }
  239. let params = {
  240. pageNo: this.pageNo,
  241. pageSize: this.pageSize,
  242. orderStateList: this.tabList[this.current].queryLabel, // tab分类
  243. }
  244. this.noDataText = '暂无数据'
  245. this.status = "loading"
  246. getOrderList(params).then(res => {
  247. if (res.status == 200) {
  248. if (this.pageNo > 1) {
  249. this.list = this.list.concat(res.data.list || [])
  250. } else {
  251. this.list = res.data.list || []
  252. }
  253. let nowT = new Date().valueOf() // 现在时间戳
  254. this.list.map(item=>{
  255. let orderT = new Date(item.orderTime).valueOf() // 下单时间戳
  256. let tt = ((1800 * 1000) - (nowT - orderT))/1000 // 距离30分钟支付 相差时间戳
  257. item.leftTimeT = tt > 0 ? tt : 0
  258. })
  259. this.total = res.data.count || 0
  260. } else {
  261. this.list = []
  262. this.total = 0
  263. this.noDataText = res.message
  264. }
  265. this.status = "loadmore"
  266. })
  267. },
  268. resetPage() {
  269. this.status = 'loading';
  270. // 上划分页
  271. if (this.action == 'onreachBottom') {
  272. this.getRow();
  273. }
  274. // 左右切换tab
  275. if (this.action == 'swiperChange') {
  276. this.list = [];
  277. this.getRow(1);
  278. }
  279. },
  280. // 获取查询参数 刷新列表
  281. refresh(params) {
  282. // console.log(params,'1111111111')
  283. this.searchParams = params
  284. this.getRow(1)
  285. },
  286. // 跳转到设置支付密码页
  287. toSetPwd () {
  288. uni.navigateTo({
  289. url:"/pages/userCenter/userInfo/smsVerification"
  290. })
  291. },
  292. // 设置密码成功, 打开输入密码弹窗
  293. setPsw (e) {
  294. if (e.success) {
  295. this.showInputPsw = true
  296. }
  297. },
  298. //确认放弃
  299. canclePay() {
  300. this.password = ''
  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. this.password = ''
  357. uni.showToast({
  358. title: res.message,
  359. icon: 'none'
  360. })
  361. }
  362. })
  363. },
  364. // 提醒发货
  365. showTip() {
  366. uni.showToast({
  367. title: '已提醒商家发货',
  368. icon: 'none'
  369. })
  370. },
  371. // 查看物流
  372. showLog(item) {
  373. console.log(item, '111111')
  374. uni.navigateTo({
  375. url: "/pages/order/LogList?orderNo=" + item.orderNo
  376. })
  377. },
  378. // 详细页
  379. viewRow(item) {
  380. // if (!this.$hasPermissions('M_backlog_detail_mobile')) {
  381. // return
  382. // }
  383. console.log(item, '111111')
  384. // 已完成的
  385. uni.navigateTo({
  386. url: "/pages/order/orderDetail?id=" + item.id
  387. })
  388. },
  389. }
  390. }
  391. </script>
  392. <style lang="scss">
  393. page {
  394. height: 100%;
  395. width: 100%;
  396. background: #F8F8F8;
  397. }
  398. .pagesCons {
  399. height: 100%;
  400. width: 100%;
  401. background: #F8F8F8;
  402. display: flex;
  403. flex-direction: column;
  404. .text-right {
  405. text-align: right;
  406. }
  407. .tab-body {
  408. flex: 1;
  409. display: flex;
  410. flex-direction: column;
  411. .uTabs {
  412. border-bottom: 1px solid #EEEEEE;
  413. box-shadow: 1px 1px 3px #eeeeee;
  414. }
  415. .check-list {
  416. flex: 1;
  417. overflow-y: scroll;
  418. .swiper-item {
  419. width: 100%;
  420. height: 100%;
  421. overflow: hidden;
  422. .scroll-view {
  423. width: 100%;
  424. height: 100%;
  425. overflow: auto;
  426. }
  427. }
  428. }
  429. // 列表样式
  430. .check-order-list {
  431. background: #ffffff;
  432. padding: 10upx 20upx;
  433. margin: 25upx;
  434. border-radius: 6upx;
  435. box-shadow: 1px 1px 3px #EEEEEE;
  436. font-size: 28upx;
  437. .check-row {
  438. display: flex;
  439. align-items: center;
  440. padding: 20upx 10upx;
  441. .icon-xian {
  442. text-align: right;
  443. width: 40upx;
  444. }
  445. &:first-child {
  446. border-bottom: 1px dashed #F8F8F8;
  447. .createDate {
  448. color: #666;
  449. font-size: 26upx;
  450. margin-left: 10upx;
  451. }
  452. }
  453. &:last-child {
  454. border-top: 1px dashed #F8F8F8;
  455. }
  456. >view {
  457. &:first-child {
  458. flex: 1;
  459. }
  460. }
  461. }
  462. // 订单中商品列表
  463. .bundle-list {
  464. display: flex;
  465. padding: 20upx 10upx;
  466. font-size: 28upx;
  467. border-bottom: 1px solid #F8F8F8;
  468. .img-cont {
  469. width: 158rpx;
  470. height: 140upx;
  471. border-radius: 15upx;
  472. overflow: hidden;
  473. >image {
  474. width: 100%;
  475. height: 100%;
  476. }
  477. }
  478. >view {
  479. &:last-child {
  480. flex: 1;
  481. padding: 10upx 0;
  482. margin-left: 20upx;
  483. display: flex;
  484. flex-direction: column;
  485. justify-content: space-between;
  486. }
  487. }
  488. .bundle-num {
  489. display: flex;
  490. justify-content: space-between;
  491. }
  492. }
  493. .btn-cont {
  494. width: 180upx;
  495. font-size: 30upx;
  496. }
  497. .price-text {
  498. font-size: 20upx;
  499. margin-left: 10upx;
  500. }
  501. .price-num {
  502. font-size: 32upx;
  503. color: red;
  504. }
  505. .total-text {
  506. margin-right: 50upx;
  507. }
  508. .money-total {
  509. margin-right: 10upx;
  510. }
  511. }
  512. }
  513. // 支付密码弹窗
  514. .slot-content{
  515. padding: 30upx 0;
  516. display: flex;
  517. flex-direction: column;
  518. align-items: center;
  519. justify-content: space-between;
  520. .text-cont{
  521. width: 100%;
  522. padding: 60upx 0;
  523. text-align: center;
  524. .num-big{
  525. font-size: 40upx;
  526. color: red;
  527. }
  528. }
  529. .footer{
  530. width: 80%;
  531. border-bottom: 1px solid #b1b1b1;
  532. margin-bottom: 30upx;
  533. }
  534. }
  535. }
  536. </style>