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

get-code.vue 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 { checkCode } from "@/utils/network/api.js";
  27. import { request } from "@/utils/network/request.js";
  28. import { stringToJson } from "@/utils/network/encryption";
  29. import { useUserStore } from "@/stores/user";
  30. import { getItem } from "@/utils/storage";
  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. if (option.q) {
  43. const q = decodeURIComponent(option.q); // 获取到二维码原始链接内容
  44. console.log(q);
  45. // var json = getRequest(q);
  46. state.json = getRequest(q)
  47. console.log("state.json", state.json, getItem("mobile"))
  48. if (getItem("mobile") == state.json.phone) {
  49. state.mobile = state.json.phone
  50. } else {
  51. msg("号码错误");
  52. return;
  53. }
  54. console.log("state.json", state.json);
  55. }
  56. });
  57. onUnload(() => {
  58. });
  59. const toNext = () => {
  60. if (!state.mobile) {
  61. msg("请输入手机号!");
  62. return;
  63. }
  64. if (state.loginType === "code" && !state.code) {
  65. msg("请输入验证码!");
  66. return;
  67. }
  68. if (!checkStr(state.mobile, "mobile")) {
  69. msg("请输入正确的手机号!");
  70. return;
  71. }
  72. const options = {
  73. type: 2,
  74. data: {
  75. mobile: state.mobile,
  76. code: state.code
  77. },
  78. method: "POST",
  79. showLoading: true,
  80. };
  81. request(checkCode, options).then((res) => {
  82. console.log("过来了", res)
  83. if (state.json.type == 1) {
  84. uni.navigateTo({
  85. url: `/subpackage/orders/order_payment?orderId=${state.json.orderId}`,
  86. });
  87. } else if (state.json.type == 2) {
  88. uni.navigateTo({
  89. url: `/subpackage/orders/product-detail?orderId=${state.json.orderId}&url=${state.json.url}&typeScanCode=${state.json.type}`,
  90. });
  91. }
  92. })
  93. .catch((err) => {
  94. // msg("验证码错误");
  95. });
  96. };
  97. //解析URL获取参数
  98. const getRequest = (urlStr) => {
  99. if (typeof urlStr == "undefined") {
  100. // 获取url中"?"符后的字符串
  101. var url = decodeURI(location.search);
  102. } else {
  103. var url = "?" + urlStr.split("?")[1];
  104. }
  105. var theRequest = new Object();
  106. if (url.indexOf("?") != -1) {
  107. var str = url.substr(1);
  108. var strs = str.split("&");
  109. for (var i = 0; i < strs.length; i++) {
  110. theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
  111. }
  112. }
  113. return theRequest;
  114. };
  115. </script>
  116. <style lang="scss" scoped>
  117. .login-main {
  118. border-top: 1rpx solid #dcdcdc;
  119. padding: 22rpx 30rpx 140rpx;
  120. .title {
  121. font-size: 46rpx;
  122. color: #333333;
  123. margin-top: 30rpx;
  124. font-weight: 600;
  125. }
  126. .form {
  127. width: 100%;
  128. margin-top: 100rpx;
  129. .form-input {
  130. display: flex;
  131. flex-direction: row;
  132. align-items: center;
  133. height: 90rpx;
  134. border-bottom: 1rpx solid #dcdcdc;
  135. padding: 0rpx 12rpx;
  136. color: #333333;
  137. &:last-child {
  138. margin-top: 50rpx;
  139. }
  140. .input {
  141. flex: 1;
  142. padding-right: 48rpx;
  143. font-size: 28rpx;
  144. font-family: Microsoft YaHei;
  145. background-color: transparent;
  146. }
  147. .arror {
  148. width: 28rpx;
  149. height: 25rpx;
  150. margin-left: 16rpx;
  151. margin-right: 40rpx;
  152. }
  153. .eye {
  154. width: 48rpx;
  155. height: 48rpx;
  156. }
  157. }
  158. .form-placeholder {
  159. color: #999999;
  160. }
  161. }
  162. .btn {
  163. width: 100%;
  164. margin: 120rpx 40rpx 50rpx;
  165. }
  166. }
  167. </style>