editPassword.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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 maxlength="6" 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. if (this.password.length < 6) {
  146. uni.showToast({
  147. title: '密码请输入6-16字符格式',
  148. icon: 'none',
  149. duration: 2000
  150. })
  151. return
  152. }
  153. uni.showLoading({
  154. title: '重置密码中'
  155. })
  156. this.$request.baseRequest('post','/commonUser/resetPassword',{phone:this.phone,password:this.password,verifyCode:this.verifyCode,identification:1}).then(res => {
  157. // 获得数据
  158. if(res.code==200){
  159. if(this.isPhone){//判断是否是在个人首页进来的(若是退出重进)
  160. uni.clearStorageSync();
  161. this.$request.baseRequest('post', '/auth/api/logout').then(res => {})
  162. this.$store.commit('logout')
  163. this.$api.logout()
  164. setTimeout(() => {
  165. uni.showToast({
  166. title: '修改成功',
  167. icon: 'none',
  168. duration: 2000
  169. })
  170. },2000)
  171. uni.navigateTo({
  172. url: `/pages/public/login`
  173. })
  174. }else{
  175. setTimeout(() => {
  176. uni.navigateBack()
  177. }, 1000)
  178. }
  179. uni.showToast({
  180. title: '重置成功',
  181. icon: 'none',
  182. duration: 2000
  183. })
  184. }else{
  185. uni.showToast({
  186. title: res.message,
  187. icon:'none',
  188. duration: 2000
  189. })
  190. }
  191. uni.hideLoading()
  192. })
  193. .catch(res => {
  194. uni.showToast({
  195. title: "系统异常,请联系管理员",
  196. icon:'none',
  197. duration: 2000
  198. })
  199. uni.hideLoading()
  200. });
  201. },
  202. switchover(){
  203. if(this.type=='password'){
  204. this.type='text'
  205. }else{
  206. this.type='password'
  207. }
  208. },
  209. cancel() {
  210. this.inputShow = false
  211. this.inputStatus = 'none'
  212. this.isPhone = false
  213. },
  214. ...mapMutations(['login']),
  215. inputChange(e) {
  216. const key = e.currentTarget.dataset.key;
  217. this[key] = e.detail.value;
  218. },
  219. navBack() {
  220. uni.navigateBack();
  221. },
  222. },
  223. }
  224. </script>
  225. <style lang='scss' scoped>
  226. .apple{
  227. background: #000;
  228. width: 35px;
  229. height: 35px;
  230. padding: 8px;
  231. border-radius: 50%;
  232. vertical-align: middle;
  233. }
  234. page {
  235. background: #fff;
  236. }
  237. .cuIcon-weixin{
  238. background: #2772FB;
  239. color: #fff;
  240. font-size: 18px;
  241. padding: 9px;
  242. border-radius: 50%;
  243. vertical-align: middle;
  244. margin-right:5px;
  245. }
  246. .container {
  247. padding-top: 85px;
  248. position: relative;
  249. width: 100vw;
  250. height:calc(100vh - 85px);
  251. overflow: hidden;
  252. background: url('~@/static/images/mine/bg@2x.png');
  253. background-size:100%;
  254. }
  255. .wrapper {
  256. position: relative;
  257. z-index: 90;
  258. padding-bottom: 40upx;
  259. height:100%;
  260. padding:0 30px;
  261. }
  262. .back-btn {
  263. position: absolute;
  264. left: 40upx;
  265. z-index: 9999;
  266. padding-top: var(--status-bar-height);
  267. top: 40upx;
  268. font-size: 40upx;
  269. color:black;
  270. }
  271. .verificationCode{
  272. margin-top:20px;
  273. background:#F5F6F9;
  274. color:#AFB3BF;
  275. }
  276. .verificationCode:after{
  277. border:none;
  278. }
  279. .verificationCode.active{
  280. background:#2772FB;
  281. color:#fff;
  282. }
  283. .register{
  284. position:absolute;
  285. bottom:20px;
  286. left:50%;
  287. transform: translateX(-50%);
  288. color:#333333;
  289. height:50px;
  290. line-height:50px;
  291. border-radius:30px;border: 1px solid #444444;
  292. }
  293. .register:after{
  294. border:none;
  295. }
  296. .getcode{
  297. font-size:14px;
  298. position:absolute;
  299. right:0;
  300. top:50%;
  301. transform: translateY(-50%);
  302. color:#AFB3BF;
  303. background:#F5F6F9;
  304. height:30px;
  305. line-height:30px;
  306. }
  307. .password{
  308. border:none;
  309. outline: none;
  310. }
  311. .getcode:after{
  312. border:none;
  313. }
  314. .getcode.active{
  315. background:#2772FB;
  316. color:#fff;
  317. }
  318. uni-navigator{
  319. display:inline-block;
  320. color:#2772FB;
  321. }
  322. </style>