entrustForm.vue 5.3 KB

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