paymoment.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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="item.title"
  10. @click="onChange(index)"
  11. >
  12. <template slot="icon" style="padding-right: 10upx;">
  13. <van-radio-group :value="radio" >
  14. <van-radio checked-color="#D9332E" :name="index" >
  15. </van-radio>
  16. </van-radio-group>
  17. </template>
  18. </van-cell>
  19. </van-cell-group>
  20. </van-radio-group>
  21. <view class="payMoney" @click="payMoney" v-if="radio == 1">支付(圈币{{prices*ratio_points}})</view>
  22. <view class="payMoney" @click="payMoney" v-if="radio == 0">支付(¥{{prices}})</view>
  23. <Dialog :orderCancel="orderCancel"
  24. :titles="titles"
  25. :values="values"
  26. @colseDialog="cancelDialog"
  27. @confirmPay="confirmOrder"
  28. />
  29. </view>
  30. </template>
  31. <script>
  32. import Dialog from '@/component/Dialog.vue'
  33. export default {
  34. components: {
  35. Dialog
  36. },
  37. data() {
  38. return {
  39. values:'',
  40. orderCancel: false,
  41. titles:'',
  42. list:[
  43. {title:'微信支付'},
  44. {title:'圈币支付'}
  45. ],
  46. radio: 0,
  47. prices: '',
  48. order_id:'',
  49. isform: 0,
  50. ratio_points: 2,
  51. }
  52. },
  53. onLoad(e) {
  54. console.log(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. console.log(this.ratio_points);
  80. if(this.ratio_points > 0) {
  81. this.list = [
  82. {title:'微信支付'},
  83. {title:'圈币支付'}
  84. ];
  85. }else {
  86. this.list = [
  87. {title:'微信支付'}
  88. ];
  89. }
  90. }
  91. })
  92. },
  93. // 圈币取消支付
  94. cancelDialog() {
  95. this.orderCancel = false;
  96. },
  97. // 圈币确定支付
  98. confirmOrder() {
  99. this.orderCancel = false;
  100. this.request({
  101. url:'/v1/payment/pay',
  102. method:'POST',
  103. data: {
  104. pay_code: 'point',
  105. order_id: this.order_id
  106. },
  107. success: (res) => {
  108. console.log(res);
  109. //uni.$emit('finshesitmate');
  110. setTimeout(()=> {
  111. uni.navigateTo({
  112. url: `/pages/myOrder/finsh?isform=${this.isform}&order_id=${this.order_id}`
  113. })
  114. //uni.navigateBack()
  115. }, 2000)
  116. }
  117. })
  118. },
  119. onChange(index) {
  120. this.radio = index;
  121. },
  122. payMoney() {
  123. console.log("kkk")
  124. if(this.radio == 0) {
  125. // 微信支付
  126. this.request({
  127. url:'/v1/payment/pay',
  128. method: 'post',
  129. data: {
  130. pay_code: 'wx',
  131. type: 1,
  132. order_id: this.order_id
  133. },
  134. success:(res) => {
  135. let { wx } = res.data.data;
  136. console.log(wx)
  137. uni.requestPayment({
  138. provider: 'wxpay',
  139. timeStamp: wx.timeStamp,
  140. nonceStr: wx.nonceStr,
  141. package: wx.package,
  142. signType: 'MD5',
  143. paySign: wx.paySign,
  144. success: function (res) {
  145. console.log('success:' + JSON.stringify(res));
  146. },
  147. fail: function (err) {
  148. console.log('fail:' + JSON.stringify(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. </style>