您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

get-code.vue 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <!-- 密码登录 -->
  2. <template>
  3. <view class="login-main as-gravity-center as-layout-vertical" >
  4. <view class="form">
  5. <view class="form-input">
  6. <view> +86</view>
  7. <image :src="`${$imgUrl}common/arror_down_black.png`" class="arror" mode="aspectFill" />
  8. <input class="input" v-model="state.mobile" focus placeholder="请输入手机号"
  9. placeholder-class="form-placeholder" type="number" maxlength="11" disabled />
  10. </view>
  11. <view class="form-input" v-if="state.loginType === 'code'">
  12. <input class="input" v-model="state.code" placeholder="请输入验证码" placeholder-class="form-placeholder"
  13. maxlength="6" type="number" />
  14. <verification-code :bg="false" :mobile="state.mobile"></verification-code>
  15. </view>
  16. </view>
  17. <view class="btn">
  18. <submit-button title="下一步" @submit="toNext"></submit-button>
  19. </view>
  20. </view>
  21. </template>
  22. <script setup lang="ts">
  23. import { reactive } from "vue";
  24. import { checkStr, msg, navTo } from "@/utils/utils";
  25. import { onLoad, onUnload } from "@dcloudio/uni-app";
  26. import { messageValid } from "@/utils/network/api.js";
  27. import { requestNew } from "@/utils/network/request.js";
  28. import { useUserStore } from "@/stores/user";
  29. import { getItem, setItem } from "@/utils/storage";
  30. import { jump } from "@/datas/9901Jump.js";
  31. const userStore = useUserStore();
  32. const { fetchToken } = userStore;
  33. const state = reactive({
  34. loginType: "code", //pwd-密码登录 code-验证码登录
  35. mobile: "", //用户名
  36. password: "", //密码
  37. code: "", //验证码
  38. json: {}
  39. });
  40. onLoad((option) => {
  41. // https://qtzl.etcjz.cn/default-bucket/20231204/scanPay.html?orderId=20231016180507480853307&phone=18786896573&type=1
  42. // https://qtzl.etcjz.cn/default-bucket/20231204/protocol.html?orderId=20231012114651162505354&phone=18786896573&type=2&url=default-bucket/20231024/fcae5e580ecc4cacaaa75138_ETC用户协议20230805(法审终版).docx
  43. console.log("option", option)
  44. if (option.q) {
  45. const q = decodeURIComponent(option.q); // 获取到二维码原始链接内容
  46. console.log(q);
  47. state.json = getRequest(q)
  48. console.log("state.json==",state.json)
  49. if(state.json['wechatSignNo']){
  50. console.log("wechatSignNo",state.json)
  51. // app跳往异地得签约
  52. jump(16, state.json['wechatSignNo'])
  53. }else{
  54. console.log("state.json", state.json, getItem("mobile"), getItem("mobile") == state.json.phone)
  55. setItem('scanCode', state.json)
  56. if (!getItem("openId")) {
  57. uni.showModal({
  58. title: '提示',
  59. content: '您还未登录小程序,请先登录小程序',
  60. showCancel: false,
  61. success: function (res) {
  62. if (res.confirm) {
  63. navTo(`/login/login?back=1`)
  64. }
  65. }
  66. });
  67. }
  68. // 直接用传过来的手机号(不让他修改)
  69. state.mobile = state.json.phone
  70. }
  71. } else {
  72. state.json = getItem("scanCode")
  73. state.mobile = state.json.phone
  74. }
  75. });
  76. onUnload(() => {
  77. });
  78. const toNext = () => {
  79. if (!state.mobile) {
  80. msg("请输入手机号!");
  81. return;
  82. }
  83. if (state.loginType === "code" && !state.code) {
  84. msg("请输入验证码!");
  85. return;
  86. }
  87. if (!checkStr(state.mobile, "mobile")) {
  88. msg("请输入正确的手机号!");
  89. return;
  90. }
  91. const options = {
  92. type: 2,
  93. data: {
  94. mobile: state.mobile,
  95. code: state.code
  96. },
  97. method: "POST",
  98. showLoading: true,
  99. };
  100. requestNew(messageValid, options).then((res) => {
  101. console.log("过来了", res)
  102. // type 1扫码支付 2扫描协议确认 3售后卡签注销支付 4售后更换设备支付
  103. if (state.json.type == 1) {
  104. uni.navigateTo({
  105. url: `/subpackage/orders/order_payment?orderId=${state.json.orderId}&isValueCard=${state.json.isValueCard}&vehicleId=${state.json.vehicleId}`,
  106. });
  107. } else if (state.json.type == 2) {
  108. uni.navigateTo({
  109. url: `/subpackage/orders/product-detail?orderId=${state.json.orderId}&url=${state.json.url}&typeScanCode=${state.json.type}`,
  110. });
  111. } else if (state.json.type == 3 || state.json.type == 4) {
  112. uni.navigateTo({
  113. url: `/subpackage/after-sale/replace-equipment/order-payment?orderId=${state.json.orderId}&orderType=${state.json.orderType}`,
  114. });
  115. }
  116. })
  117. .catch((err) => {
  118. // msg("验证码错误");
  119. });
  120. };
  121. //解析URL获取参数
  122. const getRequest = (urlStr) => {
  123. if (typeof urlStr == "undefined") {
  124. // 获取url中"?"符后的字符串
  125. var url = decodeURI(location.search);
  126. } else {
  127. var url = "?" + urlStr.split("?")[1];
  128. }
  129. var theRequest = new Object();
  130. if (url.indexOf("?") != -1) {
  131. var str = url.substr(1);
  132. var strs = str.split("&");
  133. for (var i = 0; i < strs.length; i++) {
  134. theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
  135. }
  136. }
  137. return theRequest;
  138. };
  139. </script>
  140. <style lang="scss" scoped>
  141. .login-main {
  142. border-top: 1rpx solid #dcdcdc;
  143. padding: 22rpx 30rpx 140rpx;
  144. .title {
  145. font-size: 46rpx;
  146. color: #333333;
  147. margin-top: 30rpx;
  148. font-weight: 600;
  149. }
  150. .form {
  151. width: 100%;
  152. margin-top: 100rpx;
  153. .form-input {
  154. display: flex;
  155. flex-direction: row;
  156. align-items: center;
  157. height: 90rpx;
  158. border-bottom: 1rpx solid #dcdcdc;
  159. padding: 0rpx 12rpx;
  160. color: #333333;
  161. &:last-child {
  162. margin-top: 50rpx;
  163. }
  164. .input {
  165. flex: 1;
  166. padding-right: 48rpx;
  167. font-size: 28rpx;
  168. font-family: Microsoft YaHei;
  169. background-color: transparent;
  170. }
  171. .arror {
  172. width: 28rpx;
  173. height: 25rpx;
  174. margin-left: 16rpx;
  175. margin-right: 40rpx;
  176. }
  177. .eye {
  178. width: 48rpx;
  179. height: 48rpx;
  180. }
  181. }
  182. .form-placeholder {
  183. color: #999999;
  184. }
  185. }
  186. .btn {
  187. width: 100%;
  188. margin: 120rpx 40rpx 50rpx;
  189. }
  190. }
  191. </style>