bindemail.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="container login">
  3. <view class="login-main">
  4. <text class="logo-text">您的账号尚未绑定机构邮箱,请填写机构邮箱地址进行绑定。邮箱可用于登录和修改密码。</text>
  5. </view>
  6. <view class="login-form clearfix">
  7. <view class="login-input">
  8. <input type="text"
  9. v-model="bindEmail"
  10. maxlength="30"
  11. class="input"
  12. placeholder="请输入邮箱地址"
  13. />
  14. </view>
  15. </view>
  16. <view class="login-form clearfix">
  17. <view class="login-input code">
  18. <input type="number"
  19. v-model="bindEmailCode"
  20. maxlength="4"
  21. class="input"
  22. placeholder="请输入邮箱验证码"
  23. />
  24. </view>
  25. <view class="login-input btn" :class="[isEmialDisabled ? 'disabled' : '']">
  26. <button type="button"
  27. @click.stop="getEmailCodeFn"
  28. :disabled="isEmialDisabled"
  29. class="input" >
  30. {{ emailCodeText }}
  31. </button>
  32. </view>
  33. </view>
  34. <view class="login-form btns clearfix">
  35. <view class="login-btn none" @click="bindEmailNone">暂不绑定</view>
  36. <view class="login-btn" @click="bindEmailFrist">绑定</view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import authorize from '@/common/config/authorize.js'
  42. import { bindingEmail } from '@/api/use.js'
  43. import { getEmailCode } from "@/api/utils.js"
  44. export default{
  45. data() {
  46. return{
  47. userID:'', //用户ID
  48. bindEmail:'', //用户绑定邮箱
  49. bindEmailCode:'', //用户绑定邮箱验证码
  50. isEmialDisabled:false, //获取验证码按钮
  51. count: '', //倒计时
  52. emailCodeText: '获取验证码',
  53. codeTime: null,
  54. codeType:'', //用户状态 为4状态的跳绑定微信
  55. getOption:'', //储存上一级页面的option
  56. loginType:'', //跳转类型
  57. loginPath:'', //从哪个页面跳的
  58. alertText:'',
  59. id:''//商品ID
  60. }
  61. },
  62. onLoad(option) {
  63. if(option.data){
  64. let data = JSON.parse(option.data);
  65. this.getOption = data
  66. this.loginType = data.type;
  67. }
  68. this.loginPath = option.pathType
  69. this.codeType = option.codeType
  70. console.log(this.loginPath)
  71. },
  72. methods:{
  73. bindEmailFrist(){
  74. let params = {
  75. userID:this.userID,
  76. email:this.bindEmail,
  77. code:this.bindEmailCode
  78. }
  79. bindingEmail(params).then(res =>{
  80. if(this.loginPath == 1){
  81. uni.switchTab({
  82. url:'/pages/tabBar/user/user'
  83. })
  84. }else{
  85. this.$api.navigateTo(`/pages/user-module/bindwechat?data=${JSON.stringify(this.getOption)}&type=${this.loginType}`)
  86. }
  87. })
  88. },
  89. bindEmailNone(){
  90. this.$api.navigateTo(`/pages/user-module/bindwechat?data=${JSON.stringify(this.getOption)}&type=${this.loginType}`)
  91. },
  92. getEmailCodeFn(){
  93. if( this.bindEmail == ''){
  94. this.$util.msg('请输入邮箱地址',2000);
  95. return
  96. }
  97. if(!this.$reg.isEmail(this.bindEmail)){
  98. this.$util.msg('请输入正确的邮箱地址',2000);
  99. return
  100. }
  101. this.isEmialDisabled = true;
  102. getEmailCode({email:this.bindEmail,status:1}).then(res =>{
  103. this.$util.msg('验证邮件已发送至邮箱,请登录邮箱查收',2000)
  104. const TIME_COUNT = 60;
  105.       if (!this.codeTime) {
  106.         this.count = TIME_COUNT;
  107. this.isEmialDisabled = true;
  108.         this.codeTime = setInterval(() => {
  109.         if (this.count > 1 && this.count <= TIME_COUNT) {
  110.           this.count--
  111.           this.emailCodeText = this.count +'s重新发送'
  112.          } else {
  113.           this.isEmialDisabled = false;
  114.           clearInterval(this.codeTime)
  115.           this.codeTime = null
  116. this.emailCodeText = '获取验证码'
  117.          }
  118.         },1000)
  119.        }
  120. }).catch( res =>{
  121. this.$util.msg(res.msg,2000);
  122. this.isEmialDisabled = false;
  123. })
  124. }
  125. },
  126. onShow() {
  127. this.$api.getStorage().then((resolve) => {
  128. this.userID = resolve.userID
  129. })
  130. }
  131. }
  132. </script>
  133. <style lang="scss">
  134. .login{
  135. width: 100%;
  136. height: auto;
  137. border-top: 1px solid #F7F7F7;
  138. .model-warp.none{
  139. display: none;
  140. }
  141. .model-warp.show{
  142. display: block;
  143. }
  144. .login-main{
  145. width: 702rpx;
  146. background: rgba(225, 86, 22, 0.1);
  147. display: flex;
  148. flex-direction: column;
  149. align-items: center;
  150. height: 68rpx;
  151. padding: 20rpx 24rpx;
  152. margin: 24rpx 0 118rpx 0;
  153. .logo-text{
  154. font-size: 24rpx;
  155. line-height: 34rpx;
  156. color: $color-system;
  157. }
  158. }
  159. .login-form{
  160. width: 702rpx;
  161. height: auto;
  162. padding: 0 24rpx;
  163. &.btns{
  164. display: flex;
  165. margin-top: 80rpx;
  166. .login-btn{
  167. flex:1;
  168. width: 303rpx;
  169. height: 88rpx;
  170. margin: 0 24rpx;
  171. border-radius: 14rpx;
  172. font-size: $font-size-28;
  173. line-height: 88rpx;
  174. color: #FFFFFF;
  175. text-align: center;
  176. background: $btn-confirm;
  177. &.none{
  178. background: #999999;
  179. color: #FFFFFF;
  180. }
  181. }
  182. }
  183. .login-input{
  184. width: 654rpx;
  185. height: 40rpx;
  186. padding: 24rpx;
  187. margin-bottom: 20rpx;
  188. background: #F7F7F7;
  189. border-radius: 14rpx;
  190. display: flex;
  191. flex-direction: column;
  192. align-items: center;
  193. &.code{
  194. width: 377rpx;
  195. float: left;
  196. margin-right: 20rpx;
  197. }
  198. &.btn{
  199. width: 258rpx;
  200. height: 88rpx;
  201. padding: 0;
  202. float: left;
  203. background: $btn-confirm;
  204. .input{
  205. width: 258rpx;
  206. height: 88rpx;
  207. line-height: 88rpx;
  208. padding: 0;
  209. border-radius: 14rpx;
  210. color: #FFFFFF;
  211. background: $btn-confirm;
  212. }
  213. &.disabled{
  214. background: #F7F7F7;
  215. .input{
  216. background: #F7F7F7;
  217. color: #999999;
  218. }
  219. }
  220. }
  221. .input{
  222. width: 100%;
  223. height: 100%;
  224. background: #F7F7F7;
  225. font-size: $font-size-28;
  226. line-height: 40rpx;
  227. color: #333333;
  228. border-radius: 14rpx;
  229. }
  230. }
  231. }
  232. }
  233. </style>