phoneBill.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <view class="content">
  3. <view class="cz-top">
  4. <!-- 背景半圆 -->
  5. <view class="top-bg"></view>
  6. <view class="top-tit">
  7. 充值号码
  8. </view>
  9. <input type="number" class="top-phone" placeholder="请输入充值号码" v-model="phone">
  10. </view>
  11. <view class="tc-wrap">
  12. <view class="tc-tit">
  13. 请选择充值套餐
  14. </view>
  15. <view class="tc-list flex">
  16. <view class="list-item flex" v-for="(item,index) in list" :class="{'item-action': index == actionIndex}" @click="choosTc(item,index)">
  17. <view class="item-val">
  18. {{item.get_money}}<text class="dw">元</text>
  19. </view>
  20. <view class="item-price">
  21. 售价{{item.price}}元
  22. </view>
  23. </view>
  24. </view>
  25. <view class="tc-pay flex">
  26. <view class="pay-tit">
  27. 应付金额
  28. </view>
  29. <view class="pay-price">
  30. ¥{{action.price}}元
  31. </view>
  32. </view>
  33. </view>
  34. <view class="pay-type-list">
  35. <view class="type-item b-b" @click="changePayType(1)">
  36. <text class="icon iconfont iconweixin"></text>
  37. <view class="con">
  38. <text class="tit">微信支付</text>
  39. </view>
  40. <label class="radio">
  41. <radio value="" color="#921a23" :checked="payType == 1"></radio>
  42. </label>
  43. </view>
  44. <!-- <view class="type-item" @click="changePayType(3)">
  45. <text class="icon iconfont iconyue"></text>
  46. <view class="con">
  47. <text class="tit">余额支付</text>
  48. </view>
  49. <label class="radio">
  50. <radio value="" color="#921a23" :checked="payType == 3"></radio>
  51. </label>
  52. </view> -->
  53. </view>
  54. <view class="sub-btn" @click="gopay">
  55. 立即充值
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import { getPhoneTc, phonePay } from '@/api/index.js'
  61. export default {
  62. data() {
  63. return {
  64. action: {},
  65. list: [],
  66. phone: '',
  67. payType: 1, //支付类型 1-》微信 3-》余额
  68. actionIndex: 0,
  69. payMoney: 0,
  70. loaded: false,//是否提交中
  71. }
  72. },
  73. onLoad() {
  74. this.getTc()
  75. },
  76. onShow() {
  77. },
  78. onReachBottom() {
  79. },
  80. onReady() {
  81. },
  82. methods: {
  83. // 选择支付方式
  84. changePayType(index) {
  85. this.payType = index
  86. },
  87. // 选择套餐
  88. choosTc(item,index) {
  89. this.actionIndex = index
  90. this.action = item
  91. },
  92. gopay() {
  93. let obj = this
  94. if(obj.loaded) {
  95. return
  96. }
  97. if(obj.phone == '') {
  98. return obj.$api.msg('请输入充值号码')
  99. }
  100. if (!/(^1[2|3|4|5|6|7|8|9][0-9]{9}$)/.test(obj.phone)) {
  101. return obj.$api.msg('请输入正确的手机号码')
  102. }
  103. obj.loaded = true
  104. phonePay({
  105. rechar_id: obj.action.id,
  106. mobile: obj.phone
  107. }).then(res => {
  108. console.log(res)
  109. let da = res.data
  110. let data = {
  111. // #ifdef H5
  112. timestamp: da.timestamp,
  113. // #endif
  114. // #ifdef MP
  115. timeStamp: da.timestamp,
  116. // #endif
  117. nonceStr: da.nonceStr,
  118. package: da.package,
  119. signType: da.signType,
  120. paySign: da.paySign,
  121. success: function(res) {
  122. // obj.paySuccessTo();
  123. uni.showToast({
  124. title:'充值成功',
  125. duration:2000
  126. });
  127. obj.loaded = false
  128. },
  129. fail: () => {
  130. obj.loaded = false
  131. },
  132. };
  133. wx.requestPayment(data);
  134. })
  135. },
  136. // 获取套餐
  137. getTc() {
  138. getPhoneTc().then(res => {
  139. console.log(res)
  140. this.list = res.data.recharge_quota
  141. this.action = res.data.recharge_quota[0]
  142. })
  143. },
  144. }
  145. }
  146. </script>
  147. <style lang="scss">
  148. .cz-top {
  149. height: 450rpx;
  150. width: 750rpx;
  151. // overflow: hidden;
  152. position: relative;
  153. .top-bg {
  154. position: absolute;
  155. bottom: 0;
  156. left: -825rpx;
  157. margin: auto;
  158. width: 2400rpx;
  159. height: 2400rpx;
  160. border-radius: 50%;
  161. background-color: #901b21;
  162. }
  163. .top-tit {
  164. position: relative;
  165. padding: 50rpx 27rpx 30rpx;
  166. font-size: 26rpx;
  167. font-weight: bold;
  168. color: #FFFFFF;
  169. }
  170. .top-phone {
  171. position: relative;
  172. font-size: 28rpx;
  173. font-weight: bold;
  174. color: #FFFFFF;
  175. display: block;
  176. border-bottom: 1px solid #ffff;
  177. width: 696rpx;
  178. height: 70rpx;
  179. line-height: 70rpx;
  180. margin: auto;
  181. }
  182. }
  183. .tc-wrap {
  184. width: 694rpx;
  185. min-height: 308rpx;
  186. background: #FFFFFF;
  187. box-shadow: 0px 0px 20px 0px rgba(50, 50, 52, 0.06);
  188. border-radius: 21rpx;
  189. margin: -200rpx auto 0;
  190. position: relative;
  191. padding: 30rpx;
  192. .tc-tit {
  193. font-size: 28rpx;
  194. font-weight: bold;
  195. color: #010101;
  196. }
  197. .tc-list {
  198. flex-wrap: wrap;
  199. justify-content: flex-start;
  200. padding: 20rpx 0;
  201. .list-item {
  202. width: 200rpx;
  203. height: 129rpx;
  204. background: #fff4f5;
  205. border-radius: 7px;
  206. flex-direction: column;
  207. justify-content: center;
  208. align-items: center;
  209. margin-right: 10rpx;
  210. margin-bottom: 10rpx;
  211. .item-val {
  212. font-size: 36rpx;
  213. font-weight: bold;
  214. color: #ff4c4c;
  215. padding-bottom: 15rpx;
  216. .dw {
  217. font-size: 26rpx;
  218. }
  219. }
  220. .item-price {
  221. font-size: 21rpx;
  222. font-weight: bold;
  223. color: #999999;
  224. }
  225. }
  226. .item-action {
  227. background: #901b21;
  228. .item-val {
  229. color: #fff;
  230. }
  231. .item-price {
  232. color: #fff;
  233. }
  234. }
  235. }
  236. .tc-pay {
  237. font-size: 28rpx;
  238. justify-content: space-between;
  239. font-weight: bold;
  240. color: #333333;
  241. .pay-price {
  242. color: #FF0000;
  243. }
  244. }
  245. }
  246. .pay-type-list {
  247. margin: auto;
  248. margin-top: 20rpx;
  249. background-color: #fff;
  250. padding-left: 60upx;
  251. width: 694rpx;
  252. border-radius: 20rpx;
  253. .type-item {
  254. height: 120upx;
  255. padding: 20upx 0;
  256. display: flex;
  257. justify-content: space-between;
  258. align-items: center;
  259. padding-right: 60upx;
  260. font-size: 30upx;
  261. position: relative;
  262. }
  263. .icon {
  264. width: 100upx;
  265. font-size: 52upx;
  266. }
  267. .iconyue {
  268. color: #fe8e2e;
  269. }
  270. .iconweixin {
  271. color: #36cb59;
  272. }
  273. .iconzhifubao {
  274. color: #01aaef;
  275. }
  276. .tit {
  277. font-size: $font-lg;
  278. color: $font-color-dark;
  279. margin-bottom: 4upx;
  280. }
  281. .con {
  282. flex: 1;
  283. display: flex;
  284. flex-direction: column;
  285. font-size: $font-sm;
  286. color: $font-color-light;
  287. }
  288. }
  289. .sub-btn {
  290. width: 680rpx;
  291. height: 83rpx;
  292. background-color: #901b21;
  293. border-radius: 42rpx;
  294. margin: 74rpx auto 20rpx;
  295. font-size: 32rpx;
  296. font-weight: bold;
  297. color: #fff;
  298. text-align: center;
  299. line-height: 83rpx;
  300. }
  301. </style>