order.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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.orderStateDictValue=='待支付'"><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.orderStateDictValue=='待支付'" 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.orderStateDictValue=='待发货'" class="text-right">
  48. <u-button :custom-style="btnStyle" @click="showTip" shape="circle" size="medium">提醒发货</u-button>
  49. </view>
  50. <view v-if="item.orderStateDictValue=='已发货'" 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.orderStateDictValue=='已完成'" 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, existPayPwd
  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. this.showLeavePsw = false
  340. setTimeout(()=>{
  341. // 跳转到支付完成界面
  342. uni.navigateTo({
  343. url:"/pages/toOrder/payFinish?id=" + this.orderId
  344. })
  345. },300)
  346. } else{
  347. uni.showToast({
  348. title: res.message,
  349. icon: 'none'
  350. })
  351. }
  352. })
  353. },
  354. // 提醒发货
  355. showTip() {
  356. uni.showToast({
  357. title: '已提醒商家发货',
  358. icon: 'none'
  359. })
  360. },
  361. // 查看物流
  362. showLog(item) {
  363. console.log(item, '111111')
  364. uni.navigateTo({
  365. url: "/pages/order/LogList?id=" + item.id
  366. })
  367. },
  368. // 详细页
  369. viewRow(item) {
  370. // if (!this.$hasPermissions('M_backlog_detail_mobile')) {
  371. // return
  372. // }
  373. console.log(item, '111111')
  374. // 已完成的
  375. uni.navigateTo({
  376. url: "/pages/order/orderDetail?id=" + item.id
  377. })
  378. },
  379. }
  380. }
  381. </script>
  382. <style lang="scss">
  383. page {
  384. height: 100%;
  385. width: 100%;
  386. background: #F8F8F8;
  387. }
  388. .pagesCons {
  389. height: 100%;
  390. width: 100%;
  391. background: #F8F8F8;
  392. display: flex;
  393. flex-direction: column;
  394. .text-right {
  395. text-align: right;
  396. }
  397. .tab-body {
  398. flex: 1;
  399. display: flex;
  400. flex-direction: column;
  401. .uTabs {
  402. border-bottom: 1px solid #EEEEEE;
  403. box-shadow: 1px 1px 3px #eeeeee;
  404. }
  405. .check-list {
  406. flex: 1;
  407. overflow-y: scroll;
  408. .swiper-item {
  409. width: 100%;
  410. height: 100%;
  411. overflow: hidden;
  412. .scroll-view {
  413. width: 100%;
  414. height: 100%;
  415. overflow: auto;
  416. }
  417. }
  418. }
  419. // 列表样式
  420. .check-order-list {
  421. background: #ffffff;
  422. padding: 10upx 20upx;
  423. margin: 25upx;
  424. border-radius: 6upx;
  425. box-shadow: 1px 1px 3px #EEEEEE;
  426. font-size: 28upx;
  427. .check-row {
  428. display: flex;
  429. align-items: center;
  430. padding: 20upx 10upx;
  431. .icon-xian {
  432. text-align: right;
  433. width: 40upx;
  434. }
  435. &:first-child {
  436. border-bottom: 1px dashed #F8F8F8;
  437. .createDate {
  438. color: #666;
  439. font-size: 26upx;
  440. margin-left: 10upx;
  441. }
  442. }
  443. &:last-child {
  444. border-top: 1px dashed #F8F8F8;
  445. }
  446. >view {
  447. &:first-child {
  448. flex: 1;
  449. }
  450. }
  451. }
  452. // 订单中商品列表
  453. .bundle-list {
  454. display: flex;
  455. padding: 20upx 10upx;
  456. font-size: 28upx;
  457. border-bottom: 1px solid #F8F8F8;
  458. .img-cont {
  459. width: 158rpx;
  460. height: 140upx;
  461. border-radius: 15upx;
  462. overflow: hidden;
  463. >image {
  464. width: 100%;
  465. height: 100%;
  466. }
  467. }
  468. >view {
  469. &:last-child {
  470. flex: 1;
  471. padding: 10upx 0;
  472. margin-left: 20upx;
  473. display: flex;
  474. flex-direction: column;
  475. justify-content: space-between;
  476. }
  477. }
  478. .bundle-num {
  479. display: flex;
  480. justify-content: space-between;
  481. }
  482. }
  483. .btn-cont {
  484. width: 180upx;
  485. font-size: 30upx;
  486. }
  487. .price-text {
  488. font-size: 20upx;
  489. margin-left: 10upx;
  490. }
  491. .price-num {
  492. font-size: 32upx;
  493. color: red;
  494. }
  495. .total-text {
  496. margin-right: 50upx;
  497. }
  498. .money-total {
  499. margin-right: 10upx;
  500. }
  501. }
  502. }
  503. // 支付密码弹窗
  504. .slot-content{
  505. padding: 30upx 0;
  506. display: flex;
  507. flex-direction: column;
  508. align-items: center;
  509. justify-content: space-between;
  510. .text-cont{
  511. width: 100%;
  512. padding: 60upx 0;
  513. text-align: center;
  514. .num-big{
  515. font-size: 40upx;
  516. color: red;
  517. }
  518. }
  519. .footer{
  520. width: 80%;
  521. border-bottom: 1px solid #b1b1b1;
  522. margin-bottom: 30upx;
  523. }
  524. }
  525. }
  526. </style>