index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  1. <template>
  2. <view>
  3. <view class="flex text-center text-lg bg" v-if="isAgency == 1 && tgCheck != '否'">
  4. <view class="title_btn flex-sub bg" @click="cut(1)" :class="title_color==1?'bgCol2': ''">我的充值
  5. </view>
  6. <view class="title_btn flex-sub bg" @click="cut(2)" :class="title_color==2?'bgCol2': ''">我的收益
  7. </view>
  8. </view>
  9. <view v-if="title_color==1" class="padding">
  10. <view class="info-box">
  11. <view class=" u-flex u-p-l-30 u-p-t-30 u-p-b-30">
  12. <view class="u-m-r-20">
  13. <u-avatar :src="avatar" size="140"></u-avatar>
  14. </view>
  15. <view class="u-flex-1 ">
  16. <view style="font-size: 48rpx;color: #222222;font-weight: bold;">¥{{money}}</view>
  17. <view style="font-size: 24rpx;color: #AAAAAA;margin-top: 20rpx;">只能用于平台消费支付,充值后不可退款</view>
  18. </view>
  19. </view>
  20. </view>
  21. <!-- <view class="margin-top radius bg flex justify-between flex-wrap padding-lr padding-bottom">
  22. <view v-for="(item,index) in wallet" :key='index'
  23. class="flex justify-between padding-sm radius margin-top"
  24. style="color:#20C675;background-color:#EAFFF5; width:48%;border: 1rpx solid #20C675;"
  25. @click="active(item)" :class="{active:item.isSelect}">
  26. <view>
  27. ¥{{item.price}}
  28. </view>
  29. </view>
  30. </view> -->
  31. <view class=" flex justify-between flex-wrap"
  32. v-if="wallet.length > 0">
  33. <view v-for="(item,index) in wallet" :key='index' class="item"
  34. @click="active(item)" :class="{active:item.isSelect}">
  35. <view class="price" v-if="item.coupon && item.coupon.money">
  36. ¥{{item.price}}
  37. </view>
  38. <view class="price" v-else style="height: 100%;display: flex;align-items: center;">
  39. ¥{{item.price}}
  40. </view>
  41. <view class="desc" v-if="item.coupon && item.coupon.money">
  42. 赠送{{item.giveNum}}张{{item.coupon.money}}元优惠券
  43. </view>
  44. </view>
  45. </view>
  46. <view class="bg margin-top padding-lr radius">
  47. <view>
  48. <view style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;justify-content: space-between;"
  49. v-for="(item,index) in openLists" :key='index'>
  50. <view class="flex">
  51. <image :src="item.image" style="width: 48rpx;height: 48rpx;border-radius: 50upx;"></image>
  52. <view style="font-size: 30upx;margin-left: 20upx;">{{item.text}}
  53. </view>
  54. </view>
  55. <radio-group name="openWay" style="margin-left: 20upx;" @tap='selectWay(item)'>
  56. <label class="tui-radio">
  57. <radio color="#FF6E98" style="transform:scale(0.7)" :checked="openWay === item.id ? true : false" />
  58. </label>
  59. </radio-group>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="bg radius margin-top padding">
  64. <view class="flex align-center justify-between" @click="goNav('/my/wallet/mymoneydetail')">
  65. <view class="flex align-center">
  66. <image
  67. src="/static/image/icon_coin.png"
  68. style="width: 48rpx;height: 48rpx;"></image>
  69. <view class="margin-left">钱包明细</view>
  70. </view>
  71. <image src="../../static/img/you.png" style="width: 18rpx;height: 32rpx;"></image>
  72. </view>
  73. <view class="flex align-center justify-between margin-top-xl" @click="goNav('/my/wallet/zhifubao')"
  74. v-if="isAgency == 1">
  75. <view class="flex align-center">
  76. <image
  77. src="/static/image/icon_card.png"
  78. style="width: 48rpx;height: 34rpx;"></image>
  79. <view style="margin-left:26upx">提现账号</view>
  80. </view>
  81. <image src="../../static/img/you.png" style="width: 18rpx;height: 32rpx;"></image>
  82. </view>
  83. <view class="flex align-center justify-between margin-top-xl" @click="goNav('/my/wallet/cashList')"
  84. v-if="isAgency == 1">
  85. <view class="flex align-center">
  86. <image
  87. src="/static/image/icon_note.png"
  88. style="width: 40rpx;height: 52rpx;"></image>
  89. <view style="margin-left: 36rpx;">提现记录</view>
  90. </view>
  91. <image src="../../static/img/you.png" style="width: 18rpx;height: 32rpx;"></image>
  92. </view>
  93. <!-- <view @click="TuiPrice()" v-if="renzheng ==2||renzheng ==5">退保证金</view> -->
  94. </view>
  95. <view class="btn" @click="pay">确定充值</view>
  96. </view>
  97. <view v-if="title_color==2 && isAgency == 1" class="padding">
  98. <view class="bg radius padding">
  99. <view class="text-lg">可用余额</view>
  100. <view class="flex margin-top-sm">
  101. <!-- <view class="text-xxl"></view> -->
  102. <view class="text-xxl">{{money}}元</view>
  103. </view>
  104. </view>
  105. <view class="bg radius padding margin-top">
  106. <view class="text-lg margin-bottom">提现金额</view>
  107. <input type="number" placeholder="请输入提现金额" v-model="moneyNum">
  108. <view style="width: 100%;height: 1rpx;background: #F2F2F2;margin-top: 15rpx;"></view>
  109. <view class="text-grey margin-top-sm">{{placeholder}}</view>
  110. <view class="margin-top-xs" style="color: red;font-size: 26rpx;" v-if="txMsg">*{{txMsg}}</view>
  111. </view>
  112. <view class="bg margin-top padding-lr radius">
  113. <view>
  114. <view v-for="(item,index) in openList" :key='index'>
  115. <view style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;"
  116. v-if="item.text === '微信' && wxTxSel != '否'">
  117. <image :src="item.image" style="width: 55upx;height: 55upx;border-radius: 50upx;"></image>
  118. <view style="font-size: 30upx;margin-left: 20upx;width: 70%;">{{item.text}}
  119. </view>
  120. <radio-group name="openWay" style="margin-left: 20upx;" @tap='selectWay(item)'>
  121. <label class="tui-radio">
  122. <radio color="#2FB57A" :checked="openWay === item.id ? true : false" />
  123. </label>
  124. </radio-group>
  125. </view>
  126. <view style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;"
  127. v-if="item.text === '银联' && ylTxSel != '否'">
  128. <image :src="item.image" style="width: 55upx;height: 55upx;border-radius: 50upx;"></image>
  129. <view style="font-size: 30upx;margin-left: 20upx;width: 70%;">{{item.text}}
  130. </view>
  131. <radio-group name="openWay" style="margin-left: 20upx;" @tap='selectWay(item)'>
  132. <label class="tui-radio">
  133. <radio color="#2FB57A" :checked="openWay === item.id ? true : false" />
  134. </label>
  135. </radio-group>
  136. </view>
  137. <view style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;"
  138. v-if="item.text === '支付宝'">
  139. <image :src="item.image" style="width: 55upx;height: 55upx;border-radius: 50upx;"></image>
  140. <view style="font-size: 30upx;margin-left: 20upx;width: 70%;">{{item.text}}
  141. </view>
  142. <radio-group name="openWay" style="margin-left: 20upx;" @tap='selectWay(item)'>
  143. <label class="tui-radio">
  144. <radio color="#2FB57A" :checked="openWay === item.id ? true : false" />
  145. </label>
  146. </radio-group>
  147. </view>
  148. </view>
  149. </view>
  150. </view>
  151. <view class="bg radius margin-top padding">
  152. <view class="flex align-center justify-between" @click="goNav('/my/wallet/mymoneydetail')">
  153. <view class="flex align-center">
  154. <image
  155. src="/static/image/icon_coin.png"
  156. style="width: 44rpx;height: 44rpx;"></image>
  157. <view class="margin-left">钱包明细</view>
  158. </view>
  159. <image src="../../static/img/you.png" style="width: 18rpx;height: 32rpx;"></image>
  160. </view>
  161. <view class="flex align-center justify-between margin-top-xl" @click="goNav('/my/wallet/zhifubao')">
  162. <view class="flex align-center">
  163. <image
  164. src="/static/image/icon_card.png"
  165. style="width: 48rpx;height: 34rpx;"></image>
  166. <view style="margin-left:26upx">提现账号</view>
  167. </view>
  168. <image src="../../static/img/you.png" style="width: 18rpx;height: 32rpx;"></image>
  169. </view>
  170. <view class="flex align-center justify-between margin-top-xl" @click="goNav('/my/wallet/cashList')">
  171. <view class="flex align-center">
  172. <image
  173. src="/static/image/icon_note.png"
  174. style="width: 40rpx;height: 52rpx;"></image>
  175. <view style="margin-left: 36rpx;">提现记录</view>
  176. </view>
  177. <image src="../../static/img/you.png" style="width: 18rpx;height: 32rpx;"></image>
  178. </view>
  179. <view class="flex align-center justify-between margin-top-xl" @click="goNav('/my/wallet/yinhangka')"
  180. v-if="isAgency == 1 && ylTxSel != '否'">
  181. <view class="flex align-center">
  182. <image
  183. src="/static/image/icon_card.png"
  184. style="width: 48rpx;height: 34rpx;"></image>
  185. <view class="margin-left">银行卡账号</view>
  186. </view>
  187. <image src="../../static/img/you.png" style="width: 18rpx;height: 32rpx;"></image>
  188. </view>
  189. <!-- <view @click="TuiPrice()" v-if="renzheng ==2||renzheng ==5">退保证金</view> -->
  190. </view>
  191. <view class="btn" @click="cashMoney">立即提现</view>
  192. </view>
  193. <view class="flex justify-around margin-top " v-if="jsczSel != '否'">
  194. <view @click="goNav('/pages/therapist/therapistList?index=2')">为TA充值</view>
  195. <view @click="goNav('/pages/therapist/therapistList?index=3')">我的技师</view>
  196. </view>
  197. </view>
  198. </template>
  199. <script>
  200. export default {
  201. data() {
  202. return {
  203. jsczSel: '否',
  204. tgCheck: '否',
  205. isAgency: 0,
  206. tablist: [{
  207. id: 1,
  208. name: '我的充值'
  209. }, {
  210. id: 2,
  211. name: '我的提现'
  212. }],
  213. title_color: 1,
  214. money: 0,
  215. avatar: '',
  216. Profit: 0,
  217. openLists: [{
  218. image: '../static/images/zhifubao.png',
  219. text: '支付宝',
  220. id: 1
  221. }, {
  222. image: '../static/images/icon_weixin.png',
  223. text: '微信',
  224. id: 2
  225. }],
  226. openList: [{
  227. image: '../static/images/zhifubao.png',
  228. text: '支付宝',
  229. id: 1
  230. }, {
  231. image: '../static/images/yinlian.png',
  232. text: '银联',
  233. id: 2
  234. }, {
  235. image: '../static/images/icon_weixin.png',
  236. text: '微信',
  237. id: 3
  238. }],
  239. wxTxSel: '否',
  240. ylTxSel: '否',
  241. tabIndex: 0,
  242. bankCard: '',
  243. openWay: 2,
  244. wallet: [],
  245. moneyNum: null,
  246. thisSelect: {},
  247. charge: 0, //提现手续费
  248. maxMoney: 0, //最高提现额度
  249. minMoney: 0, //最低提现额度
  250. ratio: '', //金元比例
  251. placeholder: '',
  252. renzheng: 0,
  253. sp: 0,
  254. txMsg: ''
  255. }
  256. },
  257. onLoad(d) {
  258. if (d.tabIndex) {
  259. this.tabIndex = d.tabIndex;
  260. this.title_color = 2;
  261. } else {
  262. this.tabIndex = 0;
  263. }
  264. this.wxTxSel = this.$queue.getData('wxTxSel');
  265. this.ylTxSel = this.$queue.getData('ylTxSel');
  266. this.jsczSel = this.$queue.getData('jsczSel');
  267. this.txMsg = this.$queue.getData('txMsg');
  268. this.avatar = uni.getStorageSync('avatar')
  269. this.renzheng = uni.getStorageSync("renzheng")
  270. this.getMoneyList();
  271. // #ifndef MP-WEIXIN
  272. this.openLists = [{
  273. image: '../../static/images/zhifubao.png',
  274. text: '支付宝',
  275. id: 1
  276. }, {
  277. image: '../../static/images/icon_weixin.png',
  278. text: '微信',
  279. id: 2
  280. }];
  281. this.openWay = 1;
  282. // #endif
  283. // #ifdef MP-WEIXIN
  284. this.openLists = [{
  285. image: '../../static/images/icon_weixin.png',
  286. text: '微信',
  287. id: 2
  288. }];
  289. this.openWay = 2;
  290. // #endif
  291. },
  292. onShow() {
  293. this.tgCheck = this.$queue.getData('tgCheck');
  294. this.getMoney()
  295. this.getCharge()
  296. this.getMinMoney()
  297. this.getMaxMoney()
  298. this.getRatio()
  299. this.getUserInfo()
  300. },
  301. methods: {
  302. getMoneyList() {
  303. this.$Request.get("/app/payClassify/selectPayClassifyList").then(res => {
  304. if (res.code == 0) {
  305. this.wallet = [];
  306. res.data.forEach((d, index) => {
  307. // if(!d.coupon){
  308. // return;
  309. // }
  310. if (index == 0) {
  311. d.isSelect = true;
  312. this.thisSelect = d;
  313. } else {
  314. d.isSelect = false;
  315. }
  316. this.wallet.push(d);
  317. });
  318. }
  319. });
  320. },
  321. //退保证金
  322. TuiPrice() {
  323. let that = this
  324. let zhiFuBao = uni.getStorageSync('zhiFuBao')
  325. let zhiFuBaoName = uni.getStorageSync('zhiFuBaoName')
  326. if (!zhiFuBao && !zhiFuBaoName) {
  327. uni.navigateTo({
  328. url: '/my/wallet/zhifubao'
  329. })
  330. } else {
  331. let renzheng = uni.getStorageSync("renzheng")
  332. console.log(renzheng)
  333. if (renzheng == 2 || renzheng == 5) {
  334. uni.showModal({
  335. title: '提示',
  336. content: '是否确定退还保证金?退还后将不能发布订单',
  337. success: function(res) {
  338. if (res.confirm) {
  339. console.log('用户点击确定');
  340. that.$Request.post("/app/userCertification/exitMoney").then(res => {
  341. console.log(res)
  342. if (res.msg == '您还有未下架的订单,请先下架!') {
  343. uni.showToast({
  344. title: res.msg,
  345. icon: 'none'
  346. });
  347. } else if (res.msg == '您还有未服务的订单,请先完成!') {
  348. uni.showToast({
  349. title: res.msg,
  350. icon: 'none'
  351. });
  352. } else if (res.msg == 'success') {
  353. uni.showToast({
  354. title: '退还成功',
  355. icon: 'none'
  356. });
  357. uni.switchTab({
  358. url: '/pages/my/index'
  359. })
  360. }
  361. });
  362. } else if (res.cancel) {
  363. console.log('用户点击取消');
  364. }
  365. }
  366. });
  367. }
  368. }
  369. },
  370. getUserInfo() {
  371. this.$Request.get("/app/user/selectUserById").then(res => {
  372. if (res.code == 0) {
  373. this.avatar = res.data.avatar ? res.data.avatar : '../../static/logo.png'
  374. if (this.tabIndex == 1) {
  375. this.isAgency = 1
  376. } else {
  377. this.isAgency = res.data.isAgency ? res.data.isAgency : 0
  378. }
  379. if (res.data.bankCard) {
  380. this.bankCard = res.data.bankCard
  381. }
  382. uni.setStorageSync('avatar', res.data.avatar)
  383. }
  384. });
  385. },
  386. // 提现手续费
  387. getCharge() {
  388. this.$Request.get("/app/common/type/152").then(res => {
  389. if (res.code == 0) {
  390. this.charge = res.data.value
  391. this.placeholder = '服务费:' + this.charge * 100 + '%' + ',最低提现:' +
  392. this.minMoney * 1 + ',最高提现:' + this.maxMoney * 1
  393. }
  394. });
  395. },
  396. // 最低提现额度
  397. getMinMoney() {
  398. this.$Request.get("/app/common/type/112").then(res => {
  399. if (res.code == 0) {
  400. this.minMoney = res.data.value
  401. this.placeholder = '服务费:' + this.charge * 100 + '%' + ',最低提现:' +
  402. this.minMoney * 1 + ',最高提现:' + this.maxMoney * 1
  403. }
  404. });
  405. },
  406. // 最高提现额度
  407. getMaxMoney() {
  408. this.$Request.get("/app/common/type/153").then(res => {
  409. if (res.code == 0) {
  410. this.maxMoney = res.data.value
  411. this.placeholder = '服务费:' + this.charge * 100 + '%' + ',最低提现:' +
  412. this.minMoney * 1 + ',最高提现:' + this.maxMoney * 1
  413. }
  414. });
  415. },
  416. // 金元比例
  417. getRatio() {
  418. this.$Request.get("/app/common/type/154").then(res => {
  419. if (res.code == 0) {
  420. this.ratio = res.data.value
  421. this.placeholder = '服务费:' + this.charge * 100 + '%' + ',最低提现:' +
  422. this.minMoney * 1 + ',最高提现:' + this.maxMoney * 1
  423. this.wallet.forEach(re => {
  424. re.num = re.price * res.data.value
  425. })
  426. }
  427. });
  428. },
  429. cut(e) {
  430. this.title_color = e
  431. },
  432. goNav(url) {
  433. uni.navigateTo({
  434. url
  435. })
  436. },
  437. active(e) {
  438. this.wallet.forEach(res => {
  439. if (res.payClassifyId == e.payClassifyId) {
  440. res.isSelect = true
  441. this.thisSelect = e
  442. } else {
  443. res.isSelect = false
  444. }
  445. })
  446. },
  447. // 我的余额
  448. getMoney() {
  449. this.$Request.get("/app/userMoney/selectMyMoney").then(res => {
  450. if (res.code == 0 && res.data) {
  451. console.log(res.data.money)
  452. this.money = res.data.money
  453. }
  454. });
  455. },
  456. selectWay: function(item) {
  457. this.openWay = item.id;
  458. },
  459. pay() {
  460. if (this.openWay == 2) {
  461. // #ifdef APP-PLUS
  462. // 微信APP支付 根据订单id获取支付信息
  463. let data = {
  464. payClassifyId: this.thisSelect.payClassifyId,
  465. type: 1,
  466. userId: uni.getStorageSync('userId')
  467. }
  468. this.$Request.post("/app/wxPay/payMoney", data).then(ret => {
  469. console.log(ret)
  470. this.isCheckPay(ret.code, 'wxpay', JSON.stringify(ret.data));
  471. });
  472. // #endif
  473. // #ifdef MP-WEIXIN
  474. // 微信小程序支付
  475. let data = {
  476. payClassifyId: this.thisSelect.payClassifyId,
  477. type: 3,
  478. userId: uni.getStorageSync('userId')
  479. }
  480. this.$Request.post('/app/wxPay/payMoney', data).then(ret => {
  481. uni.hideLoading()
  482. uni.requestPayment({
  483. provider: 'wxpay',
  484. timeStamp: ret.data.timestamp,
  485. nonceStr: ret.data.noncestr,
  486. package: ret.data.package,
  487. signType: ret.data.signType,
  488. paySign: ret.data.sign,
  489. success: function(suc) {
  490. console.log('success:' + JSON.stringify(suc));
  491. uni.showToast({
  492. title: '支付成功',
  493. icon: 'success'
  494. })
  495. setTimeout(d => {
  496. uni.navigateBack(1)
  497. }, 1000);
  498. },
  499. fail: function(err) {
  500. console.log('fail:' + JSON.stringify(err));
  501. uni.showToast({
  502. title: '支付失败',
  503. icon: 'none'
  504. })
  505. }
  506. });
  507. });
  508. // #endif
  509. // #ifdef H5
  510. let ua = navigator.userAgent.toLowerCase();
  511. if (ua.indexOf('micromessenger') !== -1) {
  512. let data = {
  513. payClassifyId: this.thisSelect.payClassifyId,
  514. type: 2,
  515. userId: uni.getStorageSync('userId')
  516. }
  517. this.$Request.post('/app/wxPay/payMoney', data).then(res => {
  518. if (res.code == 0) {
  519. this.callPay(res.data);
  520. } else {
  521. uni.showToast({
  522. icon: 'none',
  523. title: '支付失败!'
  524. });
  525. }
  526. });
  527. } else {
  528. let data = {
  529. payClassifyId: this.thisSelect.payClassifyId,
  530. type: 4,
  531. userId: uni.getStorageSync('userId')
  532. }
  533. this.$Request.post('/app/wxPay/payMoney', data).then(res => {
  534. if (res.code == 0) {
  535. const urlArr = window.location.href;
  536. const hostUrl = urlArr.split("/");
  537. const callBack = hostUrl[0] + "//" + hostUrl[2] + "/";
  538. const url = '&redirect_url=' + callBack + 'my/wallet/index';
  539. window.location = res.data.mweb_url + url
  540. } else {
  541. uni.showToast({
  542. icon: 'none',
  543. title: '支付失败!'
  544. });
  545. }
  546. });
  547. }
  548. // #endif
  549. } else {
  550. // #ifdef H5
  551. let data = {
  552. payClassifyId: this.thisSelect.payClassifyId,
  553. type: 2,
  554. userId: uni.getStorageSync('userId')
  555. }
  556. this.$Request.post('/app/aliPay/payOrderMoney', data).then(
  557. res => {
  558. if (res.code === 0) {
  559. const div = document.createElement('div')
  560. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  561. document.body.appendChild(div)
  562. document.forms[0].submit()
  563. setTimeout(d => {
  564. uni.navigateBack(1)
  565. }, 1000);
  566. } else {
  567. uni.showToast({
  568. icon: 'none',
  569. title: '支付失败!'
  570. });
  571. }
  572. });
  573. // #endif
  574. // #ifdef APP-PLUS
  575. // APP支付宝支付
  576. let data = {
  577. payClassifyId: this.thisSelect.payClassifyId,
  578. type: 1,
  579. userId: uni.getStorageSync('userId')
  580. }
  581. this.$Request.post("/app/aliPay/payOrderMoney", data).then(ret => {
  582. console.log(ret)
  583. this.isCheckPay(ret.code, 'alipay', ret.data);
  584. });
  585. // #endif
  586. }
  587. },
  588. callPay: function(response) {
  589. if (typeof WeixinJSBridge === "undefined") {
  590. if (document.addEventListener) {
  591. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  592. } else if (document.attachEvent) {
  593. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  594. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  595. }
  596. } else {
  597. this.onBridgeReady(response);
  598. }
  599. },
  600. onBridgeReady: function(response) {
  601. let that = this;
  602. if (!response.package) {
  603. return;
  604. }
  605. console.log(response, '++++++++')
  606. WeixinJSBridge.invoke(
  607. 'getBrandWCPayRequest', {
  608. "appId": response.appid, //公众号名称,由商户传入
  609. "timeStamp": response.timestamp, //时间戳,自1970年以来的秒数
  610. "nonceStr": response.noncestr, //随机串
  611. "package": response.package,
  612. "signType": response.signType, //微信签名方式:
  613. "paySign": response.sign //微信签名
  614. },
  615. function(res) {
  616. console.log(res, '/*-/*-/*-')
  617. if (res.err_msg === "get_brand_wcpay_request:ok") {
  618. // 使用以上方式判断前端返回,微信团队郑重提示:
  619. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  620. uni.showLoading({
  621. title: '支付成功'
  622. });
  623. setTimeout(function() {
  624. uni.hideLoading();
  625. }, 1000);
  626. } else {
  627. uni.hideLoading();
  628. }
  629. WeixinJSBridge.log(response.err_msg);
  630. }
  631. );
  632. },
  633. isCheckPay(status, name, order) {
  634. if (status == 0) {
  635. this.setPayment(name, order);
  636. } else {
  637. uni.hideLoading();
  638. uni.showToast({
  639. title: '支付信息有误',
  640. icon: 'none'
  641. });
  642. }
  643. },
  644. setPayment(name, order) {
  645. console.log('*-*-*')
  646. uni.requestPayment({
  647. provider: name,
  648. orderInfo: order, //微信、支付宝订单数据
  649. success: function(res) {
  650. console.log(res)
  651. uni.hideLoading();
  652. uni.showLoading({
  653. title: '支付成功'
  654. });
  655. },
  656. fail: function(err) {
  657. console.log(err)
  658. uni.hideLoading();
  659. },
  660. complete() {
  661. uni.hideLoading();
  662. }
  663. });
  664. },
  665. // 提现
  666. cashMoney() {
  667. if (!this.moneyNum) {
  668. uni.showToast({
  669. icon: 'none',
  670. title: '请输入提现金额'
  671. })
  672. return
  673. }
  674. if (this.moneyNum > this.money * 1) {
  675. uni.showToast({
  676. icon: 'none',
  677. title: '您的余额不足'
  678. })
  679. return
  680. }
  681. if (this.moneyNum < this.minMoney * 1) {
  682. uni.showToast({
  683. icon: 'none',
  684. title: '最低可提现10元'
  685. })
  686. return
  687. }
  688. // if (this.moneyNum*1+this.charge*this.moneyNum > this.money*1) {
  689. // uni.showToast({
  690. // icon: 'none',
  691. // title: '您的手续费不足'
  692. // })
  693. // return
  694. // }
  695. let zhiFuBao = uni.getStorageSync('zhiFuBao')
  696. let zhiFuBaoName = uni.getStorageSync('zhiFuBaoName')
  697. // if (this.openWay == 2) {
  698. if (!zhiFuBao && !zhiFuBaoName && this.openWay == 1) {
  699. uni.navigateTo({
  700. url: '/my/wallet/zhifubao'
  701. })
  702. return
  703. }
  704. if (!this.bankCard && this.openWay == 2) {
  705. uni.navigateTo({
  706. url: '/my/wallet/yinhangka'
  707. })
  708. return
  709. }
  710. let that = this
  711. that.sp = (that.moneyNum * this.charge).toFixed(2)
  712. uni.showModal({
  713. title: '提示',
  714. content: '本次提现' + that.moneyNum + '元,服务费' + this.sp + '元,是否确认提现?',
  715. success: function(res) {
  716. if (res.confirm) {
  717. that.$Request.get("/app/cash/cashMoney", {
  718. money: that.moneyNum,
  719. userType: 1,
  720. classify: that.openWay
  721. }).then(res => {
  722. if (res.code == 0) {
  723. uni.showToast({
  724. icon: 'none',
  725. title: res.msg
  726. })
  727. that.moneyNum = null
  728. } else {
  729. uni.showToast({
  730. icon: 'none',
  731. title: res.msg
  732. })
  733. }
  734. that.getMoney()
  735. });
  736. } else if (res.cancel) {
  737. console.log('用户点击取消');
  738. }
  739. }
  740. });
  741. }
  742. }
  743. }
  744. </script>
  745. <style lang="scss" scoped>
  746. page {
  747. background-color: #F7F7F7;
  748. }
  749. .bg {
  750. background-color: #FFFFFF;
  751. }
  752. .info-box{
  753. height: 212rpx;
  754. background: url('/static/info-bg.png') no-repeat;
  755. background-size: 100% 212rpx;
  756. }
  757. .item{
  758. width: 334rpx;
  759. height: 166rpx;
  760. background: linear-gradient( 0deg, #FFFFFF 0%, #FFBACA 100%);
  761. border-radius: 36rpx 36rpx 36rpx 36rpx;
  762. display: flex;
  763. flex-direction: column;
  764. align-items: center;
  765. justify-content: center;
  766. box-sizing: border-box;
  767. margin-top: 20rpx;
  768. .price{
  769. font-weight: bold;
  770. font-size: 40rpx;
  771. color: #222222;
  772. }
  773. .desc{
  774. font-size: 24rpx;
  775. color: #222222;
  776. margin-top: 20rpx;
  777. }
  778. }
  779. .item.active {
  780. /* border: 1px solid #2FB57A !important; */
  781. color: $uni-color-primary !important;
  782. background: linear-gradient( 0deg, #FFFFFF 0%, #FFBACA 100%) !important;
  783. border: 2rpx solid #FF6E98;
  784. .price{
  785. color: #FF6E98;
  786. }
  787. }
  788. .title_btn {
  789. height: 78upx;
  790. line-height: 78upx;
  791. color: #333333;
  792. /* background: #f7f7f7; */
  793. }
  794. .btn {
  795. width: 686rpx;
  796. height: 100rpx;
  797. line-height: 100rpx;
  798. text-align: center;
  799. background: linear-gradient( 143deg, #FFE6EE 0%, #FF9AB2 100%);
  800. border-radius: 86rpx 86rpx 86rpx 86rpx;
  801. font-weight: bold;
  802. font-size: 32rpx;
  803. color: #222222;
  804. margin-top: 28rpx;
  805. }
  806. .bgCol2 {
  807. color: #2FB57A;
  808. background: #EAFFF5;
  809. }
  810. </style>