editPassword.vue 7.9 KB

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