paymoment.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. console.log(e);
  56. console.log("支付");
  57. this.prices = e.prices;
  58. this.order_id = e.order_id;
  59. this.getuserInfo();
  60. this.isform = e.isform;
  61. //this.ratio_points = e.ratio_points;
  62. // this.isform = e.isform; // 1 dingdanfukuanguolai
  63. // if(this.ratio_points > 0) {
  64. // this.list = [
  65. // {title:'微信支付'},
  66. // {title:'圈币支付'}
  67. // ];
  68. // }else {
  69. // this.list = [
  70. // {title:'微信支付'}
  71. // ];
  72. // }
  73. },
  74. methods: {
  75. //获取用户信息
  76. getuserInfo() {
  77. this.request({
  78. url: '/v2/member/info',
  79. method:'post',
  80. success: (res) => {
  81. this.ratio_points = res.data.data.ratio_points;
  82. if(this.ratio_points > 0) {
  83. this.list = [
  84. {title:'微信支付'},
  85. {title:'圈币支付'}
  86. ];
  87. }else {
  88. this.list = [
  89. {title:'微信支付'}
  90. ];
  91. }
  92. }
  93. })
  94. },
  95. // 圈币取消支付
  96. cancelDialog() {
  97. this.orderCancel = false;
  98. },
  99. // 圈币确定支付
  100. confirmOrder() {
  101. this.orderCancel = false;
  102. this.request({
  103. url:'/v1/payment/pay',
  104. method:'POST',
  105. data: {
  106. pay_code: 'point',
  107. order_id: this.order_id
  108. },
  109. success: (res) => {
  110. if(res.data.code == 1000) {
  111. setTimeout(()=> {
  112. let isform = this.isform;
  113. uni.navigateTo({
  114. url: `/pages/myOrder/finsh?isform=${isform}&order_id=${this.order_id}`
  115. })
  116. //uni.navigateBack()
  117. }, 1000)
  118. }
  119. }
  120. })
  121. },
  122. onChange(index) {
  123. this.radio = index;
  124. },
  125. payMoney() {
  126. if(this.radio == 0) {
  127. // 微信支付
  128. this.request({
  129. url:'/v1/payment/pay',
  130. method: 'post',
  131. data: {
  132. pay_code: 'wx',
  133. type: 1,
  134. order_id: this.order_id
  135. },
  136. success:(res) => {
  137. let { wx } = res.data.data;
  138. uni.requestPayment({
  139. provider: 'wxpay',
  140. timeStamp: wx.timeStamp,
  141. nonceStr: wx.nonceStr,
  142. package: wx.package,
  143. signType: 'MD5',
  144. paySign: wx.paySign,
  145. success: (res) => {
  146. let isform = this.isform;
  147. let order_id = this.order_id;
  148. uni.navigateTo({
  149. url: `/pages/myOrder/finsh?isform=${isform}&order_id=${order_id}`
  150. })
  151. },
  152. fail: function (err) {
  153. }
  154. })
  155. }
  156. })
  157. }else {
  158. this.titles = "圈币支付";
  159. this.values = "使用圈币支付"+this.prices*this.ratio_points;
  160. this.orderCancel = true;
  161. // 圈币支付
  162. // this.request({
  163. // url:'/v1/payment/pay',
  164. // method:'POST',
  165. // data: {
  166. // pay_code: 'point',
  167. // order_id: this.order_id
  168. // },
  169. // success: (res) => {
  170. // console.log(res);
  171. // }
  172. // })
  173. }
  174. }
  175. }
  176. }
  177. </script>
  178. <style>
  179. .payMoney {
  180. width: 90%;
  181. color: #fff;
  182. background-color: #D9332E;
  183. position: fixed;
  184. text-align: center;
  185. padding: 20upx 0;
  186. bottom: 5%;
  187. left: 5%;
  188. }
  189. .changtitle {
  190. padding-left: 10upx;
  191. }
  192. </style>