registerList.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. <template>
  2. <view class="content">
  3. <!-- <view class="jg"></view> -->
  4. <view class="navbar">
  5. <view class="nav-item" v-for="(item, index) in registerList" :key="index"
  6. :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.title }}</view>
  7. </view>
  8. <swiper :interval="3000" :duration="200" :style="{'height': height}" class="swiper-wrapper"
  9. :current="tabCurrentIndex" @change="changeTab">
  10. <swiper-item v-for="(item, index) in registerList">
  11. <scroll-view scroll-y="true" :style="{'height': height}">
  12. <empty v-if="item.loaded === true && item.list.length === 0"></empty>
  13. <view v-for="(itemt,index) in item.list" class="list">
  14. <view class="" v-if="itemt.rebuy == 0">
  15. <view class="order-id">账号{{itemt.account}}
  16. <view class="fg">
  17. 注册
  18. </view>
  19. </view>
  20. <view class="time">
  21. <view class="">父接点:{{itemt.account}}</view>
  22. <view class="">接点区域:{{itemt.parent_area}}</view>
  23. </view>
  24. <view class="paynum" v-if="tabCurrentIndex == 0">
  25. 待支付¥{{itemt.pay_price}}
  26. </view>
  27. <view class="zfqx" v-if="tabCurrentIndex == 0">
  28. <view class="btn" @click="openselect(itemt)">
  29. 支付
  30. </view>
  31. <view class="btn qx" @click="cancelRegister(itemt)">
  32. 取消
  33. </view>
  34. </view>
  35. </view>
  36. <view class="" v-if="itemt.rebuy == 1">
  37. <view class="order-id">
  38. 报单编号{{itemt.order_id}}
  39. <view class="fg">
  40. 复购
  41. </view>
  42. </view>
  43. <view class="time">
  44. {{itemt.add_time | getTime}}
  45. </view>
  46. <view class="paynum" v-if="tabCurrentIndex == 0">
  47. 待支付¥{{itemt.pay_price}}
  48. </view>
  49. <view class="zfqx" v-if="tabCurrentIndex == 0">
  50. <view class="btn" @click="openselect(itemt)">
  51. 支付
  52. </view>
  53. <view class="btn qx" @click="cancelRegister(itemt)">
  54. 取消
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <uni-load-more :status="item.loadingType"></uni-load-more>
  60. </scroll-view>
  61. </swiper-item>
  62. </swiper>
  63. <uni-popup ref="popupPay" type="bottom">
  64. <view class="popup-box">
  65. <view class="popup-pay">
  66. <view class="paybox-top flex">
  67. <view class="type">选择支付方式</view>
  68. <view class="image" @click="close">
  69. <image src="../../static/img/x.png" mode="aspectFill"></image>
  70. </view>
  71. </view>
  72. <view class="paybox-main flex">
  73. <view class="zftype flex">
  74. <image src="../../static/img/zifubao.png" mode="aspectFill"></image>
  75. <view class="zf">支付宝支付</view>
  76. </view>
  77. <label class="radio1" @click="changePayType(4)"><radio style="transform:scale(0.7)" value="" :checked="paytype == 'ali'" color="#5dbc7c"></radio></label>
  78. </view>
  79. <view class="paybox-main flex">
  80. <view class="zftype flex">
  81. <image src="../../static/img/weixin.png" mode="aspectFill"></image>
  82. <view class="zf">微信支付</view>
  83. </view>
  84. <label class="radio1" @click="changePayType(1)">
  85. <radio style="transform:scale(0.7)" value="" :checked="paytype == 'weixin'" color="#5dbc7c">
  86. </radio>
  87. </label>
  88. </view>
  89. <view class="paybox-main flex">
  90. <view class="zftype flex">
  91. <image src="../../static/img/yue.png" mode="aspectFill"></image>
  92. <view class="zf">余额支付</view>
  93. </view>
  94. <label class="radio" @click="changePayType(2)">
  95. <radio style="transform:scale(0.7)" class="rad" value="" :checked="paytype == 'yue'"
  96. color="#5dbc7c"></radio>
  97. </label>
  98. </view>
  99. <view class="paybox-main flex">
  100. <view class="zftype flex">
  101. <image src="../../static/img/yong.png" mode="aspectFill"></image>
  102. <view class="zf">佣金支付</view>
  103. </view>
  104. <label class="radio1" @click="changePayType(3)">
  105. <radio style="transform:scale(0.7)" value="" :checked="paytype == 'brokerage'"
  106. color="#5dbc7c"></radio>
  107. </label>
  108. </view>
  109. </view>
  110. <view class="buttom flex">
  111. <view class="heji">
  112. 合计:
  113. <text>
  114. <text class="money">{{ payitem.pay_price }}</text>
  115. </text>
  116. </view>
  117. <view class="zhifu" @click="pay">立即支付</view>
  118. </view>
  119. </view>
  120. </uni-popup>
  121. </view>
  122. </template>
  123. <script>
  124. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  125. import empty from '@/components/empty';
  126. getTime
  127. import {
  128. getTime
  129. } from '@/utils/rocessor.js';
  130. import {
  131. getRegisterList,
  132. cancelRegister,
  133. payRegister
  134. } from '@/api/user.js'
  135. import {
  136. orderData,
  137. getUserInfo,
  138. service
  139. } from '@/api/user.js';
  140. import {
  141. getSpreadCount
  142. } from '@/api/user.js';
  143. export default {
  144. components: {
  145. uniLoadMore,
  146. empty
  147. },
  148. data() {
  149. return {
  150. payLoding: false, //判断是否支付中
  151. brokerage: 0,
  152. now_money: 0,
  153. payitem: {},
  154. paytype: '',
  155. height: '',
  156. tabCurrentIndex: 0,
  157. registerList: [{
  158. status: 0,
  159. title: '未支付',
  160. loadingType: 'more',
  161. list: [],
  162. page: 1, //当前页数
  163. limit: 10 //每次信息条数
  164. },
  165. {
  166. status: 1,
  167. title: '已支付',
  168. loadingType: 'more',
  169. list: [],
  170. page: 1, //当前页数
  171. limit: 10 //每次信息条数
  172. }
  173. ]
  174. }
  175. },
  176. filters: {
  177. getTime
  178. },
  179. onReady(res) {
  180. var _this = this;
  181. uni.getSystemInfo({
  182. success: resu => {
  183. const query = uni.createSelectorQuery();
  184. query.select('.swiper-wrapper').boundingClientRect();
  185. query.exec(function(res) {
  186. _this.height = resu.windowHeight - res[0].top + 'px';
  187. console.log('打印页面的剩余高度', _this.height);
  188. });
  189. },
  190. fail: res => {}
  191. });
  192. },
  193. onLoad() {
  194. this.getRegisterList()
  195. this.getUserInfo()
  196. },
  197. methods: {
  198. getUserInfo() {
  199. let obj = this
  200. getUserInfo().then(({
  201. data
  202. }) => {
  203. console.log(data, 111)
  204. obj.now_money = +data.now_money
  205. })
  206. getSpreadCount({}, 3).then(({
  207. data
  208. }) => {
  209. console.log(data);
  210. this.brokerage = +data.count;
  211. });
  212. },
  213. //关闭支付弹窗
  214. close() {
  215. this.$refs.popupPay.close();
  216. },
  217. // 修改支付方式
  218. changePayType(type) {
  219. // this.payType = type;
  220. if (type == 1) {
  221. this.paytype = 'weixin';
  222. }
  223. if (type == 2) {
  224. this.paytype = 'yue';
  225. }
  226. if (type == 3) {
  227. this.paytype = 'brokerage';
  228. }
  229. if (type == 4) {
  230. this.paytype = 'ali';
  231. }
  232. },
  233. getRegisterList(type) {
  234. let obj = this;
  235. let index = obj.tabCurrentIndex;
  236. let navItem = obj.registerList[index];
  237. if (navItem.loadingType == 'loading' || navItem.loadingType == 'noMore') {
  238. return;
  239. }
  240. if (type == 'tabChange' && navItem.loaded == 'loaded') {
  241. return;
  242. }
  243. navItem.loadingType == 'loading';
  244. getRegisterList({
  245. page: navItem.page,
  246. limit: navItem.limit,
  247. type: navItem.status
  248. }).then(res => {
  249. console.log(res, 'ddd')
  250. navItem.list = navItem.list.concat(res.data);
  251. if (navItem.limit == res.data.length) {
  252. navItem.loadingType = 'more';
  253. return;
  254. } else {
  255. navItem.loadingType = 'noMore';
  256. }
  257. uni.hideLoading();
  258. this.$set(navItem, 'loaded', true);
  259. });
  260. },
  261. //顶部tab点击
  262. tabClick(index) {
  263. this.tabCurrentIndex = index;
  264. },
  265. //swiper 切换
  266. changeTab(e) {
  267. this.tabCurrentIndex = e.target.current;
  268. this.getRegisterList('tabChange');
  269. },
  270. //取消订单
  271. cancelRegister(item) {
  272. let obj = this
  273. cancelRegister({}, item.id).then(res => {
  274. uni.showToast({
  275. title: '取消成功',
  276. duration: 2000
  277. });
  278. let s = obj.registerList[obj.tabCurrentIndex].list.indexOf(item);
  279. obj.registerList[obj.tabCurrentIndex].list.splice(s, 1);
  280. }).catch(err => {
  281. console.log(err)
  282. })
  283. },
  284. pay() {
  285. let obj = this;
  286. // 判断是否余额不足
  287. let id = obj.payitem.id
  288. if (obj.paytype == 'yue' && +obj.now_money < +obj.payitem.pay_price) {
  289. uni.showModal({
  290. title: '提示',
  291. content: '账户余额不足!',
  292. showCancel: false,
  293. success: res => {},
  294. fail: () => {},
  295. complete: () => {}
  296. });
  297. return;
  298. }
  299. if (obj.paytype == 'brokerage' && +obj.brokerage < +obj.payitem.pay_price) {
  300. uni.showModal({
  301. title: '提示',
  302. content: '账户佣金不足!',
  303. showCancel: false,
  304. success: res => {},
  305. fail: () => {},
  306. complete: () => {}
  307. });
  308. return;
  309. }
  310. // 支付中
  311. obj.payLoding = true;
  312. uni.showLoading({
  313. title: '支付中',
  314. mask: true
  315. });
  316. // #ifdef H5
  317. // 获取当前是否为微信浏览器
  318. obj.froms = uni.getStorageSync('weichatBrowser') || '';
  319. // #endif
  320. let data = {
  321. paytype: obj.paytype,
  322. // #ifdef H5
  323. from: obj.froms ? 'weixin' : 'H5', //来源
  324. // #endif
  325. // #ifdef MP-WEIXIN
  326. from: 'routine', //来源
  327. // #endif
  328. // #ifdef APP-PLUS
  329. from: 'app' //来源
  330. // #endif
  331. }
  332. obj.$refs.popupPay.close();
  333. payRegister(data, id).then(res => {
  334. // #ifdef APP-PLUS
  335. if (obj.paytype == 'weixin' || obj.paytype == 'routine') {
  336. console.log(res,'111111')
  337. let da = res.data.result.jsConfig;
  338. console.log('--weixinda--', da);
  339. let data = {
  340. appid:da.appid,
  341. noncestr: da.noncestr,
  342. package: da.package,
  343. partnerid:da.partnerid,
  344. prepayid:da.prepayid,
  345. timestamp: da.timestamp,
  346. sign:da.sign
  347. };
  348. console.log('--data--', data);
  349. uni.requestPayment({
  350. provider: 'wxpay',
  351. orderInfo: data,
  352. success(res) {
  353. let s = obj.registerList[obj.tabCurrentIndex].list.indexOf(obj.payitem);
  354. obj.registerList[obj.tabCurrentIndex].list.splice(s, 1);
  355. uni.showToast({
  356. title: '支付成功',
  357. duration: 2000
  358. });
  359. console.log(res)
  360. },
  361. fail(res) {
  362. console.log("微信掉起失败")
  363. console.log(res,'失败')
  364. }
  365. })
  366. }
  367. if (obj.paytype == 'ali') {
  368. console.log(res, 'url');
  369. const url = res.data.result.jsConfig;
  370. uni.requestPayment({
  371. provider: 'alipay',
  372. orderInfo: url,
  373. success: res => {
  374. console.log(res);
  375. let s = obj.registerList[obj.tabCurrentIndex].list.indexOf(obj.payitem);
  376. obj.registerList[obj.tabCurrentIndex].list.splice(s, 1);
  377. uni.showToast({
  378. title: '支付成功',
  379. duration: 2000
  380. });
  381. },
  382. fail: e => {
  383. console.log(e);
  384. },
  385. complete: () => {}
  386. });
  387. obj.payLoding = false;
  388. }
  389. // #endif
  390. if(this.paytype == 'yue' || this.paytype == "brokerage"){
  391. let s = obj.registerList[obj.tabCurrentIndex].list.indexOf(obj.payitem);
  392. obj.registerList[obj.tabCurrentIndex].list.splice(s, 1);
  393. uni.showToast({
  394. title: '支付成功',
  395. duration: 2000
  396. });
  397. }
  398. uni.hideLoading()
  399. }).catch(err => {
  400. uni.hideLoading()
  401. console.log(err)
  402. })
  403. },
  404. //调出支付选择
  405. openselect(item) {
  406. let obj = this
  407. obj.payitem = item
  408. obj.$refs.popupPay.open();
  409. },
  410. },
  411. }
  412. </script>
  413. <style lang="scss" scoped>
  414. page {
  415. height: 100%;
  416. background-color: #f8f6f6;
  417. }
  418. .content {
  419. height: 100%;
  420. .jg {
  421. height: 20rpx;
  422. background-color: #eee;
  423. }
  424. .navbar {
  425. display: flex;
  426. height: 100rpx;
  427. padding: 0 5rpx;
  428. background: #fff;
  429. box-shadow: 0 1rpx 5rpx rgba(0, 0, 0, 0.06);
  430. position: relative;
  431. z-index: 10;
  432. // margin-top: 25rpx;
  433. .nav-item {
  434. flex: 1;
  435. display: flex;
  436. justify-content: center;
  437. align-items: center;
  438. height: 100%;
  439. font-size: 15px;
  440. color: #999999;
  441. position: relative;
  442. &.current {
  443. color: #333333;
  444. &:after {
  445. content: '';
  446. position: absolute;
  447. left: 50%;
  448. bottom: 0;
  449. transform: translateX(-50%);
  450. width: 44px;
  451. height: 0;
  452. border-bottom: 2px solid #3f7c1f;
  453. }
  454. }
  455. }
  456. }
  457. .swiper-wrapper {}
  458. }
  459. .list {
  460. padding: 30rpx 30rpx 20rpx;
  461. background-color: #fff;
  462. margin-bottom: 20rpx;
  463. .paynum {
  464. padding-top: 10rpx;
  465. padding-bottom: 10rpx;
  466. font-size: 30rpx;
  467. font-family: PingFang SC;
  468. font-weight: bold;
  469. color: #FF0000;
  470. }
  471. .order-id {
  472. font-size: 30rpx;
  473. font-family: PingFang SC;
  474. font-weight: 500;
  475. color: #333;
  476. position: relative;
  477. .fg {
  478. line-height: 40rpx;
  479. width: 80rpx;
  480. background-color: #3F7C1F;
  481. border-radius: 10rpx;
  482. color: #fff;
  483. font-size: 24rpx;
  484. text-align: center;
  485. position: absolute;
  486. right: 0;
  487. top: 0;
  488. }
  489. }
  490. .time {
  491. padding-top: 10rpx;
  492. padding-bottom: 10rpx;
  493. font-size: 26rpx;
  494. font-family: PingFang SC;
  495. font-weight: 500;
  496. color: #AEAEAE;
  497. display: flex;
  498. view {
  499. margin-right: 20rpx;
  500. }
  501. }
  502. .zfqx {
  503. display: flex;
  504. justify-content: flex-end;
  505. border-top: 1px dashed #999;
  506. padding-top: 20rpx;
  507. .btn {
  508. width: 150rpx;
  509. // height: 50rpx;
  510. // background-color: #d7eeb6;
  511. color: #3F7C1F;
  512. border: 1px solid #3F7C1F;
  513. border-radius: 10rpx;
  514. text-align: center;
  515. line-height: 50rpx;
  516. // color: #FF0000;
  517. }
  518. .qx {
  519. margin-left: 30rpx;
  520. border: #999 solid 1px;
  521. color: #333;
  522. }
  523. }
  524. }
  525. .popup-box {
  526. position: relative;
  527. z-index: 100;
  528. width: 100%;
  529. height: auto;
  530. background: #ffffff;
  531. .popup-pay {
  532. position: relative;
  533. justify-content: space-between;
  534. padding: 0rpx 25rpx 32rpx 25rpx;
  535. .paybox-top {
  536. padding-top: 38rpx;
  537. width: 100%;
  538. .type {
  539. font-size: 28rpx;
  540. font-family: PingFang SC;
  541. font-weight: bold;
  542. color: #333333;
  543. }
  544. .image {
  545. padding-right: 24rpx;
  546. padding-bottom: 10rpx;
  547. image {
  548. width: 16rpx;
  549. height: 16rpx;
  550. }
  551. }
  552. }
  553. .paybox-main {
  554. width: 100%;
  555. margin-top: 54rpx;
  556. .zftype {
  557. padding-left: 5rpx;
  558. image {
  559. width: 38rpx;
  560. height: 40rpx;
  561. }
  562. .zf {
  563. padding-left: 18rpx;
  564. font-size: 28rpx;
  565. font-family: PingFang SC;
  566. font-weight: 400;
  567. color: #3f454b;
  568. }
  569. }
  570. }
  571. }
  572. .buttom {
  573. position: relative;
  574. z-index: 100;
  575. width: 100%;
  576. height: 113rpx;
  577. padding-top: 20rpx;
  578. align-items: center;
  579. .heji {
  580. height: 100%;
  581. width: 50%;
  582. padding-left: 23rpx;
  583. padding-top: 20rpx;
  584. font-size: 28rpx;
  585. font-family: PingFang SC;
  586. font-weight: 400;
  587. color: #3f454b;
  588. text {
  589. font-size: 24rpx;
  590. font-family: PingFang SC;
  591. font-weight: bold;
  592. color: #ff0000;
  593. .money {
  594. font-size: 36rpx;
  595. }
  596. }
  597. }
  598. .zhifu {
  599. width: 50%;
  600. height: 92rpx;
  601. background: #5dbc7c;
  602. text-align: center;
  603. line-height: 92rpx;
  604. font-size: 32rpx;
  605. font-family: PingFang SC;
  606. font-weight: bold;
  607. color: #ffffff;
  608. }
  609. }
  610. }
  611. </style>