money.vue 14 KB

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