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

cardloss.vue 5.2KB

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