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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <view class="oderPage">
  3. <u-form :model="form" ref="myForm">
  4. <view class="from">
  5. <u-form-item prop="phone">
  6. <view class="from_item" style="background-color: #f7f7f7">
  7. <text><text style="color: red"></text>手机号:</text>
  8. <u-input v-model="form.mobile" :disabled="true" class="input" />
  9. </view>
  10. </u-form-item>
  11. <u-form-item prop="code">
  12. <view class="from_item">
  13. <text><text style="color: red"></text>验证码:</text>
  14. <u-input v-model="form.code" placeholder="请输入验证码" class="input" type="number" />
  15. <view class="hint2">
  16. <view class="green">{{ codeDuration === 0 ? "" : codeDuration }}</view>
  17. <view class="grey" @click="getCode">{{
  18. codeDuration === 0 ? "发送验证码" : "秒后可重发"
  19. }}</view>
  20. </view>
  21. </view>
  22. </u-form-item>
  23. </view>
  24. </u-form>
  25. <button class="submit" @click="toPage()">下一步</button>
  26. </view>
  27. </template>
  28. <script setup lang="ts">
  29. import {
  30. ref,
  31. reactive
  32. } from "vue";
  33. import {
  34. onLoad
  35. } from "@dcloudio/uni-app";
  36. import {
  37. request
  38. } from "@/utils/network/request.js";
  39. import {
  40. sendCode,
  41. checkCode,
  42. } from "@/utils/network/api.js";
  43. import {
  44. msg
  45. } from "@/utils/utils";
  46. // 表单数据
  47. const form = reactive({
  48. mobile: "",
  49. code: '',
  50. type: undefined,
  51. successTip: ""
  52. });
  53. //倒计时时常
  54. const codeDuration = ref(0);
  55. let interval = null;
  56. /* 验证码倒计时 */
  57. const codeInterval = () => {
  58. codeDuration.value = 60;
  59. interval = setInterval(() => {
  60. codeDuration.value--;
  61. if (codeDuration.value === 0) {
  62. if (interval) {
  63. clearInterval(interval);
  64. interval = null;
  65. }
  66. }
  67. }, 1000);
  68. };
  69. onLoad((options) => {
  70. console.log("optionsssss", options)
  71. form.type = options.type
  72. form.mobile = options.mobile
  73. form.successTip = options.successTip
  74. uni.setNavigationBarTitle({
  75. title: options.successTip
  76. });
  77. });
  78. const getCode = () => {
  79. if (codeDuration.value !== 0) {
  80. return;
  81. }
  82. const options = {
  83. type: 2,
  84. data: {
  85. mobile: form.mobile
  86. },
  87. method: "POST",
  88. showLoading: true,
  89. };
  90. request(sendCode, options)
  91. .then((res) => {
  92. codeInterval();
  93. msg("验证码发送成功!");
  94. })
  95. .catch((err) => {
  96. console.log(err);
  97. });
  98. }
  99. //下一步
  100. const toPage = () => {
  101. if (!form.code) {
  102. msg("请输入正确的验证码");
  103. return;
  104. }
  105. const options = {
  106. type: 2,
  107. data: {
  108. mobile: form.mobile,
  109. code: form.code
  110. },
  111. method: "POST",
  112. showLoading: true,
  113. };
  114. request(checkCode, options)
  115. .then((res) => {
  116. uni.$emit('queryCardlossStatus', {
  117. type: form.type,
  118. successTip: form.successTip
  119. })
  120. uni.navigateBack()
  121. })
  122. .catch((err) => {
  123. console.log(err);
  124. });
  125. };
  126. </script>
  127. <style>
  128. page {
  129. width: 100%;
  130. height: 100%;
  131. display: flex;
  132. flex-direction: column;
  133. background-color: ##eef7f7;
  134. }
  135. </style>
  136. <style lang="scss" scoped>
  137. .hint2 {
  138. display: flex;
  139. .green {
  140. font-size: 28rpx;
  141. color: #00b38b;
  142. }
  143. .grey {
  144. font-size: 24rpx;
  145. color: #000000;
  146. margin-left: 16rpx;
  147. }
  148. }
  149. .oderPage {
  150. flex: 1;
  151. width: 100%;
  152. .from1 {
  153. background-color: #fff;
  154. margin-top: 30rpx;
  155. padding: 0 30rpx;
  156. ::v-deep .uni-forms-item {
  157. border-bottom: 1rpx solid #ccc;
  158. padding: 15rpx 0;
  159. margin-bottom: 0;
  160. .uni-forms-item__label {
  161. font-size: 28rpx;
  162. height: 50rpx;
  163. }
  164. .uni-forms-item__content {
  165. display: flex;
  166. }
  167. .uni-easyinput__content-input {
  168. font-size: 28rpx;
  169. height: 50rpx;
  170. }
  171. }
  172. .btn {
  173. line-height: 38rpx;
  174. font-size: 24rpx;
  175. font-family: Microsoft YaHei;
  176. font-weight: 400;
  177. color: #ffffff;
  178. background: #00b38b;
  179. border-radius: 10rpx;
  180. padding: 10rpx 15rpx;
  181. }
  182. }
  183. .from {
  184. background-color: #fff;
  185. margin-top: 30rpx;
  186. padding: 0 30rpx;
  187. ::v-deep .u-form-item {
  188. padding: 0;
  189. line-height: normal;
  190. .u-form-item__message {
  191. margin-bottom: 12rpx;
  192. }
  193. }
  194. .from_item {
  195. display: flex;
  196. flex-wrap: nowrap;
  197. justify-content: space-between;
  198. align-items: center;
  199. height: 80rpx;
  200. border-bottom: 1rpx solid #dcdcdc;
  201. .btn {
  202. font-size: 24rpx;
  203. font-family: Microsoft YaHei;
  204. font-weight: 400;
  205. color: #ffffff;
  206. background: #00b38b;
  207. border-radius: 10rpx;
  208. padding: 10rpx 15rpx;
  209. }
  210. ::v-deep .input {
  211. text-align: left;
  212. flex: 1;
  213. background: transparent;
  214. input {
  215. text-align: left;
  216. }
  217. }
  218. }
  219. .from_item1 {
  220. display: flex;
  221. flex-wrap: nowrap;
  222. flex-direction: column;
  223. justify-content: space-between;
  224. padding: 30rpx;
  225. border-bottom: #dcdcdc 1px solid;
  226. input {
  227. text-align: right;
  228. }
  229. .textarea {
  230. background-color: #f1f1f1;
  231. width: 100%;
  232. border-radius: 20rpx;
  233. margin-top: 10rpx;
  234. text-indent: 1rem;
  235. height: 180rpx;
  236. padding: 20rpx;
  237. box-sizing: border-box;
  238. }
  239. }
  240. }
  241. }
  242. .submit {
  243. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  244. width: 670rpx;
  245. height: 80rpx;
  246. color: #fff;
  247. border-radius: 100rpx;
  248. position: fixed;
  249. left: 50%;
  250. transform: translate(-50%);
  251. bottom: 100rpx;
  252. font-size: 32rpx;
  253. }
  254. </style>