index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view :style="viewColor">
  3. <form report-submit='true'>
  4. <view>
  5. <view class="ChangePassword">
  6. <view class="list">
  7. <view class="item">
  8. <text class="phone">{{userInfo.phone}}</text>
  9. </view>
  10. <view class="item acea-row row-between-wrapper codeVal">
  11. <input type='number' placeholder='验证码' placeholder-class='placeholder' class="codeIput" v-model="captcha"></input>
  12. <button class="code" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
  13. {{ text }}
  14. </button>
  15. </view>
  16. <view class="border"></view>
  17. <view class="item">
  18. <input type='password' placeholder='新密码' placeholder-class='placeholder' v-model="password" autocomplete="off"></input>
  19. </view>
  20. <view class="item">
  21. <input type='password' placeholder='确认新密码' placeholder-class='placeholder' v-model="repassword" autocomplete="off"></input>
  22. </view>
  23. </view>
  24. </view>
  25. <button form-type="submit" @click="confirmSubmit" class="confirmBnt">确认</button>
  26. </view>
  27. </form>
  28. <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
  29. </view>
  30. </template>
  31. <script>
  32. // +----------------------------------------------------------------------
  33. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  34. // +----------------------------------------------------------------------
  35. // | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
  36. // +----------------------------------------------------------------------
  37. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  38. // +----------------------------------------------------------------------
  39. // | Author: CRMEB Team <admin@crmeb.com>
  40. // +----------------------------------------------------------------------
  41. import sendVerifyCode from "@/mixins/SendVerifyCode";
  42. import { modifyPassword, verifyCode, appletsDecrypt } from '@/api/api.js';
  43. import { getUserInfo } from '@/api/user.js';
  44. import { registerVerify } from '@/api/user.js'
  45. import {
  46. mapGetters
  47. } from "vuex";
  48. import authorize from '@/components/Authorize';
  49. export default {
  50. mixins: [sendVerifyCode],
  51. components: {
  52. authorize
  53. },
  54. data() {
  55. return {
  56. userInfo: {},
  57. phone:'',
  58. repassword: '',
  59. password: '',
  60. captcha:'',
  61. isAuto: false, //没有授权的不会自动授权
  62. isShowAuth: false, //是否隐藏授权
  63. key: '',
  64. codeVal: '',
  65. disabled: false,
  66. };
  67. },
  68. computed: mapGetters(['isLogin', 'viewColor']),
  69. onLoad() {
  70. let that = this
  71. if (this.isLogin) {
  72. this.getUserInfo()
  73. } else {
  74. this.isAuto = true;
  75. this.isShowAuth = true
  76. }
  77. // #ifdef MP
  78. wx.login({
  79. success (res) {
  80. if (res.code) {
  81. that.codeVal = res.code
  82. } else {
  83. console.log('登录失败!' + res.errMsg)
  84. }
  85. }
  86. })
  87. // #endif
  88. },
  89. methods: {
  90. onLoadFun:function(){
  91. this.isShowAuth = false;
  92. },
  93. // 授权关闭
  94. authColse: function(e) {
  95. this.isShowAuth = e
  96. },
  97. /**
  98. * 获取个人用户信息
  99. */
  100. getUserInfo: function() {
  101. let that = this;
  102. getUserInfo().then(res => {
  103. that.userInfo = res.data
  104. });
  105. },
  106. confirmSubmit: function() {
  107. let that = this;
  108. if (!that.password) return that.$util.Tips({
  109. title: '请填写密码!'
  110. });
  111. if (!that.repassword) return that.$util.Tips({
  112. title: '请确认新密码!'
  113. });
  114. if (that.password !== that.repassword) return that.$util.Tips({
  115. title: '两次密码不一致,请重新填写!'
  116. });
  117. if (!that.captcha) return that.$util.Tips({
  118. title: '请填写验证码'
  119. });
  120. modifyPassword({
  121. password: that.password,
  122. repassword: that.repassword,
  123. sms_code: that.captcha
  124. }).then(res => {
  125. return that.$util.Tips({
  126. title: '修改成功!',
  127. icon: 'success'
  128. }, {
  129. tab: 5,
  130. url: '/pages/users/user_info/index'
  131. });
  132. }).catch(err => {
  133. return that.$util.Tips({
  134. title: err
  135. });
  136. })
  137. },
  138. /**
  139. * 发送验证码
  140. *
  141. */
  142. async code() {
  143. let that = this;
  144. // if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.userInfo.phone))) return that.$util.Tips({
  145. // title: '请输入正确的手机号码!'
  146. // });
  147. this.disabled = true
  148. await registerVerify({
  149. phone:that.userInfo.phone,
  150. code:that.captcha,
  151. type: 'change_pwd'
  152. }).then(res => {
  153. this.disabled = false
  154. that.$util.Tips({
  155. title: res.msg
  156. });
  157. that.sendCode();
  158. }).catch(err => {
  159. this.disabled = false
  160. return that.$util.Tips({
  161. title: err
  162. });
  163. });
  164. }
  165. }
  166. }
  167. </script>
  168. <style lang="scss">
  169. .ChangePassword{
  170. background: #fff;
  171. padding-top: 53rpx;
  172. }
  173. .ChangePassword .phone {
  174. font-size: 32rpx;
  175. }
  176. .ChangePassword .list .item {
  177. width: 580rpx;
  178. margin: 0 auto;
  179. height: 110rpx;
  180. border-bottom: 2rpx solid #f0f0f0;
  181. display: flex;
  182. align-items: center;
  183. }
  184. .ChangePassword .list .item input {
  185. width: 100%;
  186. font-size: 32rpx;
  187. }
  188. /deep/.uni-input-input{
  189. // box-shadow: inset 0 0 0 0 #fff;
  190. }
  191. .ChangePassword .list .item .placeholder {
  192. color: #b9b9bc;
  193. }
  194. .ChangePassword .list .item input.codeIput {
  195. width: 340rpx;
  196. }
  197. .ChangePassword .list .item .code {
  198. font-size: 32rpx;
  199. position: relative;
  200. padding-left: 26rpx;
  201. color: var(--view-theme);
  202. &::before{
  203. content: "";
  204. width: 1rpx;
  205. height: 30rpx;
  206. position: absolute;
  207. top: 10rpx;
  208. left: 0;
  209. background: #DDDDDD;
  210. display: inline-block;
  211. }
  212. }
  213. .ChangePassword .list .item .code.on {
  214. color: #b9b9bc !important;
  215. }
  216. .ChangePassword .list .border{
  217. width: 100%;
  218. height: 21rpx;
  219. background: #F5F5F5;
  220. }
  221. .confirmBnt {
  222. font-size: 32rpx;
  223. width: 580rpx;
  224. height: 90rpx;
  225. border-radius: 45rpx;
  226. color: #fff;
  227. margin: 70rpx auto 0 auto;
  228. text-align: center;
  229. line-height: 90rpx;
  230. background-color: var(--view-theme);
  231. }
  232. .getPhoneBtn{
  233. font-size: 32rpx;
  234. width: 580rpx;
  235. height: 90rpx;
  236. border-radius: 45rpx;
  237. border: 1rpx solid var(--view-theme);
  238. color: var(--view-theme);
  239. margin: 40rpx auto 0 auto;
  240. text-align: center;
  241. line-height: 90rpx;
  242. .iconfont{
  243. font-size: 32rpx;
  244. margin-right: 12rpx;
  245. }
  246. }
  247. </style>