order.vue 13 KB

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