code.vue 8.1 KB

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