money.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <template>
  2. <view>
  3. <view style="width: 100%;height: 384upx;position: relative;">
  4. <image src="../../static/images/image-bg.png" style="width: 100%;height: 100%;"></image>
  5. <view class="box">
  6. <view class="margin-top padding-top">保证金(元)</view>
  7. <view class="margin-top-lg text-bold" style="font-size: 78upx;" v-if="isCashDeposit ==1">{{money}}
  8. </view>
  9. <view class="margin-top-lg text-bold" style="font-size: 78upx;"
  10. v-if="isCashDeposit==2 ||isCashDeposit==3">{{mymoney}}</view>
  11. <view class="flex justify-between padding-lr" style="margin-top: 100upx;">
  12. <view class="btn1" @click="Tuiprice()" v-if="isCashDeposit==2 ||isCashDeposit==3">退保证金</view>
  13. <view class="btn2" @click="submit()" v-if="isCashDeposit ==1">缴纳保证金</view>
  14. <view class="btn2 margin-left" @click="goMoneylist()">保证金明细</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="padding" style="margin-top: 180upx;">
  19. <view style="color: #333333;font-size: 38upx;" class="text-bold">保证金规则</view>
  20. <view style="font-size: 32upx;margin-top: 58upx;" class="text-bold">保证金退款</view>
  21. <view style="color: #666666;margin-top: 29upx;font-size: 28upx;">
  22. 48小时内无订单记录即可申请退保证金,保证金统一退款至账户余额,实时到账。
  23. </view>
  24. <view style="font-size: 32upx;margin-top: 58upx;" class="text-bold">保证金缴纳</view>
  25. <view style="color: #666666;margin-top: 29upx;font-size: 28upx;">
  26. 所有按摩师服务接单需缴纳保证金{{money}}元,没有缴纳将无法接订单,建议您及时缴纳。
  27. </view>
  28. </view>
  29. <!-- 支付方式 -->
  30. <u-popup v-model="showpay" mode="bottom" :closeable="closeable">
  31. <view class="popup_pay">
  32. <view style="background-color: #fff;">
  33. <view style="padding: 0 20upx;margin-top: 60rpx;margin-bottom: 20rpx;">
  34. <view
  35. style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;justify-content: center;"
  36. v-for="(item,index) in openLists" :key='index'>
  37. <image :src="item.image" style="width: 55upx;height: 55upx;border-radius: 50upx;">
  38. </image>
  39. <view style="font-size: 30upx;margin-left: 20upx;width: 70%;">
  40. {{item.text}}
  41. </view>
  42. <radio-group name="openWay" style="margin-left: 45upx;" @tap='selectWay(item)'>
  43. <label class="tui-radio">
  44. <radio color="#1777FF" :checked="openWay === item.id ? true : false" />
  45. </label>
  46. </radio-group>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="pay_btn" @click="pay()">确认支付</view>
  51. </view>
  52. </u-popup>
  53. </view>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. mymoney: 0,
  60. money: 0,
  61. showpay: false,
  62. openLists: [],
  63. openWay: 1,
  64. closeable: true,
  65. renzheng: '',
  66. isCashDeposit: ''
  67. }
  68. },
  69. onLoad() {
  70. this.isCashDeposit = uni.getStorageSync('isCashDeposit')
  71. this.renzheng = uni.getStorageSync("renzheng")
  72. // #ifdef APP
  73. this.openLists = [{
  74. image: '../../static/images/icon_weixin.png',
  75. text: '微信',
  76. id: 1
  77. }, {
  78. image: '../../static/images/zhifubao.png',
  79. text: '支付宝',
  80. id: 2
  81. }];
  82. this.openWay = 1;
  83. // #endif
  84. // #ifdef MP-WEIXIN
  85. this.openLists = [{
  86. image: '../../static/images/icon_weixin.png',
  87. text: '微信',
  88. id: 1
  89. }];
  90. this.openWay = 1;
  91. // #endif
  92. // #ifdef H5
  93. let ua = navigator.userAgent.toLowerCase();
  94. console.log(ua)
  95. if (ua.indexOf('micromessenger') !== -1) {
  96. this.openLists = [{
  97. image: '../../static/images/icon_weixin.png',
  98. text: '微信',
  99. id: 1
  100. }];
  101. this.openWay = 1;
  102. } else {
  103. this.openLists = [{
  104. image: '../../static/images/zhifubao.png',
  105. text: '支付宝',
  106. id: 2
  107. }]
  108. this.openWay = 2;
  109. }
  110. // #endif
  111. },
  112. onShow() {
  113. this.Getmoney()
  114. },
  115. methods: {
  116. // 我的余额
  117. getMoney() {
  118. this.$Request.get("/app/userMoney/selectMyMoney").then(res => {
  119. if (res.code == 0 && res.data) {
  120. this.mymoney = res.data.cashDeposit ? res.data.cashDeposit : 0;
  121. }
  122. });
  123. },
  124. selectWay: function(item) {
  125. this.openWay = item.id;
  126. },
  127. //保证金明细
  128. goMoneylist() {
  129. uni.navigateTo({
  130. url: '/my/publish/moneylist'
  131. })
  132. },
  133. // 保证金
  134. Getmoney() {
  135. this.getMoney();
  136. this.$Request.get("/app/common/type/241").then(res => {
  137. console.log(res)
  138. if (res.code == 0) {
  139. this.money = res.data.value
  140. }
  141. });
  142. },
  143. //缴纳保证金
  144. submit() {
  145. if (this.isCashDeposit == 3) {
  146. uni.showToast({
  147. title: '系统审核中,请耐心等待',
  148. icon: 'none',
  149. duration: 1000
  150. })
  151. } else if (this.isCashDeposit == 1) {
  152. this.showpay = true
  153. }
  154. },
  155. //退保证金
  156. Tuiprice() {
  157. let that = this
  158. if (that.isCashDeposit == 3) {
  159. uni.showToast({
  160. title: '系统审核中,请耐心等待',
  161. icon: 'none',
  162. duration: 1000
  163. })
  164. } else if (that.isCashDeposit == 2) {
  165. uni.showModal({
  166. title: '提示',
  167. content: '是否确认退还保证金?退还后将无法接单',
  168. success: function(res) {
  169. if (res.confirm) {
  170. that.$Request.postT('/app/realname/retreatCashDeposit', {
  171. userId: uni.getStorageSync('userId')
  172. }).then(ret => {
  173. if (ret.code == 0) {
  174. uni.showToast({
  175. title: '已退还至账户余额',
  176. icon: 'none',
  177. duration: 1000
  178. })
  179. that.isCashDeposit = 1
  180. that.Getmoney()
  181. // uni.switchTab({
  182. // url: '/pages/my/index'
  183. // })
  184. } else {
  185. uni.showToast({
  186. title: ret.msg,
  187. icon: 'none',
  188. duration: 1000
  189. })
  190. }
  191. })
  192. } else if (res.cancel) {
  193. console.log('用户点击取消');
  194. }
  195. }
  196. });
  197. }
  198. },
  199. pay() {
  200. let userId = uni.getStorageSync('userId')
  201. let that = this;
  202. this.showpay = false
  203. if (this.openWay == 1) { //微信支付
  204. // #ifdef MP-WEIXIN
  205. let data = {
  206. userId: userId,
  207. type: 3
  208. }
  209. this.$Request.post('/app/wxPay/submitRealName', data).then(res => {
  210. console.log(res)
  211. if (res.code == 0) {
  212. uni.requestPayment({
  213. provider: 'wxpay',
  214. timeStamp: res.data.timestamp,
  215. nonceStr: res.data.noncestr,
  216. package: res.data.package,
  217. signType: res.data.signType,
  218. paySign: res.data.sign,
  219. success: function(res) {
  220. console.log(res)
  221. uni.showLoading({
  222. title: '支付成功',
  223. icon: 'nones'
  224. });
  225. // this.$queue.showToast('支付成功');
  226. uni.switchTab({
  227. url: '/pages/my/index'
  228. })
  229. },
  230. fail: function(err) {
  231. // this.$queue.showToast('支付失败');
  232. uni.showLoading({
  233. title: '支付失败',
  234. icon: 'nones'
  235. });
  236. }
  237. });
  238. }
  239. });
  240. // #endif
  241. // #ifdef H5
  242. let data = {
  243. userId: userId,
  244. type: 2
  245. }
  246. this.$Request.post('/app/wxPay/submitRealName', data).then(res => {
  247. that.showpay = false
  248. that.callPay(res.data);
  249. });
  250. // #endif
  251. // #ifdef APP
  252. let data = {
  253. userId: userId,
  254. type: 1
  255. }
  256. this.$Request.post('/app/wxPay/submitRealName', data).then(res => {
  257. console.log(res)
  258. this.showpay = false
  259. if (res.code == 0) {
  260. this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data));
  261. }
  262. });
  263. // #endif
  264. } else if (this.openWay == 2) { //支付宝支付
  265. // #ifdef H5
  266. let data = {
  267. userId: userId,
  268. type: 2
  269. }
  270. this.$Request.post('/app/aliPay/payOrderCashDeposit', data).then(
  271. res => {
  272. this.showpay = false
  273. const div = document.createElement('div')
  274. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  275. document.body.appendChild(div)
  276. document.forms[0].submit()
  277. });
  278. // #endif
  279. // #ifdef APP-PLUS
  280. let data = {
  281. userId: userId,
  282. type: 1
  283. }
  284. this.$Request.post('/app/aliPay/payOrderCashDeposit', data).then(
  285. res => {
  286. this.showpay = false
  287. this.setPayment('alipay', res.data);
  288. });
  289. // #endif
  290. }
  291. },
  292. callPay: function(response) {
  293. if (typeof WeixinJSBridge === "undefined") {
  294. if (document.addEventListener) {
  295. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  296. } else if (document.attachEvent) {
  297. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  298. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  299. }
  300. } else {
  301. this.onBridgeReady(response);
  302. }
  303. },
  304. onBridgeReady: function(response) {
  305. let that = this;
  306. if (!response.package) {
  307. return;
  308. }
  309. WeixinJSBridge.invoke(
  310. 'getBrandWCPayRequest', {
  311. "appId": response.appid, //公众号名称,由商户传入
  312. "timeStamp": response.timestamp, //时间戳,自1970年以来的秒数
  313. "nonceStr": response.noncestr, //随机串
  314. "package": response.package,
  315. "signType": response.signType, //微信签名方式:
  316. "paySign": response.sign //微信签名
  317. },
  318. function(res) {
  319. if (res.err_msg === "get_brand_wcpay_request:ok") {
  320. // 使用以上方式判断前端返回,微信团队郑重提示:
  321. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  322. uni.showLoading({
  323. title: '支付成功'
  324. });
  325. uni.hideLoading();
  326. uni.switchTab({
  327. url: '/pages/my/index'
  328. })
  329. } else {
  330. uni.hideLoading();
  331. }
  332. WeixinJSBridge.log(response.err_msg);
  333. }
  334. );
  335. },
  336. isCheckPay(code, name, order) {
  337. if (code == 0) {
  338. console.log('999999999999')
  339. this.setPayment(name, order);
  340. } else {
  341. uni.hideLoading();
  342. uni.showToast({
  343. title: '支付信息有误'
  344. });
  345. }
  346. },
  347. setPayment(name, order) {
  348. console.log(777777777, name, order)
  349. uni.requestPayment({
  350. provider: name,
  351. orderInfo: order, //微信、支付宝订单数据
  352. success: function(res) {
  353. uni.hideLoading();
  354. uni.showLoading({
  355. title: '支付成功'
  356. });
  357. uni.switchTab({
  358. url: '/pages/my/index'
  359. })
  360. },
  361. fail: function(err) {
  362. uni.hideLoading();
  363. },
  364. complete() {
  365. uni.hideLoading();
  366. }
  367. });
  368. }
  369. }
  370. }
  371. </script>
  372. <style>
  373. .box {
  374. width: 690upx;
  375. height: 430upx;
  376. background: #FFFDFC;
  377. box-shadow: 0upx 15upx 43upx 0upx rgba(232, 215, 199, 0.29);
  378. border-radius: 24upx;
  379. margin: 0 auto;
  380. position: absolute;
  381. top: 80upx;
  382. left: 0;
  383. right: 0;
  384. text-align: center;
  385. }
  386. .btn1 {
  387. /* width: 305upx; */
  388. width: 100%;
  389. height: 88upx;
  390. /* background: #2FB57A; */
  391. border: 2rpx solid #CCCCCC;
  392. border-radius: 8upx;
  393. line-height: 88upx;
  394. color: #333333;
  395. font-size: 28upx;
  396. }
  397. .btn2 {
  398. /* width: 305upx; */
  399. width: 100%;
  400. height: 88upx;
  401. background: #2FB57A;
  402. border-radius: 8upx;
  403. line-height: 88upx;
  404. color: #FFFFFF;
  405. font-size: 28upx;
  406. }
  407. .popup_pay {
  408. width: 100%;
  409. position: relative;
  410. padding-bottom: 45rpx;
  411. /* height: 160px; */
  412. /* #ifndef MP-WEIXIN */
  413. /* height: 130px; */
  414. /* #endif */
  415. }
  416. .pay_btn {
  417. width: 90%;
  418. margin: 0 auto;
  419. text-align: center;
  420. background: #2FB57A;
  421. height: 80rpx;
  422. border-radius: 16rpx;
  423. color: #ffffff;
  424. line-height: 80rpx;
  425. }
  426. </style>