code.vue 8.3 KB

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