order.vue 14 KB

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