Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

signContract.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <template>
  2. <view class="content" v-if="online === 2">
  3. <custom-header title="支付账户签约" :back="false"></custom-header>
  4. <view style="padding: 20rpx 0 30rpx" class="order-content">
  5. <!-- 获取产品展示 -->
  6. <view
  7. class="order-car"
  8. v-for="(item, index) in paymentChannelList"
  9. :key="index"
  10. >
  11. <view class="l-img">
  12. <image class="icon-tip" :src="item.imgUrl" mode="aspectFit"></image>
  13. </view>
  14. <view class="c-amount">
  15. <view class="goods-name">
  16. {{ item.name }}
  17. </view>
  18. <view class="goods-des">
  19. {{ item.desc }}
  20. </view>
  21. <view class="goods-label">
  22. <view
  23. class="label-item"
  24. v-for="(labelItem, index) in item.label"
  25. :key="index"
  26. >
  27. <u-tag
  28. :text="labelItem"
  29. mode="light"
  30. size="mini"
  31. bg-color="#38ca83"
  32. border-color="#38ca83"
  33. color="#fff"
  34. />
  35. </view>
  36. </view>
  37. </view>
  38. <view class="r-btn">
  39. <u-button
  40. shape="circle"
  41. plain
  42. class="custom-style"
  43. @click="handleCon"
  44. >
  45. 签约
  46. </u-button>
  47. </view>
  48. </view>
  49. </view>
  50. <u-popup
  51. v-model="show"
  52. mode="right"
  53. :closeable="true"
  54. length="100%"
  55. z-index="990"
  56. >
  57. <view
  58. style="background-color: #f4f4f4; height: 100vh; position: relative"
  59. >
  60. <view class="title">签约</view>
  61. <view class="slot-content">
  62. <view style="background-color: #fff">
  63. <view class="con-img">
  64. <!-- <qrcode-vue :value="qrCodeValue" level="H" :render-as="renderAs" style='width: 100%;height: 100%;' /> -->
  65. <image
  66. style="width: 100%; height: 100%"
  67. :src="imageSign"
  68. mode="aspectFit"
  69. ></image>
  70. </view>
  71. <view class="con-info">请打开微信扫码完成签约</view>
  72. </view>
  73. </view>
  74. <view class="bottom-btn">
  75. <button type="success" class="btn-txt btn" @click="handleNext">
  76. 下一步
  77. </button>
  78. </view>
  79. </view>
  80. </u-popup>
  81. </view>
  82. </template>
  83. <script setup lang="ts">
  84. import { fileURL } from '@/utils/network/api.js';
  85. import { reactive, ref } from 'vue';
  86. import { unifyTemplate } from '@/hooks/unifyTemplate';
  87. import { onLoad } from '@dcloudio/uni-app';
  88. import { request } from '@/utils/network/request';
  89. import wx from 'weixin-js-sdk';
  90. import QrcodeVue, { Level, RenderAs } from 'qrcode.vue';
  91. import { setToken, getToken } from '@/utils/storage';
  92. import { handleToTypes } from '@/utils/utils';
  93. const {
  94. CustomHeader //头部组件
  95. } = unifyTemplate(); //初始化数据
  96. const {
  97. initData, //初始化数据
  98. qdOrderVal //qdOrder中数据 ref
  99. } = unifyTemplate(); //初始化数据
  100. const online = ref(1); //1为线上,2为线下
  101. const jumpPage = ref('pages/payment/signAContract');
  102. //获取页面配置
  103. onLoad((opin) => {
  104. initData(opin, 4).then(async (data) => {
  105. uni.showLoading({
  106. title: '加载中',
  107. mask: true
  108. });
  109. // if (opin.jumpPage) {
  110. // jumpPage.value = opin.jumpPage
  111. // }
  112. jumpPage.value = data.config.jumpPage || jumpPage.value;
  113. online.value = data.order.promotionModes;
  114. await login(data);
  115. let key = await contractTesting(
  116. qdOrderVal.value.qdOrderNo,
  117. jumpPage.value,
  118. true
  119. );
  120. if (key) {
  121. return;
  122. }
  123. if (data.order.promotionModes === 1) {
  124. // 线上直接去内部判断
  125. handleToType(data.qdOrder.qtOrderNo);
  126. } else {
  127. uni.hideLoading();
  128. getCodeIamge(data.qdOrder.qtOrderNo);
  129. }
  130. });
  131. });
  132. // 获取签约二维码
  133. const getCodeIamge = (orderId) => {
  134. let data = {
  135. orderId,
  136. accessToken: loginData.token
  137. };
  138. request('5f0b52cc55b94827840966e3af05ec53', {
  139. data
  140. }).then((res) => {
  141. if (res.statusCode === 0) {
  142. let bizContent = JSON.parse(res.bizContent);
  143. const reg = /^\//;
  144. if (!reg.test(bizContent.codeUrl)) {
  145. bizContent.codeUrl = '/' + bizContent.codeUrl;
  146. }
  147. // 处理为完整路径
  148. imageSign.value =
  149. window.location.protocol +
  150. '//' +
  151. window.location.host +
  152. bizContent.codeUrl;
  153. console.log('签约图片', bizContent);
  154. }
  155. });
  156. };
  157. // 无感登录,如果没有登录调用登录
  158. const loginData = reactive({
  159. token: '',
  160. openId: ''
  161. });
  162. async function login(orderData) {
  163. let data = {
  164. userType: '',
  165. account: ''
  166. };
  167. if (orderData.order.userType === 'PERSONAL_USER') {
  168. // 个人办理
  169. data.userType = 'PERSONAL';
  170. data.account = orderData.order.customerTel;
  171. } else {
  172. // 单位办理
  173. data.userType = 'ENTERPRISE';
  174. data.account = orderData.order.customerIdnum;
  175. }
  176. console.log(data, '无感登录', qdOrderVal.value);
  177. await request('abaf0013caa24dafad12b0f571e8ee40', {
  178. data
  179. }).then((res) => {
  180. if (res.statusCode === 0) {
  181. let bizContent = JSON.parse(res.bizContent);
  182. console.log('login', bizContent);
  183. setToken(bizContent.accessToken);
  184. // 保存token
  185. loginData.token = bizContent.accessToken;
  186. loginData.openId = bizContent.openId;
  187. }
  188. });
  189. }
  190. // 处理进入类型
  191. const handleToType = (qtOrderNo) => {
  192. let type = parseInt(uni.getStorageSync('web_type')) || '';
  193. let userAgent = navigator.userAgent.toLowerCase();
  194. console.log('类型', type);
  195. const agentType = handleToTypes();
  196. if (type) {
  197. if (type === 1) {
  198. // 微信小程序
  199. handleTonei();
  200. } else if (type === 2) {
  201. // 微信公众号
  202. handleToWai();
  203. } else if (type === 3) {
  204. // 支付宝小程序
  205. handleToZhifubao();
  206. } else {
  207. uni.hideLoading();
  208. getCodeIamge(qtOrderNo);
  209. }
  210. } else {
  211. if (agentType === 'alipaymini') {
  212. // 支付宝小程序环境
  213. handleToZhifubao();
  214. } else if (agentType === 'wechatmini') {
  215. // 微信内部
  216. handleTonei();
  217. } else if (agentType === 'wechat') {
  218. // 微信公众号
  219. handleToWai();
  220. } else {
  221. uni.hideLoading();
  222. getCodeIamge(qtOrderNo);
  223. }
  224. }
  225. };
  226. const paymentChannelList = [
  227. {
  228. name: '微信支付',
  229. imgUrl: `${fileURL}image/applyCard/wx.png`,
  230. desc: '服务费是每笔交易金额的0',
  231. label: ['微信代付', '微信便捷支付']
  232. }
  233. ];
  234. const show = ref(false);
  235. const imageSign = ref<String>('');
  236. const renderAs = ref<RenderAs>('svg');
  237. // 签约按钮
  238. function handleCon() {
  239. show.value = true;
  240. }
  241. // 点击下一步
  242. function handleNext() {
  243. contractTesting(qdOrderVal.value.qdOrderNo, jumpPage.value);
  244. }
  245. // 跳转支付宝小程序
  246. function handleToZhifubao() {
  247. let token = loginData.token;
  248. let openId = loginData.openId;
  249. my.navigateTo({
  250. // appid:'2021004102619032',
  251. url: `/subpackage/orders/sign/sign-up-ali?token=${token}&openId=${openId}&orderId=${qdOrderVal.value.qtOrderNo}&qdOrderNo=${qdOrderVal.value.qdOrderNo}`
  252. });
  253. }
  254. // 跳转微信小程序内部
  255. function handleTonei() {
  256. let token = loginData.token;
  257. let openId = loginData.openId;
  258. // let data = JSON.parse(res.data.rd.bizContent)
  259. wx.miniProgram.navigateTo({
  260. // appId: 'wx008c60533388527a', // 要打开的小程序的AppID
  261. // url: `/pages/sign/auth?accessToken=${token}&openId=${openId}&orderId=${qdOrderVal.value.qtOrderNo}&qdOrderNo=${qdOrderVal.value.qdOrderNo}&reset=111`, // 可选,小程序的页面路径,可以不填
  262. url: `/carPark/pages/dmc/signingAContract/signingAContract?accessToken=${token}&openId=${openId}&orderId=${qdOrderVal.value.qtOrderNo}&qdOrderNo=${qdOrderVal.value.qdOrderNo}&reset=111`, // 可选,小程序的页面路径,可以不填
  263. extraData: {
  264. // 可选,传递给小程序的数据,如分享信息等
  265. },
  266. success(res) {
  267. // 打开小程序成功的回调
  268. // console.log(res);
  269. // alert(JSON.stringify(res) + '123')
  270. },
  271. fail(err) {
  272. // 打开小程序失败的回调
  273. // console.error(err);
  274. // alert(JSON.stringify(err) + '456')
  275. }
  276. });
  277. }
  278. // 跳转微信小程序-外链
  279. function handleToWai() {
  280. let token = loginData.token;
  281. let openId = loginData.openId;
  282. let getTokenUrl =
  283. '/cgi-bin/token?grant_type=client_credential&appid=wx008c60533388527a&secret=95197718b43b497f02732bd9f8011080';
  284. let getUrl = '/wxa/generatescheme?access_token=';
  285. uni.request({
  286. url: getTokenUrl,
  287. method: 'GET', //请求方式,必须为大写
  288. success: (res) => {
  289. // console.log('接口返回------', res);
  290. let accessToken = res.data['access_token'];
  291. uni.request({
  292. url: getUrl + accessToken,
  293. method: 'POST', //请求方式,必须为大写
  294. data: {
  295. jump_wxa: {
  296. path: '/carPark/pages/dmc/signingAContract/signingAContract',
  297. query: `accessToken=${token}&openId=${openId}&orderId=${qdOrderVal.value.qtOrderNo}&qdOrderNo=${qdOrderVal.value.qdOrderNo}&reset=111`,
  298. env_version: 'develop' //正式版为"release",体验版为"trial",开发版为"develop",仅在微信外打开时生效。
  299. }
  300. },
  301. success: (res) => {
  302. console.log('接口返回------', res);
  303. if (res.data.errcode === 0) {
  304. location.href = res.data.openlink;
  305. }
  306. uni.hideLoading();
  307. }
  308. });
  309. }
  310. });
  311. }
  312. // 签约检测
  313. const contractTesting = async (qdOrderNo, jumpPage, isInit = false) => {
  314. const data = {
  315. qdOrderNo
  316. };
  317. return await request('fdfbdddba6ec49f8b451cf2e299b4feb', {
  318. data
  319. }).then((res) => {
  320. if (res.statusCode === 0) {
  321. const data = JSON.parse(res.bizContent);
  322. if (
  323. data.signStatus === 1 &&
  324. data.accountStatus === 1 &&
  325. data.bindStatus === 1
  326. ) {
  327. // 上面三值都为1才进行下一步,否则进行签约初始化
  328. uni.navigateTo({
  329. url: '/' + jumpPage + `?qdOrderNo=${qdOrderNo}`,
  330. animationType: 'pop-in',
  331. animationDuration: 500
  332. });
  333. return true;
  334. /* 自定义返回 */
  335. } else {
  336. // 进行签约初始化
  337. // 提醒未通过
  338. if (!isInit) {
  339. uni.showModal({
  340. title: '提示',
  341. content: '请使用微信扫描二维码进行签约',
  342. success: function (res) {}
  343. });
  344. }
  345. }
  346. // qdOrderStore.orderInfo.value.orderId = JSON.parse(res.bizContent).orderId
  347. // 通过检测
  348. }
  349. });
  350. };
  351. // async function contractTesting(qdOrderNo, jumpPage, isInit = false) {
  352. // const data = {
  353. // qdOrderNo
  354. // };
  355. // // uni.navigateTo({
  356. // // url: '/' + jumpPage,
  357. // // animationType: 'pop-in',
  358. // // animationDuration: 500
  359. // // })
  360. // // signingInitialization(qdOrderNo)
  361. // // return
  362. // uni.showModal({
  363. // title: '提示',
  364. // content: '请使用微信扫描二维码进行签约',
  365. // success: (res) =>{
  366. // console.log(res);
  367. // },
  368. // fail:(err)=>{
  369. // console.log(err);
  370. // }
  371. // });
  372. // return request('fdfbdddba6ec49f8b451cf2e299b4feb', {
  373. // data
  374. // }).then((res) => {
  375. // if (res.statusCode === 0) {
  376. // const data = JSON.parse(res.bizContent);
  377. // if (
  378. // data.signStatus === 1 &&
  379. // data.accountStatus === 1 &&
  380. // data.bindStatus === 1
  381. // ) {
  382. // // 上面三值都为1才进行下一步,否则进行签约初始化
  383. // uni.navigateTo({
  384. // url: '/' + jumpPage + `?qdOrderNo=${qdOrderNo}`,
  385. // animationType: 'pop-in',
  386. // animationDuration: 500
  387. // });
  388. // return true;
  389. // /* 自定义返回 */
  390. // } else {
  391. // // 进行签约初始化
  392. // // 提醒未通过
  393. // console.log('isInit', isInit);
  394. // if (!isInit) {
  395. // console.log('isInit', isInit, uni.showModal);
  396. // uni.showModal({
  397. // title: '提示',
  398. // content: '请使用微信扫描二维码进行签约',
  399. // success: function (res) {}
  400. // });
  401. // }
  402. // }
  403. // // qdOrderStore.orderInfo.value.orderId = JSON.parse(res.bizContent).orderId
  404. // // 通过检测
  405. // }
  406. // });
  407. // }
  408. </script>
  409. <!-- 签约管理 -->
  410. <style lang="scss" scoped>
  411. .order-car {
  412. margin: 30rpx 30rpx 0;
  413. width: calc(100% - 60rpx);
  414. height: 190rpx;
  415. border-radius: 20rpx;
  416. background-image: linear-gradient(to right, #15e5c3, #44a2df);
  417. display: flex;
  418. justify-content: space-between;
  419. box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
  420. align-items: center;
  421. color: #fff;
  422. .l-img {
  423. flex-shrink: 0;
  424. width: 120rpx;
  425. height: 120rpx;
  426. .icon-tip {
  427. height: 100%;
  428. width: 100%;
  429. object-fit: contain;
  430. }
  431. }
  432. .c-amount {
  433. flex: 1;
  434. padding: 20rpx 0;
  435. height: 100%;
  436. box-sizing: border-box;
  437. .goods-name {
  438. margin-bottom: 15rpx;
  439. font-size: 38rpx;
  440. }
  441. .goods-des {
  442. font-size: 26rpx;
  443. margin-bottom: 15rpx;
  444. color: #eff;
  445. }
  446. .goods-label {
  447. display: flex;
  448. align-items: center;
  449. .label-item {
  450. margin-right: 10rpx;
  451. }
  452. }
  453. }
  454. .r-btn {
  455. margin-left: 10rpx;
  456. flex-shrink: 0;
  457. width: 130rpx;
  458. margin-right: 20rpx;
  459. .custom-style {
  460. height: 70rpx;
  461. color: #fff;
  462. border-color: #fff;
  463. background-color: rgba(255, 255, 255, 0.2);
  464. }
  465. }
  466. }
  467. .title {
  468. font-size: 36rpx;
  469. text-align: center;
  470. font-weight: bold;
  471. padding: 20rpx 0;
  472. }
  473. .slot-content {
  474. display: flex;
  475. flex-direction: column;
  476. justify-content: center;
  477. align-items: center;
  478. position: absolute;
  479. top: 40%;
  480. left: 50%;
  481. transform: translate(-50%, -50%);
  482. .con-img {
  483. width: 550rpx;
  484. height: 550rpx;
  485. padding: 100rpx;
  486. box-sizing: border-box;
  487. }
  488. .con-info {
  489. text-align: center;
  490. font-size: 26rpx;
  491. margin-bottom: 100rpx;
  492. }
  493. }
  494. .bottom-btn {
  495. position: absolute;
  496. padding: 20rpx;
  497. display: flex;
  498. align-items: center;
  499. bottom: 100rpx;
  500. width: 750rpx;
  501. .btn {
  502. height: 80rpx;
  503. opacity: 1;
  504. border-radius: 100rpx;
  505. margin: 20rpx 20rpx 20rpx 20rpx;
  506. width: 100%;
  507. }
  508. .btn-txt {
  509. background: #1aac1b;
  510. margin: 10px;
  511. color: #ffffff;
  512. font-size: 28rpx;
  513. }
  514. }
  515. </style>