bindemail.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. this.isEmialDisabled = true;
  94. getEmailCode({email:this.bindEmail,status:1}).then(res =>{
  95. this.$util.msg('验证邮件已发送至邮箱,请登录邮箱查收',2000)
  96. const TIME_COUNT = 60;
  97.       if (!this.codeTime) {
  98.         this.count = TIME_COUNT;
  99. this.isEmialDisabled = true;
  100.         this.codeTime = setInterval(() => {
  101.         if (this.count > 1 && this.count <= TIME_COUNT) {
  102.           this.count--
  103.           this.emailCodeText = this.count +'s重新发送'
  104.          } else {
  105.           this.isEmialDisabled = false;
  106.           clearInterval(this.codeTime)
  107.           this.codeTime = null
  108. this.emailCodeText = '获取验证码'
  109.          }
  110.         },1000)
  111.        }
  112. }).catch( res =>{
  113. this.$util.msg(res.msg,2000);
  114. this.isEmialDisabled = false;
  115. })
  116. }
  117. },
  118. onShow() {
  119. this.$api.getStorage().then((resolve) => {
  120. this.userID = resolve.userID
  121. })
  122. }
  123. }
  124. </script>
  125. <style lang="scss">
  126. .login{
  127. width: 100%;
  128. height: auto;
  129. border-top: 1px solid #F7F7F7;
  130. .model-warp.none{
  131. display: none;
  132. }
  133. .model-warp.show{
  134. display: block;
  135. }
  136. .login-main{
  137. width: 702rpx;
  138. background: rgba(225, 86, 22, 0.1);
  139. display: flex;
  140. flex-direction: column;
  141. align-items: center;
  142. height: 68rpx;
  143. padding: 20rpx 24rpx;
  144. margin: 24rpx 0 118rpx 0;
  145. .logo-text{
  146. font-size: 24rpx;
  147. line-height: 34rpx;
  148. color: $color-system;
  149. }
  150. }
  151. .login-form{
  152. width: 702rpx;
  153. height: auto;
  154. padding: 0 24rpx;
  155. &.btns{
  156. display: flex;
  157. margin-top: 80rpx;
  158. .login-btn{
  159. flex:1;
  160. width: 303rpx;
  161. height: 88rpx;
  162. margin: 0 24rpx;
  163. border-radius: 14rpx;
  164. font-size: $font-size-28;
  165. line-height: 88rpx;
  166. color: #FFFFFF;
  167. text-align: center;
  168. background: $btn-confirm;
  169. &.none{
  170. background: #999999;
  171. color: #FFFFFF;
  172. }
  173. }
  174. }
  175. .login-input{
  176. width: 654rpx;
  177. height: 40rpx;
  178. padding: 24rpx;
  179. margin-bottom: 20rpx;
  180. background: #F7F7F7;
  181. border-radius: 14rpx;
  182. display: flex;
  183. flex-direction: column;
  184. align-items: center;
  185. &.code{
  186. width: 377rpx;
  187. float: left;
  188. margin-right: 20rpx;
  189. }
  190. &.btn{
  191. width: 258rpx;
  192. height: 88rpx;
  193. padding: 0;
  194. float: left;
  195. background: $btn-confirm;
  196. .input{
  197. width: 258rpx;
  198. height: 88rpx;
  199. line-height: 88rpx;
  200. padding: 0;
  201. border-radius: 14rpx;
  202. color: #FFFFFF;
  203. background: $btn-confirm;
  204. }
  205. &.disabled{
  206. background: #F7F7F7;
  207. .input{
  208. background: #F7F7F7;
  209. color: #999999;
  210. }
  211. }
  212. }
  213. .input{
  214. width: 100%;
  215. height: 100%;
  216. background: #F7F7F7;
  217. font-size: $font-size-28;
  218. line-height: 40rpx;
  219. color: #333333;
  220. border-radius: 14rpx;
  221. }
  222. }
  223. }
  224. }
  225. </style>