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.

352 lines
8.5 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 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
  174. .projectDetail.price
  175. })
  176. }
  177. });
  178. });
  179. jWeixin.error(function(res) {
  180. // uni.showToast({
  181. // icon: 'none',
  182. // title: '支付失败',
  183. // });
  184. });
  185. },
  186. }
  187. }
  188. </script>
  189. <style scoped>
  190. .content {
  191. padding-bottom: 60px;
  192. }
  193. body {
  194. background-color: #fff;
  195. }
  196. .center {
  197. width: 710rpx;
  198. height: 316rpx;
  199. margin: 40rpx auto;
  200. }
  201. .center image {
  202. width: 710rpx;
  203. height: 316rpx;
  204. border-radius: 12rpx;
  205. }
  206. .font-m {
  207. font-family: PingFang SC, PingFang SC-Bold;
  208. font-weight: 700;
  209. text-align: left;
  210. color: #ffffff;
  211. text-shadow: 0 4rpx 6rpx 0 rgba(40, 170, 133, 0.81);
  212. }
  213. .item-line input {
  214. width: 456rpx;
  215. height: 60rpx;
  216. line-height: 60rpx;
  217. background: #f5f5f5;
  218. border-radius: 12rpx;
  219. font-size: 24rpx;
  220. font-family: PingFang SC, PingFang SC-Medium;
  221. font-weight: 500;
  222. text-align: left;
  223. color: #939393;
  224. padding: 0 20rpx;
  225. }
  226. .from-body {
  227. padding: 0rpx 20rpx 40rpx 20rpx;
  228. font-size: 28rpx;
  229. text-align: left;
  230. color: #333333;
  231. }
  232. .top-label {
  233. position: relative;
  234. width: 96%;
  235. margin-left: 2%;
  236. height: 200rpx;
  237. background-image: url(/static/ms/cz.png);
  238. background-repeat: no-repeat;
  239. background-size: 100% 100%;
  240. overflow: hidden;
  241. border-radius: 10px;
  242. margin-top: 20rpx;
  243. }
  244. .top-label-box {
  245. position: relative;
  246. height: 100%;
  247. padding-left: 35rpx;
  248. box-sizing: border-box;
  249. }
  250. .top-label-box .activeLabel {
  251. position: absolute;
  252. left: 0;
  253. top: 0;
  254. width: 100%;
  255. height: 100%;
  256. background: url('../../static/ms/select.png');
  257. background-repeat: no-repeat;
  258. background-size: 100% 100%;
  259. }
  260. .top-label-box-one {
  261. display: flex;
  262. align-items: center;
  263. }
  264. .top-label-box-two {
  265. margin-left: 18rpx;
  266. font-size: 12px;
  267. padding: 6rpx 8rpx;
  268. background-color: #EBCB85;
  269. border-bottom-left-radius: 10px;
  270. border-top-right-radius: 10px;
  271. }
  272. .top-label-box-tag {
  273. position: absolute;
  274. border: 1px solid;
  275. font-size: 12px;
  276. padding: 6rpx 10rpx;
  277. color: #fff;
  278. background-color: #24CC80;
  279. top: -1px;
  280. right: 0px;
  281. border-bottom-left-radius: 10px;
  282. }
  283. .money {
  284. margin: 20rpx 0rpx;
  285. }
  286. .money .van-cell-group--inset {
  287. margin: 0;
  288. }
  289. .money .van-field {
  290. padding: auto 0rpx;
  291. margin-bottom: 30rpx !important;
  292. }
  293. .recharge {
  294. position: fixed;
  295. display: flex;
  296. justify-content: center;
  297. align-items: center;
  298. left: 0;
  299. bottom: 0;
  300. width: 750rpx;
  301. height: 100rpx;
  302. background: white;
  303. }
  304. .recharge .btn {
  305. width: 85%;
  306. height: 80rpx;
  307. border-radius: 40rpx;
  308. color: white;
  309. text-align: center;
  310. line-height: 80rpx;
  311. font-size: 28rpx;
  312. background: #EF8C94;
  313. }
  314. .withdrawal-statement {
  315. color: #666666;
  316. }
  317. @media all and (min-width: 961px) {
  318. .recharge {
  319. left: 50% !important;
  320. transform: translateX(-50%);
  321. }
  322. }
  323. </style>