123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- <template>
- <view>
- <view class="goback" v-if="this.show == true">
- <view class="gb-bg">
- <view class="check">
- 确认要离开收银台吗?
- </view>
- <view class="toast">
- 订单已提交成功,超时未支付将会取消订单,请尽快完成支付。
- </view>
- <view class="but">
- <view class="no" @click="no()">
- 取消支付
- </view>
- <view class="yes" @click="yes()">
- 继续支付
- </view>
- </view>
- </view>
- </view>
- <view class="payBlock">
- <view class="payMoney">
- <text style="font-size: 32rpx;">¥</text>{{payData.payMoney.toFixed(2)}}
- </view>
- <view class="payToast">需支付</view>
- </view>
- <view class="payCheck">
- <view class="typeBlock border-b" @click="type = 2">
- <view class="payCheckTitle">
- <image src="../../../static/alipay.png" class="payTypeImage"></image>
- <view class="payTitle">支付宝支付</view>
- </view>
- <image src="../../../static/sel@2x.png" v-if="type === 2" class="checkIcon"></image>
- <image src="../../../static/unsel.png" v-else class="checkIcon"></image>
- </view>
- <view class="typeBlock border-b" @click="type = 1">
- <view class="payCheckTitle">
- <image src="../../../static/wechat.png" class="payTypeImage"></image>
- <view class="payTitle">微信支付</view>
- </view>
- <image src="../../../static/sel@2x.png" v-if="type === 1" class="checkIcon"></image>
- <image src="../../../static/unsel.png" v-else class="checkIcon"></image>
- </view>
- <view class="typeBlock" @click="type = 3">
- <view class="payCheckTitle">
- <image src="../../../static/yu‘e@2x.png" class="payTypeImage"></image>
- <view class="payTitle">余额支付</view>
- <view class="balance">(可用¥{{balance}})</view>
- </view>
- <image src="../../../static/sel@2x.png" v-if="type === 3" class="checkIcon"></image>
- <image src="../../../static/unsel.png" v-else class="checkIcon"></image>
- </view>
- </view>
- <view class="payBtn" @click="toPay()">
- {{type==1?'微信':type==2?'支付宝':'余额'}}支付¥{{payData.payMoney.toFixed(2)}}
- </view>
- </view>
- </template>
- <script>
- import {
- getUserInfo
- } from "../../../api/myApi.js"
- import {
- carwashOrder
- } from "@/api/carWash.js"
- import {
- payOrder
- } from '../../../api/maintain.js'
- export default {
- data() {
- return {
- show: false,
- payData: {},
- type: 1,
- balance: 0,
- orderInfo: '',
- page: ''
- };
- },
- onLoad(options) {
- this.payData = JSON.parse(options.params)
- this.page = options.page
- this.getUser()
- console.log(this.payData);
- },
- onBackPress(e) {
- if (e.from == 'backbutton') {
- this.show = true
- return true;
- } else if (e.from == 'navigateBack') {
- return false;
- }
- },
- methods: {
- no() {
- uni.showToast({
- icon: "none",
- title: "顾客取消支付"
- })
- setTimeout(()=>{
- uni.navigateBack({
- delta: 1
- })
- }, 1000)
- },
- yes() {
- this.show = false
- },
- toPay() {
- this.payData.payType = this.type
- if (this.payData.payType === 3) {
- if (this.payData.payMoney > this.balance) {
- return uni.showToast({
- icon: "none",
- title: "余额不足"
- })
- }
- }
- if (this.page === 'carwash') {
- this.carWash()
- } else if (this.page === 'maintenance') {
- this.maintenance()
- }
- },
- getUser() {
- getUserInfo().then(res => {
- this.balance = res.data.balance
- })
- },
- carWash() {
- carwashOrder(this.payData).then(res => {
- if (this.payData.payType === 1 || this.payData.payType === 2) {
- if (this.payData.payType === 1) {
- this.orderInfo = res.data.wechatOrder
- } else if (this.payData.payType === 2) {
- this.orderInfo = res.data.zfbOrder
- }
- this.payment()
- }
- })
- },
- maintenance() {
- payOrder(this.payData).then(res => {
- if (this.payData.payType === 1 || this.payData.payType === 2) {
- if (this.payData.payType === 1) {
- this.orderInfo = res.data.wechatOrder
- } else if (this.payData.payType === 2) {
- this.orderInfo = res.data.zfbOrder
- }
- this.payment()
- }
- })
- },
- payment() {
- let payType = this.payData.payType === 1 ? 'wxpay' : 'alipay'
- console.log('订单西悉尼', this.orderInfo);
- uni.requestPayment({
- provider: payType,
- orderInfo: this.orderInfo,
- success: (res) => {
- console.log('下单支付===============>', res);
- if (this.page === 'carwash') {
- uni.redirectTo({
- url: '/pages/preCarWash/washOrder/index?token=' + uni.getStorageSync(
- 'token')
- })
- } else if (this.page === 'maintenance') {
- uni.redirectTo({
- url: '/pages/maintenance/maintainOrder/index?token=' + uni
- .getStorageSync('token')
- })
- }
- },
- fail: (res) => {
- console.log(res, '支付失败fail');
- uni.showToast({
- icon: 'none',
- title: '支付失败:' + res.errMsg + ',code:' + res.code + ',errCode:' + res
- .errCode
- })
- }
- })
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #F5F5F5;
- }
- .goback {
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.5);
- position: fixed;
- z-index: 999999999999999999;
- top: 0;
- .gb-bg {
- width: 600rpx;
- height: 378rpx;
- background: #FFFFFF;
- border-radius: 16rpx;
- box-sizing: border-box;
- padding: 50rpx 70rpx;
- margin: 0 auto;
- margin-top: 50%;
- .check {
- height: 29rpx;
- font-size: 30rpx;
- font-weight: bold;
- color: #333333;
- line-height: 40rpx;
- text-align: center;
- }
- .toast {
- width: 467rpx;
- height: 63rpx;
- font-size: 26rpx;
- font-weight: 500;
- color: #333333;
- line-height: 36rpx;
- margin: 56rpx 0;
- }
- .but {
- display: flex;
- justify-content: space-between;
- .no {
- width: 210rpx;
- height: 70rpx;
- background: #FFFFFF;
- border: 1px solid #0060FF;
- border-radius: 35rpx;
- font-size: 28rpx;
- font-weight: 500;
- color: #0062FF;
- line-height: 70rpx;
- text-align: center;
- }
- .yes {
- width: 210rpx;
- height: 70rpx;
- background: linear-gradient(0deg, #005AFF 0%, #0078FF 100%);
- border-radius: 35rpx;
- font-size: 28rpx;
- font-weight: 500;
- color: #FFFFFF;
- line-height: 70rpx;
- text-align: center;
- }
- }
- }
- }
- .payBlock {
- width: 100%;
- height: 225rpx;
- background-color: $uni-text-color-inverse;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- border-radius: 0 0 16rpx 16rpx;
- margin-bottom: 30rpx;
- .payMoney {
- font: {
- size: 50rpx;
- weight: bold;
- }
- ;
- color: $uni-text-color;
- }
- .payToast {
- font: {
- size: 24rpx;
- weight: 500;
- }
- ;
- color: $uni-text-color-grey;
- }
- }
- .payCheck {
- width: calc(100% - 80rpx);
- padding: 0 40rpx;
- background-color: $uni-text-color-inverse;
- border-radius: 16px;
- .typeBlock {
- width: calc(100% - 10rpx);
- height: 125rpx;
- padding-left: 10rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .payCheckTitle {
- height: 100%;
- display: flex;
- align-items: center;
- .payTypeImage {
- width: 44rpx;
- height: 44rpx;
- }
- .payTitle {
- font: {
- size: 30rpx;
- weight: 500;
- }
- ;
- color: $uni-text-color;
- margin-left: 24rpx;
- }
- .balance {
- font: {
- size: 30rpx;
- weight: 500;
- }
- ;
- color: $uni-text-color-grey;
- margin-left: 17rpx;
- }
- }
- .checkIcon {
- width: 36rpx;
- height: 36rpx;
- }
- }
- .border-b {
- border-bottom: 1px solid #EEEEEE;
- }
- }
- .payBtn {
- width: 600rpx;
- height: 90rpx;
- text-align: center;
- line-height: 90rpx;
- background: linear-gradient(0deg, #0078FF 0%, #005AFF 100%);
- font: {
- size: 32rpx;
- weight: 500;
- }
- ;
- color: $uni-text-color-inverse;
- border-radius: 45rpx;
- margin: 174rpx auto;
- }
- </style>
|