entrustForm.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="container">
  3. <view class="entrust-form">
  4. <u-cell-group :border="false">
  5. <u-cell-item title="委托金额" title-width="180" :arrow="false">
  6. <u-number-box :min="1" v-model="entrustForm.payAomount" bg-color="#51A539" color="#ffffff"></u-number-box>
  7. </u-cell-item>
  8. <u-cell-item title="委托时长" title-width="180" :arrow="false">
  9. <u-number-box :min="1" v-model="entrustForm.entrustDurationTime" bg-color="#51A539" color="#ffffff"></u-number-box>
  10. </u-cell-item>
  11. <u-cell-item title="委托开始时间" title-width="180" @click="dateShow = true">
  12. <text class="">{{entrustForm.entrustStartTime}}</text>
  13. </u-cell-item>
  14. <u-field type="textarea" placeholder="请输入备注" v-model="entrustForm.remarks" label-width="0"></u-field>
  15. </u-cell-group>
  16. </view>
  17. <view class="entrust-handle">
  18. <u-button type="success" shape="circle" :ripple="true" @click="toPay()" class="handle-custom" :disabled="!entrustForm.payAomount">支付</u-button>
  19. </view>
  20. <u-picker mode="time" v-model="dateShow" :start-year="startYear" :params="params" @confirm="setDate"></u-picker>
  21. <u-top-tips ref="uTips"></u-top-tips>
  22. </view>
  23. </template>
  24. <script>
  25. const NET = require('@/utils/request')
  26. const API = require('@/config/api')
  27. export default {
  28. data() {
  29. return {
  30. userData: {},
  31. entrustForm: {
  32. productId: '',
  33. productName: '',
  34. tenantCode: '',
  35. areaSize: '',
  36. payAomount: '',
  37. entrustDurationTime: '',
  38. entrustStartTime: '',
  39. remarks: '',
  40. },
  41. dateShow: false,
  42. params: {
  43. year: true,
  44. month: true,
  45. day: true,
  46. hour: true,
  47. minute: true,
  48. second: true
  49. },
  50. startYear: ''
  51. }
  52. },
  53. onLoad(options) {
  54. this.userData = uni.getStorageSync("userData")
  55. this.startYear = new Date().getFullYear()
  56. this.entrustForm.productId = options.productId
  57. this.entrustForm.productName = options.productName
  58. this.entrustForm.tenantCode = options.tenantCode
  59. this.entrustForm.areaSize = options.areaSize
  60. },
  61. methods: {
  62. // 设置时间
  63. setDate(data) {
  64. this.entrustForm.entrustStartTime = data.year + '-' + data.month + '-' + data.day + ' ' + data.hour + ':' + data.minute +
  65. ':' + data.second
  66. },
  67. // 支付
  68. toPay() {
  69. NET.request(API.submitEvaluate, {
  70. // 会员
  71. mid: this.userData.userId,
  72. nickname: this.userData.userName,
  73. // 数据
  74. ...this.entrustForm,
  75. entrustDurationTime: JSON.stringify(this.entrustForm.entrustDurationTime)
  76. }, 'POST').then(res => {
  77. uni.requestPayment({
  78. provider: 'wxpay',
  79. timeStamp: res.data.timeStamp,
  80. nonceStr: res.data.nonceStr,
  81. package: res.data.packageValue,
  82. signType: res.data.signType,
  83. paySign: res.data.paySign,
  84. success: (payRes) => {
  85. this.$refs.uTips.show({
  86. title: '支付成功',
  87. type: 'success',
  88. })
  89. setTimeout(() => {
  90. uni.reLaunch({
  91. url: '/pagesMain/paySuccess'
  92. });
  93. }, 1000)
  94. },
  95. fail: (error) => {
  96. this.$refs.uTips.show({
  97. title: '支付失败',
  98. type: 'warning',
  99. })
  100. }
  101. })
  102. }).catch(error => {
  103. this.$refs.uTips.show({
  104. title: '支付失败',
  105. type: 'warning',
  106. })
  107. })
  108. },
  109. },
  110. }
  111. </script>
  112. <style lang="less" scoped>
  113. page {
  114. width: 100%;
  115. height: 100%;
  116. }
  117. .container {
  118. width: 100%;
  119. height: 100%;
  120. float: left;
  121. box-sizing: border-box;
  122. background-color: #f7f7f7;
  123. padding-bottom: 70px;
  124. overflow-y: auto;
  125. .address-form {
  126. width: 100%;
  127. float: left;
  128. box-sizing: border-box;
  129. padding: 0 15px;
  130. background-color: #ffffff;
  131. /deep/.u-field {
  132. padding-left: 0px;
  133. padding-right: 0px;
  134. }
  135. /deep/.u-cell {
  136. padding-left: 0px;
  137. padding-right: 0px;
  138. }
  139. /deep/.u-cell_title {
  140. color: #999999;
  141. }
  142. /deep/.u-label-text {
  143. color: #999999;
  144. }
  145. }
  146. .entrust-handle {
  147. width: calc(100% - 30px);
  148. height: 40px;
  149. position: fixed;
  150. bottom: 20px;
  151. left: 15px;
  152. .handle-custom {
  153. background-color: #51A539;
  154. }
  155. }
  156. }
  157. </style>