123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- <template>
- <view class="content">
- <view class="top">
- <view class="inner">
- <view class="pay">
- <view class="title">
- <text class="name">付款给 芳华佳选</text>
- <text class="desc">微信收款</text>
- </view>
- <view class="pay-money">
- <view class="pay-money-title">支付金额</view>
- <view class="money">
- <text class="fh">¥</text>
- <input v-model="money" class="uni-input" @input="testMoney" type="digit" focus />
- </view>
- <textarea class="desc" placeholder="请填写备注说明" maxlength="20" v-model="desc" />
- </view>
- </view>
- </view>
- <view class="btn-box">
- <view class="btn" @click="pay()">确认支付</view>
- </view>
- </view>
- <view class="ad">
- <ad unit-id="adunit-a018415a6deb69e8"></ad>
- </view>
- </view>
- </template>
- <script>
- import {payment} from '@/api/payment'
- export default {
- data() {
- return {
- companyUserId:null,
- companyId:null,
- desc:"",
- money:null,
- wxPay: true,
- }
- },
- onLoad: function(options) {
- // if (options.hasOwnProperty('q') && options.q) {
- // // 通过下面这步解码,可以拿到url的值
- // const url = decodeURIComponent(options.q)
- // this.url=url;
- // // // 对url中携带的参数提取处理
- // const obj = this.utils.urlToObj(url)
- // console.log(obj)
- // this.companyId=obj.companyId;
- // this.companyUserId=obj.companyUserId;
- // }
- this.companyId=options.companyId;
- this.companyUserId=options.companyUserId;
- },
- onShareAppMessage(res) {
- return {
- title: '芳华佳选-收款',
- path: `/pages_user/user/pay?companyId=`+this.companyId+"&companyUserId="+this.companyUserId
- }
- },
- methods: {
- testMoney(e){
- let that = this;
- let price = e.detail.value
- if (price.indexOf(".") == 0) {
- //'首位小数点情况'
- price = price.replace(/[^$#$]/g, "0.");
- price = price.replace(/\.{2,}/g, ".");
- }
- price = price.match(/^\d*(\.?\d{0,2})/g)[0] || null;
- //重新赋值给input
- this.$nextTick(() => {
- this.money = price;
- });
- },
- pay(){
- if(this.money==null){
- uni.showToast({
- icon:'none',
- title: "请输入支付金额"
- });
- return;
- }
- uni.login({
- success: res => {
- console.log(res)
- this.payment(res.code);
- }
- });
- },
- payment(code){
- var data = {payMoney:this.money,remark:this.desc,code:code,companyId:this.companyId,companyUserId:this.companyUserId};
- var that=this;
- uni.showLoading();
- payment(data).then(
- res => {
- if(res.code==200){
- console.log(res);
- var result=res.result;
- wx.navigateToMiniProgram({
- appId: 'wx1b63de1096c46cde', // 收银台小程序 AppId 固定值
- path: '/pages/pay/pay', // 收银台小程序 固定路径
- extraData: {
- orderNo: result.orderNo,
- orderAmt: result.orderAmt,
- platMerCstNo: result.platMerCstNo,
- platMerCstName: result.platMerCstName,
- businessCstNo: result.businessCstNo,
- licenseCode: result.licenseCode,
- },
- envVersion: 'release', // 开发版 develop,体验版 trial,正式环境传 release
- success(res) {
- uni.showLoading({
- title:"查询支付结果中..."
- })
- setTimeout(()=>{
- uni.navigateTo({
- url: 'pages_user/user/storeOrder'
- })
- },4000)
- console.log(res)
- // 接口调用成功的回调函数
- },
- fail(res) {
- // 接口调用失败的回调函数
- }
- })
- // uni.requestPayment({
- // provider: 'wxpay',
- // timeStamp: res.result.timeStamp,
- // nonceStr: res.result.nonceStr,
- // package: res.result.packageValue,
- // signType: res.result.signType,
- // paySign: res.result.paySign,
- // success: function(res) {
- // uni.hideLoading();
- // uni.showToast({
- // icon:'success',
- // title: "支付成功",
- // });
- // uni.navigateTo({
- // url:'./success'
- // })
- // },
- // fail: function(err) {
- // console.log('fail:' + JSON.stringify(err));
- // uni.hideLoading();
- // }
- // });
- }else{
- uni.showToast({
- icon:'none',
- title: res.msg,
- });
- }
- },
- rej => {}
- );
- }
- }
- }
- </script>
- <style lang="scss">
- page{
- height: 100%;
- background-color: #f0eff4;
- }
- .content{
- height: 100%;
- display: flex;
- flex-direction: column;
- .top{
- flex:1;
- padding: 20rpx;
- .inner{
- width: 100%;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: center;
- .pay{
- width: 100%;
- box-shadow: 1px 1px 5px #e6e6e6;
- background: #FFFFFF;
- border-radius: 5upx;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- .title{
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- width: 100%;
- background-color: #f7f7f7;
- padding: 30rpx 0rpx;
- .name{
- padding: 15rpx 30rpx;
- font-size: 32rpx;
- }
- .desc{
- color: #989898;
- padding: 15rpx 30rpx;
- font-size: 25rpx;
- }
- }
- .pay-money
- {
- padding: 30rpx 0rpx;
- width: 100%;
- background: #FFFFFF;
- border-radius: 5upx;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- .pay-money-title{
- padding: 15rpx 30rpx;
- font-size: 32rpx;
- }
- .money{
- font-size: 42rpx;
- padding: 15rpx 30rpx;
- display: flex;
- flex-direction: row;
- align-items: flex-start;
- input{
- margin-left: 15rpx;
- }
- }
- .desc{
- width: 100%;
- padding: 30rpx 30rpx;
- border-top: 1rpx solid #e6e6e6;
- }
- textarea {
- height:50rpx;
- line-height: 50rpx;
- }
- }
- }
- }
- .btn-box{
- padding: 30rpx 0rpx;
- height: 121upx;
- display: flex;
- align-items: center;
- justify-content: center;
- .btn{
- width: 91.73%;
- height: 88upx;
- line-height: 88upx;
- font-size: 30upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FFFFFF;
- text-align: center;
- background: #2BC7B9;
- border-radius: 44upx;
- }
- }
- }
- .ad{
- margin: 0rpx 0rpx 60rpx;
- }
- }
- </style>
|