Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

cardloss.vue 5.2KB

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