approve.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  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. console.log(that.form,'实名' + res)
  296. uni.hideLoading()
  297. uni.showToast({
  298. title: '实名认证提交成功',
  299. icon: 'none'
  300. })
  301. setTimeout(function () {
  302. uni.navigateBack(1)
  303. }, 1000)
  304. // uni.requestPayment({
  305. // provider: 'wxpay',
  306. // timeStamp: res.data.timestamp,
  307. // nonceStr: res.data.noncestr,
  308. // package: res.data.package,
  309. // signType: res.data.signType,
  310. // paySign: res.data.sign,
  311. // success: function (res) {
  312. // console.log('实名' + res)
  313. // uni.hideLoading()
  314. // uni.showToast({
  315. // title: '实名认证提交成功',
  316. // icon: 'none'
  317. // })
  318. // setTimeout(function () {
  319. // uni.navigateBack(1)
  320. // }, 1000)
  321. // },
  322. // fail: function (err) {
  323. // console.log('fail:' + JSON.stringify(err))
  324. // uni.hideLoading()
  325. // that.$queue.showToast('支付失败')
  326. // }
  327. // })
  328. } else {
  329. uni.showToast({
  330. title: res.msg,
  331. icon: 'none'
  332. })
  333. }
  334. })
  335. // #endif
  336. // #ifdef H5
  337. this.showpay = true
  338. // #endif
  339. // #ifdef APP-PLUS
  340. this.showpay = true
  341. // #endif
  342. },
  343. getUserInfo() {
  344. this.$Request.get('/app/userinfo/findUserInfoById').then((res) => {
  345. if (res.code == 0) {
  346. this.form.name = res.data.name ? res.data.name : ''
  347. this.form.idNumber = res.data.idNumber ? res.data.idNumber : ''
  348. this.form.front = res.data.front ? res.data.front : ''
  349. this.form.back = res.data.back ? res.data.back : ''
  350. if (res.data.status == 1) {
  351. this.disabled = true
  352. }
  353. if (res.data.status == 2) {
  354. this.form.remek = res.data.remek ? res.data.remek : ''
  355. }
  356. }
  357. })
  358. },
  359. addImages(e) {
  360. let that = this
  361. uni.chooseImage({
  362. count: 1,
  363. sourceType: ['album', 'camera'],
  364. success: (res) => {
  365. for (let i = 0; i < 1; i++) {
  366. //这里的id和页面中写的html代码的canvas的id要一致
  367. let canvasId = 'zipCanvas'
  368. //原图的路径
  369. let imagePath = res.tempFiles[i].path
  370. //大小限制
  371. let limitSize = 1024 * 2
  372. //初始绘画区域是画布自身的宽度也就是屏幕宽度
  373. let drawWidth = uni.getSystemInfoSync().windowWidth
  374. let that = this
  375. let token = uni.getStorageSync('token')
  376. getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, that, (resPath) => {
  377. uni.showLoading({
  378. title: '上传中'
  379. })
  380. uni.uploadFile({
  381. url: configurl.APIHOST2 + '/app/new-file/upload',
  382. filePath: resPath,
  383. header: {
  384. token: token
  385. },
  386. name: 'file',
  387. success: (uploadFileRes) => {
  388. console.log(uploadFileRes)
  389. if (e == 1) {
  390. that.form.identityCardFront = JSON.parse(uploadFileRes.data).data
  391. } else if (e == 2) {
  392. that.form.identityCardVerso = JSON.parse(uploadFileRes.data).data
  393. } else if (e == 3) {
  394. that.form.selfIdentityCard = JSON.parse(uploadFileRes.data).data
  395. }
  396. uni.hideLoading()
  397. },
  398. fail: () => {
  399. uni.showToast({
  400. title: '上传失败',
  401. icon: 'error'
  402. })
  403. }
  404. })
  405. })
  406. }
  407. }
  408. })
  409. },
  410. config: function (name) {
  411. var info = null
  412. if (name) {
  413. var name2 = name.split('.') //字符分割
  414. if (name2.length > 1) {
  415. info = configdata[name2[0]][name2[1]] || null
  416. } else {
  417. info = configdata[name] || null
  418. }
  419. if (info == null) {
  420. let web_config = cache.get('web_config')
  421. if (web_config) {
  422. if (name2.length > 1) {
  423. info = web_config[name2[0]][name2[1]] || null
  424. } else {
  425. info = web_config[name] || null
  426. }
  427. }
  428. }
  429. }
  430. return info
  431. },
  432. pay() {
  433. if (this.openWay == 0) {
  434. this.$queue.showToast('请选择支付方式!')
  435. return
  436. }
  437. if (this.openWay == 1) {
  438. // #ifdef H5
  439. this.$Request.postJson('/app/wxPayErrRider/wxPayJsApiRiderCertification/2', this.form).then((res) => {
  440. console.log(res)
  441. if (res.code == 0) {
  442. console.log()
  443. this.callPay(res.data)
  444. } else {
  445. uni.showToast({
  446. icon: 'none',
  447. title: '支付失败!'
  448. })
  449. }
  450. })
  451. // #endif
  452. // #ifdef APP-PLUS
  453. // 微信APP支付 根据订单id获取支付信息
  454. this.$Request.postJson('/app/wxPayErrRider/wxPayJsApiRiderCertification/1', this.form).then((res) => {
  455. console.log(JSON.stringify(res), '微信支付信息')
  456. this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data))
  457. })
  458. // #endif
  459. } else if (this.openWay == 2) {
  460. //支付宝支付
  461. // #ifdef H5
  462. this.$Request.postJson('/app/wxPayErrRider/wxPayJsApiRiderCertification/5', this.form).then((res) => {
  463. console.log(res)
  464. if (res.code == 0) {
  465. console.log()
  466. const div = document.createElement('div')
  467. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  468. document.body.appendChild(div)
  469. document.forms[0].submit()
  470. } else {
  471. uni.showToast({
  472. icon: 'none',
  473. title: '支付失败!'
  474. })
  475. }
  476. })
  477. // #endif
  478. console.log('支付宝')
  479. // APP支付宝支付
  480. // #ifdef APP
  481. this.$Request.postJson('/app/wxPayErrRider/wxPayJsApiRiderCertification/4', this.form).then((res) => {
  482. console.log(JSON.stringify(res), '支付宝支付信息')
  483. this.setPayment('alipay', res.data)
  484. })
  485. // #endif
  486. }
  487. },
  488. callPay: function (response) {
  489. console.log(response)
  490. if (typeof WeixinJSBridge === 'undefined') {
  491. if (document.addEventListener) {
  492. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false)
  493. } else if (document.attachEvent) {
  494. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response))
  495. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response))
  496. }
  497. } else {
  498. this.onBridgeReady(response)
  499. }
  500. },
  501. onBridgeReady: function (response) {
  502. let that = this
  503. // if (!response.package) {
  504. // return;
  505. // }
  506. console.log(response, 111111)
  507. WeixinJSBridge.invoke(
  508. 'getBrandWCPayRequest',
  509. {
  510. appId: response.appid, //公众号名称,由商户传入
  511. timeStamp: response.timestamp, //时间戳,自1970年以来的秒数
  512. nonceStr: response.noncestr, //随机串
  513. package: response.package,
  514. signType: response.signType, //微信签名方式:
  515. paySign: response.sign //微信签名
  516. },
  517. function (res) {
  518. console.log(res, '/*-/*-/*-')
  519. if (res.err_msg === 'get_brand_wcpay_request:ok') {
  520. // 使用以上方式判断前端返回,微信团队郑重提示:
  521. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  522. uni.showLoading({
  523. title: '支付成功'
  524. })
  525. setTimeout(function () {
  526. uni.hideLoading()
  527. uni.navigateBack()
  528. }, 1000)
  529. } else {
  530. uni.hideLoading()
  531. }
  532. WeixinJSBridge.log(response.err_msg)
  533. }
  534. )
  535. },
  536. isCheckPay(status, name, order) {
  537. if (status == 0) {
  538. this.setPayment(name, order)
  539. } else {
  540. uni.hideLoading()
  541. uni.showToast({
  542. title: '支付信息有误',
  543. icon: 'none'
  544. })
  545. }
  546. },
  547. setPayment(name, order) {
  548. console.log(name, '*-*-*', order)
  549. uni.requestPayment({
  550. provider: name,
  551. orderInfo: order, //微信、支付宝订单数据
  552. success: function (res) {
  553. console.log(res)
  554. uni.hideLoading()
  555. uni.showLoading({
  556. title: '支付成功'
  557. })
  558. setTimeout(function () {
  559. uni.navigateBack()
  560. }, 1000)
  561. },
  562. fail: function (err) {
  563. console.log(err)
  564. uni.hideLoading()
  565. },
  566. complete() {
  567. uni.hideLoading()
  568. }
  569. })
  570. }
  571. }
  572. }
  573. </script>
  574. <style>
  575. .footer {
  576. /* // padding-left: 140upx; */
  577. /* justify-content: center; */
  578. margin-top: 32upx;
  579. font-size: 24upx;
  580. color: #666666;
  581. display: flex;
  582. text-align: center;
  583. align-items: center;
  584. }
  585. /* 支付弹框 */
  586. .popup_pay {
  587. width: 100%;
  588. }
  589. .pay_btns {
  590. width: 90%;
  591. margin: 0 auto 40rpx;
  592. text-align: center;
  593. background: #ff7f00;
  594. height: 80rpx;
  595. border-radius: 16rpx;
  596. color: #ffffff;
  597. line-height: 80rpx;
  598. margin-top: 20rpx;
  599. }
  600. </style>