editPassword.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <view class="container">
  3. <u-icon class="back-btn" name="arrow-left" color="black" size="20" @click="navBack"></u-icon>
  4. <view class="wrapper">
  5. <h2>重置密码</h2>
  6. <view style='width:100%;margin-top:50px;border-bottom:1px solid #E8E9ED;padding:10px;' class="flex">
  7. <view style='width:15%;border-right:1px solid #E8E9ED;'>+86</view>
  8. <view style='width:85%;'><input maxlength="11" @input='phoneinput' style='padding-left:10px;' v-model='phone' placeholder="请输入手机号码" type="text"></view>
  9. </view>
  10. <view style='width:100%;border-bottom:1px solid #E8E9ED;position:relative;padding:10px;' class="flex">
  11. <view style='width:85%;'><input v-model='verifyCode' placeholder="请输入验证码" type="text"></view>
  12. <button @click='getcode' :class='status&&!sendDisabled?"active":""' class='getcode'>{{sendText}}</button>
  13. </view>
  14. <view style='border-bottom:1px solid #E8E9ED;padding:10px;position:relative;'>
  15. <input class='password' style='height:30px;' v-model='password' placeholder="请输入新密码,6-16位字符" :type="type" value="" />
  16. <view @click='switchover' style='position:absolute;right:0;top:38%;z-index:10;cursor:pointer;' class="iconfont " :class='type=="password"?"icon-yanjing-biyan":"icon-yanjing-zhengyan"'></view>
  17. </view>
  18. <button :class='phone!=""&&verifyCode!=""&&password!=""?"active":""' @click='reset' class='verificationCode'>重置密码</button>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. mapMutations
  25. } from 'vuex';
  26. // import { openFSqlite, createFSQL, selectFSQL, addFSQL } from '../../util/f.js'
  27. // import { queryData, upData, initData } from '../../util/dbUtil.js'
  28. export default {
  29. data() {
  30. return {
  31. inputContent: null,
  32. loginType: "wechat",
  33. phone: '',
  34. password: '',
  35. logining: false,
  36. isPhone: false,
  37. isApple: true,
  38. accessToken:'',
  39. params:{
  40. encryptedData:'',
  41. session_key:'',
  42. iv:'',
  43. },
  44. status:false,
  45. userInfo:{
  46. nickName:'',
  47. avatarUrl:'',
  48. gender:'',
  49. phone:''
  50. },
  51. consentStatus:false,
  52. type:'password',
  53. inputStatus:'none',
  54. verifyCode:null,
  55. sendText:'获取验证码',
  56. sendDisabled: false,
  57. system:'',
  58. platform:'',
  59. userData:undefined,
  60. canIUseProfile:false,
  61. isPhone:""
  62. }
  63. },
  64. onShow() {
  65. // this.loginType = "wechat"
  66. this.$api.logout()
  67. },
  68. onLoad(options) {
  69. this.phone = options.phone //个人首页修改密码
  70. // this.isPhone = options.phone //个人首页修改密码成功后自动退出重新登录
  71. // if( wx.getUserProfile ){
  72. // console.log('--check getUserProfile--OK');
  73. // this.canIUseProfile = true;
  74. // }
  75. // console.log("login on load")
  76. // var that = this
  77. // that.$api.request('user', 'sendIsApple', {
  78. // }).then(res => {
  79. // that.isApple = res.data
  80. // })
  81. // uni.getSystemInfo({
  82. // success:(res) => {
  83. // // console.log(res)
  84. // this.system = res.system // ios
  85. // this.platform = res.platform // 14.3
  86. // }
  87. // })
  88. },
  89. methods: {
  90. phoneinput(e){
  91. if(e.detail.value.length==11){
  92. this.status=true
  93. }
  94. },
  95. getcode(e){
  96. if(this.phone.length!=11){
  97. uni.showToast({
  98. title: '请输入正确的手机号',
  99. icon:'none',
  100. duration: 2000
  101. })
  102. return
  103. }
  104. if(/^0?1[3|4|5|6|7|8][0-9]\d{8}$/.test(this.phone)){
  105. var that=this
  106. this.$request.baseRequest('get','/commonUser/sendVerifyCode',{phone:this.phone}).then(res => {
  107. that.sendDisabled = true
  108. let sec = 60
  109. let interval = setInterval(() => {
  110. sec--;
  111. that.sendText = sec + 's后重发'
  112. if (sec <= 0) {
  113. that.sendDisabled = false
  114. that.sendText = "获取验证码"
  115. clearInterval(interval)
  116. }
  117. }, 1000)
  118. })
  119. .catch(res => {
  120. if(res.errmsg){
  121. uni.showToast({
  122. title: res.errmsg,
  123. icon: 'none',
  124. duration: 2000
  125. })
  126. }
  127. else{
  128. uni.showToast({
  129. title: "系统异常,请联系管理员",
  130. icon: 'none',
  131. duration: 2000
  132. })
  133. }
  134. });
  135. }else{
  136. uni.showToast({
  137. title: '请输入正确的手机号',
  138. icon:'none',
  139. duration: 2000
  140. })
  141. }
  142. },
  143. reset(){
  144. var that = this
  145. uni.showLoading({
  146. title: '重置密码中'
  147. })
  148. this.$request.baseRequest('post','/commonUser/resetPassword',{phone:this.phone,password:this.password,verifyCode:this.verifyCode}).then(res => {
  149. console.log("重置密码",res)
  150. // 获得数据
  151. if(res.data.code==200){
  152. if(this.isPhone){//判断是否是在个人首页进来的(若是退出重进)
  153. uni.clearStorageSync();
  154. this.$request.baseRequest('post', '/auth/api/logout').then(res => {})
  155. this.$store.commit('logout')
  156. this.$api.logout()
  157. setTimeout(() => {
  158. uni.showToast({
  159. title: '修改成功',
  160. icon: 'none',
  161. duration: 2000
  162. })
  163. },2000)
  164. uni.navigateTo({
  165. url: `/pages/public/login`
  166. })
  167. }else{
  168. setTimeout(() => {
  169. uni.navigateBack()
  170. }, 1000)
  171. }
  172. uni.showToast({
  173. title: '重置成功',
  174. icon: 'none',
  175. duration: 2000
  176. })
  177. }else{
  178. uni.showToast({
  179. title: "系统异常或验证码已过期,请退出重试",
  180. icon:'none',
  181. duration: 2000
  182. })
  183. }
  184. uni.hideLoading()
  185. })
  186. .catch(res => {
  187. console.log("重置密码",res)
  188. uni.showToast({
  189. title: "系统异常,请联系管理员",
  190. icon:'none',
  191. duration: 2000
  192. })
  193. uni.hideLoading()
  194. });
  195. },
  196. switchover(){
  197. if(this.type=='password'){
  198. this.type='text'
  199. }else{
  200. this.type='password'
  201. }
  202. },
  203. cancel() {
  204. this.inputShow = false
  205. this.inputStatus = 'none'
  206. this.isPhone = false
  207. },
  208. ...mapMutations(['login']),
  209. inputChange(e) {
  210. const key = e.currentTarget.dataset.key;
  211. this[key] = e.detail.value;
  212. },
  213. navBack() {
  214. uni.navigateBack();
  215. },
  216. },
  217. }
  218. </script>
  219. <style lang='scss' scoped>
  220. .apple{
  221. background: #000;
  222. width: 35px;
  223. height: 35px;
  224. padding: 8px;
  225. border-radius: 50%;
  226. vertical-align: middle;
  227. }
  228. page {
  229. background: #fff;
  230. }
  231. .cuIcon-weixin{
  232. background: #2772FB;
  233. color: #fff;
  234. font-size: 18px;
  235. padding: 9px;
  236. border-radius: 50%;
  237. vertical-align: middle;
  238. margin-right:5px;
  239. }
  240. .container {
  241. padding-top: 85px;
  242. position: relative;
  243. width: 100vw;
  244. height:calc(100vh - 85px);
  245. overflow: hidden;
  246. background: url('~@/static/images/mine/bg@2x.png');
  247. background-size:100%;
  248. }
  249. .wrapper {
  250. position: relative;
  251. z-index: 90;
  252. padding-bottom: 40upx;
  253. height:100%;
  254. padding:0 30px;
  255. }
  256. .back-btn {
  257. position: absolute;
  258. left: 40upx;
  259. z-index: 9999;
  260. padding-top: var(--status-bar-height);
  261. top: 40upx;
  262. font-size: 40upx;
  263. color:black;
  264. }
  265. .verificationCode{
  266. margin-top:20px;
  267. background:#F5F6F9;
  268. color:#AFB3BF;
  269. }
  270. .verificationCode:after{
  271. border:none;
  272. }
  273. .verificationCode.active{
  274. background:#2772FB;
  275. color:#fff;
  276. }
  277. .register{
  278. position:absolute;
  279. bottom:20px;
  280. left:50%;
  281. transform: translateX(-50%);
  282. color:#333333;
  283. height:50px;
  284. line-height:50px;
  285. border-radius:30px;border: 1px solid #444444;
  286. }
  287. .register:after{
  288. border:none;
  289. }
  290. .getcode{
  291. font-size:14px;
  292. position:absolute;
  293. right:0;
  294. top:50%;
  295. transform: translateY(-50%);
  296. color:#AFB3BF;
  297. background:#F5F6F9;
  298. height:30px;
  299. line-height:30px;
  300. }
  301. .password{
  302. border:none;
  303. outline: none;
  304. }
  305. .getcode:after{
  306. border:none;
  307. }
  308. .getcode.active{
  309. background:#2772FB;
  310. color:#fff;
  311. }
  312. uni-navigator{
  313. display:inline-block;
  314. color:#2772FB;
  315. }
  316. </style>