money.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. <template>
  2. <view>
  3. <view style="width: 100%;height: 384upx;position: relative;">
  4. <image src="../../static/images/img/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;">{{cashDeposit?cashDeposit:0}}</view>
  8. <view class="mingxi" @click="bindmingxi()">保证金明细</view>
  9. <view class="flex justify-center padding-lr" style="margin-top: 100upx;">
  10. <view class="btn1" @click="Tuiprice()">退保证金</view>
  11. <view class="btn2" @click="submit()">缴纳保证金</view>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="padding" style="margin-top: 180upx;">
  16. <view style="color: #333333;font-size: 38upx;" class="text-bold">保证金规则</view>
  17. <view style="font-size: 32upx;margin-top: 58upx;" class="text-bold">保证金退款</view>
  18. <view style="color: #666666;margin-top: 29upx;font-size: 28upx;">
  19. 48小时内无订单记录即可申请退保证金,保证金统一退款至账户余额,实时到账。
  20. </view>
  21. <view style="font-size: 32upx;margin-top: 58upx;" class="text-bold">保证金缴纳</view>
  22. <view style="color: #666666;margin-top: 29upx;font-size: 28upx;">
  23. 所有店铺发布商品需缴纳保证金{{money}}元,没有缴纳者将无法接订单,建议您及时缴纳。
  24. </view>
  25. </view>
  26. <!-- 支付方式 -->
  27. <!-- <u-popup v-model="showpay" mode="bottom" :closeable="closeable">
  28. <view class="popup_pay">
  29. <view style="background-color: #fff;">
  30. <view style="padding: 0 20upx;margin-top: 60rpx;margin-bottom: 20rpx;">
  31. <view
  32. style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;justify-content: center;"
  33. v-for="(item,index) in openLists" :key='index'>
  34. <image :src="item.image" style="width: 55upx;height: 55upx;border-radius: 50upx;">
  35. </image>
  36. <view style="font-size: 30upx;margin-left: 20upx;width: 70%;">
  37. {{item.text}}
  38. </view>
  39. <radio-group name="openWay" style="margin-left: 45upx;" @tap='selectWay(item)'>
  40. <label class="tui-radio">
  41. <radio color="#1777FF" :checked="openWay === item.id ? true : false" />
  42. </label>
  43. </radio-group>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="pay_btn" @click="pay()">确认支付</view>
  48. </view>
  49. </u-popup> -->
  50. <!-- 支付方式 -->
  51. <u-popup v-model="showpay" mode="center" width="640rpx" height="640rpx" border-radius="14" :closeable="true"
  52. close-icon="close-circle" close-icon-size="50" close-icon-color="#CCCCCC" @close="closePopup()">
  53. <view style="width: 100%;height: 300upx;background: #FFFFFF;">
  54. <view class="receipt_code">
  55. <view class="code_title">请输入支付金额</view>
  56. <u-input v-model="earnestMoney" placeholder="请输入支付金额" :border="true" />
  57. <view class="margin-tb padding-lr radius bg-white" style="height: 220upx;">
  58. <view class="flex align-center justify-between padding-tb-sm" v-for="(item,index) in openLists"
  59. :key='index'>
  60. <image :src="item.image" style="width: 80upx;height: 80upx;border-radius: 50upx;"></image>
  61. <view class="flex-sub text-xl text-bold margin-left">{{item.text}}</view>
  62. <radio-group name="openWay" style="margin-left: 20upx;" @change='selectWay(item)'>
  63. <label class="tui-radio">
  64. <radio class="red" :checked="openWay === item.id ? true : false" />
  65. </label>
  66. </radio-group>
  67. </view>
  68. </view>
  69. <view class="sure" @click="pay()">确定</view>
  70. </view>
  71. </view>
  72. </u-popup>
  73. </view>
  74. </template>
  75. <script>
  76. export default {
  77. data() {
  78. return {
  79. money: 0,
  80. showpay: false,
  81. openLists: [],
  82. openWay: 1,
  83. closeable: true,
  84. renzheng: '',
  85. cashDeposit: '',
  86. earnestMoney: '',
  87. openId: ''
  88. }
  89. },
  90. onLoad() {
  91. this.cashDeposit = uni.getStorageSync('cashDeposit')
  92. this.openId = uni.getStorageSync('openId')
  93. this.renzheng = uni.getStorageSync("renzheng")
  94. // #ifdef APP
  95. this.openLists = [{
  96. image: '../../static/images/img/icon_weixin.png',
  97. text: '微信',
  98. id: 1
  99. }, {
  100. image: '../../static/images/img/zhifubao.png',
  101. text: '支付宝',
  102. id: 2
  103. }],
  104. this.openWay = 1;
  105. // #endif
  106. // #ifdef MP-WEIXIN
  107. this.openLists = [{
  108. image: '../../static/images/img/icon_weixin.png',
  109. text: '微信',
  110. id: 1
  111. }],
  112. this.openWay = 1;
  113. // #endif
  114. // #ifdef H5
  115. this.openLists = [{
  116. image: '../../static/images/img/zhifubao.png',
  117. text: '支付宝',
  118. id: 2
  119. }]
  120. this.openWay = 2;
  121. // #endif
  122. },
  123. onShow() {
  124. this.Getmoney()
  125. this.getshanghuinfo()
  126. },
  127. methods: {
  128. selectWay: function(item) {
  129. this.openWay = item.id;
  130. },
  131. //保证金明细
  132. bindmingxi() {
  133. uni.navigateTo({
  134. url: '/my/other/moneylist'
  135. })
  136. },
  137. getshanghuinfo() {
  138. let data = {
  139. shopId: uni.getStorageSync('shopId')
  140. }
  141. this.$Request.get("/app/shop/selectShopMessage", data).then(res => {
  142. if (res.code == 0) {
  143. this.cashDeposit = res.data.cashDeposit
  144. uni.setStorageSync('cashDeposit', res.data.cashDeposit)
  145. }
  146. });
  147. },
  148. // 保证金
  149. Getmoney() {
  150. this.$Request.get("/app/common/type/270").then(res => {
  151. console.log(res)
  152. if (res.code == 0) {
  153. this.money = res.data.value
  154. }
  155. });
  156. },
  157. //缴纳保证金
  158. submit() {
  159. // if (this.isCashDeposit == 3) {
  160. // uni.showToast({
  161. // title: '系统审核中,请耐心等待',
  162. // icon: 'none',
  163. // duration: 1000
  164. // })
  165. // } else if (this.isCashDeposit == 1) {
  166. // this.showpay = true
  167. // }
  168. this.showpay = true
  169. // #ifdef MP-WEIXIN
  170. this.wxlogin()
  171. // #endif
  172. },
  173. //退保证金
  174. Tuiprice() {
  175. if (this.cashDeposit == 0) {
  176. uni.showToast({
  177. title: '保证金余额0',
  178. icon: 'none',
  179. duration: 1000
  180. })
  181. } else {
  182. this.$Request.getT('/app/shop/shopRefundCashDeposit', {
  183. shopId: uni.getStorageSync('shopId')
  184. }).then(res => {
  185. if (res.code == 0) {
  186. uni.showToast({
  187. title: '申请提交成功,保证金已退还至您的钱包账户',
  188. icon: 'none',
  189. duration: 1000
  190. })
  191. uni.switchTab({
  192. url: '/pages/my/index'
  193. })
  194. }else{
  195. this.$queue.showToast(res.msg);
  196. }
  197. })
  198. }
  199. },
  200. // 关闭底部弹出层
  201. closePopup() {
  202. this.shows = false
  203. },
  204. wxlogin() {
  205. let that = this
  206. wx.login({
  207. success(res) {
  208. if (res.code) {
  209. console.log(res)
  210. //发起网络请求
  211. let data = {
  212. code: res.code
  213. }
  214. that.$Request.getA("/app/Login/wxShopLogin", data).then(res => {
  215. if (res.code == 0) {
  216. that.$queue.setData("openId", res.data.open_id);
  217. }
  218. })
  219. } else {
  220. console.log('登录失败!' + res.errMsg)
  221. }
  222. }
  223. })
  224. },
  225. pay() {
  226. let that = this;
  227. if (!this.earnestMoney) {
  228. that.$queue.showToast('请输入支付金额');
  229. return;
  230. }
  231. uni.showLoading({
  232. title: '支付中',
  233. mask: true, // 是否显示透明蒙层,防止触摸穿透
  234. });
  235. let userId = uni.getStorageSync('userId')
  236. let openId = uni.getStorageSync('openId')
  237. that.showpay = false
  238. if (that.openWay == 1) { //微信支付
  239. // #ifdef MP-WEIXIN
  240. let data = {
  241. money: that.earnestMoney,
  242. openId: openId,
  243. type: 3
  244. }
  245. console.log(data,'支付参数')
  246. that.$Request.post('/shop/shopmoney/shopCashDeposit', data).then(res => {
  247. console.log(res)
  248. uni.hideLoading();
  249. if (res.code == 0) {
  250. that.earnestMoney = ''
  251. uni.requestPayment({
  252. provider: 'wxpay',
  253. appId:res.appId, //公众号名称,由商户传入
  254. timeStamp: res.timeStamp,
  255. nonceStr: res.nonceStr,
  256. package: res.packageStr,
  257. signType: res.signType,
  258. paySign: res.paySign,
  259. success: function(res) {
  260. console.log(res,'支付')
  261. uni.showToast({
  262. title: '支付成功',
  263. icon: 'nones'
  264. });
  265. // this.$queue.showToast('支付成功');
  266. that.getshanghuinfo()
  267. // uni.switchTab({
  268. // url: '/pages/my/index'
  269. // })
  270. },
  271. fail: function(err) {
  272. console.log(err,'失败')
  273. that.$queue.showToast('支付失败');
  274. }
  275. });
  276. }
  277. });
  278. // #endif
  279. // #ifdef H5
  280. let data = {
  281. money: that.money,
  282. type: 2
  283. }
  284. that.$Request.post('/shop/shopmoney/shopCashDeposit', data).then(res => {
  285. uni.hideLoading();
  286. that.showpay = false
  287. that.callPay(res);
  288. });
  289. // #endif
  290. // #ifdef APP
  291. let data = {
  292. money: that.money,
  293. type: 1
  294. }
  295. that.$Request.post('/shop/shopmoney/shopCashDeposit', data).then(res => {
  296. uni.hideLoading()
  297. console.log(res)
  298. that.showpay = false
  299. if (res.code == 0) {
  300. that.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data));
  301. }
  302. });
  303. // #endif
  304. } else if (that.openWay == 2) { //支付宝支付
  305. // #ifdef H5
  306. let data = {
  307. money: that.money,
  308. type: 5
  309. }
  310. that.$Request.post('/shop/shopmoney/shopCashDeposit', data).then(
  311. res => {
  312. uni.hideLoading()
  313. that.showpay = false
  314. const div = document.createElement('div')
  315. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  316. document.body.appendChild(div)
  317. document.forms[0].submit()
  318. });
  319. // #endif
  320. // #ifdef APP-PLUS
  321. let data = {
  322. money: that.money,
  323. type: 4
  324. }
  325. that.$Request.post('/shop/shopmoney/shopCashDeposit', data).then(
  326. res => {
  327. uni.hideLoading()
  328. that.showpay = false
  329. that.setPayment('alipay', res.data);
  330. });
  331. // #endif
  332. }
  333. },
  334. callPay: function(response) {
  335. if (typeof WeixinJSBridge === "undefined") {
  336. if (document.addEventListener) {
  337. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  338. } else if (document.attachEvent) {
  339. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  340. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  341. }
  342. } else {
  343. this.onBridgeReady(response);
  344. }
  345. },
  346. onBridgeReady: function(response) {
  347. let that = this;
  348. if (!response.package) {
  349. return;
  350. }
  351. WeixinJSBridge.invoke(
  352. 'getBrandWCPayRequest', {
  353. "appId": response.appId, //公众号名称,由商户传入
  354. "timeStamp": response.timeStamp, //时间戳,自1970年以来的秒数
  355. "nonceStr": response.nonceStr, //随机串
  356. "package": response.packageStr,
  357. "signType": response.signType, //微信签名方式:
  358. "paySign": response.paySign //微信签名
  359. },
  360. function(res) {
  361. if (res.err_msg === "get_brand_wcpay_request:ok") {
  362. // 使用以上方式判断前端返回,微信团队郑重提示:
  363. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  364. uni.showLoading({
  365. title: '支付成功'
  366. });
  367. uni.hideLoading();
  368. uni.navigateTo({
  369. url: '/pages/my/index'
  370. })
  371. } else {
  372. uni.hideLoading();
  373. }
  374. WeixinJSBridge.log(response.err_msg);
  375. }
  376. );
  377. },
  378. isCheckPay(code, name, order) {
  379. if (code == 0) {
  380. console.log('999999999999')
  381. this.setPayment(name, order);
  382. } else {
  383. uni.hideLoading();
  384. uni.showToast({
  385. title: '支付信息有误'
  386. });
  387. }
  388. },
  389. setPayment(name, order) {
  390. console.log(777777777, name, order)
  391. uni.requestPayment({
  392. provider: name,
  393. orderInfo: order, //微信、支付宝订单数据
  394. success: function(res) {
  395. uni.hideLoading();
  396. uni.showLoading({
  397. title: '支付成功'
  398. });
  399. uni.switchTab({
  400. url: '/pages/my/index'
  401. })
  402. },
  403. fail: function(err) {
  404. uni.hideLoading();
  405. },
  406. complete() {
  407. uni.hideLoading();
  408. }
  409. });
  410. }
  411. }
  412. }
  413. </script>
  414. <style>
  415. page {
  416. background: #FFFfff;
  417. }
  418. .box {
  419. width: 690upx;
  420. height: 430upx;
  421. background: #FFFDFC;
  422. box-shadow: 0upx 15upx 43upx 0upx rgba(232, 215, 199, 0.29);
  423. border-radius: 24upx;
  424. margin: 0 auto;
  425. position: absolute;
  426. top: 80upx;
  427. left: 0;
  428. right: 0;
  429. text-align: center;
  430. }
  431. .btn1 {
  432. /* width: 305upx; */
  433. width: 100%;
  434. height: 88upx;
  435. background: #ffffff;
  436. border: 2upx solid #CCCCCC;
  437. border-radius: 8upx;
  438. line-height: 88upx;
  439. /* color: #FFFFFF; */
  440. font-size: 28upx;
  441. margin-right: 20upx;
  442. }
  443. .btn2 {
  444. /* width: 305upx; */
  445. width: 100%;
  446. height: 88upx;
  447. background: #FCD202;
  448. border-radius: 8upx;
  449. line-height: 88upx;
  450. /* color: #FFFFFF; */
  451. font-size: 28upx;
  452. }
  453. .popup_pay {
  454. width: 100%;
  455. position: relative;
  456. padding-bottom: 45rpx;
  457. /* height: 160px; */
  458. /* #ifndef MP-WEIXIN */
  459. /* height: 130px; */
  460. /* #endif */
  461. }
  462. .pay_btn {
  463. width: 90%;
  464. margin: 0 auto;
  465. text-align: center;
  466. background: #2FB57A;
  467. height: 80rpx;
  468. border-radius: 16rpx;
  469. color: #ffffff;
  470. line-height: 80rpx;
  471. }
  472. /* 支付金额弹框 */
  473. .receipt_code {
  474. width: 90%;
  475. margin: 0 auto;
  476. }
  477. .code_title {
  478. width: 100%;
  479. line-height: 100rpx;
  480. font-size: 31rpx;
  481. font-weight: bold;
  482. text-align: center;
  483. letter-spacing: 2rpx;
  484. margin-top: 21rpx;
  485. margin-bottom: 25rpx;
  486. }
  487. .u-input--border {
  488. border: 1px solid #F2F2F2 !important;
  489. background: #F2F2F2 !important;
  490. color: #999999 !important;
  491. font-weight: 500 !important;
  492. letter-spacing: 2rpx !important;
  493. }
  494. .u-input__input {
  495. font-size: 30rpx;
  496. font-weight: bold;
  497. flex: 1;
  498. color: #999999 !important;
  499. min-height: 85rpx !important;
  500. margin-top: 7rpx;
  501. }
  502. .sure {
  503. width: 100%;
  504. height: 80rpx;
  505. background: #2FB57A;
  506. color: white;
  507. border-radius: 46rpx;
  508. text-align: center;
  509. line-height: 80rpx;
  510. margin-top: 30rpx;
  511. letter-spacing: 2rpx;
  512. }
  513. .mingxi {
  514. position: relative;
  515. top: 10px;
  516. }
  517. </style>