You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template></template>
  2. <script setup lang="ts">
  3. import { unifyTemplate } from '@/hooks/unifyTemplate';
  4. import { onLoad } from '@dcloudio/uni-app';
  5. import { request, requestNew } from '@/utils/network/request';
  6. import { setItem, setToken, StorageKeys } from '@/utils/storage';
  7. const {
  8. initData, //初始化数据
  9. qdOrderVal //qdOrder中数据 ref
  10. } = unifyTemplate(); //初始化数据
  11. //获取页面配置
  12. onLoad((opin) => {
  13. initData(opin, 3).then(async (data) => {
  14. await login(data);
  15. if (parseInt(data.order.isValueCard) === 1) {
  16. // 1-储值,2-记账
  17. handleGoods(data.order.orderNo, data.config.jumpPage);
  18. } else {
  19. contractTesting(data.order.orderNo, data.config.jumpPage);
  20. }
  21. });
  22. });
  23. // 推送
  24. function handleGoods(orderNo, jumpPage) {
  25. uni.navigateTo({
  26. url: '/' + jumpPage,
  27. animationType: 'pop-in',
  28. animationDuration: 500
  29. });
  30. }
  31. // 签约检测
  32. function contractTesting(orderId, jumpPage) {
  33. const data = {
  34. orderNo: orderId
  35. };
  36. console.log(data, '签约检测');
  37. requestNew('/iaw/h5/order/web/signcheck', {
  38. data
  39. }).then((res) => {
  40. if (res.code === 0) {
  41. const data = res.data;
  42. console.log(data, '签约状态');
  43. if (
  44. data.signStatus === 1 &&
  45. data.accountStatus === 1 &&
  46. data.bindStatus === 1
  47. ) {
  48. // 上面三值都为1才进行下一步,否则进行签约初始化
  49. if (!jumpPage) return;
  50. uni.navigateTo({
  51. url: '/' + jumpPage,
  52. animationType: 'pop-in',
  53. animationDuration: 500
  54. });
  55. /* 自定义返回 */
  56. } else {
  57. // 进行签约初始化
  58. signingInitialization(orderId);
  59. }
  60. // qdOrderStore.orderInfo.value.orderId = JSON.parse(res.bizContent).orderId
  61. // 通过检测
  62. }
  63. });
  64. }
  65. // 签约初始化
  66. function signingInitialization(qdOrderNo) {
  67. const data = {
  68. qdOrderNo
  69. };
  70. requestNew('/iaw/h5/order/web/signinit', {
  71. data
  72. }).then((res) => {
  73. if (res.code === 0) {
  74. const data = res.data;
  75. console.log(data);
  76. if (data.returnType === 0) {
  77. // 0-无需跳转,关闭H5即可 1-需跳转至返回url
  78. // const opened = window.open('about:blank', '_self');
  79. // opened.opener = null;
  80. // opened.close();
  81. closeWin();
  82. } else {
  83. // uni.navigateTo({
  84. // url: `/pages/sigManage/signContract?qdOrderNo=${qdOrderNo}&jumpPage=${data.returnUrl}`,
  85. // animationType: 'pop-in',
  86. // animationDuration: 500
  87. // })
  88. console.log(data,'签约初始化跳转');
  89. const local = window.location.protocol + '//' + window.location.host + location.pathname
  90. data.signUrl = data.signUrl.replace('https://qtzl.etcjz.cn/h5/', local)
  91. data.signUrl = data.signUrl.replace('https://qtzl.etcjz.cn/order/', local)
  92. window.open(data.signUrl, '_self');
  93. // window.open('https://qtzl.etcjz.cn/prohtmlproduct/#/pages/sigManage/signContract', '_self');
  94. // window.open('http://localhost:3000/#/pages/sigManage/signContract', '_self');
  95. }
  96. }
  97. });
  98. }
  99. import wx from 'weixin-js-sdk';
  100. // 关闭当前页面方法
  101. function closeWin() {
  102. // @ts-ignore
  103. wx.miniProgram.getEnv(function (res) {
  104. if (res.miniprogram) {
  105. // @ts-ignore
  106. wx.miniProgram.navigateTo({
  107. url: '/page/index/index'
  108. });
  109. } else {
  110. const opened = window.open('about:blank', '_self');
  111. opened.opener = null;
  112. opened.close();
  113. }
  114. });
  115. }
  116. // 无感登录,如果没有登录调用登录
  117. async function login(orderData) {
  118. let data = {
  119. userType: '',
  120. accountNumber: '',
  121. loginSource: '431bfdc8b9c645e0b293b85d6ce1948n',
  122. }
  123. if (orderData.order.userType === "PERSONAL_USER") {
  124. // 个人办理
  125. data.userType = 'PERSONAL'
  126. data.accountNumber = orderData.order.customerTel
  127. } else {
  128. // 单位办理
  129. data.userType = 'ENTERPRISE'
  130. data.accountNumber = orderData.order.customerIdnum
  131. }
  132. console.log('login请求参数', data);
  133. await requestNew('/iaw/portal/loginByNoPassword', {
  134. data,
  135. }).then((res) => {
  136. if (res.code === 0) {
  137. let data = res.data
  138. // 保存token
  139. setToken(data.accessToken)
  140. setItem(StorageKeys.OpenId, data.openId)
  141. console.log(data, '登录获取的数据')
  142. return data.openId;
  143. }
  144. // contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
  145. })
  146. }
  147. </script>
  148. <!-- 签约管理 -->
  149. <style lang="scss" scoped>
  150. .sig-manage {
  151. height: 100vh;
  152. width: 100%;
  153. display: flex;
  154. justify-content: center;
  155. align-items: center;
  156. }
  157. .container {
  158. height: 100%;
  159. width: 100%;
  160. display: flex;
  161. flex-direction: column;
  162. }
  163. :deep(.u-checkbox__label) {
  164. margin: 0;
  165. margin-right: 5rpx;
  166. }
  167. .check-content {
  168. flex: 1 1 auto;
  169. position: relative;
  170. .posi {
  171. position: absolute;
  172. padding: 20rpx;
  173. bottom: 30rpx;
  174. left: 0;
  175. width: 100%;
  176. }
  177. }
  178. .content {
  179. display: inline;
  180. word-wrap: break-word;
  181. }
  182. .item-line {
  183. color: $u-type-primary;
  184. cursor: pointer;
  185. }
  186. .btn {
  187. height: 80rpx;
  188. opacity: 1;
  189. border-radius: 100rpx;
  190. margin: 20rpx;
  191. }
  192. .btn-text {
  193. color: #ffffff;
  194. font-size: 28rpx;
  195. }
  196. .nav-bg {
  197. /* background: linear-gradient(to right, #13E7C1, #43A1E0); */
  198. border: 1px solid #ffffff;
  199. background: #1aac1b;
  200. }
  201. .btn-buttom {
  202. flex: 0 0 auto;
  203. }
  204. .slot-content {
  205. height: 82vh;
  206. overflow-y: auto;
  207. }
  208. </style>