code.vue 8.3 KB

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