gs.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="content">
  3. <view class="flex gs-item">
  4. <view class="item-name">
  5. 参考价格
  6. </view>
  7. <input type="text" class="item-val val-red" disabled v-model="pUser.points_transaction" />
  8. </view>
  9. <!-- //挂售价格(元) -->
  10. <view class="flex gs-item">
  11. <view class="item-name">
  12. {{type == 1?'挂售': '买入'}}价格(元)
  13. </view>
  14. <input type="text" class="item-val" :placeholder="'请输入您的' + (type == 1?'挂售': '买入') + '价(单价)'" v-model="total_price" />
  15. </view>
  16. <view class="flex gs-item">
  17. <view class="item-name">
  18. {{type == 1?'挂售': '买入'}}数量
  19. </view>
  20. <input type="text" class="item-val" :placeholder="'请输入' + (type == 1?'挂售': '买入') + '数量'" v-model="amount" />
  21. </view>
  22. <view class="flex gs-item" v-if="type !=1 && type != 3">
  23. <view class="item-name">
  24. 联系方式
  25. </view>
  26. <input type="text" class="item-val" placeholder="请输入联系方式" v-model="phone" />
  27. </view>
  28. <view class="fwf" v-if="type != 1 && type != 3">
  29. 服务费:<text>{{(total_price * amount * pUser.fee_ratio / 100).toFixed(2) || 0}} 阅读积分</text>
  30. </view>
  31. <view class="fwf" v-if="type == 1">
  32. 服务费:<text>{{( amount * 0.05).toFixed(4) || 0}} 余额宝</text>
  33. </view>
  34. <view class="fwf" v-if="type == 3">
  35. <!-- 服务费:<text>{{( amount * 0.05).toFixed(4) || 0}} 余额宝</text> -->
  36. 买入价格不得低于参考价
  37. </view>
  38. <view class="btn" @click="createGs">
  39. 确认
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. createGs,
  46. passUser,
  47. createBuy
  48. } from '@/api/zero.js'
  49. export default {
  50. data() {
  51. return {
  52. type: 0,
  53. total_price: '',
  54. amount: '',
  55. phone: '',
  56. pUser: {}
  57. }
  58. },
  59. onLoad(opt) {
  60. if (opt.type) {
  61. this.type = opt.type
  62. }
  63. if(opt.type == 3) {
  64. uni.setNavigationBarTitle({
  65. title: '买入'
  66. })
  67. }
  68. },
  69. onShow() {
  70. this.passUser()
  71. },
  72. onReachBottom() {
  73. },
  74. onReady() {
  75. },
  76. methods: {
  77. passUser() {
  78. passUser().then(res => {
  79. this.pUser = res.data
  80. })
  81. },
  82. createGs() {
  83. let that = this
  84. if(!that.total_price) {
  85. return that.$api.msg('请输入挂售单价')
  86. }
  87. if(!that.amount) {
  88. return that.$api.msg('请输入挂售数量')
  89. }
  90. if(that.type == 1) {
  91. createGs({
  92. total_price: that.total_price * that.amount,
  93. amount: that.amount,
  94. phone: that.phone,
  95. type: that.type
  96. }).then(res => {
  97. uni.showToast({
  98. title: '挂售成功',
  99. duration: 2000
  100. });
  101. setTimeout(() => {
  102. uni.navigateBack()
  103. }, 1500)
  104. })
  105. }else {
  106. createBuy({
  107. total_price: that.total_price * that.amount,
  108. amount: that.amount,
  109. }).then(res => {
  110. uni.showToast({
  111. title: '提交成功',
  112. duration: 2000
  113. });
  114. setTimeout(() => {
  115. uni.navigateBack()
  116. }, 1500)
  117. })
  118. }
  119. }
  120. }
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. .gs-item {
  125. height: 135rpx;
  126. background-color: #fff;
  127. padding: 0 65rpx;
  128. .item-val {
  129. width: 405rpx;
  130. height: 87rpx;
  131. background: #F4F4F4;
  132. border-radius: 10rpx;
  133. text-align: center;
  134. font-size: 36rpx;
  135. font-weight: bold;
  136. }
  137. .val-red {
  138. color: #FD3B39;
  139. }
  140. }
  141. .fwf {
  142. font-size: 30rpx;
  143. font-weight: bold;
  144. color: #333333;
  145. text-align: right;
  146. padding-right: 65rpx;
  147. background-color: #fff;
  148. padding-bottom: 62rpx;
  149. text {
  150. color: #FD3B39;
  151. }
  152. }
  153. .btn {
  154. width: 616rpx;
  155. height: 88rpx;
  156. background: #ff4c4c;
  157. border-radius: 10rpx;
  158. font-size: 36rpx;
  159. font-weight: bold;
  160. color: #FFFFFF;
  161. line-height: 88rpx;
  162. text-align: center;
  163. margin: 60rpx auto;
  164. }
  165. </style>