code.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view class="top">
  3. <view class="back-btn cuIcon-back" @click="navBack"></view>
  4. <!-- 文字 -->
  5. <view class="top_one">请输入验证码</view>
  6. <view class="top_two">验证码已发送到<text class="text">{{phone}}</text></view>
  7. <!-- 六个显示框 -->
  8. <view class="top_three">
  9. <view :class="[ !inputList[0]||inputList.length>0 ? 'inb' : '' ]" class="input">
  10. <text>{{inputList[0]}}</text>
  11. <view v-if="!inputList[0]" class="fours"></view>
  12. </view>
  13. <view :class="[ inputList[0] && !inputList[1]||inputList.length>1 ? 'inb' : '' ]" class="input">
  14. <text>{{inputList[1]}}</text>
  15. <view v-if="inputList[0] && !inputList[1]" class="fours"></view>
  16. </view>
  17. <view :class="[ inputList[1] && !inputList[2]||inputList.length>2 ? 'inb' : '' ]" class="input">
  18. <text>{{inputList[2]}}</text>
  19. <view v-if="inputList[1] && !inputList[2]" class="fours"></view>
  20. </view>
  21. <view :class="[ inputList[2] && !inputList[3]||inputList.length>3 ? 'inb' : '' ]" class="input">
  22. <text>{{inputList[3]}}</text>
  23. <view v-if="inputList[2] && !inputList[3]" class="fours"></view>
  24. </view>
  25. <view :class="[ inputList[3] && !inputList[4]||inputList.length>4 ? 'inb' : '' ]" class="input">
  26. <text>{{inputList[4]}}</text>
  27. <view v-if="inputList[3] && !inputList[4]" class="fours"></view>
  28. </view>
  29. <view :class="[ inputList[4] && !inputList[5]||inputList.length>5 ? 'inb' : '' ]" class="input">
  30. <text>{{inputList[5]}}</text>
  31. <view v-if="inputList[4] && !inputList[5]" class="fours"></view>
  32. </view>
  33. </view>
  34. <!-- 隐藏的input -->
  35. <view class="top_four">
  36. <input type="number" class="input_show" maxlength="6" @input='submit' v-model="inputList" focus="true" />
  37. </view>
  38. <!-- 重新获取 -->
  39. <view class="top_five" @click='regain' :class="!status ? 'active' : '' "><text v-if="!status">重新发送</text><text
  40. v-if="status">{{count_down}}秒后重新发送</text></view>
  41. </view>
  42. </template>
  43. <script>
  44. import helper from '@/common/helper.js';
  45. export default {
  46. data() {
  47. return {
  48. // 电话
  49. phone: '',
  50. // 跟隐藏input绑定的数组
  51. inputList: [],
  52. //计时器
  53. count_down: 60,
  54. status: false
  55. }
  56. },
  57. onLoad(options) {
  58. console.log("options", options.phone)
  59. this.phone = options.phone
  60. console.log("phone:", this.phone);
  61. if (this.phone) {
  62. this.regain()
  63. } else {
  64. uni.showToast({
  65. title: '请输入正确的手机号',
  66. icon: 'none',
  67. duration: 2000
  68. })
  69. }
  70. },
  71. methods: {
  72. navBack() {
  73. uni.navigateBack();
  74. },
  75. regain() {
  76. console.log("regain", this.phone);
  77. this.status = true
  78. // console.log(e)150500
  79. // 设定一个定时器 1000是1秒的意思
  80. var interval = setInterval(() => {
  81. --this.count_down
  82. }, 1000)
  83. if (this.count_down == 0) {
  84. this.status = false
  85. }
  86. // 设定一个定时器 60000就是六十秒
  87. setTimeout(() => {
  88. this.status = false
  89. clearInterval(interval) //括号里面的名字要与setInterval定义的相同
  90. }, 60000)
  91. this.$request.baseRequest('get', '/commonUser/sendVerifyCode', {
  92. phone: this.phone
  93. }).then(res => {
  94. // 获得数据
  95. if (res.code != 200) {
  96. uni.showToast({
  97. title: res.message,
  98. icon: 'none',
  99. duration: 2000
  100. })
  101. }
  102. console.log(res);
  103. })
  104. .catch(res => {
  105. uni.showToast({
  106. title: res.errMsg,
  107. icon: 'none',
  108. duration: 2000
  109. })
  110. });
  111. },
  112. submit(e) {
  113. if (e.detail.value.length == 6) {
  114. var that = this
  115. uni.showLoading({
  116. title: '登录中',
  117. mask: true
  118. })
  119. that.$request.baseRequest('get', '/commonUser/loginVerifyCode', {
  120. phone: this.phone,
  121. verifyCode: this.inputList,
  122. loginFlag: 2,
  123. identification:1
  124. }).then(res => {
  125. if (res.code == 200) {
  126. uni.setStorageSync('userInfo', res.data)
  127. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  128. reCommonId: res.data.id,
  129. }).then(res3 => {
  130. if (res3.data) {
  131. let name = 'myTip';
  132. let value = res3.data
  133. if (value == 0) {
  134. uni.removeTabBarBadge({
  135. index: 2
  136. })
  137. }
  138. that.$store.commit('$uStore', {
  139. name,
  140. value
  141. });
  142. if (value != 0 && value) {
  143. uni.setTabBarBadge({
  144. index: 2,
  145. text: value + ""
  146. })
  147. }
  148. }
  149. })
  150. that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  151. driverPhone: this.phone,
  152. }).then(res2 => {
  153. if (res.data.statusFlag == '已禁用') {
  154. this.isShowAlert = true
  155. uni.hideLoading()
  156. return
  157. }
  158. uni.setStorageSync('pcuserInfo', res.data)
  159. uni.setStorageSync('userInfo', res.data)
  160. uni.setStorageSync('firstAuthentication', res2.data)
  161. helper.getListByUserId()
  162. that.$store.commit('login', res.data)
  163. var name = 'userInfo';
  164. var value = res.data;
  165. that.$store.commit('$uStore', {
  166. name,
  167. value
  168. });
  169. uni.switchTab({
  170. url: '/pages/goodSource/index'
  171. });
  172. uni.hideLoading()
  173. // that.liangxinLogin()
  174. uni.switchTab({
  175. url: '/pages/goodSource/index'
  176. });
  177. uni.hideLoading()
  178. })
  179. } else {
  180. uni.hideLoading()
  181. uni.showToast({
  182. title: res.message,
  183. icon: 'none',
  184. duration: 2000
  185. })
  186. }
  187. })
  188. .catch(res => {
  189. uni.showToast({
  190. title: res.message,
  191. icon: 'none',
  192. duration: 2000
  193. })
  194. });
  195. }
  196. }
  197. }
  198. }
  199. </script>1
  200. <style>
  201. .top {
  202. padding-top: 85px;
  203. position: relative;
  204. width: 100vw;
  205. height: calc(100vh - 85px);
  206. overflow: hidden;
  207. background: url('~@/static/images/mine/bg@2x.png');
  208. background-size: 100%;
  209. }
  210. .back-btn {
  211. position: absolute;
  212. left: 40upx;
  213. z-index: 9999;
  214. padding-top: var(--status-bar-height);
  215. top: 40upx;
  216. font-size: 40upx;
  217. color: $font-color-dark;
  218. }
  219. /* 文字 */
  220. .top_one {
  221. /* margin-top: 85px; */
  222. width: 90%;
  223. height: 90rpx;
  224. line-height: 90rpx;
  225. font-size: 44rpx;
  226. margin: auto;
  227. font-weight: bold;
  228. }
  229. .top_two {
  230. width: 90%;
  231. height: 40rpx;
  232. line-height: 40rpx;
  233. font-size: 24rpx;
  234. margin: auto;
  235. color: #545454;
  236. }
  237. .text {
  238. font-weight: bold;
  239. }
  240. /* 六个显示框容器 */
  241. .top_three {
  242. width: 80%;
  243. height: 200rpx;
  244. margin: auto;
  245. display: flex;
  246. align-items: center;
  247. justify-content: center;
  248. }
  249. /* 六个框显示框 */
  250. .input {
  251. width: 14%;
  252. height: 80rpx;
  253. background-color: #F5F5F5;
  254. margin-right: 12rpx;
  255. text-align: center;
  256. line-height: 80rpx;
  257. font-size: 50rpx;
  258. border-radius: 3px;
  259. color: #181818;
  260. }
  261. /* 模拟的焦点 */
  262. .inb {
  263. background: #FFFFFF;
  264. box-shadow: 0px 9px 10px 4px rgba(0, 0, 0, 0.07);
  265. }
  266. .fours {
  267. width: 5rpx;
  268. height: 40rpx;
  269. margin: auto;
  270. background-color: #000000;
  271. margin-top: 20rpx;
  272. animation: show .8s linear infinite;
  273. }
  274. /* 模拟焦点动画 更改animation以更改动画样式*/
  275. @keyframes show {
  276. from {
  277. background-color: #000000;
  278. }
  279. to {
  280. background-color: #ffffff;
  281. }
  282. }
  283. /* 隐藏的inpit容器 */
  284. .top_four {
  285. width: 80%;
  286. height: 100rpx;
  287. margin: auto;
  288. margin-top: -140rpx;
  289. }
  290. .input_show {
  291. width: 100%;
  292. height: 100rpx;
  293. border-bottom: 2rpx solid #000000;
  294. margin: auto;
  295. opacity: 0;
  296. background-color: #c6c6c6;
  297. }
  298. /* 重新获取 */
  299. .top_five {
  300. width: 100%;
  301. height: 60rpx;
  302. margin-top: 180rpx;
  303. text-align: center;
  304. line-height: 60rpx;
  305. color: #959595;
  306. }
  307. /* 定时器结束的字体样式 */
  308. .active {
  309. color: #22C572;
  310. }
  311. .button {
  312. width: 80%;
  313. height: 100rpx;
  314. line-height: 100rpx;
  315. background-color: #5473E8;
  316. border-radius: 60rpx;
  317. }
  318. </style>