bindemail.vue 5.9 KB

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