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.

159 lines
4.1 KiB

1 year ago
  1. <template>
  2. <view class="payOrder">
  3. <u-navbar :title="$t('page.productDetail.payOrder.select-pay-method')" :safeAreaInsetTop="false" placeholder
  4. @leftClick="leftClick">
  5. </u-navbar>
  6. <view class="img">
  7. <img src="/static/payOrder/46660.png" alt="" />
  8. <view class="text"></view>
  9. </view>
  10. <view class="line">
  11. <u-cell class="celi" :title="$t('page.productDetail.payOrder.order-number')" :value="orderInfo.id"></u-cell>
  12. <u-cell class="celi" :title="$t('page.productDetail.payOrder.price')" :value="orderInfo.sumPrice"></u-cell>
  13. <u-cell class="celi" :title="$t('page.productDetail.payOrder.pay-method')"
  14. :value="$t('page.productDetail.payOrder.balance_payment')" isLink></u-cell>
  15. <selectAddress @selectAddress="selectAddress" @toAdd="toAdd" ref="selectAddress"></selectAddress>
  16. </view>
  17. <!-- <view class="line">
  18. <u-input :placeholder="$t('page.productDetail.payOrder.pay-input-placeholder')" class="celi">
  19. <u-text
  20. :text="$t('page.productDetail.payOrder.pay-password')"
  21. slot="prefix"
  22. margin="0 3px 0 0"
  23. color="#000"
  24. ></u-text>
  25. </u-input>
  26. </view> -->
  27. <u--form labelPosition="left" :model="model1" :rules="rules" class="line" ref="uForm">
  28. <u-form-item :label="$t('page.productDetail.payOrder.pay-password')" prop="payPassword" borderBottom
  29. labelWidth="80px">
  30. <u--input v-model="model1.payPassword" type="password"
  31. :placeholder="$t('page.productDetail.payOrder.pay-input-placeholder')"></u--input>
  32. </u-form-item>
  33. </u--form>
  34. <u-button class="submit" size="large" @click="submit"
  35. :text="$t('page.productDetail.payOrder.firm-pay')"></u-button>
  36. </view>
  37. </template>
  38. <script>
  39. import selectAddress from '@/components/select-address/selectAddress.vue'
  40. export default {
  41. components: {
  42. selectAddress,
  43. },
  44. data() {
  45. return {
  46. shopId: null,
  47. model1: {
  48. payPassword: '',
  49. addressId: 0,
  50. },
  51. orderInfo: {},
  52. rules: {
  53. 'payPassword': {
  54. type: 'string',
  55. required: true,
  56. message: this.$t('page.productDetail.payOrder.pay-input-placeholder'),
  57. trigger: ['blur', 'change']
  58. },
  59. },
  60. }
  61. },
  62. onShow() {
  63. this.getOrder();
  64. if (this.$refs.selectAddress) {
  65. this.$refs.selectAddress.getAddressList()
  66. }
  67. },
  68. methods: {
  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. leftClick() {
  90. uni.redirectTo({
  91. url: '/pages/productDetail/productDetail?id=' + this.shopId
  92. })
  93. this.$MyToast(this.$t('page.productDetail.payOrder.cancel-pay'), {
  94. title: this.$t('myToactTitle')
  95. })
  96. },
  97. selectAddress(id) {
  98. this.model1.addressId = id
  99. },
  100. getOrder() { //获取当前订单
  101. this.request("getOrderOne", {}, {
  102. id: this.$route.query.id
  103. }).then(res => {
  104. this.shopId = res.result.shopId;
  105. this.orderInfo = res.result;
  106. })
  107. },
  108. toAdd(){
  109. return setTimeout(() => {
  110. uni.navigateTo({
  111. url: `/pages/user/address/addAddres?url=/pages/productDetail/payOrder/payOrder&oid=${this.$route.query.id}&quantity=${this.$route.query.quantity}`
  112. })
  113. }, 500)
  114. }
  115. }
  116. }
  117. </script>
  118. <style scoped lang="scss">
  119. .payOrder {
  120. padding-bottom: 50px;
  121. .img {
  122. display: flex;
  123. justify-content: center;
  124. align-items: center;
  125. text-align: center;
  126. padding: 20px;
  127. background-color: #fff;
  128. margin-top: 10px;
  129. flex-direction: column;
  130. font-size: 28rpx;
  131. .text {
  132. margin-top: 20px;
  133. }
  134. }
  135. .line {
  136. background-color: #fff;
  137. padding: 10px;
  138. margin-top: 10px;
  139. .celi {
  140. background-color: #F8F8F8;
  141. border-radius: 10px;
  142. margin: 10px 0;
  143. }
  144. }
  145. .submit {
  146. border-radius: 30px;
  147. position: fixed;
  148. bottom: 0;
  149. background-color: #ED762F;
  150. color: #fff;
  151. }
  152. }
  153. </style>