code.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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 v-if="status">{{count_down}}秒后重新发送</text></view>
  40. </view>
  41. </template>
  42. <script>
  43. import helper from '@/common/helper.js';
  44. export default {
  45. data() {
  46. return {
  47. // 电话
  48. phone:'',
  49. // 跟隐藏input绑定的数组
  50. inputList:[],
  51. //计时器
  52. count_down:60,
  53. status:false
  54. }
  55. },
  56. onLoad(options){
  57. console.log("options",options.phone)
  58. this.phone=options.phone
  59. console.log("phone:",this.phone);
  60. if(this.phone){
  61. this.regain()
  62. }else{
  63. uni.showToast({
  64. title: '请输入正确的手机号',
  65. icon:'none',
  66. duration: 2000
  67. })
  68. }
  69. },
  70. methods: {
  71. navBack() {
  72. uni.navigateBack();
  73. },
  74. liangxinLogin(){
  75. const that = this
  76. var userInfoTmp = uni.getStorageSync("userInfo")
  77. console.log('userInfoTmp',userInfoTmp)
  78. that.$socket.login(userInfoTmp.phone, "123456", null, res=>{
  79. console.log('粮信登录',res)
  80. if (res.success) {
  81. that.$socket.showLoginDialog = false
  82. // 缓存用户
  83. that.userData = res.response.data
  84. console.log('userData',that.userData)
  85. that.$u.vuex("userData", that.userData);
  86. // 缓存通讯录
  87. that.$socket.listGuests(that.userData.user.operId, res => {
  88. // #ifdef APP-PLUS
  89. createFSQL(that.userData.user.operId).then();
  90. let contact = res.response.data;
  91. contact.forEach(c=>{
  92. c.members.forEach(m=>{
  93. m.name = c.name;
  94. addFSQL(m, that.userData.user.operId).then();
  95. })
  96. })
  97. // #endif
  98. that.$u.vuex('firendItem', res.response.data)
  99. });
  100. // 缓存消息列表
  101. that.$socket.queryOnlineMessage(that.userData.user.operId,q =>{
  102. let data = q.response.data;
  103. for(var i in data){
  104. initData(data[i].groupMsg.list, data[i].groupInfo.chatId);
  105. }
  106. })
  107. // 缓存链接
  108. that.$socket.getLinks(that.userData.user.operId, res=>{
  109. that.$u.vuex('linkItem',res.response.data)
  110. });
  111. // // 跳转到消息列表
  112. // that.$u.route({
  113. // url: 'pages/home/home',
  114. // type: 'switchTab'
  115. // });
  116. } else {
  117. uni.showModal({
  118. title:res.reason + ",请稍后再试",
  119. showCancel:false
  120. })
  121. }
  122. });
  123. },
  124. regain(){
  125. console.log("regain",this.phone);
  126. this.status=true
  127. // console.log(e)150500
  128. // 设定一个定时器 1000是1秒的意思
  129. var interval = setInterval(() =>{
  130. --this.count_down
  131. },1000)
  132. if(this.count_down == 0){
  133. this.status=false
  134. }
  135. // 设定一个定时器 60000就是六十秒
  136. setTimeout(() =>{
  137. this.status=false
  138. clearInterval(interval)//括号里面的名字要与setInterval定义的相同
  139. },60000)
  140. this.$api.doRequest('get','/commonUser/sendVerifyCode',{phone:this.phone}).then(res => {
  141. // 获得数据
  142. if(res.statusCode!=200){
  143. uni.showToast({
  144. title: res.data.message,
  145. icon:'none',
  146. duration: 2000
  147. })
  148. }
  149. console.log(res);
  150. })
  151. .catch(res => {
  152. uni.showToast({
  153. title: res.errMsg,
  154. icon:'none',
  155. duration: 2000
  156. })
  157. });
  158. },
  159. submit(e){
  160. if(e.detail.value.length==6){
  161. var that=this
  162. uni.showLoading({
  163. title: '登录中',
  164. mask:true
  165. })
  166. this.$api.doRequest('get','/commonUser/loginVerifyCode',{phone:this.phone,verifyCode:this.inputList,cid:this.clientId}).then(res => {
  167. if(res.data.code==200){
  168. this.$api.doRequest('post','/commonUser/api/loginQuickly',{mobilePhone: this.phone,
  169. veriCode: "123456",}).then(res1 => {
  170. if(res1.data.code==200){
  171. uni.setStorageSync('pcUserInfo', res1.data.data)
  172. helper.getListByUserId()
  173. }
  174. else{
  175. that.$api.doRequest('post','/commonUser/api/loginQuickly',{mobilePhone: '14444444444',
  176. veriCode: "123456",}).then(res2 => {
  177. uni.setStorageSync('pcUserInfo', res2.data.data)
  178. helper.getListByUserId()
  179. })
  180. }
  181. })
  182. uni.setStorageSync('userInfo', res.data.data)
  183. helper.getListByUserId()
  184. that.$store.commit('login', res.data.data)
  185. // that.liangxinLogin()
  186. uni.switchTab({
  187. url: '/pages/sale/information'
  188. });
  189. uni.hideLoading()
  190. }else{
  191. uni.hideLoading()
  192. uni.showToast({
  193. title: res.data.message,
  194. icon:'none',
  195. duration: 2000
  196. })
  197. }
  198. })
  199. .catch(res => {
  200. uni.showToast({
  201. title: res.data.message,
  202. icon:'none',
  203. duration: 2000
  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: 100vh;
  217. overflow: hidden;
  218. background: url('~@/static/img/login/bg.png');
  219. background-size:100%;}
  220. .back-btn {
  221. position: absolute;
  222. left: 40upx;
  223. z-index: 9999;
  224. padding-top: var(--status-bar-height);
  225. top: 40upx;
  226. font-size: 40upx;
  227. color: $font-color-dark;
  228. }
  229. /* 文字 */
  230. .top_one{width: 90%; height: 90rpx; line-height: 90rpx; font-size: 44rpx; margin: auto; font-weight: bold;}
  231. .top_two{width: 90%; height: 40rpx; line-height: 40rpx; font-size: 24rpx; margin: auto; color: #545454;}
  232. .text{font-weight: bold;}
  233. /* 六个显示框容器 */
  234. .top_three{width: 80%; height: 200rpx; margin: auto;
  235. display: flex; align-items: center; justify-content: center;
  236. }
  237. /* 六个框显示框 */
  238. .input{width: 14%; height: 80rpx; background-color: #F5F5F5; margin-right: 12rpx;
  239. text-align: center; line-height: 80rpx; font-size: 50rpx;
  240. border-radius:3px;
  241. color:#181818;
  242. }
  243. /* 模拟的焦点 */
  244. .inb{
  245. background:#FFFFFF;
  246. box-shadow: 0px 9px 10px 4px rgba(0, 0, 0, 0.07);
  247. }
  248. .fours{width: 5rpx; height: 40rpx; margin: auto; background-color: #000000;
  249. margin-top: 20rpx; animation: show .8s linear infinite;
  250. }
  251. /* 模拟焦点动画 更改animation以更改动画样式*/
  252. @keyframes show{
  253. from{background-color: #000000;}
  254. to{background-color: #ffffff;}
  255. }
  256. /* 隐藏的inpit容器 */
  257. .top_four{width: 80%; height: 100rpx; margin: auto; margin-top: -140rpx;}
  258. .input_show{width: 100%; height: 100rpx; border-bottom: 2rpx solid #000000; margin: auto;
  259. opacity: 0;background-color: #c6c6c6;
  260. }
  261. /* 重新获取 */
  262. .top_five{width: 100%; height: 60rpx; margin-top: 180rpx; text-align: center; line-height: 60rpx;
  263. color: #959595;
  264. }
  265. /* 定时器结束的字体样式 */
  266. .active{color: #22C572;}
  267. .button{width: 80%; height: 100rpx; line-height: 100rpx; background-color: #5473E8; border-radius: 60rpx;
  268. }
  269. </style>