reg.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view class="container">
  3. <image class="bg-image" src="../../../static/loginBg.png"></image>
  4. <view class="up">
  5. <!-- 自定义导航栏 -->
  6. <uni-nav-bar id="nav-bar" status-bar='true' :border='false' backgroundColor="rgba(164, 136, 220, 0)" @clickLeft="showClickEvent()"
  7. :title="title" color="#FFFFFF" fixed="true">
  8. <view slot="left">
  9. <view class=" flex align-center margin-left" @tap="onBack">
  10. <image class="png-more" src="../../../static/m-icon/leftBack.png"></image>
  11. </view>
  12. </view>
  13. <view slot="right">
  14. </view>
  15. </uni-nav-bar>
  16. <!-- 手机端登录 -->
  17. <view class="text-26px text-white" style="margin: 105px 0 0 56rpx;">输入验证码</view>
  18. <view class="text-16px text-white" style="margin: 40px 0 0 56rpx;">已发送4位验证码至 +86 {{phoneNumber}}</view>
  19. <!-- <view class="flex" style="margin: 71px 0 0 46rpx;">
  20. <view class="grid col-4 grid-square flex-sub ">
  21. <view v-for="(item,index) in 4" :key="index">
  22. <input class='iptbox' type="number" disabled :value="Value.length>=index+1?Value[index]:''" :password="false"
  23. @tap="onTap"></input>
  24. </view>
  25. </view>
  26. </view> -->
  27. <view class="code-input-main">
  28. <view class="inputLine">
  29. <input class="input-item" maxlength="1" :value="code[0]"></input>
  30. <input class="input-item" maxlength="1" :value="code[1]"></input>
  31. <input class="input-item" maxlength="1" :value="code[2]"></input>
  32. <input class="input-item" maxlength="1" :value="code[3]"></input>
  33. </view>
  34. <!-- <view class="inputLine">
  35. <input class="input-item" maxlength="1" :value="code[3]"></input>
  36. <input class="input-item" maxlength="1" :value="code[4]"></input>
  37. <input class="input-item" maxlength="1" :value="code[5]"></input>
  38. </view> -->
  39. <input @input="inputEvent" class="code-input-input" v-model="code" maxlength="4" type="number" />
  40. </view>
  41. <view class="btn-row" style="margin-top: 46px;">
  42. <button type="primary" class="primary btn-confirm" :disabled="code.length<4" @tap="onConfirm">确认</button>
  43. </view>
  44. <view v-if="bCodeDisabled" class="action-row">
  45. <view class="action-child text-gray">重新获取({{count}})</view>
  46. <!-- <text style="color: #FFFFFF;">|</text>
  47. <navigator url="../pwd/pwd">忘记密码</navigator> -->
  48. </view>
  49. <view v-else class="action-row">
  50. <view class="action-child" @tap="onGetCode">重新发送验证码</view>
  51. <!-- <text style="color: #FFFFFF;">|</text>
  52. <navigator url="../pwd/pwd">忘记密码</navigator> -->
  53. </view>
  54. <input class='ipt' type="number" :maxlength="Length" :focus="bFocus" @input="onInputFocus" @focus="onFocus"></input>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import service from '../../../util/util-js/service.js';
  60. import mInput from '../../../components/m-input.vue';
  61. import reqUtil from "@/util/util-js/requstUtil.js";
  62. import config from '../../../common/config.js';
  63. import verify from '../../../util/util-js/verify.js';
  64. import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue";
  65. import {
  66. mapState,
  67. mapMutations
  68. } from 'vuex'
  69. export default {
  70. components: {
  71. mInput,
  72. uniNavBar
  73. },
  74. data() {
  75. return {
  76. //输入框参数
  77. Length: 4, //输入框个数
  78. bFocus: false, //聚焦
  79. Value: "", //输入的内容
  80. code: '',
  81. }
  82. },
  83. computed: mapState(['phoneNumber', 'bCodeDisabled', 'count']),
  84. onLoad() {
  85. // console.log("初始化onLoad");
  86. this.onGetCode();
  87. },
  88. methods: {
  89. ...mapMutations(['countDown', 'accountLogin']),
  90. //注册
  91. onConfirm() {
  92. reqUtil.requestData(config.URL.SMSLOGIN, {
  93. "phoneNumber": this.phoneNumber,
  94. "code": this.code
  95. }).then(res => {
  96. console.log('requestData GETCODE =====', res);
  97. if (res.code == 0) {
  98. uni.showToast({
  99. title: "注册成功",
  100. mask: true,
  101. duration: 1000
  102. })
  103. //登录成功
  104. uni.setStorageSync('token', res.data.token);
  105. // this.$store.state.hasLogin = true;
  106. this.accountLogin();
  107. uni.navigateTo({
  108. url: "../../personal-page/personal/personal"
  109. })
  110. } else {
  111. uni.showToast({
  112. title: "验证码错误",
  113. mask: true,
  114. icon: 'none',
  115. duration: 1000
  116. })
  117. }
  118. },
  119. e => {
  120. console.log(e)
  121. });
  122. },
  123. onGetCode() {
  124. //置灰状态
  125. if (this.bCodeDisabled) return;
  126. //调用store 倒计时
  127. this.countDown();
  128. },
  129. onTap() {
  130. this.bFocus = true;
  131. console.log(this.bFocus);
  132. },
  133. onFocus(e) {
  134. console.log(e);
  135. setTimeout(() => {
  136. // this.bFocus = false;
  137. }, 1000)
  138. },
  139. onInputFocus(e) {
  140. console.log(e.detail.value);
  141. this.Value = e.detail.value;
  142. },
  143. onBack() {
  144. uni.navigateBack();
  145. },
  146. inputEvent(res) {
  147. console.log("input 1 input code components : ", res.detail.value);
  148. /* this.$emit('vueMsg',res.detail.value); */
  149. }
  150. }
  151. }
  152. </script>
  153. <style>
  154. .action-row {
  155. margin-top: 25px;
  156. display: flex;
  157. flex-direction: row;
  158. justify-content: center;
  159. }
  160. .action-child {
  161. color: #FFFFFF;
  162. padding: 0 20upx;
  163. }
  164. .iptbox {
  165. width: 102rpx;
  166. height: 102rpx;
  167. border: 1rpx solid #ddd;
  168. border-radius: 8rpx;
  169. display: flex;
  170. justify-content: center;
  171. align-items: center;
  172. text-align: center;
  173. background-color: rgba(255, 255, 255, 0.2);
  174. color: #FFFFFF;
  175. font-size: 20px;
  176. }
  177. .ipt {
  178. width: 0;
  179. height: 0;
  180. }
  181. .btn-confirm {
  182. width: 636rpx;
  183. height: 102rpx;
  184. background-color: rgba(75, 208, 200, 1);
  185. border-radius: 25px;
  186. opacity: 0.84;
  187. }
  188. .container {
  189. position: absolute;
  190. top: 0;
  191. bottom: 0;
  192. left: 0;
  193. right: 0;
  194. background-color: #000000;
  195. }
  196. .bg-image {
  197. position: absolute;
  198. top: 0;
  199. left: 0;
  200. width: 100%;
  201. height: 100%;
  202. opacity: 0.55;
  203. }
  204. .up {
  205. position: absolute;
  206. z-index: 1;
  207. width: 100%;
  208. /* display: flex; */
  209. /* align-items: flex-start; */
  210. /* flex-direction: column; */
  211. }
  212. .png-more {
  213. width: 10px;
  214. height: 19px;
  215. }
  216. .code-input-input {
  217. height: 150px;
  218. position: absolute;
  219. width: 100%;
  220. outline: none;
  221. color: transparent;
  222. text-shadow: 0 0 0 transparent;
  223. width: 300%;
  224. margin-left: -100%;
  225. background: #00000000;
  226. /* border: 1rpx solid #007AFF; */
  227. }
  228. .code-input-main {
  229. display: flex;
  230. flex-direction: column;
  231. width: 100%;
  232. margin-bottom: 46px;
  233. /* border: 1rpx solid #000000; */
  234. height: 150px;
  235. }
  236. .input-item {
  237. width: 102rpx;
  238. height: 102rpx;
  239. font-size: 20px;
  240. background-color: rgba(255, 255, 255, 0.2);
  241. border: 1rpx solid #ddd;
  242. text-align: center;
  243. border-radius: 8px;
  244. margin-left: 40upx;
  245. margin-right: 40upx;
  246. color: #FFFFFF;
  247. }
  248. .inputLine {
  249. display: flex;
  250. justify-content: center;
  251. width: 100%;
  252. margin-top: 80upx;
  253. }
  254. </style>