approve.vue 17 KB

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