bindemail.vue 5.4 KB

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