bindEmail.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <!-- 绑定电子邮箱页面 -->
  2. <template>
  3. <view class="container flex_column_start_center">
  4. <view class="input-content flex_column_start_center">
  5. <view class="input-item pwd_wrap">
  6. <input type="text" :value="email" :placeholder="$L('请输入邮箱')" maxlength="50" data-key="email" placeholder-class='placeholder_class'
  7. @input="inputChange" @confirm="confirm" />
  8. <view class="pwd-right" @click="clearContent('email')">
  9. <text class="clear-pwd iconfont iconziyuan51" v-show="email" ></text>
  10. </view>
  11. </view>
  12. <view class="input-item pwd_wrap">
  13. <input type="number" :value="smsCode" maxlength="4" :placeholder="$L('请输入邮箱验证码')" data-key="smsCode" @input="inputChange"
  14. placeholder-class='placeholder_class' />
  15. <view class="pwd-right">
  16. <text class="clear-pwd iconfont iconziyuan51" v-if="smsCode" @click.prevent="clearContent('smsCode')"></text>
  17. <view :style="{opacity: countDownM?0.3:1}" class="sms-code-view" @click="getSmsCode">
  18. <text class="sms-code">{{countDownM?`${countDownM}s后重新获取`:'获取验证码'}}</text>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <button class="confirm-btn" @click="confirm" :disabled="logining">{{$L('确定')}}</button>
  24. <uni-popup ref="popup" type="dialog">
  25. <uni-popup-dialog type="input" :title=$L("温馨提示") :content="bindTip" :duration="2000" before-close="true" @close="closeDialog"
  26. @confirm="confirmBind"></uni-popup-dialog>
  27. </uni-popup>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. mapMutations,
  33. mapState
  34. } from 'vuex';
  35. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  36. import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue'
  37. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
  38. export default {
  39. components: {
  40. uniPopup,
  41. uniPopupMessage,
  42. uniPopupDialog
  43. },
  44. data() {
  45. return {
  46. email: '',
  47. smsCode: '',
  48. logining: false,
  49. countDownM: 0, //短信验证码倒计时
  50. timeOutId: '', //定时器的返回值
  51. bind:'',//是否进行绑定,1-解绑,0-不解绑
  52. bindTip:'',//弹框内容提示
  53. }
  54. },
  55. onLoad(options) {},
  56. computed: {
  57. ...mapState(['userInfo', 'userCenterData']),
  58. },
  59. methods: {
  60. ...mapMutations(['login', 'setUserCenterData', 'userInfo']),
  61. inputChange(e) {
  62. const key = e.currentTarget.dataset.key;
  63. this[key] = e.detail.value;
  64. },
  65. navBack() {
  66. uni.navigateBack();
  67. },
  68. //获取邮箱验证码
  69. getSmsCode() {
  70. if (this.countDownM) {
  71. return;
  72. }
  73. //验证邮箱是否正确
  74. if (!this.$checkEmail(this.email)) {
  75. return false
  76. }
  77. let param = {};
  78. param.url = 'v3/msg/front/commons/sendVerifyCode';
  79. param.data = {};
  80. param.method = 'GET';
  81. param.data.verifyType = 1;
  82. param.data.verifyAddr = this.email;
  83. param.data.changeType = '';
  84. this.$request(param).then(res => {
  85. this.$api.msg(res.msg);
  86. if (res.state == 200) {
  87. this.countDownM = 60;
  88. this.countDown();
  89. }
  90. })
  91. },
  92. //确认事件
  93. confirm() {
  94. const {
  95. email,
  96. smsCode
  97. } = this;
  98. //验证邮箱是否正确
  99. if (!this.$checkEmail(email)) {
  100. return false
  101. }
  102. //是否填写验证码
  103. if(!smsCode){
  104. this.$api.msg('验证码不能为空');
  105. return;
  106. }
  107. let param = {};
  108. param.data = {};
  109. param.method = 'POST';
  110. param.url = 'v3/member/front/memberPassword/editEmail';
  111. param.data.memberEmail = email;
  112. param.data.emailCode = smsCode;
  113. if (this.bind != '') {
  114. param.data.isUnbound = this.bind;
  115. }
  116. this.$request(param).then(res => {
  117. if (res.state == 200) {
  118. this.$api.msg(res.msg);
  119. this.userCenterData.hasMemberEmail = 1;
  120. this.userCenterData.memberEmail = email;
  121. //更新个人信息数据
  122. this.setUserCenterData(this.userCenterData);
  123. setTimeout(() => {
  124. uni.navigateBack();
  125. }, 2000)
  126. }else if(res.state == 267){
  127. //提示是否进行绑定
  128. this.bindTip = res.msg;
  129. this.$refs.popup.open();
  130. } else {
  131. this.$api.msg(res.msg);
  132. }
  133. }).catch((e) => {})
  134. },
  135. //清空输入的内容
  136. clearContent(type) {
  137. this[type] = '';
  138. },
  139. //跳转事件 type:跳转类型,1为redirectTo 2为navigateTo
  140. navTo(url, type) {
  141. if (type == 1) {
  142. uni.redirectTo({
  143. url
  144. })
  145. } else if (type == 2) {
  146. uni.navigateTo({
  147. url
  148. })
  149. }
  150. },
  151. //倒计时
  152. countDown() {
  153. this.countDownM--;
  154. if (this.countDownM == 0) {
  155. clearTimeout(this.timeOutId);
  156. } else {
  157. this.timeOutId = setTimeout(this.countDown, 1000);
  158. }
  159. },
  160. //关闭弹框
  161. closeDialog() {
  162. this.bind = 0;
  163. this.$refs.popup.close();
  164. //返回上级页面
  165. setTimeout(() => {
  166. uni.navigateBack();
  167. }, 200)
  168. },
  169. //确认绑定
  170. confirmBind() {
  171. this.bind = 1;
  172. this.$refs.popup.close();
  173. this.confirm();
  174. },
  175. },
  176. }
  177. </script>
  178. <style lang='scss'>
  179. page {
  180. background: $bg-color-split;
  181. display: flex;
  182. flex: 1;
  183. height: 100%;
  184. width: 750rpx;
  185. margin: 0 auto;
  186. }
  187. uni-page-body {
  188. display: flex;
  189. height: 100%;
  190. }
  191. .container {
  192. flex: 1;
  193. margin-top: 20rpx;
  194. .bind_mobile {
  195. height: 80rpx;
  196. width: 100%;
  197. width: 100%;
  198. background: #F8F8F8;
  199. padding-left: 40rpx;
  200. color: $main-font-color;
  201. font-size: 26rpx;
  202. }
  203. }
  204. .wrapper {
  205. position: relative;
  206. z-index: 90;
  207. background: #fff;
  208. padding-bottom: 40upx;
  209. }
  210. .back-btn {
  211. position: absolute;
  212. left: 40upx;
  213. z-index: 9999;
  214. padding-top: var(--status-bar-height);
  215. top: 40upx;
  216. font-size: 40upx;
  217. color: $font-color-dark;
  218. }
  219. .input-content {
  220. flex: 1;
  221. width: 100%;
  222. background-color: #fff;
  223. padding: 0 40rpx;
  224. }
  225. .input-item {
  226. display: flex;
  227. flex-direction: row;
  228. align-items: center;
  229. justify-content: space-between;
  230. width: 100%;
  231. padding: 0 20rpx;
  232. height: 80rpx;
  233. margin-bottom: 40rpx;
  234. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  235. position: relative;
  236. .placeholder_class {
  237. color: #949494;
  238. font-size: 26rpx;
  239. }
  240. .clear-account {
  241. position: absolute;
  242. right: 6rpx;
  243. top: 28rpx;
  244. font-size: 24rpx;
  245. color: #999;
  246. }
  247. &:first-child {
  248. margin-top: 40rpx;
  249. }
  250. &:last-child {
  251. input{
  252. width: 80% !important;
  253. }
  254. .pwd-right {
  255. position: absolute;
  256. right: 6rpx;
  257. top: 6rpx;
  258. display: flex;
  259. align-items: center;
  260. .clear-pwd {
  261. font-size: 24rpx;
  262. color: #999;
  263. z-index: 999;
  264. }
  265. .sms-code-view {
  266. border: 1px solid $main-color;
  267. padding: 14rpx;
  268. border-radius: 6rpx;
  269. line-height: 0;
  270. margin-left: 20rpx;
  271. .sms-code {
  272. color: $main-color;
  273. font-size: 24rpx;
  274. line-height: 24rpx;
  275. }
  276. }
  277. }
  278. }
  279. &:last-child {
  280. margin-bottom: 0;
  281. .pwd-right {
  282. position: absolute;
  283. right: 6rpx;
  284. top: 14rpx;
  285. .clear-pwd {
  286. font-size: 24rpx;
  287. color: #999;
  288. }
  289. .pwd-tab {
  290. font-size: 30rpx;
  291. color: #666;
  292. margin-left: 20rpx;
  293. margin-right: 28rpx;
  294. }
  295. .forget-pwd {
  296. color: #2D2D2D;
  297. font-size: 28rpx;
  298. line-height: 28rpx;
  299. font-weight: 400;
  300. border-left: 1px solid $border-color-split;
  301. padding-left: 28rpx;
  302. }
  303. }
  304. }
  305. input {
  306. height: 60upx;
  307. font-size: 28rpx;
  308. color: $main-font-color;
  309. width: 100%;
  310. }
  311. }
  312. .confirm-btn {
  313. position: fixed;
  314. width: 668rpx;
  315. height: 88rpx;
  316. background: linear-gradient(-90deg, rgba(252, 29, 28, 1) 0%, rgba(255, 122, 24, 1) 100%);
  317. box-shadow: 0px 10rpx 20rpx 0px rgba(252, 30, 28, 0.2);
  318. border-radius: 44rpx;
  319. left: 0;
  320. right: 0;
  321. bottom: 40rpx;
  322. color: #fff;
  323. font-size: 36rpx;
  324. margin: 0 auto;
  325. }
  326. </style>