payList.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="content" :style="{height:nowHeight}">
  3. <view class="pay-list-box">
  4. <view class="pay-title">
  5. <image src="../../../static/icon/moneyIcon.png" mode=""></image>
  6. <text>购买查询次数</text>
  7. </view>
  8. <view class="pay-content" :class="{'border-select':selectId === search.id}"
  9. v-for="search in searchList" :key='search.id' @click="selectPackage(search)">
  10. <view style="margin-left: 3%;">可查询次数 {{search.times}}</view>
  11. <view style="margin-right: 5%;">¥ {{search.money}}</view>
  12. </view>
  13. </view>
  14. <view class="pay-box">
  15. <view style="margin-left: 5%;">{{packageMoney}}元</view>
  16. <button type="primary" class="submit-message" @click="payPackage()">购买</button>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. var md5 = require("../../../common/md5.js");
  22. export default {
  23. data() {
  24. return {
  25. nowHeight:getApp().globalData.glbalHeight,
  26. selectId:'',
  27. packageMoney:'',
  28. searchList:[
  29. /* {
  30. times:'100',
  31. money:'10',
  32. id:'1',
  33. },
  34. {
  35. times:'200',
  36. money:'20',
  37. id:'2',
  38. },{
  39. times:'300',
  40. money:'30',
  41. id:'3',
  42. }, */
  43. ],
  44. }
  45. },
  46. onLoad() {
  47. this.getPayListRequest()
  48. },
  49. methods: {
  50. getPayListRequest(){
  51. let that = this;
  52. uni.request({
  53. url: getApp().globalData.shareUrl, //需要设置为全局
  54. method: 'POST',
  55. header: {
  56. 'content-type': 'application/x-www-form-urlencoded'
  57. },
  58. data: {
  59. method: 'charge_rule_list',
  60. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  61. uid: getApp().globalData.user_id,
  62. sign: md5('charge_rule_list' + getApp().globalData.globalTimestamp),
  63. },
  64. success: res => {
  65. that.searchList = res.data.msg;
  66. that.selectId = res.data.msg[0].id;
  67. that.packageMoney = res.data.msg[0].money
  68. }
  69. });
  70. },
  71. selectPackage(param){
  72. this.selectId = param.id;
  73. this.packageMoney = param.money + '元';
  74. },
  75. rechargeNext(obj){
  76. let that = this;
  77. uni.requestPayment({
  78. // provider: 'wxpay',
  79. timeStamp: obj.timeStamp,
  80. nonceStr: obj.nonceStr,
  81. package: obj.package,
  82. signType:obj.signType,
  83. paySign:obj.paySign,
  84. success: function (res) {
  85. uni.showToast({
  86. title: '支付成功',
  87. icon:'none'
  88. });
  89. uni.navigateBack({})
  90. },
  91. fail: function (err) {
  92. console.log('支付失败:' + JSON.stringify(err));
  93. }
  94. });
  95. },
  96. payPackage(){
  97. let that = this;
  98. uni.request({
  99. url:getApp().globalData.shareUrl, //需要设置为全局
  100. method: 'POST',
  101. header:{'content-type': 'application/x-www-form-urlencoded'},
  102. data: {
  103. method:'charge',
  104. timestamp:getApp().globalData.globalTimestamp, //Date.now()
  105. sign:md5('charge'+getApp().globalData.globalTimestamp),
  106. rule_id:that.selectId,//充值对应的id
  107. uid:getApp().globalData.user_id
  108. },
  109. success: res => {
  110. if(res.data.code === 200){
  111. console.log(res.data)
  112. that.rechargeNext(res.data.msg)
  113. }
  114. },
  115. fail: err => {
  116. console.log(err)
  117. },
  118. complete: () => {}
  119. });
  120. }
  121. }
  122. }
  123. </script>
  124. <style>
  125. .content {
  126. display: flex;
  127. flex-direction: column;
  128. align-items: center;
  129. justify-content: flex-start;
  130. background: #f4f5f7;
  131. }
  132. .pay-list-box {
  133. width: 95%;
  134. /* min-height:400upx; */
  135. background: #fff;
  136. margin-top: 3%;
  137. border-radius: 10rpx;
  138. }
  139. .pay-title {
  140. width: 95%;
  141. height: 80rpx;
  142. font-size: 30rpx;
  143. margin: 0 auto;
  144. border-bottom: 1px solid #d9d9d9;
  145. display: flex;
  146. align-items: center;
  147. }
  148. .pay-title image {
  149. width: 50upx;
  150. height: 50upx;
  151. margin-right: 2%;
  152. }
  153. .pay-content {
  154. width: 95%;
  155. height: 90rpx;
  156. font-size: 30rpx;
  157. margin: 3% auto;
  158. border: 1px solid #d9d9d9;
  159. display: flex;
  160. align-items: center;
  161. justify-content: space-between;
  162. border-radius: 10rpx;
  163. }
  164. .pay-box {
  165. width: 100%;
  166. height: 100rpx;
  167. position: fixed;
  168. bottom: 0;
  169. background: #fff;
  170. display: flex;
  171. align-items: center;
  172. }
  173. .pay-box button {
  174. margin-right: 5%;
  175. height: 55rpx;
  176. line-height: 55rpx;
  177. font-size: 28rpx;
  178. background: #27BCEF;
  179. }
  180. .border-select {
  181. border:2px solid #27BCEF !important;
  182. }
  183. </style>