code.vue 7.6 KB

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