approve.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <view v-if="XCXIsSelect !='否'">
  3. <view class="padding">
  4. <view class=" padding-lr bg-white radius">
  5. <u-form :model="form" ref="uForm" label-position="top" :label-style='lableStyle'>
  6. <u-form-item label="真实姓名" :border-bottom='false'>
  7. <u-input :disabled="disabled" placeholder="请输入真实姓名" v-model="form.userName" />
  8. </u-form-item>
  9. <u-form-item label="证件号码" :border-bottom='false'>
  10. <u-input :disabled="disabled" placeholder="请输入身份证号码" v-model="form.identityCardNumber" />
  11. </u-form-item>
  12. </u-form>
  13. </view>
  14. <view class=" padding bg-white radius margin-top">
  15. <view class="margin-top"
  16. style="border: 2rpx dashed #484B74; width: 100%;height: 320rpx;position: relative;">
  17. <view style="text-align: center;margin: 80rpx auto 0;" @click="addImages(1)"
  18. v-if="!form.identityCardFront">
  19. <image src="../../../static/my/photo.png" mode="widthFix" style="width: 73rpx;"></image>
  20. <view class="text-sm text-gray margin-top-sm">请拍摄身份证正面</view>
  21. </view>
  22. <image @click="disabled? '':addImages(1)" v-else :src="form.identityCardFront"
  23. style="width: 100%;height: 320rpx;"></image>
  24. </view>
  25. <!-- <view class="text-lg">上传身份证反面</view> -->
  26. <view class="margin-top"
  27. style="border: 2rpx dashed #484B74; width: 100%;height: 320rpx;position: relative;">
  28. <view style="text-align: center;margin: 80rpx auto 0;" @click="addImages(2)"
  29. v-if="!form.identityCardVerso">
  30. <image src="../../../static/my/photo.png" mode="widthFix" style="width: 73rpx;"></image>
  31. <view class="text-sm text-gray margin-top-sm">请拍摄身份证反面</view>
  32. </view>
  33. <image @click="disabled? '':addImages(2)" v-else :src="form.identityCardVerso"
  34. style="width: 100%;height: 320rpx;"></image>
  35. </view>
  36. <view class="margin-top"
  37. style="border: 2rpx dashed #484B74; width: 100%;height: 320rpx;position: relative;">
  38. <view style="text-align: center;margin: 80rpx auto 0;" @click="addImages(3)"
  39. v-if="!form.selfIdentityCard">
  40. <image src="../../../static/my/photo.png" mode="widthFix" style="width: 73rpx;"></image>
  41. <view class="text-sm text-gray margin-top-sm">请拍摄手持身份证正面</view>
  42. </view>
  43. <image @click="disabled? '':addImages(3)" v-else :src="form.selfIdentityCard"
  44. style="width: 100%;height: 320rpx;"></image>
  45. </view>
  46. </view>
  47. <view class="padding bg-white radius margin-top">
  48. <view class="text-bold">缴纳保证金</view>
  49. <view class="flex justify-between margin-top-sm">
  50. <view class="text-gray">满足订单量及好评率即可申请退还保证金</view>
  51. <view class="text-bold" style="color: #FF6A04;">¥{{money}}</view>
  52. </view>
  53. </view>
  54. <view class="padding margin-top footer text-xxl">
  55. <text @tap="isShowAgree" class="cuIcon" :class="showAgree?'cuIcon-radiobox':'cuIcon-round'">同意并接受</text>
  56. <!-- 协议地址 -->
  57. <navigator url="/pages/riderMy/paotuixieyi" open-type="navigate">《跑腿代购用户协议》</navigator>
  58. </view>
  59. <view style="height: 120rpx;"></view>
  60. </view>
  61. <view class="bg-white flex justify-between align-center padding-lr"
  62. style="position: fixed;bottom: 0;width: 100%;height: 120rpx;">
  63. <view class="">
  64. <text class="text-lg text-bold text-black">支付:</text>
  65. <text class="text-red">¥{{money}}</text>
  66. </view>
  67. <view>
  68. <u-button v-if="!disabled" @click="submit" class="" :custom-style="customStyle" shape="circle"
  69. :hair-line="false">提交认证</u-button>
  70. </view>
  71. </view>
  72. <u-popup v-model="showpay" mode="bottom" close-icon="close-circle" close-icon-pos="top-right"
  73. close-icon-color="#8f9298" close-icon-size="50">
  74. <view class="popup_pay">
  75. <view class="bg margin-top padding-lr radius">
  76. <view style="padding: 0 20upx;margin-top: 36rpx;">
  77. <view
  78. style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;justify-content: center;"
  79. v-for="(item,index) in openLists" :key='index'>
  80. <image :src="item.image" style="width: 55upx;height: 55upx;border-radius: 50upx;">
  81. </image>
  82. <view style="font-size: 30upx;margin-left: 20upx;width: 70%;">
  83. {{item.name}}
  84. </view>
  85. <radio-group name="openWay" style="margin-left: 45rpx;" @tap='selectWay(item)'>
  86. <label class="tui-radio">
  87. <radio color="#FF7F00" :checked="openWay == item.id ? true : false" />
  88. </label>
  89. </radio-group>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="pay_btns" @click="pay()">确认支付</view>
  94. </view>
  95. </u-popup>
  96. </view>
  97. </template>
  98. <script>
  99. import configdata from '@/common/config.js';
  100. import configurl from '../../../common/config.js'
  101. export default {
  102. data() {
  103. return {
  104. form: {
  105. userName: '',
  106. // phone: '',
  107. identityCardNumber: '',
  108. identityCardFront: '',
  109. identityCardVerso: '',
  110. selfIdentityCard: '',
  111. cashDeposit: ''
  112. },
  113. disabled: false,
  114. lableStyle: {
  115. color: '#000',
  116. fontSize: '36upx',
  117. fontWeight: 700
  118. },
  119. customStyle: {
  120. backgroundColor: '#FF6A04',
  121. color: '#FFFFFF',
  122. border: 0,
  123. width: '200rpx'
  124. },
  125. btnStyle: {
  126. backgroundColor: '#FF6A04',
  127. color: '#FFFFFF',
  128. },
  129. money: 0,
  130. showAgree: false, //协议是否选择
  131. sessionkey: '',
  132. showpay: false,
  133. openWay: 1,
  134. openLists: [],
  135. indentNumber: '',
  136. XCXIsSelect:'否'
  137. }
  138. },
  139. onLoad() {
  140. this.XCXIsSelect = this.$queue.getData('XCXIsSelect');
  141. if(this.XCXIsSelect =='否'){
  142. uni.setNavigationBarTitle({
  143. title: '隐私政策'
  144. });
  145. }else{
  146. uni.setNavigationBarTitle({
  147. title: '实名认证'
  148. });
  149. }
  150. // #ifdef MP-WEIXIN
  151. this.openLists = [{
  152. id: 1,
  153. image: '../../../static/my/weixin.png',
  154. name: '微信'
  155. }]
  156. this.openWay = 1
  157. // #endif
  158. // #ifdef H5
  159. this.openLists = [
  160. {
  161. id: 1,
  162. image: '../../../static/my/weixin.png',
  163. name: '微信'
  164. },
  165. {
  166. id: 2,
  167. image: '../../../static/my/zhifubao.png',
  168. name: '支付宝'
  169. }
  170. ]
  171. this.openWay = 1
  172. // #endif
  173. // #ifdef APP-PLUS
  174. this.openLists = [{
  175. id: 1,
  176. image: '../../../static/my/weixin.png',
  177. name: '微信'
  178. },
  179. {
  180. id: 2,
  181. image: '../../../static/my/zhifubao.png',
  182. name: '支付宝'
  183. }
  184. ]
  185. // #endif
  186. this.getRZmoney()
  187. this.sessionkey = this.$queue.getData("sessionkey");
  188. },
  189. methods: {
  190. isShowAgree() {
  191. this.showAgree = !this.showAgree
  192. },
  193. getRZmoney() {
  194. this.$Request.get("/app/common/type/273").then(res => {
  195. if (res.code == 0) {
  196. this.money = res.data.value
  197. this.form.cashDeposit = res.data.value
  198. }
  199. });
  200. },
  201. selectWay: function(item) {
  202. this.openWay = item.id;
  203. },
  204. submit() {
  205. let that = this
  206. console.log(that.form)
  207. if (!that.form.userName) {
  208. uni.showToast({
  209. title: '请输入真实姓名',
  210. icon: 'none',
  211. duration: 1000
  212. })
  213. return;
  214. }
  215. if (!that.form.identityCardNumber) {
  216. uni.showToast({
  217. title: '请输入身份证号',
  218. icon: 'none',
  219. duration: 1000
  220. })
  221. return;
  222. }
  223. if (!that.form.identityCardFront) {
  224. uni.showToast({
  225. title: '请上传身份证正面',
  226. icon: 'none',
  227. duration: 1000
  228. })
  229. return;
  230. }
  231. if (!that.form.identityCardVerso) {
  232. uni.showToast({
  233. title: '请上传身份证反面',
  234. icon: 'none',
  235. duration: 1000
  236. })
  237. return;
  238. }
  239. if (!that.form.selfIdentityCard) {
  240. uni.showToast({
  241. title: '请上传手持身份证正面',
  242. icon: 'none',
  243. duration: 1000
  244. })
  245. return;
  246. }
  247. if (!this.showAgree) {
  248. uni.showToast({
  249. title: '请勾选跑腿代购用户协议',
  250. icon: 'none',
  251. duration: 1000
  252. })
  253. return;
  254. }
  255. // #ifdef MP-WEIXIN
  256. that.$Request.postJson("/app/wxPayErrRider/wxPayJsApiRiderCertification/3", that.form).then(res => {
  257. if (res.code == 0) {
  258. uni.requestPayment({
  259. provider: 'wxpay',
  260. timeStamp: res.data.timestamp,
  261. nonceStr: res.data.noncestr,
  262. package: res.data.package,
  263. signType: res.data.signType,
  264. paySign: res.data.sign,
  265. success: function(res) {
  266. console.log(res)
  267. uni.hideLoading();
  268. uni.showToast({
  269. title: '实名认证提交成功',
  270. icon: 'none'
  271. });
  272. setTimeout(function() {
  273. uni.navigateBack(1)
  274. }, 1000)
  275. },
  276. fail: function(err) {
  277. console.log('fail:' + JSON.stringify(err));
  278. uni.hideLoading();
  279. that.$queue.showToast('支付失败');
  280. }
  281. });
  282. } else {
  283. uni.showToast({
  284. title: res.msg,
  285. icon: 'none'
  286. })
  287. }
  288. });
  289. // #endif
  290. // #ifdef H5
  291. this.showpay = true
  292. // #endif
  293. // #ifdef APP-PLUS
  294. this.showpay = true
  295. // #endif
  296. },
  297. getUserInfo() {
  298. this.$Request.get("/app/userinfo/findUserInfoById").then(res => {
  299. if (res.code == 0) {
  300. this.form.name = res.data.name ? res.data.name : ''
  301. this.form.idNumber = res.data.idNumber ? res.data.idNumber : ''
  302. this.form.front = res.data.front ? res.data.front : ''
  303. this.form.back = res.data.back ? res.data.back : ''
  304. if (res.data.status == 1) {
  305. this.disabled = true
  306. }
  307. if (res.data.status == 2) {
  308. this.form.remek = res.data.remek ? res.data.remek : ''
  309. }
  310. }
  311. });
  312. },
  313. addImages(e) {
  314. let that = this
  315. uni.chooseImage({
  316. count: 1,
  317. sourceType: ['album', 'camera'],
  318. success: res => {
  319. for (let i = 0; i < 1; i++) {
  320. that.$queue.showLoading("上传中...");
  321. uni.uploadFile({ // 上传接口
  322. url: configurl.APIHOST2 + '/sqx_fast/alioss/upload', //真实的接口地址
  323. // url: 'https://mxys.chuanghai-tech.com/sqx_fast/alioss/upload',
  324. filePath: res.tempFilePaths[i],
  325. name: 'file',
  326. success: (uploadFileRes) => {
  327. console.log(uploadFileRes)
  328. if (e == 1) {
  329. that.form.identityCardFront = JSON.parse(uploadFileRes
  330. .data).data
  331. } else if (e == 2) {
  332. that.form.identityCardVerso = JSON.parse(uploadFileRes
  333. .data).data
  334. } else if (e == 3) {
  335. that.form.selfIdentityCard = JSON.parse(uploadFileRes.data)
  336. .data
  337. }
  338. uni.hideLoading();
  339. }
  340. });
  341. }
  342. }
  343. })
  344. },
  345. config: function(name) {
  346. var info = null;
  347. if (name) {
  348. var name2 = name.split("."); //字符分割
  349. if (name2.length > 1) {
  350. info = configdata[name2[0]][name2[1]] || null;
  351. } else {
  352. info = configdata[name] || null;
  353. }
  354. if (info == null) {
  355. let web_config = cache.get("web_config");
  356. if (web_config) {
  357. if (name2.length > 1) {
  358. info = web_config[name2[0]][name2[1]] || null;
  359. } else {
  360. info = web_config[name] || null;
  361. }
  362. }
  363. }
  364. }
  365. return info;
  366. },
  367. pay() {
  368. if (this.openWay == 0) {
  369. this.$queue.showToast('请选择支付方式!')
  370. return;
  371. }
  372. if (this.openWay == 1) {
  373. // #ifdef H5
  374. this.$Request.postJson("/app/wxPayErrRider/wxPayJsApiRiderCertification/2", this.form).then(
  375. res => {
  376. console.log(res)
  377. if (res.code == 0) {
  378. console.log()
  379. this.callPay(res.data);
  380. } else {
  381. uni.showToast({
  382. icon: 'none',
  383. title: '支付失败!'
  384. });
  385. }
  386. });
  387. // #endif
  388. // #ifdef APP-PLUS
  389. // 微信APP支付 根据订单id获取支付信息
  390. this.$Request.postJson("/app/wxPayErrRider/wxPayJsApiRiderCertification/1", this.form).then(
  391. res => {
  392. console.log(JSON.stringify(res), '微信支付信息')
  393. this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data));
  394. });
  395. // #endif
  396. } else if (this.openWay == 2) { //支付宝支付
  397. // #ifdef H5
  398. this.$Request.postJson("/app/wxPayErrRider/wxPayJsApiRiderCertification/5", this.form).then(
  399. res => {
  400. console.log(res)
  401. if (res.code == 0) {
  402. console.log()
  403. const div = document.createElement('div')
  404. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  405. document.body.appendChild(div)
  406. document.forms[0].submit()
  407. } else {
  408. uni.showToast({
  409. icon: 'none',
  410. title: '支付失败!'
  411. });
  412. }
  413. });
  414. // #endif
  415. console.log('支付宝')
  416. // APP支付宝支付
  417. // #ifdef APP
  418. this.$Request.postJson("/app/wxPayErrRider/wxPayJsApiRiderCertification/4", this.form).then(
  419. res => {
  420. console.log(JSON.stringify(res), '支付宝支付信息')
  421. this.setPayment('alipay', res.data);
  422. });
  423. // #endif
  424. }
  425. },
  426. callPay: function(response) {
  427. console.log(response)
  428. if (typeof WeixinJSBridge === "undefined") {
  429. if (document.addEventListener) {
  430. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  431. } else if (document.attachEvent) {
  432. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  433. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  434. }
  435. } else {
  436. this.onBridgeReady(response);
  437. }
  438. },
  439. onBridgeReady: function(response) {
  440. let that = this;
  441. // if (!response.package) {
  442. // return;
  443. // }
  444. console.log(response, 111111)
  445. WeixinJSBridge.invoke(
  446. 'getBrandWCPayRequest', {
  447. "appId": response.appid, //公众号名称,由商户传入
  448. "timeStamp": response.timestamp, //时间戳,自1970年以来的秒数
  449. "nonceStr": response.noncestr, //随机串
  450. "package": response.package,
  451. "signType": response.signType, //微信签名方式:
  452. "paySign": response.sign //微信签名
  453. },
  454. function(res) {
  455. console.log(res, '/*-/*-/*-')
  456. if (res.err_msg === "get_brand_wcpay_request:ok") {
  457. // 使用以上方式判断前端返回,微信团队郑重提示:
  458. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  459. uni.showLoading({
  460. title: '支付成功'
  461. });
  462. setTimeout(function() {
  463. uni.hideLoading();
  464. uni.navigateBack()
  465. }, 1000);
  466. } else {
  467. uni.hideLoading();
  468. }
  469. WeixinJSBridge.log(response.err_msg);
  470. }
  471. );
  472. },
  473. isCheckPay(status, name, order) {
  474. if (status == 0) {
  475. this.setPayment(name, order);
  476. } else {
  477. uni.hideLoading();
  478. uni.showToast({
  479. title: '支付信息有误',
  480. icon: 'none'
  481. });
  482. }
  483. },
  484. setPayment(name, order) {
  485. console.log(name, '*-*-*', order)
  486. uni.requestPayment({
  487. provider: name,
  488. orderInfo: order, //微信、支付宝订单数据
  489. success: function(res) {
  490. console.log(res)
  491. uni.hideLoading();
  492. uni.showLoading({
  493. title: '支付成功'
  494. });
  495. setTimeout(function() {
  496. uni.navigateBack()
  497. }, 1000);
  498. },
  499. fail: function(err) {
  500. console.log(err)
  501. uni.hideLoading();
  502. },
  503. complete() {
  504. uni.hideLoading();
  505. }
  506. });
  507. },
  508. }
  509. }
  510. </script>
  511. <style>
  512. .footer {
  513. /* // padding-left: 140upx; */
  514. /* justify-content: center; */
  515. margin-top: 32upx;
  516. font-size: 24upx;
  517. color: #666666;
  518. display: flex;
  519. text-align: center;
  520. align-items: center;
  521. }
  522. /* 支付弹框 */
  523. .popup_pay {
  524. width: 100%;
  525. }
  526. .pay_btns {
  527. width: 90%;
  528. margin: 0 auto 40rpx;
  529. text-align: center;
  530. background: #FF7F00;
  531. height: 80rpx;
  532. border-radius: 16rpx;
  533. color: #ffffff;
  534. line-height: 80rpx;
  535. margin-top: 20rpx;
  536. }
  537. </style>