<template> <view class="container"> <view class="entrust-form"> <u-cell-group :border="false"> <u-cell-item title="委托金额" title-width="180" :arrow="false"> <u-number-box :positive-integer="false" :min="0" v-model="entrustForm.payAomount" bg-color="#51A539" color="#ffffff"></u-number-box> </u-cell-item> <u-cell-item title="委托时长" title-width="180" :arrow="false"> <u-number-box :min="1" v-model="entrustForm.entrustDurationTime" bg-color="#51A539" color="#ffffff"></u-number-box> </u-cell-item> <u-cell-item title="委托开始时间" title-width="180" @click="dateShow = true"> <text class="">{{entrustForm.entrustStartTime}}</text> </u-cell-item> <u-field type="textarea" placeholder="请输入备注" v-model="entrustForm.remarks" label-width="0"></u-field> </u-cell-group> </view> <view class="entrust-handle"> <u-button type="success" shape="circle" :ripple="true" @click="toPay()" class="handle-custom" :disabled="!entrustForm.payAomount">支付</u-button> </view> <u-picker mode="time" v-model="dateShow" :start-year="startYear" :params="params" @confirm="setDate"></u-picker> <u-top-tips ref="uTips"></u-top-tips> </view> </template> <script> const NET = require('@/utils/request') const API = require('@/config/api') export default { data() { return { userData: {}, entrustForm: { productId: '', productName: '', tenantCode: '', areaSize: '', payAomount: '', entrustDurationTime: '', entrustStartTime: '', remarks: '', }, dateShow: false, params: { year: true, month: true, day: true, hour: true, minute: true, second: true }, startYear: '' } }, onLoad(options) { this.userData = uni.getStorageSync("userData") this.startYear = new Date().getFullYear() this.entrustForm.productId = options.productId this.entrustForm.productName = options.productName this.entrustForm.tenantCode = options.tenantCode this.entrustForm.areaSize = options.areaSize }, methods: { // 设置时间 setDate(data) { this.entrustForm.entrustStartTime = data.year + '-' + data.month + '-' + data.day + ' ' + data.hour + ':' + data.minute + ':' + data.second }, // 支付 toPay() { NET.request(API.submitEvaluate, { // 会员 mid: this.userData.userId, nickname: this.userData.userName, // 数据 ...this.entrustForm, entrustDurationTime: JSON.stringify(this.entrustForm.entrustDurationTime) }, 'POST').then(res => { uni.requestPayment({ provider: 'wxpay', timeStamp: res.data.timeStamp, nonceStr: res.data.nonceStr, package: res.data.packageValue, signType: res.data.signType, paySign: res.data.paySign, success: (payRes) => { this.$refs.uTips.show({ title: '支付成功', type: 'success', }) setTimeout(() => { uni.reLaunch({ url: '/pagesMain/paySuccess' }); }, 1000) }, fail: (error) => { this.$refs.uTips.show({ title: '支付失败', type: 'warning', }) } }) }).catch(error => { this.$refs.uTips.show({ title: '支付失败', type: 'warning', }) }) }, }, } </script> <style lang="less" scoped> page { width: 100%; height: 100%; } .container { width: 100%; height: 100%; float: left; box-sizing: border-box; background-color: #f7f7f7; padding-bottom: 70px; overflow-y: auto; .address-form { width: 100%; float: left; box-sizing: border-box; padding: 0 15px; background-color: #ffffff; /deep/.u-field { padding-left: 0px; padding-right: 0px; } /deep/.u-cell { padding-left: 0px; padding-right: 0px; } /deep/.u-cell_title { color: #999999; } /deep/.u-label-text { color: #999999; } } .entrust-handle { width: calc(100% - 30px); height: 40px; position: fixed; bottom: 20px; left: 15px; .handle-custom { background-color: #51A539; } } } </style>