123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585 |
- <template>
- <view class="container cashier">
- <view class="container-cash clearfix">
- <view class="container-wrapper">
- <view class="pay-content">
- <view class="pay-p"><text>待付金额</text></view>
- <view class="pay-money">
- <text class="pay-sm">¥</text>
- <text class="pay-bg">{{payableAmount | NumFormat}}</text>
- </view>
- <view class="pay-mouth">套餐:{{ payableMouth }}</view>
- </view>
- <view class="pay-check">
- <view class="check-title"><view class="text">选择支付方式</view></view>
- <view class="pay-checked">
- <view class="pay-item" :class="{ 'current' : tabCurrentIndex === 0}" @click="tabClick(0)" >
- <view class="item-l">
- <view class="item-icon"><text class="iconfont icon-weixinzhifu"></text></view>
- <view class="item-texts"><text>微信支付</text></view>
- </view>
- <view class="item-r">
- <text class="iconfont icon-duigou"></text>
- </view>
- </view>
- <view class="pay-item" :class="{ 'current' : tabCurrentIndex === 1}" @click="tabClick(1)" >
- <view class="item-l">
- <view class="item-icon"><text class="iconfont icon-qiyewangyinzhifu"></text></view>
- <view class="item-text">
- <view class="txt-p">企业网银支付</view>
- <view class="txt-t">需要在电脑端汇款</view>
- </view>
- </view>
- <view class="item-r">
- <text class="iconfont icon-duigou"></text>
- </view>
- </view>
- <view class="pay-item" :class="{ 'current' : tabCurrentIndex === 2}" @click="tabClick(2)" >
- <view class="item-l">
- <view class="item-icon"><text class="iconfont icon-gerenwangyinzhifu"></text></view>
- <view class="item-text">
- <view class="txt-p">个人网银支付</view>
- <view class="txt-t">需要在电脑端汇款</view>
- </view>
- </view>
- <view class="item-r">
- <text class="iconfont icon-duigou"></text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="pay-button">
- <view class="btn" @click.stop="goOrderCash" :style="{'background':btnColor}">{{buttonText}}</view>
- </view>
- </view>
- <view class="alert spec" :class="specClass" v-if="isShowTip">
- <!-- 选择支付弹窗说明 -->
- <view class="payun-alert" @tap="hideTips">
- <view class="content">
- <view class="title">
- <text>支付链接</text>
- <text class="iconfont icon-iconfontguanbi" @click.stop="hideTips"></text>
- </view>
- <view class="text-content">
- <view class="text">请复制以下链接,并发送至电脑端,在浏览器访问该链接并选择银行尽快完成支付</view>
- <view class="text-p">{{payHttpUrl}}</view>
- <view class="text-b">链接有效期为72小时</view>
- </view>
- <view class="text-button" @click.stop="clipboard(payHttpUrl)">复制链接</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- const thorui = require("@/components/clipboard/clipboard.thorui.js")
- export default{
- data(){
- return{
- orderId:'',
- payableAmount:4800,
- emptyWrapperH: '',
- payorderId:'',
- isIphoneX:this.$store.state.isIphoneX,
- CustomBar:this.CustomBar,// 顶部导航栏高度
- tabCurrentIndex:0,
- isShowTip:false,
- isReceiptStatus:false,
- buttonText:'使用微信支付',
- btnColor:'#09BB07',
- receiptStatus:'',
- invoiceStatus:false,
- optionType:'',
- onlinePayFlag:'',
- pageType:'',
- payableMouth:'12个月',
- payHttpUrl:'https://www.so.com/link?'
- }
- },
- onLoad(option) {
- this.initData(option)
- },
- filters: {
- NumFormat(value) {
- if(!value) return '0.00';
- /*原来用的是Number(value).toFixed(0),这样取整时有问题,例如0.51取整之后为1,感谢Nils指正*/
- /*后来改成了 Number(value)|0,但是输入超过十一位就为负数了,具体见评论 */
- var intPart = Number(value) - Number(value)%1; //获取整数部分(这里是windy93的方法)
- var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); //将整数部分逢三一断
- var floatPart = ".00"; //预定义小数部分
- var value2Array = value.toString().split(".");
- //=2表示数据有小数位
- if(value2Array.length == 2) {
- floatPart = value2Array[1].toString(); //拿到小数部分
- if(floatPart.length == 1) { //补0,实际上用不着
- return intPartFormat + "." + floatPart + '0';
- } else {
- return intPartFormat + "." + floatPart;
- }
- } else {
- return intPartFormat + floatPart;
- }
- }
- },
- methods:{
- initData(e){
- console.log(e)
- this.orderId = e.orderId;
- this.payOrderId ='#'+e.orderId+'#';
- this.optionType = e.type;
- this.PayOrderCheckoutCounter(this.orderId)
- },
- PayOrderCheckoutCounter(orderId){
- this.PayService.PayOrderCheckoutCounter({orderId:orderId}).then(response =>{
- let data = response.data.order
- this.payableAmount = data.payableAmount - data.receiptAmount //待付金额
- this.receiptStatus = data.receiptStatus
- this.onlinePayFlag = data.onlinePayFlag
- //判断线上线下显示
- if(this.optionType == 'onlinePay'){
- this.invoiceStatus = true
- }else{
- this.invoiceStatus = data.invoiceStatus
- }
- if(data.receiptAmount>0){
- this.isReceiptStatus = false
- }else{
- this.isReceiptStatus = true
- }
- }).catch(error =>{
- this.$util.msg(error.msg,2000)
- })
- },
- goOrderCash(){
- // // 友盟埋点收集选择支付方式
- // if(process.env.NODE_ENV != 'development'){
- // this.$uma.trackEvent('Um_Event_ChooseWechatPay', {
- // Um_Key_PageName: '线上支付',
- // Um_Key_SourcePage: '选择支付',
- // Um_Key_PayName:`${this.buttonText}`,
- // Um_Key_PayOrderID:`${this.orderId}`
- // })
- // }
- switch(this.tabCurrentIndex){
- case 0:
- this.MiniWxPayFor();
- break;
- case 1:
- this.BuildCatenate();
- break;
- case 2:
- this.BuildCatenate();
- break;
- }
- },
- async MiniWxPayFor(){// 使用微信支付
- const WechatCode = authorize.getCode('weixin')
- this.PayService.WeChatMiniWxPay(
- {
- payAmount:this.accMul(this.payAmount,100),
- payWay:"WEIXIN",
- code:wechatcode,
- orderId:this.orderId
- }
- ).then(response =>{
- // // 友盟埋点收集微信支付
- // if(process.env.NODE_ENV != 'development'){
- // this.$uma.trackEvent('Um_Event_ConfirmWechatPay', {
- // Um_Key_PageName: '微信支付',
- // Um_Key_SourcePage: '线上支付',
- // Um_Key_PayName:`${this.buttonText}`,
- // Um_Key_PayOrderID:`${this.orderId}`
- // })
- // }
- let PayInfo = JSON.parse(response.data.data.payInfo);
- this.WxRequestPayment(PayInfo)
- }).catch(error =>{
- this.$util.msg(error.msg,2000)
- })
- },
- WxRequestPayment(data){// 微信支付Api
- let self = this
- wx.requestPayment({
- 'timeStamp': data.timeStamp,
- 'nonceStr': data.nonceStr,
- 'package': data.package,
- 'signType': data.signType,
- 'paySign': data.paySign,
- 'success':function(res){
- wx.reLaunch({url: '/pages/tabBar/user/user'});
- },
- 'fail':function(res){
- self.$util.msg('用户取消支付~')
- },
- 'complete':function(res){
-
- }
- })
- },
- BuildCatenate(){// 生成网银支付链接
- this.isShowTip = true
- // this.PayService.PayOrderPayLink(
- // {
- // unpaidAmount:this.payAmount,
- // orderId:this.orderId,
- // payType:this.payType,
- // }
- // ).then(response =>{
- // this.payHttpUrl = response.data
- // this.isShowTip = true
- // }).catch(error =>{
- // this.$util.msg(error.msg,2000)
- // })
- },
- tabClick(index) {//tab切换
- this.tabCurrentIndex = index;
- switch(index){
- case 0:
- this.btnColor="#09BB07"
- this.buttonText='使用微信支付';
- break;
- case 1:
- this.btnColor="#034582"
- this.buttonText='生成企业网银链接';
- break;
- case 2:
- this.btnColor="#034582"
- this.buttonText='生成个人网银链接';
- break;
- }
- },
- hideTips(){//隐藏弹窗
- this.isShowTip = false
- },
- clipboard(data) {
- thorui.getClipboardData(data, (res) => {
- if (res) {
- this.isShowTip = false;
- this.$util.msg("复制成功",2000,true,'success');
- // // 友盟埋点收集复制网银链接
- // if(process.env.NODE_ENV != 'development'){
- // this.$uma.trackEvent('Um_Event_CopyUnionPay', {
- // Um_Key_PageName: '网银支付',
- // Um_Key_SourcePage: '线上支付',
- // Um_Key_PayName:`${this.buttonText}`,
- // Um_Key_PayOrderID:`${this.orderId}`
- // })
- // }
- } else {
- this.$util.msg("复制失败",2000,true,'none');
- }
- })
- },
- },
- onShow() {
- }
- }
- </script>
- <style lang="scss">
- page{
- height: auto !important;
- background-color: #FFFFFF;
- }
- .container-cash{
- width: 100%;
- margin-top: 40rpx;
- .container-wrapper{
- width: 100%;
- box-sizing: border-box;
- padding: 0 24rpx;
- .pay-content{
- width: 100%;
- height: 254rpx;
- padding: 92rpx 40rpx 16rpx 40rpx;
- box-sizing: border-box;
- background: url(https://static.caimei365.com/app/img/icon/icon-member-pay@2x.png) no-repeat;
- background-size: cover;
- float: left;
- position: relative;
- .pay-p{
- font-size: $font-size-26;
- color: #4E4539;
- line-height: 36rpx;
- }
- .pay-money{
- color: #4E4539;
- line-height: 84rpx;
- font-weight: bold;
- .pay-sm{
- font-size: $font-size-26;
- }
- .pay-bg{
- font-size: 50rpx;
- }
- }
- .pay-mouth{
- position: absolute;
- right: 40rpx;
- bottom: 16rpx;
- line-height: 36rpx;
- font-size: $font-size-26;
- color: #4E4539;
- }
- }
- .pay-check{
- width: 100%;
- height: auto;
- float: left;
- .check-title{
- width: 622rpx;
- height: 40rpx;
- line-height: 40rpx;
- padding: 0 20rpx;
- margin-top: 24rpx;
- .text{
- font-size: $font-size-28;
- color: $text-color;
- text-align: left;
- float: left;
- }
- .icon{
- width: 40rpx;
- height: 40rpx;
- border-radius: 50%;
- line-height: 40rpx;
- text-align: center;
- color: #FFFFFF;
- font-size: $font-size-24;
- background: radial-gradient(circle,rgba(225,86,22,1) 0%,rgba(255,170,0,1) 67%,rgba(249,185,156,1) 100%);
- float: right;
- }
- }
- .pay-checked{
- width: 100%;
- height: auto;
- .pay-item{
- width: 100%;
- height: 120rpx;
- box-sizing: border-box;
- border: 1px solid #E1E1E1;
- border-radius: 8rpx;
- padding: 20rpx;
- margin: 24rpx 0;
- display: flex;
- background-color: #FFFFFF;
- &.current{
- border-color:#E4AA43;
- .item-r{
- .icon-duigou{
- color: #E4AA43;
- }
- }
- }
- .item-l{
- flex: 8;
- .item-icon{
- width: 72rpx;
- height: 72rpx;
- float: left;
- text-align: center;
- line-height: 72rpx;
- margin-right: 20rpx;
- .iconfont{
- font-size:78rpx;
- }
- .icon-weixinzhifu{
- color: #09BB07;
- }
- .icon-gerenwangyinzhifu{
- color: #034582;
- }
- .icon-qiyewangyinzhifu{
- color: #004889;
- }
- }
- .item-texts{
- line-height: 66rpx;
- font-size:$font-size-26;
- color: $text-color;
- }
- .item-text{
- line-height: 36rpx;
- font-size:$font-size-26;
- .txt-p{
- color: $text-color;
- }
- .txt-t{
- color: #999999;
- }
- }
- }
- .item-r{
- flex: 2;
- text-align: center;
- line-height: 72rpx;
- .icon-duigou{
- font-size: 54rpx;
- color: #FFFFFF;
- }
- }
- }
- }
- }
- }
- .pay-button{
- width: 100%;
- float: left;
- margin-top:30rpx;
- .btn{
- width: 662rpx;
- height: 88rpx;
- border-radius: 44rpx;
- font-size: $font-size-28;
- line-height: 88rpx;
- color: #FFFFFF;
- margin: 0 auto;
- text-align: center;
- background:$btn-confirm;
- }
- }
- .pay-bring-wrapper{
- width: 100%;
- padding: 24rpx 0;
- background-color: #FFFFFF;
- display: flex;
- align-items: center;
- flex-direction: column;
- .pay-bring-content{
- width: 654rpx;
- height: auto;
- padding: 0 24rpx;
- .text{
- font-size: $font-size-24;
- color: #666;
- line-height: 44rpx;
- text-align: center;
- &.bg-color{
- color: $color-system;
- line-height: 88rpx;
- }
- }
- .text-v{
- font-size: $font-size-28;
- color: #999;
- line-height: 70rpx;
- text-align: left;
- &.title{
- font-size: $font-size-28;
- color: #666666;
- }
- &.bg-color{
- line-height: 44rpx;
- color: $color-system;
- }
- .clipboard{
- width: 84rpx;
- height: 36rpx;
- background:linear-gradient(34deg,rgba(255,41,41,1) 0%,rgba(255,109,27,1) 100%);
- text-align: center;
- font-size: $font-size-24;
- color: #FFFFFF;
- border-radius: 4rpx;
- line-height: 36rpx;
- display: inline-block;
- margin-left: 10rpx;
- }
- }
- }
- }
- }
- .payun-alert{
- width: 100%;
- height: 100%;
- background: rgba(0,0,0,.5);
- position: fixed;
- top: 0;
- left: 0;
- z-index: 8888;
- transition: all 0.4s;
- &.none{
- display: none;
- }
- &.show{
- display: block;
- }
- .content{
- width: 422rpx;
- height:434rpx;
- position: absolute;
- background: $bg-color;
- left: 0;
- right: 0;
- bottom: 0;
- top: 0;
- margin: auto;
- padding: 20rpx 32rpx;
- border-radius: 12rpx;
- .title{
- width: 100%;
- height: 68rpx;
- line-height: 68rpx;
- font-size: $font-size-28;
- color: $text-color;
- text-align: center;
- position: relative;
- .icon-iconfontguanbi{
- width: 68rpx;
- height: 68rpx;
- text-align: center;
- line-height: 68rpx;
- position: absolute;
- right: 0;
- top: 0;
- font-size: $font-size-36;
- color: #999999;
- }
- }
- .text-content{
- width: 100%;
- height: auto;
- .text{
- padding: 20rpx 0 0 0;
- line-height: 44rpx;
- font-size: $font-size-26;
- color:#666666;
- text-align: justify;
- }
- .text-p{
- width: 100%;
- line-height: 44rpx;
- font-size: $font-size-26;
- color:$color-system;
- text-align: left;
- text-overflow:ellipsis;
- display: -webkit-box;
- word-break: break-all;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
- overflow: hidden;
- }
- .text-b{
- line-height: 44rpx;
- font-size: $font-size-24;
- color:#999999;
- text-align: left;
- }
- }
- .text-button{
- width: 100%;
- height: 88rpx;
- line-height: 88rpx;
- background: $btn-confirm;
- font-size: $font-size-28;
- border-radius: 44rpx;
- color:#FFFFFF;
- text-align: center;
- margin-top: 20rpx;
- }
- }
- }
- </style>
|