entrustForm.vue 5.7 KB

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