bindemail.vue 5.3 KB

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