code.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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. that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  116. driverPhone: this.phone,
  117. }).then(res2 => {
  118. if (res.data.authenticationStatus == '已禁用') {
  119. that.$refs.uToast.show({
  120. type: 'error',
  121. message: "账号审核中!"
  122. })
  123. return
  124. }
  125. uni.showLoading({
  126. title: '登录中',
  127. mask: true
  128. })
  129. that.$request.baseRequest('get', '/commonUser/loginVerifyCode', {
  130. phone: this.phone,
  131. verifyCode: this.inputList,
  132. loginFlag: 2,
  133. identification:1
  134. }).then(res => {
  135. if (res.code == 200) {
  136. uni.setStorageSync('userInfo', res.data)
  137. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  138. reCommonId: res.data.id,
  139. }).then(res3 => {
  140. if (res3.data) {
  141. let name = 'myTip';
  142. let value = res3.data
  143. if (value == 0) {
  144. uni.removeTabBarBadge({
  145. index: 2
  146. })
  147. }
  148. that.$store.commit('$uStore', {
  149. name,
  150. value
  151. });
  152. if (value != 0 && value) {
  153. uni.setTabBarBadge({
  154. index: 2,
  155. text: value + ""
  156. })
  157. }
  158. }
  159. })
  160. uni.setStorageSync("shiro",encodeURIComponent(`ws_login_companyShortName=
  161. '黑龙江中天昊元贸易有限公司'; ws_login_rememberMe=1; ws_login_account=${that.phone}; ws_login_pwd=${that.password}; shiro.session=65500189-7bb5-457f-9ff6-0db069150e78`))
  162. uni.setStorageSync('pcuserInfo', res.data)
  163. uni.setStorageSync('userInfo', res.data)
  164. uni.setStorageSync('firstAuthentication', res2.data)
  165. helper.getListByUserId()
  166. that.$store.commit('login', res.data)
  167. var name = 'userInfo';
  168. var value = res.data;
  169. that.$store.commit('$uStore', {
  170. name,
  171. value
  172. });
  173. uni.switchTab({
  174. url: '/pages/goodSource/index'
  175. });
  176. uni.hideLoading()
  177. // that.liangxinLogin()
  178. uni.switchTab({
  179. url: '/pages/goodSource/index'
  180. });
  181. uni.hideLoading()
  182. } else {
  183. uni.hideLoading()
  184. uni.showToast({
  185. title: res.message,
  186. icon: 'none',
  187. duration: 2000
  188. })
  189. }
  190. })
  191. .catch(res => {
  192. uni.showToast({
  193. title: res.message,
  194. icon: 'none',
  195. duration: 2000
  196. })
  197. });
  198. })
  199. }
  200. }
  201. }
  202. }
  203. </script>1
  204. <style>
  205. .top {
  206. padding-top: 85px;
  207. position: relative;
  208. width: 100vw;
  209. height: calc(100vh - 85px);
  210. overflow: hidden;
  211. background: url('~@/static/images/mine/bg@2x.png');
  212. background-size: 100%;
  213. }
  214. .back-btn {
  215. position: absolute;
  216. left: 40upx;
  217. z-index: 9999;
  218. padding-top: var(--status-bar-height);
  219. top: 40upx;
  220. font-size: 40upx;
  221. color: $font-color-dark;
  222. }
  223. /* 文字 */
  224. .top_one {
  225. /* margin-top: 85px; */
  226. width: 90%;
  227. height: 90rpx;
  228. line-height: 90rpx;
  229. font-size: 44rpx;
  230. margin: auto;
  231. font-weight: bold;
  232. }
  233. .top_two {
  234. width: 90%;
  235. height: 40rpx;
  236. line-height: 40rpx;
  237. font-size: 24rpx;
  238. margin: auto;
  239. color: #545454;
  240. }
  241. .text {
  242. font-weight: bold;
  243. }
  244. /* 六个显示框容器 */
  245. .top_three {
  246. width: 80%;
  247. height: 200rpx;
  248. margin: auto;
  249. display: flex;
  250. align-items: center;
  251. justify-content: center;
  252. }
  253. /* 六个框显示框 */
  254. .input {
  255. width: 14%;
  256. height: 80rpx;
  257. background-color: #F5F5F5;
  258. margin-right: 12rpx;
  259. text-align: center;
  260. line-height: 80rpx;
  261. font-size: 50rpx;
  262. border-radius: 3px;
  263. color: #181818;
  264. }
  265. /* 模拟的焦点 */
  266. .inb {
  267. background: #FFFFFF;
  268. box-shadow: 0px 9px 10px 4px rgba(0, 0, 0, 0.07);
  269. }
  270. .fours {
  271. width: 5rpx;
  272. height: 40rpx;
  273. margin: auto;
  274. background-color: #000000;
  275. margin-top: 20rpx;
  276. animation: show .8s linear infinite;
  277. }
  278. /* 模拟焦点动画 更改animation以更改动画样式*/
  279. @keyframes show {
  280. from {
  281. background-color: #000000;
  282. }
  283. to {
  284. background-color: #ffffff;
  285. }
  286. }
  287. /* 隐藏的inpit容器 */
  288. .top_four {
  289. width: 80%;
  290. height: 100rpx;
  291. margin: auto;
  292. margin-top: -140rpx;
  293. }
  294. .input_show {
  295. width: 100%;
  296. height: 100rpx;
  297. border-bottom: 2rpx solid #000000;
  298. margin: auto;
  299. opacity: 0;
  300. background-color: #c6c6c6;
  301. }
  302. /* 重新获取 */
  303. .top_five {
  304. width: 100%;
  305. height: 60rpx;
  306. margin-top: 180rpx;
  307. text-align: center;
  308. line-height: 60rpx;
  309. color: #959595;
  310. }
  311. /* 定时器结束的字体样式 */
  312. .active {
  313. color: #22C572;
  314. }
  315. .button {
  316. width: 80%;
  317. height: 100rpx;
  318. line-height: 100rpx;
  319. background-color: #5473E8;
  320. border-radius: 60rpx;
  321. }
  322. </style>