editPassword.vue 8.3 KB

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