add.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <view class="main">
  3. <view class="form_group">
  4. <view class="lable re">充值金额</view>
  5. <input type="number" v-model="item.money" placeholder="请输入充值金额" />
  6. </view>
  7. <button class="btn" @click="pay()">确认</button>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. item: {}
  15. };
  16. },
  17. methods: {
  18. pay() {
  19. this.http.request({
  20. url: '/app/wxPay/pay',
  21. method: 'POST',
  22. data: this.item,
  23. success: (res) => {
  24. wx.requestPayment({
  25. appId: res.data.data.appId,
  26. nonceStr: res.data.data.nonceStr,
  27. package: res.data.data.package,
  28. paySign: res.data.data.paySign,
  29. timeStamp: res.data.data.timeStamp,
  30. signType: res.data.data.signType,
  31. success: (r) => {
  32. uni.showModal({
  33. title: '提示',
  34. content: '充值成功:' + this.item.money + ' 元',
  35. showCancel: false,
  36. success: (res) => {
  37. uni.$emit('payMoney');
  38. uni.navigateBack();
  39. }
  40. });
  41. },
  42. fail: (r) => {
  43. uni.showModal({ content: r.data.msg, showCancel: false });
  44. }
  45. });
  46. }
  47. });
  48. }
  49. }
  50. };
  51. </script>
  52. <style lang="scss"></style>