payList.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. }
  67. });
  68. },
  69. selectPackage(param){
  70. this.selectId = param.id;
  71. this.packageMoney = param.money + '元';
  72. },
  73. rechargeNext(obj){
  74. let that = this;
  75. uni.requestPayment({
  76. // provider: 'wxpay',
  77. timeStamp: obj.timeStamp,
  78. nonceStr: obj.nonceStr,
  79. package: obj.package,
  80. signType:obj.signType,
  81. paySign:obj.paySign,
  82. success: function (res) {
  83. uni.showToast({
  84. title: '支付成功',
  85. icon:'none'
  86. });
  87. uni.navigateBack({})
  88. },
  89. fail: function (err) {
  90. console.log('支付失败:' + JSON.stringify(err));
  91. }
  92. });
  93. },
  94. payPackage(){
  95. let that = this;
  96. uni.request({
  97. url:getApp().globalData.shareUrl, //需要设置为全局
  98. method: 'POST',
  99. header:{'content-type': 'application/x-www-form-urlencoded'},
  100. data: {
  101. method:'charge',
  102. timestamp:getApp().globalData.globalTimestamp, //Date.now()
  103. sign:md5('charge'+getApp().globalData.globalTimestamp),
  104. rule_id:that.selectId,//充值对应的id
  105. uid:getApp().globalData.user_id
  106. },
  107. success: res => {
  108. if(res.data.code === 200){
  109. console.log(res.data)
  110. that.rechargeNext(res.data.msg)
  111. }
  112. },
  113. fail: err => {
  114. console.log(err)
  115. },
  116. complete: () => {}
  117. });
  118. }
  119. }
  120. }
  121. </script>
  122. <style>
  123. .content {
  124. display: flex;
  125. flex-direction: column;
  126. align-items: center;
  127. justify-content: flex-start;
  128. background: #f4f5f7;
  129. }
  130. .pay-list-box {
  131. width: 95%;
  132. /* min-height:400upx; */
  133. background: #fff;
  134. margin-top: 3%;
  135. border-radius: 10rpx;
  136. }
  137. .pay-title {
  138. width: 95%;
  139. height: 80rpx;
  140. font-size: 30rpx;
  141. margin: 0 auto;
  142. border-bottom: 1px solid #d9d9d9;
  143. display: flex;
  144. align-items: center;
  145. }
  146. .pay-title image {
  147. width: 50upx;
  148. height: 50upx;
  149. margin-right: 2%;
  150. }
  151. .pay-content {
  152. width: 95%;
  153. height: 90rpx;
  154. font-size: 30rpx;
  155. margin: 3% auto;
  156. border: 1px solid #d9d9d9;
  157. display: flex;
  158. align-items: center;
  159. justify-content: space-between;
  160. border-radius: 10rpx;
  161. }
  162. .pay-box {
  163. width: 100%;
  164. height: 100rpx;
  165. position: fixed;
  166. bottom: 0;
  167. background: #fff;
  168. display: flex;
  169. align-items: center;
  170. }
  171. .pay-box button {
  172. margin-right: 5%;
  173. height: 55rpx;
  174. line-height: 55rpx;
  175. font-size: 28rpx;
  176. background: #27BCEF;
  177. }
  178. .border-select {
  179. border:2px solid #27BCEF !important;
  180. }
  181. </style>