entrustForm.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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" :value="price">
  6. <!-- <u-number-box digit :positive-integer="false" :min="0" v-model="entrustForm.payAomount" bg-color="#51A539" color="#ffffff"></u-number-box> -->
  7. </u-cell-item>
  8. <u-cell-item title="委托时长(小时)" title-width="190" :arrow="false">
  9. <u-number-box digit :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">支付</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. price: 0,
  31. userData: {},
  32. entrustForm: {
  33. productId: '',
  34. productName: '',
  35. tenantCode: '',
  36. areaSize: '',
  37. payAomount: '',
  38. entrustDurationTime: 1,
  39. entrustStartTime: '',
  40. remarks: '',
  41. },
  42. dateShow: false,
  43. params: {
  44. year: true,
  45. month: true,
  46. day: true,
  47. hour: true,
  48. minute: true,
  49. second: true
  50. },
  51. startYear: '',
  52. orderId: ''
  53. }
  54. },
  55. onLoad(options) {
  56. this.userData = uni.getStorageSync("userData")
  57. this.startYear = new Date().getFullYear()
  58. this.entrustForm.productId = options.productId
  59. this.entrustForm.productName = options.productName
  60. this.entrustForm.tenantCode = options.tenantCode
  61. this.entrustForm.areaSize = options.areaSize
  62. this.getPrice()
  63. this.orderId = options.orderId
  64. },
  65. methods: {
  66. // 设置时间
  67. setDate(data) {
  68. this.entrustForm.entrustStartTime = data.year + '-' + data.month + '-' + data.day + ' ' + data.hour + ':' + data.minute +
  69. ':' + data.second
  70. },
  71. // 获取委托金额
  72. getPrice() {
  73. NET.request(API.getShareTaskPric, {}, 'GET').then(res => {
  74. if (res.isSuccess) {
  75. if (res.data) {
  76. this.price = res.data
  77. }
  78. } else {
  79. this.$refs.uTips.show({
  80. title: res.msg,
  81. type: 'warning',
  82. })
  83. }
  84. })
  85. },
  86. // 支付
  87. toPay() {
  88. if (!this.entrustForm.remarks) {
  89. this.$refs.uTips.show({
  90. title: '请填写备注信息',
  91. type: 'warning',
  92. })
  93. return
  94. }
  95. if (!this.entrustForm.entrustStartTime) {
  96. this.$refs.uTips.show({
  97. title: '请选择开始时间',
  98. type: 'warning',
  99. })
  100. return
  101. }
  102. NET.request(API.submitEvaluate, {
  103. // 会员
  104. mid: this.userData.userId,
  105. nickname: this.userData.userName,
  106. // 数据
  107. ...this.entrustForm,
  108. entrustDurationTime: JSON.stringify(this.entrustForm.entrustDurationTime),
  109. payAomount: this.price * Number(this.entrustForm.entrustDurationTime),
  110. orderId: Number(this.orderId)
  111. }, 'POST').then(res => {
  112. if (res.isSuccess) {
  113. if (res.data) {
  114. this.orderId = res.data.orderId
  115. uni.requestPayment({
  116. provider: 'wxpay',
  117. timeStamp: res.data.timeStamp,
  118. nonceStr: res.data.nonceStr,
  119. package: res.data.packageValue,
  120. signType: res.data.signType,
  121. paySign: res.data.paySign,
  122. success: (payRes) => {
  123. this.$refs.uTips.show({
  124. title: '支付成功',
  125. type: 'success',
  126. })
  127. // setTimeout(() => {
  128. // uni.reLaunch({
  129. // url: '/pagesMain/paySuccess?orderId=' + this.orderId
  130. // });
  131. // }, 1000)
  132. uni.navigateBack(-1);
  133. },
  134. fail: (error) => {
  135. this.$refs.uTips.show({
  136. title: '支付失败',
  137. type: 'warning',
  138. })
  139. }
  140. })
  141. }
  142. } else {
  143. this.$refs.uTips.show({
  144. title: res.msg,
  145. type: 'warning',
  146. })
  147. }
  148. }).catch(error => {
  149. this.$refs.uTips.show({
  150. title: '支付未成功',
  151. type: 'warning',
  152. })
  153. })
  154. },
  155. },
  156. }
  157. </script>
  158. <style>
  159. page {
  160. width: 100%;
  161. height: 100%;
  162. background-color: #f7f7f7;
  163. }
  164. </style>
  165. <style lang="less" scoped>
  166. .container {
  167. width: 100%;
  168. height: 100%;
  169. float: left;
  170. box-sizing: border-box;
  171. background-color: #f7f7f7;
  172. padding-bottom: 70px;
  173. overflow-y: auto;
  174. .entrust-form {
  175. width: 100%;
  176. float: left;
  177. box-sizing: border-box;
  178. padding: 0 15px;
  179. background-color: #ffffff;
  180. /deep/.u-field {
  181. padding-left: 0px;
  182. padding-right: 0px;
  183. }
  184. /deep/.u-cell {
  185. padding-left: 0px;
  186. padding-right: 0px;
  187. }
  188. /deep/.u-cell_title {
  189. color: #999999;
  190. }
  191. /deep/.u-label-text {
  192. color: #999999;
  193. }
  194. }
  195. .entrust-handle {
  196. width: calc(100% - 30px);
  197. height: 40px;
  198. position: fixed;
  199. bottom: 20px;
  200. left: 15px;
  201. .handle-custom {
  202. background-color: #56a83a;
  203. /deep/button {
  204. background-color: #56a83a;
  205. }
  206. /deep/.u-btn--success--disabled {
  207. background-color: #74bd60 !important;
  208. }
  209. }
  210. }
  211. }
  212. </style>