order.vue 13 KB

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