選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

cardloss.vue 5.0KB

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