paymoment.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view>
  3. <van-radio-group >
  4. <van-cell-group
  5. v-for="(item, index) in list"
  6. :key="index"
  7. >
  8. <van-cell
  9. title-class="changtitle"
  10. :title="item.title"
  11. @click="onChange(index)"
  12. >
  13. <template slot="icon" style="padding-right: 10upx;">
  14. <van-radio-group :value="radio" >
  15. <van-radio checked-color="#D9332E" :name="index" >
  16. </van-radio>
  17. </van-radio-group>
  18. </template>
  19. </van-cell>
  20. </van-cell-group>
  21. </van-radio-group>
  22. <view class="payMoney" @click="payMoney" v-if="radio == 1">支付(圈币{{prices*ratio_points}})</view>
  23. <view class="payMoney" @click="payMoney" v-if="radio == 0">支付(¥{{prices}})</view>
  24. <Dialog :orderCancel="orderCancel"
  25. :titles="titles"
  26. :values="values"
  27. @colseDialog="cancelDialog"
  28. @confirmPay="confirmOrder"
  29. />
  30. </view>
  31. </template>
  32. <script>
  33. import Dialog from '@/component/Dialog.vue'
  34. export default {
  35. components: {
  36. Dialog
  37. },
  38. data() {
  39. return {
  40. values:'',
  41. orderCancel: false,
  42. titles:'',
  43. list:[
  44. {title:'微信支付'},
  45. {title:'圈币支付'}
  46. ],
  47. radio: 0,
  48. prices: '',
  49. order_id:'',
  50. isform: 0,
  51. ratio_points: 2,
  52. }
  53. },
  54. onLoad(e) {
  55. this.prices = e.prices;
  56. this.order_id = e.order_id;
  57. this.getuserInfo();
  58. //this.ratio_points = e.ratio_points;
  59. // this.isform = e.isform; // 1 dingdanfukuanguolai
  60. // if(this.ratio_points > 0) {
  61. // this.list = [
  62. // {title:'微信支付'},
  63. // {title:'圈币支付'}
  64. // ];
  65. // }else {
  66. // this.list = [
  67. // {title:'微信支付'}
  68. // ];
  69. // }
  70. },
  71. methods: {
  72. //获取用户信息
  73. getuserInfo() {
  74. this.request({
  75. url: '/v2/member/info',
  76. method:'post',
  77. success: (res) => {
  78. this.ratio_points = res.data.data.ratio_points;
  79. if(this.ratio_points > 0) {
  80. this.list = [
  81. {title:'微信支付'},
  82. {title:'圈币支付'}
  83. ];
  84. }else {
  85. this.list = [
  86. {title:'微信支付'}
  87. ];
  88. }
  89. }
  90. })
  91. },
  92. // 圈币取消支付
  93. cancelDialog() {
  94. this.orderCancel = false;
  95. },
  96. // 圈币确定支付
  97. confirmOrder() {
  98. this.orderCancel = false;
  99. this.request({
  100. url:'/v1/payment/pay',
  101. method:'POST',
  102. data: {
  103. pay_code: 'point',
  104. order_id: this.order_id
  105. },
  106. success: (res) => {
  107. if(res.data.code == 1000) {
  108. setTimeout(()=> {
  109. uni.navigateTo({
  110. url: `/pages/myOrder/finsh?isform=${this.isform}&order_id=${this.order_id}`
  111. })
  112. //uni.navigateBack()
  113. }, 1000)
  114. }
  115. }
  116. })
  117. },
  118. onChange(index) {
  119. this.radio = index;
  120. },
  121. payMoney() {
  122. if(this.radio == 0) {
  123. // 微信支付
  124. this.request({
  125. url:'/v1/payment/pay',
  126. method: 'post',
  127. data: {
  128. pay_code: 'wx',
  129. type: 1,
  130. order_id: this.order_id
  131. },
  132. success:(res) => {
  133. let { wx } = res.data.data;
  134. uni.requestPayment({
  135. provider: 'wxpay',
  136. timeStamp: wx.timeStamp,
  137. nonceStr: wx.nonceStr,
  138. package: wx.package,
  139. signType: 'MD5',
  140. paySign: wx.paySign,
  141. success: (res) => {
  142. let isform = 2;
  143. let order_id = this.order_id;
  144. uni.navigateTo({
  145. url: `/pages/myOrder/finsh?isform=${isform}&order_id=${order_id}`
  146. })
  147. },
  148. fail: function (err) {
  149. }
  150. })
  151. }
  152. })
  153. }else {
  154. this.titles = "圈币支付";
  155. this.values = "使用圈币支付"+this.prices*this.ratio_points;
  156. this.orderCancel = true;
  157. // 圈币支付
  158. // this.request({
  159. // url:'/v1/payment/pay',
  160. // method:'POST',
  161. // data: {
  162. // pay_code: 'point',
  163. // order_id: this.order_id
  164. // },
  165. // success: (res) => {
  166. // console.log(res);
  167. // }
  168. // })
  169. }
  170. }
  171. }
  172. }
  173. </script>
  174. <style>
  175. .payMoney {
  176. width: 90%;
  177. color: #fff;
  178. background-color: #D9332E;
  179. position: fixed;
  180. text-align: center;
  181. padding: 20upx 0;
  182. bottom: 5%;
  183. left: 5%;
  184. }
  185. .changtitle {
  186. padding-left: 10upx;
  187. }
  188. </style>