editPassword.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. if(this.phone.length==11){
  71. this.status=true
  72. }
  73. // this.isPhone = options.phone //个人首页修改密码成功后自动退出重新登录
  74. // if( wx.getUserProfile ){
  75. // console.log('--check getUserProfile--OK');
  76. // this.canIUseProfile = true;
  77. // }
  78. // console.log("login on load")
  79. // var that = this
  80. // that.$api.request('user', 'sendIsApple', {
  81. // }).then(res => {
  82. // that.isApple = res.data
  83. // })
  84. // uni.getSystemInfo({
  85. // success:(res) => {
  86. // // console.log(res)
  87. // this.system = res.system // ios
  88. // this.platform = res.platform // 14.3
  89. // }
  90. // })
  91. },
  92. methods: {
  93. phoneinput(e){
  94. if(e.detail.value.length==11){
  95. this.status=true
  96. }
  97. },
  98. getcode(e){
  99. if(this.phone.length!=11){
  100. uni.showToast({
  101. title: '请输入正确的手机号',
  102. icon:'none',
  103. duration: 2000
  104. })
  105. return
  106. }
  107. if(/^0?1[3|4|5|6|7|8][0-9]\d{8}$/.test(this.phone)){
  108. var that=this
  109. this.$request.baseRequest('get','/commonUser/sendVerifyCode',{phone:this.phone,identification:1,flag:2}).then(res => {
  110. if(res.code==200){
  111. that.sendDisabled = true
  112. let sec = 60
  113. let interval = setInterval(() => {
  114. sec--;
  115. that.sendText = sec + 's后重发'
  116. if (sec <= 0) {
  117. that.sendDisabled = false
  118. that.sendText = "获取验证码"
  119. clearInterval(interval)
  120. }
  121. }, 1000)
  122. }else{
  123. uni.showToast({
  124. title: res.message,
  125. icon: 'none',
  126. duration: 2000
  127. })
  128. }
  129. })
  130. .catch(res => {
  131. if(res.message){
  132. uni.showToast({
  133. title: res.message,
  134. icon: 'none',
  135. duration: 2000
  136. })
  137. }
  138. else{
  139. uni.showToast({
  140. title: "系统异常,请联系管理员",
  141. icon: 'none',
  142. duration: 2000
  143. })
  144. }
  145. });
  146. }else{
  147. uni.showToast({
  148. title: '请输入正确的手机号',
  149. icon:'none',
  150. duration: 2000
  151. })
  152. }
  153. },
  154. reset(){
  155. var that = this
  156. if (this.password.length < 6) {
  157. uni.showToast({
  158. title: '密码请输入6-16字符格式',
  159. icon: 'none',
  160. duration: 2000
  161. })
  162. return
  163. }
  164. uni.showLoading({
  165. title: '重置密码中'
  166. })
  167. this.$request.baseRequest('post','/commonUser/resetPassword',{phone:this.phone,password:this.password,verifyCode:this.verifyCode,identification:1}).then(res => {
  168. // 获得数据
  169. if(res.code==200){
  170. if(this.isPhone){//判断是否是在个人首页进来的(若是退出重进)
  171. uni.clearStorageSync();
  172. this.$request.baseRequest('post', '/auth/api/logout').then(res => {})
  173. this.$store.commit('logout')
  174. this.$api.logout()
  175. setTimeout(() => {
  176. uni.showToast({
  177. title: '修改成功',
  178. icon: 'none',
  179. duration: 2000
  180. })
  181. },2000)
  182. uni.navigateTo({
  183. url: `/pages/public/login`
  184. })
  185. }else{
  186. setTimeout(() => {
  187. uni.navigateBack()
  188. }, 1000)
  189. }
  190. uni.showToast({
  191. title: '重置成功',
  192. icon: 'none',
  193. duration: 2000
  194. })
  195. }else{
  196. uni.showToast({
  197. title: res.message,
  198. icon:'none',
  199. duration: 2000
  200. })
  201. }
  202. uni.hideLoading()
  203. })
  204. .catch(res => {
  205. uni.showToast({
  206. title: "系统异常,请联系管理员",
  207. icon:'none',
  208. duration: 2000
  209. })
  210. uni.hideLoading()
  211. });
  212. },
  213. switchover(){
  214. if(this.type=='password'){
  215. this.type='text'
  216. }else{
  217. this.type='password'
  218. }
  219. },
  220. cancel() {
  221. this.inputShow = false
  222. this.inputStatus = 'none'
  223. this.isPhone = false
  224. },
  225. ...mapMutations(['login']),
  226. inputChange(e) {
  227. const key = e.currentTarget.dataset.key;
  228. this[key] = e.detail.value;
  229. },
  230. navBack() {
  231. uni.navigateBack();
  232. },
  233. },
  234. }
  235. </script>
  236. <style lang='scss' scoped>
  237. .apple{
  238. background: #000;
  239. width: 35px;
  240. height: 35px;
  241. padding: 8px;
  242. border-radius: 50%;
  243. vertical-align: middle;
  244. }
  245. page {
  246. background: #fff;
  247. }
  248. .cuIcon-weixin{
  249. background: #2772FB;
  250. color: #fff;
  251. font-size: 18px;
  252. padding: 9px;
  253. border-radius: 50%;
  254. vertical-align: middle;
  255. margin-right:5px;
  256. }
  257. .container {
  258. padding-top: 85px;
  259. position: relative;
  260. width: 100vw;
  261. height:calc(100vh - 85px);
  262. overflow: hidden;
  263. background: url('~@/static/images/mine/bg@2x.png');
  264. background-size:100%;
  265. }
  266. .wrapper {
  267. position: relative;
  268. z-index: 90;
  269. padding-bottom: 40upx;
  270. height:100%;
  271. padding:0 30px;
  272. }
  273. .back-btn {
  274. position: absolute;
  275. left: 40upx;
  276. z-index: 9999;
  277. padding-top: var(--status-bar-height);
  278. top: 40upx;
  279. font-size: 40upx;
  280. color:black;
  281. }
  282. .verificationCode{
  283. margin-top:20px;
  284. background:#F5F6F9;
  285. color:#AFB3BF;
  286. }
  287. .verificationCode:after{
  288. border:none;
  289. }
  290. .verificationCode.active{
  291. background:#2772FB;
  292. color:#fff;
  293. }
  294. .register{
  295. position:absolute;
  296. bottom:20px;
  297. left:50%;
  298. transform: translateX(-50%);
  299. color:#333333;
  300. height:50px;
  301. line-height:50px;
  302. border-radius:30px;border: 1px solid #444444;
  303. }
  304. .register:after{
  305. border:none;
  306. }
  307. .getcode{
  308. font-size:14px;
  309. position:absolute;
  310. right:0;
  311. top:50%;
  312. transform: translateY(-50%);
  313. color:#AFB3BF;
  314. background:#F5F6F9;
  315. height:30px;
  316. line-height:30px;
  317. }
  318. .password{
  319. border:none;
  320. outline: none;
  321. }
  322. .getcode:after{
  323. border:none;
  324. }
  325. .getcode.active{
  326. background:#2772FB;
  327. color:#fff;
  328. }
  329. uni-navigator{
  330. display:inline-block;
  331. color:#2772FB;
  332. }
  333. </style>