bindemail.vue 5.9 KB

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