123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- <template>
- <view class="container">
- <view class="entrust-form">
- <u-cell-group :border="false">
- <u-cell-item title="委托金额" title-width="180" :arrow="false" :value="price">
- <!-- <u-number-box digit :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="190" :arrow="false">
- <!-- <u-number-box digit :min="1" v-model="entrustForm.entrustDurationTime" bg-color="#51A539" color="#ffffff"></u-number-box> -->
- <CnumberBox style="right: 0;position: absolute;top: 25%;" @getNum="getNum" minNum="1" :isInt="false"></CnumberBox>
- </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">支付</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')
- import CnumberBox from '@/components/CnumberBox.vue'
- export default {
- components: {
- CnumberBox
- },
- data() {
- return {
- price: 0,
- userData: {},
- entrustForm: {
- productId: '',
- productName: '',
- tenantCode: '',
- areaSize: '',
- payAomount: 1,
- entrustDurationTime: 1,
- entrustStartTime: '',
- remarks: '',
- },
- dateShow: false,
- params: {
- year: true,
- month: true,
- day: true,
- hour: true,
- minute: true,
- second: true
- },
- startYear: '',
- orderId: ''
- }
- },
- 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
- this.getPrice()
- this.orderId = options.orderId
- },
- methods: {
- // 获取子组件的购买数量
- getNum(num) {
- this.entrustForm.entrustDurationTime = num
- },
- // 设置时间
- setDate(data) {
- this.entrustForm.entrustStartTime = data.year + '-' + data.month + '-' + data.day + ' ' + data.hour + ':' + data.minute +
- ':' + data.second
- },
- // 获取委托金额
- getPrice() {
- NET.request(API.getShareTaskPric, {}, 'GET').then(res => {
- if (res.isSuccess) {
- if (res.data) {
- this.price = res.data
- }
- } else {
- this.$refs.uTips.show({
- title: res.msg,
- type: 'warning',
- })
- }
- })
- },
- // 支付
- toPay() {
- if (!this.entrustForm.remarks) {
- this.$refs.uTips.show({
- title: '请填写备注信息',
- type: 'warning',
- })
- return
- }
- if (!this.entrustForm.entrustStartTime) {
- this.$refs.uTips.show({
- title: '请选择开始时间',
- type: 'warning',
- })
- return
- }
- if (!this.entrustForm.entrustDurationTime) {
- this.$refs.uTips.show({
- title: '请输入委托时长',
- type: 'warning',
- })
- return
- }
- console.log('委托时长',this.entrustForm.entrustDurationTime)
- NET.request(API.submitEvaluate, {
- // 会员
- mid: this.userData.userId,
- nickname: this.userData.userName,
- // 数据
- ...this.entrustForm,
- entrustDurationTime: JSON.stringify(this.entrustForm.entrustDurationTime),
- payAomount: this.price * Number(this.entrustForm.entrustDurationTime),
- orderId: Number(this.orderId),
- // #ifdef APP-PLUS
- channel: 2
- //#endif
- }, 'POST').then(res => {
- if (res.isSuccess) {
- if (res.data) {
- this.orderId = res.data.orderId
- // #ifdef MP-WEIXIN
- 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?orderId=' + this.orderId
- // });
- // }, 1000)
- uni.navigateBack(-1);
- },
- fail: (error) => {
- this.$refs.uTips.show({
- title: '支付失败',
- type: 'warning',
- })
- }
- })
- //#endif
-
- // #ifdef APP-PLUS
- uni.requestPayment({
- provider: 'wxpay',
- orderInfo:{
- "package": res.data.packageValue,
- "appid": res.data.appId,
- "sign": res.data.sign,
- "partnerid": res.data.partnerId,
- "prepayid": res.data.prepayId,
- "noncestr": res.data.nonceStr,
- "timestamp": res.data.timeStamp,
- },
- success: (payRes) => {
- this.$refs.uTips.show({
- title: '支付成功',
- type: 'success',
- })
- uni.navigateBack(-1);
- },
- fail: (error) => {
- this.$refs.uTips.show({
- title: '支付失败',
- type: 'warning',
- })
- }
- })
- //#endif
- }
- } else {
- this.$refs.uTips.show({
- title: res.msg,
- type: 'warning',
- })
- }
- }).catch(error => {
- this.$refs.uTips.show({
- title: '支付未成功',
- type: 'warning',
- })
- })
- },
- },
- }
- </script>
- <style>
- page {
- width: 100%;
- height: 100%;
- background-color: #f7f7f7;
- }
- </style>
- <style lang="less" scoped>
- .container {
- width: 100%;
- height: 100%;
- float: left;
- box-sizing: border-box;
- background-color: #f7f7f7;
- padding-bottom: 70px;
- overflow-y: auto;
- .entrust-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: #56a83a;
-
- /deep/button {
- background-color: #56a83a;
- }
- /deep/.u-btn--success--disabled {
- background-color: #74bd60 !important;
- }
- }
- }
- }
- </style>
|