money.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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. that.$Request.post('/shop/shopmoney/shopCashDeposit', data).then(res => {
  246. console.log(res)
  247. uni.hideLoading();
  248. if (res.code == 0) {
  249. that.earnestMoney = ''
  250. uni.requestPayment({
  251. provider: 'wxpay',
  252. timeStamp: res.data.timestamp,
  253. nonceStr: res.data.noncestr,
  254. package: res.data.package,
  255. signType: res.data.signType,
  256. paySign: res.data.sign,
  257. success: function(res) {
  258. console.log(res)
  259. uni.showToast({
  260. title: '支付成功',
  261. icon: 'nones'
  262. });
  263. // this.$queue.showToast('支付成功');
  264. that.getshanghuinfo()
  265. // uni.switchTab({
  266. // url: '/pages/my/index'
  267. // })
  268. },
  269. fail: function(err) {
  270. that.$queue.showToast('支付失败');
  271. }
  272. });
  273. }
  274. });
  275. // #endif
  276. // #ifdef H5
  277. let data = {
  278. money: that.money,
  279. type: 2
  280. }
  281. that.$Request.post('/shop/shopmoney/shopCashDeposit', data).then(res => {
  282. uni.hideLoading();
  283. that.showpay = false
  284. that.callPay(res);
  285. });
  286. // #endif
  287. // #ifdef APP
  288. let data = {
  289. money: that.money,
  290. type: 1
  291. }
  292. that.$Request.post('/shop/shopmoney/shopCashDeposit', data).then(res => {
  293. uni.hideLoading()
  294. console.log(res)
  295. that.showpay = false
  296. if (res.code == 0) {
  297. that.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data));
  298. }
  299. });
  300. // #endif
  301. } else if (that.openWay == 2) { //支付宝支付
  302. // #ifdef H5
  303. let data = {
  304. money: that.money,
  305. type: 5
  306. }
  307. that.$Request.post('/shop/shopmoney/shopCashDeposit', data).then(
  308. res => {
  309. uni.hideLoading()
  310. that.showpay = false
  311. const div = document.createElement('div')
  312. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  313. document.body.appendChild(div)
  314. document.forms[0].submit()
  315. });
  316. // #endif
  317. // #ifdef APP-PLUS
  318. let data = {
  319. money: that.money,
  320. type: 4
  321. }
  322. that.$Request.post('/shop/shopmoney/shopCashDeposit', data).then(
  323. res => {
  324. uni.hideLoading()
  325. that.showpay = false
  326. that.setPayment('alipay', res.data);
  327. });
  328. // #endif
  329. }
  330. },
  331. callPay: function(response) {
  332. if (typeof WeixinJSBridge === "undefined") {
  333. if (document.addEventListener) {
  334. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  335. } else if (document.attachEvent) {
  336. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  337. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  338. }
  339. } else {
  340. this.onBridgeReady(response);
  341. }
  342. },
  343. onBridgeReady: function(response) {
  344. let that = this;
  345. if (!response.package) {
  346. return;
  347. }
  348. WeixinJSBridge.invoke(
  349. 'getBrandWCPayRequest', {
  350. "appId": response.appid, //公众号名称,由商户传入
  351. "timeStamp": response.timestamp, //时间戳,自1970年以来的秒数
  352. "nonceStr": response.noncestr, //随机串
  353. "package": response.package,
  354. "signType": response.signType, //微信签名方式:
  355. "paySign": response.sign //微信签名
  356. },
  357. function(res) {
  358. if (res.err_msg === "get_brand_wcpay_request:ok") {
  359. // 使用以上方式判断前端返回,微信团队郑重提示:
  360. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  361. uni.showLoading({
  362. title: '支付成功'
  363. });
  364. uni.hideLoading();
  365. uni.navigateTo({
  366. url: '/pages/my/index'
  367. })
  368. } else {
  369. uni.hideLoading();
  370. }
  371. WeixinJSBridge.log(response.err_msg);
  372. }
  373. );
  374. },
  375. isCheckPay(code, name, order) {
  376. if (code == 0) {
  377. console.log('999999999999')
  378. this.setPayment(name, order);
  379. } else {
  380. uni.hideLoading();
  381. uni.showToast({
  382. title: '支付信息有误'
  383. });
  384. }
  385. },
  386. setPayment(name, order) {
  387. console.log(777777777, name, order)
  388. uni.requestPayment({
  389. provider: name,
  390. orderInfo: order, //微信、支付宝订单数据
  391. success: function(res) {
  392. uni.hideLoading();
  393. uni.showLoading({
  394. title: '支付成功'
  395. });
  396. uni.switchTab({
  397. url: '/pages/my/index'
  398. })
  399. },
  400. fail: function(err) {
  401. uni.hideLoading();
  402. },
  403. complete() {
  404. uni.hideLoading();
  405. }
  406. });
  407. }
  408. }
  409. }
  410. </script>
  411. <style>
  412. page {
  413. background: #FFFfff;
  414. }
  415. .box {
  416. width: 690upx;
  417. height: 430upx;
  418. background: #FFFDFC;
  419. box-shadow: 0upx 15upx 43upx 0upx rgba(232, 215, 199, 0.29);
  420. border-radius: 24upx;
  421. margin: 0 auto;
  422. position: absolute;
  423. top: 80upx;
  424. left: 0;
  425. right: 0;
  426. text-align: center;
  427. }
  428. .btn1 {
  429. /* width: 305upx; */
  430. width: 100%;
  431. height: 88upx;
  432. background: #ffffff;
  433. border: 2upx solid #CCCCCC;
  434. border-radius: 8upx;
  435. line-height: 88upx;
  436. /* color: #FFFFFF; */
  437. font-size: 28upx;
  438. margin-right: 20upx;
  439. }
  440. .btn2 {
  441. /* width: 305upx; */
  442. width: 100%;
  443. height: 88upx;
  444. background: #FCD202;
  445. border-radius: 8upx;
  446. line-height: 88upx;
  447. /* color: #FFFFFF; */
  448. font-size: 28upx;
  449. }
  450. .popup_pay {
  451. width: 100%;
  452. position: relative;
  453. padding-bottom: 45rpx;
  454. /* height: 160px; */
  455. /* #ifndef MP-WEIXIN */
  456. /* height: 130px; */
  457. /* #endif */
  458. }
  459. .pay_btn {
  460. width: 90%;
  461. margin: 0 auto;
  462. text-align: center;
  463. background: #2FB57A;
  464. height: 80rpx;
  465. border-radius: 16rpx;
  466. color: #ffffff;
  467. line-height: 80rpx;
  468. }
  469. /* 支付金额弹框 */
  470. .receipt_code {
  471. width: 90%;
  472. margin: 0 auto;
  473. }
  474. .code_title {
  475. width: 100%;
  476. line-height: 100rpx;
  477. font-size: 31rpx;
  478. font-weight: bold;
  479. text-align: center;
  480. letter-spacing: 2rpx;
  481. margin-top: 21rpx;
  482. margin-bottom: 25rpx;
  483. }
  484. .u-input--border {
  485. border: 1px solid #F2F2F2 !important;
  486. background: #F2F2F2 !important;
  487. color: #999999 !important;
  488. font-weight: 500 !important;
  489. letter-spacing: 2rpx !important;
  490. }
  491. .u-input__input {
  492. font-size: 30rpx;
  493. font-weight: bold;
  494. flex: 1;
  495. color: #999999 !important;
  496. min-height: 85rpx !important;
  497. margin-top: 7rpx;
  498. }
  499. .sure {
  500. width: 100%;
  501. height: 80rpx;
  502. background: #2FB57A;
  503. color: white;
  504. border-radius: 46rpx;
  505. text-align: center;
  506. line-height: 80rpx;
  507. margin-top: 30rpx;
  508. letter-spacing: 2rpx;
  509. }
  510. .mingxi {
  511. position: relative;
  512. top: 10px;
  513. }
  514. </style>