You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

365 lines
8.7 KiB

8 months ago
  1. <template>
  2. <view class="content">
  3. <mNavbar title="我的钱包" :leftClick="leftClick" />
  4. <view class="banner" />
  5. <view class="b-relative center font-m">
  6. <image src="/static/ms/w.png" />
  7. <view class="title" style="position: absolute; top: 40rpx; left: 40rpx">
  8. <view style="line-height: 40rpx; font-size: 28rpx">账号余额</view>
  9. <view style="line-height: 60rpx; font-size: 40rpx">{{ userInfo.price }}</view>
  10. </view>
  11. <view class="font-menu flex flex-sb">
  12. <view @click="toRunningWater(0)">充值记录</view>
  13. <view @click="toRunningWater(1)">提现记录</view>
  14. <view @click="toRunningWater(2)">下单记录</view>
  15. <view @click="toRunningWater(3)">佣金记录</view>
  16. </view>
  17. </view>
  18. <view class="from-body">
  19. <view>我要充值</view>
  20. <view @click="selectOption(index)" class="top-label" v-for="(item,index) in rechargeList" :key="item.id">
  21. <view class="top-label-box">
  22. <view style="font-size: 14px; font-weight: 500; padding: 20rpx 0px 10rpx;">充值</view>
  23. <view class="top-label-box-one">
  24. <view style="font-size: 20px;">{{ item.money }}</view>
  25. <text></text>
  26. <!-- <view class="top-label-box-two">{{ item.discount == 0 ? "不享优惠" : `${item.discount}折优惠`}}</view> -->
  27. <view style="font-size: 12px; color: #47D594; margin-left: 20rpx;">{{ item.sendMoney }}.00
  28. </view>
  29. </view>
  30. <view style="font-size: 10px; margin-top: 40rpx;">{{ item.remarks }}</view>
  31. <!-- <view class="top-label-box-tag">到期时间{{ item.endTime }}</view> -->
  32. <div :class="{ activeLabel : optionIndex == index }"></div>
  33. </view>
  34. </view>
  35. <view class="money">
  36. <van-cell-group inset>
  37. <van-field @update:model-value="priceChange" type="number" v-model="price" label="¥"
  38. placeholder="请输入自定义金额" label-width="10" label-align="center "
  39. style="background-color: #F5F5F5; margin: 10rpx 0px; border-radius: 20px;" />
  40. <van-field v-model="phone" placeholder="请输入技师手机号"
  41. style="background-color: #F5F5F5; margin: 10rpx 0px; border-radius: 20px;" />
  42. </van-cell-group>
  43. </view>
  44. <view>充值说明</view>
  45. <view v-html="instructions" style="line-height: 40rpx; font-size: 24rpx;color: #666666; font-weight: 400;">
  46. </view>
  47. </view>
  48. <view class="recharge">
  49. <view @click="wxPay" class="btn">
  50. 立即充值
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import mNavbar from '@/components/base/m-navbar.vue'
  57. export default {
  58. components: {
  59. mNavbar,
  60. },
  61. data() {
  62. return {
  63. rechargeList: [],
  64. userInfo: {},
  65. optionIndex: 0,
  66. instructions: [],
  67. price: '',
  68. phone: '',
  69. id: undefined,
  70. rechargePrice: 0
  71. }
  72. },
  73. onShow() {
  74. this.getrRechargeList()
  75. this.getUserInfo()
  76. this.getConfig()
  77. },
  78. methods: {
  79. getUserInfo() {
  80. this.$api('getUserInfo', {}, res => {
  81. if (res.code == 200) {
  82. this.userInfo = res.result;
  83. }
  84. })
  85. },
  86. //获取充值套餐
  87. getrRechargeList() {
  88. this.$api('getRechargeList', {}, res => {
  89. if (res.code == 200) {
  90. const rechargeList = res.result;
  91. this.rechargeList = rechargeList;
  92. //默认选中第一个充值方案
  93. this.rechargePrice = rechargeList[0].money;
  94. this.id = rechargeList[0].id;
  95. }
  96. })
  97. },
  98. leftClick() { //返回个人中心
  99. uni.switchTab({
  100. url: '/pages/index/center'
  101. })
  102. },
  103. selectOption(index) { //选择充值方案
  104. this.optionIndex = index;
  105. this.id = this.rechargeList[index].id;
  106. this.rechargePrice = this.rechargeList[index].money;
  107. },
  108. toRunningWater(status) { //跳转流水页面
  109. uni.navigateTo({
  110. url: `/pages/mine/runningWater?status=${status}`
  111. })
  112. },
  113. wxPay() { //立即充值(支付)
  114. if (this.phone) {
  115. if (!this.validatePhone(this.phone)) {
  116. return uni.showToast({
  117. title: '手机号格式不合法',
  118. icon: 'none'
  119. })
  120. }
  121. }
  122. let data = {
  123. price: this.rechargePrice ? this.rechargePrice : this.price,
  124. type: 0,
  125. phone: this.phone,
  126. id: this.id
  127. }
  128. this.$api('recharge', data, res => {
  129. if (res.code == 200) {
  130. this.chooseWXPay(res)
  131. }
  132. })
  133. },
  134. getConfig() { //获取配置
  135. this.$api('getConfig', {}, res => {
  136. if (res.code == 200) {
  137. for (let i = 0; i < res.result.length; i++) {
  138. if (res.result[i].keyValue == 'payValue') {
  139. this.instructions = res.result[i].content
  140. }
  141. }
  142. }
  143. })
  144. },
  145. priceChange(price) { //用户输入充值金额
  146. this.rechargePrice = undefined;
  147. this.optionIndex = undefined;
  148. this.id = undefined;
  149. },
  150. validatePhone(phone) {
  151. var phoneRegex = /^1(3|4[0-9]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9\d)\d{8}$/;
  152. return phoneRegex.test(phone);
  153. },
  154. chooseWXPay(res){
  155. window.jWeixin.config({
  156. debug: false,
  157. appId:res.result.appId,//必填
  158. jsApiList: ['chooseWXPay']
  159. });
  160. window.jWeixin.ready(function() {
  161. window.jWeixin.chooseWXPay({
  162. appId: res.result.appId,
  163. timestamp: res.result
  164. .timeStamp, // 支付签名时间戳,注意微信 jssdk 中的所有使用 timestamp 字段均为小写。但最新版的支付后台生成签名使用的 timeStamp 字段名需大写其中的 S 字符
  165. nonceStr: res.result.nonceStr, // 支付签名随机串,不长于 32 位
  166. package: res.result.packageValue, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
  167. signType: res.result.signType, // 微信支付V3的传入 RSA ,微信支付V2的传入格式与V2统一下单的签名格式保持一致
  168. paySign: res.result.paySign, // 支付签名
  169. success: function(res) {
  170. this.getUserInfo()
  171. // 支付成功后的回调函数
  172. uni.navigateTo({
  173. url: '/pages/payment/payment-success?price=' + this.projectDetail.price
  174. })
  175. }
  176. });
  177. });
  178. jWeixin.error(function(res) {
  179. // uni.showToast({
  180. // icon: 'none',
  181. // title: '支付失败',
  182. // });
  183. });
  184. },
  185. }
  186. }
  187. </script>
  188. <style scoped>
  189. .content {
  190. padding-bottom: 60px;
  191. }
  192. body {
  193. background-color: #fff;
  194. }
  195. .banner {
  196. width: 100vw;
  197. height: 256rpx;
  198. background: #cfece7;
  199. }
  200. .center {
  201. width: 710rpx;
  202. height: 316rpx;
  203. margin: -204rpx auto 0;
  204. }
  205. .center image {
  206. width: 710rpx;
  207. height: 316rpx;
  208. border-radius: 12rpx;
  209. }
  210. .font-m {
  211. font-family: PingFang SC, PingFang SC-Bold;
  212. font-weight: 700;
  213. text-align: left;
  214. color: #ffffff;
  215. text-shadow: 0 4rpx 6rpx 0 rgba(40, 170, 133, 0.81);
  216. }
  217. .font-menu {
  218. font-size: 24rpx;
  219. font-family: PingFang SC, PingFang SC-Regular;
  220. font-weight: 500;
  221. text-align: center;
  222. color: #ffffff;
  223. line-height: 24rpx;
  224. width: 710rpx;
  225. position: absolute;
  226. left: 0;
  227. bottom: 25rpx;
  228. }
  229. .font-menu view {
  230. width: calc(100% / 4);
  231. border-right: 1rpx solid #fff;
  232. }
  233. .item-line input {
  234. width: 456rpx;
  235. height: 60rpx;
  236. line-height: 60rpx;
  237. background: #f5f5f5;
  238. border-radius: 12rpx;
  239. font-size: 24rpx;
  240. font-family: PingFang SC, PingFang SC-Medium;
  241. font-weight: 500;
  242. text-align: left;
  243. color: #939393;
  244. padding: 0 20rpx;
  245. }
  246. .from-body {
  247. padding: 40rpx 20rpx;
  248. font-size: 28rpx;
  249. text-align: left;
  250. color: #333333;
  251. }
  252. .top-label {
  253. position: relative;
  254. width: 96%;
  255. margin-left: 2%;
  256. height: 200rpx;
  257. background-image: url(/static/ms/cz.png);
  258. background-repeat: no-repeat;
  259. background-size: 100% 100%;
  260. overflow: hidden;
  261. border-radius: 10px;
  262. margin-top: 20rpx;
  263. }
  264. .top-label-box {
  265. position: relative;
  266. height: 100%;
  267. padding-left: 35rpx;
  268. box-sizing: border-box;
  269. }
  270. .top-label-box .activeLabel {
  271. position: absolute;
  272. left: 0;
  273. top: 0;
  274. width: 100%;
  275. height: 100%;
  276. background: url('../../static/ms/select.png');
  277. background-repeat: no-repeat;
  278. background-size: 100% 100%;
  279. }
  280. .top-label-box-one {
  281. display: flex;
  282. align-items: center;
  283. }
  284. .top-label-box-two {
  285. margin-left: 18rpx;
  286. font-size: 12px;
  287. padding: 6rpx 8rpx;
  288. background-color: #EBCB85;
  289. border-bottom-left-radius: 10px;
  290. border-top-right-radius: 10px;
  291. }
  292. .top-label-box-tag {
  293. position: absolute;
  294. border: 1px solid;
  295. font-size: 12px;
  296. padding: 6rpx 10rpx;
  297. color: #fff;
  298. background-color: #24CC80;
  299. top: -1px;
  300. right: 0px;
  301. border-bottom-left-radius: 10px;
  302. }
  303. .money {
  304. margin: 20rpx 0rpx;
  305. }
  306. .recharge {
  307. position: fixed;
  308. display: flex;
  309. justify-content: center;
  310. align-items: center;
  311. left: 0;
  312. bottom: 0;
  313. width: 750rpx;
  314. height: 100rpx;
  315. background: white;
  316. }
  317. .recharge .btn {
  318. display: flex;
  319. align-items: center;
  320. justify-content: center;
  321. width: 85%;
  322. height: 80rpx;
  323. border-radius: 40rpx;
  324. color: white;
  325. font-size: 28rpx;
  326. background: linear-gradient(180deg, #6FDFBE, #5AC796);
  327. }
  328. @media all and (min-width: 961px) {
  329. .recharge {
  330. left: 50% !important;
  331. transform: translateX(-50%);
  332. }
  333. }
  334. </style>