bindemail.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. option:'', //储存上一级页面的option
  52. loginType:'', //跳转类型
  53. alertText:'',
  54. listType: '',
  55. listVal: '',
  56. detilType:'',
  57. id:''//商品ID
  58. }
  59. },
  60. onLoad(option) {
  61. console.log(option)
  62. this.codeType = option.codeType
  63. this.option = option
  64. this.loginType = option.type;
  65. this.id = option.id
  66. if(option.listType) {
  67. this.listType = option.listType;
  68. this.listVal = option.listVal;
  69. }
  70. },
  71. methods:{
  72. ...mapMutations(['login']),
  73. bindEmailFrist(){
  74. let params = {
  75. userID:this.userID,
  76. email:this.bindEmail,
  77. code:this.bindEmailCode
  78. }
  79. bindingEmail(params).then(res =>{
  80. this.$util.msg(res.msg,2000)
  81. if(this.codeType == '4'){
  82. this.$api.navigateTo(`/pages/user-module/bindwechat?data=${this.option}`)
  83. }else{
  84. this.goUserLogininit()
  85. }
  86. })
  87. },
  88. bindEmailNone(){
  89. this.$api.switchTabTo('/pages/tabBar/user/user')
  90. },
  91. getEmailCodeFn(){
  92. getEmailCode({email:this.bindEmail,status:1}).then(res =>{
  93. this.$util.msg('验证邮件已发送至邮箱,请登录邮箱查收',2000)
  94. const TIME_COUNT = 60;
  95.       if (!this.codeTime) {
  96.         this.count = TIME_COUNT;
  97.         this.isEmialDisabled = true;
  98.         this.codeTime = setInterval(() => {
  99.         if (this.count > 1 && this.count <= TIME_COUNT) {
  100.           this.count--
  101.           this.emailCodeText = this.count +'s重新发送'
  102.          } else {
  103.           this.isEmialDisabled = false;
  104.           clearInterval(this.codeTime)
  105.           this.codeTime = null
  106. this.emailCodeText = '获取验证码'
  107.          }
  108.         },1000)
  109.        }
  110. }).catch( res =>{
  111. this.$util.msg(res.msg,2000);
  112. })
  113. },
  114. goUserLogininit(){
  115. let url;
  116. if(this.loginType) {
  117. if(this.loginType=='detilType'){
  118. this.$api.redirectTo(`/pages/goods/product?id=${this.id}&page=2`);
  119. }else if(this.loginType=='search'){
  120. this.$api.redirectTo('/pages/search/search');
  121. }else if(this.loginType == 1){
  122. url ='/pages/tabBar/cart/cart'
  123. }else if(this.loginType == 2){
  124. url ='/pages/tabBar/user/user'
  125. }else {
  126. url ='/pages/tabBar/home/home'
  127. }
  128. uni.switchTab({
  129. url
  130. })
  131. } else if(this.listType) {
  132. this.$api.navToListPage({type:this.listType,value:this.listVal,lType:'4'});
  133. }
  134. },
  135. },
  136. onShow() {
  137. this.$api.getStorage().then((resolve) => {
  138. console.log(resolve)
  139. this.userID = resolve.userID
  140. })
  141. }
  142. }
  143. </script>
  144. <style lang="scss">
  145. .login{
  146. width: 100%;
  147. height: auto;
  148. border-top: 1px solid #F7F7F7;
  149. .model-warp.none{
  150. display: none;
  151. }
  152. .model-warp.show{
  153. display: block;
  154. }
  155. .login-main{
  156. width: 702rpx;
  157. background: rgba(225, 86, 22, 0.1);
  158. display: flex;
  159. flex-direction: column;
  160. align-items: center;
  161. height: 68rpx;
  162. padding: 20rpx 24rpx;
  163. margin: 24rpx 0 118rpx 0;
  164. .logo-text{
  165. font-size: 24rpx;
  166. line-height: 34rpx;
  167. color: $color-system;
  168. }
  169. }
  170. .login-form{
  171. width: 702rpx;
  172. height: auto;
  173. padding: 0 24rpx;
  174. &.btns{
  175. display: flex;
  176. margin-top: 80rpx;
  177. .login-btn{
  178. flex:1;
  179. width: 303rpx;
  180. height: 88rpx;
  181. margin: 0 24rpx;
  182. border-radius: 14rpx;
  183. font-size: $font-size-28;
  184. line-height: 88rpx;
  185. color: #FFFFFF;
  186. text-align: center;
  187. background: $btn-confirm;
  188. &.none{
  189. background: #999999;
  190. color: #FFFFFF;
  191. }
  192. }
  193. }
  194. .login-input{
  195. width: 654rpx;
  196. height: 40rpx;
  197. padding: 24rpx;
  198. margin-bottom: 20rpx;
  199. background: #F7F7F7;
  200. border-radius: 14rpx;
  201. display: flex;
  202. flex-direction: column;
  203. align-items: center;
  204. &.code{
  205. width: 380rpx;
  206. float: left;
  207. margin-right: 20rpx;
  208. }
  209. &.btn{
  210. width: 210rpx;
  211. float: left;
  212. background: $btn-confirm;
  213. .input{
  214. background: $btn-confirm;
  215. color: #FFFFFF;
  216. }
  217. &.disabled{
  218. background: #F7F7F7;
  219. .input{
  220. background: #F7F7F7;
  221. color: #999999;
  222. }
  223. }
  224. }
  225. .input{
  226. width: 100%;
  227. height: 100%;
  228. background: #F7F7F7;
  229. font-size: $font-size-28;
  230. line-height: 40rpx;
  231. color: #333333;
  232. border-radius: 14rpx;
  233. }
  234. }
  235. }
  236. }
  237. </style>