You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.5 KiB

10 months ago
  1. <template>
  2. <view>
  3. <u-navbar :title="$t('page.payOrder.title')" :safeAreaInsetTop="false" placeholder @leftClick="leftClick">
  4. </u-navbar>
  5. <view class="line">
  6. <u-cell class="celi" :title="$t('page.productDetail.payOrder.order-number')" :value="orderInfo.id"></u-cell>
  7. <u-cell class="celi" :title="$t('page.productDetail.payOrder.price')"
  8. :value="$t('$') + orderInfo.sumPrice"></u-cell>
  9. <u-cell class="celi" :title="$t('page.productDetail.payOrder.pay-method')"
  10. :value="$t('page.productDetail.payOrder.balance_payment')" isLink></u-cell>
  11. <selectAddress @selectAddress="selectAddress" @toAdd="toAdd" ref="selectAddress"></selectAddress>
  12. </view>
  13. <!-- <view class="line">
  14. <u-input :placeholder="$t('page.productDetail.payOrder.pay-input-placeholder')" class="celi">
  15. <u-text
  16. :text="$t('page.productDetail.payOrder.pay-password')"
  17. slot="prefix"
  18. margin="0 3px 0 0"
  19. color="#000"
  20. ></u-text>
  21. </u-input>
  22. </view> -->
  23. <u--form labelPosition="left" :model="model1" :rules="rules" class="line" ref="uForm">
  24. <u-form-item :label="$t('page.productDetail.payOrder.pay-password')" prop="payPassword" borderBottom
  25. labelWidth="80px">
  26. <u--input v-model="model1.payPassword" type="password"
  27. :placeholder="$t('page.productDetail.payOrder.pay-input-placeholder')"></u--input>
  28. </u-form-item>
  29. </u--form>
  30. <u-button class="submit" size="large" @click="submit"
  31. :text="$t('page.productDetail.payOrder.firm-pay')"></u-button>
  32. </view>
  33. </template>
  34. <script>
  35. import selectAddress from '@/components/select-address/selectAddress.vue'
  36. export default {
  37. components: {
  38. selectAddress
  39. },
  40. data() {
  41. return {
  42. model1: {
  43. payPassword: '',
  44. addressId: null
  45. },
  46. rules: {
  47. 'payPassword': {
  48. type: 'string',
  49. required: true,
  50. message: this.$t('page.productDetail.payOrder.pay-input-placeholder'),
  51. trigger: ['blur', 'change']
  52. },
  53. },
  54. orderInfo: {}
  55. }
  56. },
  57. onShow() {
  58. this.getOrder();
  59. if (this.$refs.selectAddress) {
  60. this.$refs.selectAddress.getAddressList()
  61. }
  62. },
  63. methods: {
  64. leftClick() {
  65. uni.switchTab({
  66. url: '/pages/order/order'
  67. })
  68. },
  69. submit() { //订单支付
  70. this.$refs.uForm.validate().then(res => {
  71. if (!this.model1.addressId) { //用户没有地址
  72. this.$u.toast(this.$t('page.payOrder.no-address'));
  73. return this.toAdd();
  74. }
  75. this.request('payOrder', {
  76. orderId: this.orderInfo.id,
  77. payPass: this.model1.payPassword,
  78. addressId: this.model1.addressId,
  79. }).then(res => {
  80. if (res.code == 200) {
  81. uni.$u.toast(this.$t('success-operation'));
  82. uni.redirectTo({
  83. url: '/pages/productDetail/successTransaction/successTransaction'
  84. })
  85. }
  86. })
  87. })
  88. },
  89. getOrder() { //获取当前订单
  90. this.request("getOrderOne", {}, {
  91. id: this.$route.query.id
  92. }).then(res => {
  93. this.orderInfo = res.result;
  94. })
  95. },
  96. selectAddress(id) { //用户选择了地址
  97. this.model1.addressId = id
  98. },
  99. toAdd() {
  100. return setTimeout(() => {
  101. uni.navigateTo({
  102. url: `/pages/user/address/addAddres?url=/pages/payOrder/payOrder&oid=${this.$route.query.id}&quantity=${this.$route.query.quantity}`
  103. })
  104. }, 500)
  105. }
  106. }
  107. }
  108. </script>
  109. <style scoped lang="scss">
  110. .line {
  111. background-color: #fff;
  112. padding: 10px;
  113. margin-top: 10px;
  114. .celi {
  115. border-radius: 10px;
  116. margin: 10px 0;
  117. }
  118. }
  119. .submit {
  120. border-radius: 30px;
  121. background-color: #ED762F;
  122. color: #fff;
  123. margin-top: 10px;
  124. }
  125. </style>