approve.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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. let token = uni.getStorageSync('token');
  321. that.$queue.showLoading("上传中...");
  322. uni.uploadFile({ // 上传接口
  323. url: configurl.APIHOST2 + '/alioss/upload', //真实的接口地址
  324. // url: 'https://mxys.chuanghai-tech.com/sqx_fast/alioss/upload',
  325. filePath: res.tempFilePaths[i],
  326. header: {
  327. token: token
  328. },
  329. name: 'file',
  330. success: (uploadFileRes) => {
  331. console.log(uploadFileRes)
  332. if (e == 1) {
  333. that.form.identityCardFront = JSON.parse(uploadFileRes
  334. .data).data
  335. } else if (e == 2) {
  336. that.form.identityCardVerso = JSON.parse(uploadFileRes
  337. .data).data
  338. } else if (e == 3) {
  339. that.form.selfIdentityCard = JSON.parse(uploadFileRes.data)
  340. .data
  341. }
  342. uni.hideLoading();
  343. }
  344. });
  345. }
  346. }
  347. })
  348. },
  349. config: function(name) {
  350. var info = null;
  351. if (name) {
  352. var name2 = name.split("."); //字符分割
  353. if (name2.length > 1) {
  354. info = configdata[name2[0]][name2[1]] || null;
  355. } else {
  356. info = configdata[name] || null;
  357. }
  358. if (info == null) {
  359. let web_config = cache.get("web_config");
  360. if (web_config) {
  361. if (name2.length > 1) {
  362. info = web_config[name2[0]][name2[1]] || null;
  363. } else {
  364. info = web_config[name] || null;
  365. }
  366. }
  367. }
  368. }
  369. return info;
  370. },
  371. pay() {
  372. if (this.openWay == 0) {
  373. this.$queue.showToast('请选择支付方式!')
  374. return;
  375. }
  376. if (this.openWay == 1) {
  377. // #ifdef H5
  378. this.$Request.postJson("/app/wxPayErrRider/wxPayJsApiRiderCertification/2", this.form).then(
  379. res => {
  380. console.log(res)
  381. if (res.code == 0) {
  382. console.log()
  383. this.callPay(res.data);
  384. } else {
  385. uni.showToast({
  386. icon: 'none',
  387. title: '支付失败!'
  388. });
  389. }
  390. });
  391. // #endif
  392. // #ifdef APP-PLUS
  393. // 微信APP支付 根据订单id获取支付信息
  394. this.$Request.postJson("/app/wxPayErrRider/wxPayJsApiRiderCertification/1", this.form).then(
  395. res => {
  396. console.log(JSON.stringify(res), '微信支付信息')
  397. this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data));
  398. });
  399. // #endif
  400. } else if (this.openWay == 2) { //支付宝支付
  401. // #ifdef H5
  402. this.$Request.postJson("/app/wxPayErrRider/wxPayJsApiRiderCertification/5", this.form).then(
  403. res => {
  404. console.log(res)
  405. if (res.code == 0) {
  406. console.log()
  407. const div = document.createElement('div')
  408. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  409. document.body.appendChild(div)
  410. document.forms[0].submit()
  411. } else {
  412. uni.showToast({
  413. icon: 'none',
  414. title: '支付失败!'
  415. });
  416. }
  417. });
  418. // #endif
  419. console.log('支付宝')
  420. // APP支付宝支付
  421. // #ifdef APP
  422. this.$Request.postJson("/app/wxPayErrRider/wxPayJsApiRiderCertification/4", this.form).then(
  423. res => {
  424. console.log(JSON.stringify(res), '支付宝支付信息')
  425. this.setPayment('alipay', res.data);
  426. });
  427. // #endif
  428. }
  429. },
  430. callPay: function(response) {
  431. console.log(response)
  432. if (typeof WeixinJSBridge === "undefined") {
  433. if (document.addEventListener) {
  434. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  435. } else if (document.attachEvent) {
  436. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  437. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  438. }
  439. } else {
  440. this.onBridgeReady(response);
  441. }
  442. },
  443. onBridgeReady: function(response) {
  444. let that = this;
  445. // if (!response.package) {
  446. // return;
  447. // }
  448. console.log(response, 111111)
  449. WeixinJSBridge.invoke(
  450. 'getBrandWCPayRequest', {
  451. "appId": response.appid, //公众号名称,由商户传入
  452. "timeStamp": response.timestamp, //时间戳,自1970年以来的秒数
  453. "nonceStr": response.noncestr, //随机串
  454. "package": response.package,
  455. "signType": response.signType, //微信签名方式:
  456. "paySign": response.sign //微信签名
  457. },
  458. function(res) {
  459. console.log(res, '/*-/*-/*-')
  460. if (res.err_msg === "get_brand_wcpay_request:ok") {
  461. // 使用以上方式判断前端返回,微信团队郑重提示:
  462. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  463. uni.showLoading({
  464. title: '支付成功',
  465. });
  466. setTimeout(function() {
  467. uni.hideLoading();
  468. uni.navigateBack()
  469. }, 1000);
  470. } else {
  471. uni.hideLoading();
  472. }
  473. WeixinJSBridge.log(response.err_msg);
  474. }
  475. );
  476. },
  477. isCheckPay(status, name, order) {
  478. if (status == 0) {
  479. this.setPayment(name, order);
  480. } else {
  481. uni.hideLoading();
  482. uni.showToast({
  483. title: '支付信息有误',
  484. icon: 'none'
  485. });
  486. }
  487. },
  488. setPayment(name, order) {
  489. console.log(name, '*-*-*', order)
  490. uni.requestPayment({
  491. provider: name,
  492. orderInfo: order, //微信、支付宝订单数据
  493. success: function(res) {
  494. console.log(res)
  495. uni.hideLoading();
  496. uni.showLoading({
  497. title: '支付成功'
  498. });
  499. setTimeout(function() {
  500. uni.navigateBack()
  501. }, 1000);
  502. },
  503. fail: function(err) {
  504. console.log(err)
  505. uni.hideLoading();
  506. },
  507. complete() {
  508. uni.hideLoading();
  509. }
  510. });
  511. },
  512. }
  513. }
  514. </script>
  515. <style>
  516. .footer {
  517. /* // padding-left: 140upx; */
  518. /* justify-content: center; */
  519. margin-top: 32upx;
  520. font-size: 24upx;
  521. color: #666666;
  522. display: flex;
  523. text-align: center;
  524. align-items: center;
  525. }
  526. /* 支付弹框 */
  527. .popup_pay {
  528. width: 100%;
  529. }
  530. .pay_btns {
  531. width: 90%;
  532. margin: 0 auto 40rpx;
  533. text-align: center;
  534. background: #FF7F00;
  535. height: 80rpx;
  536. border-radius: 16rpx;
  537. color: #ffffff;
  538. line-height: 80rpx;
  539. margin-top: 20rpx;
  540. }
  541. </style>