verification.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <uv-button
  3. round
  4. size="mini"
  5. block
  6. type="primary"
  7. @click="startCountdown"
  8. >
  9. {{ buttonText }}
  10. </uv-button>
  11. </template>
  12. <script setup>
  13. import {
  14. ref,
  15. computed,
  16. onUnmounted
  17. } from 'vue'
  18. import {
  19. sendSmsCode
  20. } from '@/api/auth'
  21. const props = defineProps(['mobile', 'scene'])
  22. const countingDown = ref(false); // 是否正在倒计时
  23. const countdownSeconds = ref(60); // 倒计时的总秒数
  24. const timer = ref(null); // 倒计时的总秒数
  25. const buttonText = computed(() => {
  26. return countingDown.value ? `${countdownSeconds.value} 秒` : '发送验证码';
  27. });
  28. const startCountdown = () => {
  29. if (!countingDown.value) {
  30. countingDown.value = true;
  31. handleSendSmsCode()
  32. }
  33. };
  34. const handleSendSmsCode = () => {
  35. uni.showLoading({
  36. title: '发送验证码中'
  37. });
  38. console.log("gxs --> % handleSendSmsCode % props.mobile:\n", props.mobile)
  39. sendSmsCode({
  40. "mobile": props.mobile,
  41. "scene": props.scene
  42. }).then(res => {
  43. uni.hideLoading();
  44. uni.showToast({
  45. icon: 'none',
  46. title: '验证码已发送',
  47. duration: 2000
  48. });
  49. timer.value = setInterval(() => {
  50. countdownSeconds.value--;
  51. console.log("gxs --> % timer % countdownSeconds.value:\n", countdownSeconds.value)
  52. if (countdownSeconds.value <= 0) {
  53. clearInterval(timer.value);
  54. countdownSeconds.value = 60; // 倒计时结束后重置为初始值
  55. countingDown.value = false;
  56. }
  57. }, 1000);
  58. }).catch(error => {
  59. countingDown.value = false;
  60. })
  61. }
  62. onUnmounted(() => {
  63. clearInterval(timer.value);
  64. })
  65. </script>
  66. <style lang="less">
  67. .goods {
  68. position: relative;
  69. padding: 30rpx 0;
  70. &-card {
  71. display: flex;
  72. flex-direction: column;
  73. .goods {
  74. &-content {
  75. padding: 0 20rpx;
  76. display: flex;
  77. flex-direction: column;
  78. }
  79. &-info {
  80. margin-top: 15rpx;
  81. }
  82. &-thumb {
  83. margin-bottom: 15rpx;
  84. width: 100%;
  85. height: 203rpx;
  86. &-img {
  87. width: 100%;
  88. height: 100%;
  89. display: block;
  90. }
  91. }
  92. }
  93. }
  94. &-header {}
  95. &-thumb {
  96. background: #FAFAFA;
  97. }
  98. &-content {}
  99. &-storeName {
  100. line-height: 40rpx;
  101. font-size: 28rpx;
  102. font-weight: 500;
  103. color: #333333;
  104. }
  105. &-price {
  106. &-row {
  107. display: flex;
  108. align-items: center;
  109. .goods-price {}
  110. }
  111. &-primary {
  112. line-height: 42rpx;
  113. font-size: 30rpx;
  114. font-weight: 500;
  115. color: #EE6D46;
  116. }
  117. &-default {
  118. line-height: 40rpx;
  119. font-size: 28rpx;
  120. font-weight: 500;
  121. color: #333333;
  122. }
  123. &-original {
  124. margin-left: 9rpx;
  125. line-height: 28rpx;
  126. font-size: 20rpx;
  127. color: #999999;
  128. text-decoration: line-through;
  129. }
  130. }
  131. &-desc {
  132. line-height: 33rpx;
  133. font-size: 24rpx;
  134. color: #999999;
  135. }
  136. &-info {
  137. display: flex;
  138. align-items: flex-end;
  139. justify-content: space-between;
  140. &-left {}
  141. &-action {
  142. &-btn {}
  143. &-desc {
  144. line-height: 28rpx;
  145. font-size: 20rpx;
  146. color: #999999;
  147. }
  148. }
  149. }
  150. &-image {
  151. &-img {}
  152. }
  153. &-list {
  154. display: flex;
  155. flex-direction: row;
  156. padding: 14rpx;
  157. box-sizing: border-box;
  158. width: 100%;
  159. .goods {
  160. &-thumb {
  161. margin-bottom: 0;
  162. width: 220rpx;
  163. height: 220rpx;
  164. &-img {
  165. width: 100%;
  166. height: 100%;
  167. display: block;
  168. }
  169. }
  170. &-content {
  171. padding-right: 40rpx;
  172. margin-left: 30rpx;
  173. flex: 1;
  174. display: flex;
  175. flex-direction: column;
  176. justify-content: space-between;
  177. }
  178. }
  179. &-model {
  180. display: flex;
  181. margin-bottom: 28rpx;
  182. &-border {
  183. display: flex;
  184. align-items: center;
  185. height: 40rpx;
  186. border: 1px solid #CCCCCC;
  187. opacity: 1;
  188. border-radius: 0rpx;
  189. padding: 0 10rpx;
  190. }
  191. &-info {}
  192. &-label {
  193. line-height: 38rpx;
  194. font-size: 24rpx;
  195. color: #999999;
  196. margin-right: 10rpx;
  197. }
  198. &-value {
  199. line-height: 38rpx;
  200. font-size: 24rpx;
  201. color: #333333;
  202. margin-right: 10rpx;
  203. }
  204. &-action {
  205. width: 11rpx;
  206. height: 7rpx;
  207. }
  208. }
  209. }
  210. &-min {
  211. .goods {
  212. &-thumb {
  213. margin-bottom: 0;
  214. width: 150rpx;
  215. height: 150rpx;
  216. &-img {
  217. width: 100%;
  218. height: 100%;
  219. display: block;
  220. }
  221. }
  222. }
  223. }
  224. // .goods {
  225. // padding: 16rpx 14rpx;
  226. // &-header {
  227. // display: flex;
  228. // align-items: flex-start;
  229. // }
  230. // &-thumb {
  231. // width: 220rpx;
  232. // height: 220rpx;
  233. // &-img {
  234. // width: 100%;
  235. // height: 100%;
  236. // display: block;
  237. // }
  238. // }
  239. // &-content {
  240. // margin-top: 24rpx;
  241. // margin-left: 40rpx;
  242. // flex: 1
  243. // }
  244. // &-storeName {
  245. // line-height: 40rpx;
  246. // font-size: 28rpx;
  247. // font-weight: 500;
  248. // color: #333333;
  249. // margin-bottom: 35rpx;
  250. // }
  251. // &-info {
  252. // display: flex;
  253. // align-items: center;
  254. // justify-content: space-between;
  255. // &-left {
  256. // display: flex;
  257. // align-items: flex-end;
  258. // }
  259. // &-action {
  260. // &-btn {}
  261. // &-desc {
  262. // color: #999999;
  263. // font-size: 24rpx;
  264. // line-height: 40rpx;
  265. // }
  266. // }
  267. // }
  268. // &-price {
  269. // &-default {
  270. // line-height: 28rpx;
  271. // font-size: 20rpx;
  272. // color: #999999;
  273. // }
  274. // &-primary {
  275. // line-height: 42rpx;
  276. // font-size: 30rpx;
  277. // font-weight: 500;
  278. // color: #EE6D46;
  279. // margin-left: 5rpx;
  280. // }
  281. // }
  282. // &-desc {
  283. // color: #999999;
  284. // font-size: 24rpx;
  285. // line-height: 40rpx;
  286. // }
  287. &-model {
  288. display: inline-flex;
  289. align-items: center;
  290. width: auto;
  291. height: 40rpx;
  292. border: 1px solid #CCCCCC;
  293. opacity: 1;
  294. border-radius: 0rpx;
  295. padding: 0 10rpx;
  296. margin-bottom: 28rpx;
  297. &-label {
  298. line-height: 38rpx;
  299. font-size: 24rpx;
  300. color: #999999;
  301. }
  302. &-value {
  303. line-height: 38rpx;
  304. font-size: 24rpx;
  305. color: #333333;
  306. margin-right: 10rpx;
  307. }
  308. &-action {
  309. width: 11rpx;
  310. height: 7rpx;
  311. }
  312. }
  313. // &-model-info {
  314. // display: inline-flex;
  315. // align-items: center;
  316. // width: auto;
  317. // height: 40rpx;
  318. // opacity: 1;
  319. // border-radius: 0rpx;
  320. // margin-bottom: 28rpx;
  321. // &-label {
  322. // line-height: 38rpx;
  323. // font-size: 24rpx;
  324. // color: #999999;
  325. // }
  326. // &-value {
  327. // line-height: 38rpx;
  328. // font-size: 24rpx;
  329. // color: #333333;
  330. // margin-right: 10rpx;
  331. // }
  332. // &-action {
  333. // width: 11rpx;
  334. // height: 7rpx;
  335. // }
  336. // }
  337. // }
  338. }
  339. .buy-progress {
  340. display: flex;
  341. align-items: center;
  342. justify-content: space-between;
  343. &-info {
  344. flex: 1;
  345. &-desc {
  346. color: #999999;
  347. font-size: 24rpx;
  348. line-height: 32rpx;
  349. }
  350. }
  351. &-action {
  352. margin-left: 17rpx;
  353. }
  354. }
  355. .buy-num {
  356. &-info-desc {
  357. color: #999999;
  358. font-size: 24rpx;
  359. line-height: 32rpx;
  360. }
  361. }
  362. </style>