retrieve-account-password.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view class="container">
  3. <view class="login-wrap">
  4. <view class="login-form">
  5. <u--form
  6. labelPosition="left"
  7. :model="userInfo"
  8. :rules="rules"
  9. ref="form1"
  10. >
  11. <u-form-item
  12. label="账号密码"
  13. prop="password"
  14. borderBottom
  15. labelWidth="auto"
  16. labelAlign="right"
  17. >
  18. <u--input
  19. v-model="userInfo.password"
  20. placeholder="请输入账号密码"
  21. border="bottom"
  22. type="password"
  23. ></u--input>
  24. </u-form-item>
  25. </u--form>
  26. </view>
  27. </view>
  28. <view @click="submitAccountPasswordVerify()" class="op-btn-wrap">
  29. <view class="h-btn">
  30. <text>确定</text>
  31. </view>
  32. </view>
  33. <!-- 密码正确 -->
  34. <u-popup :show="show" :round="10" mode="center" @close="close" @open="open">
  35. <view class="h-popo-content">
  36. <view class="h-img">
  37. <u-icon name="checkbox-mark" color="green" size="40"></u-icon>
  38. </view>
  39. <view class="text">
  40. <text>账号找回成功</text>
  41. </view>
  42. <view class="text">
  43. <text> 是否立即绑定新的微信号</text>
  44. </view>
  45. <view class="h-btn-wrap">
  46. <view @click="show = false" class="h-left-btn">
  47. <text>取消</text>
  48. </view>
  49. <view @click="gotoBindWechat()" class="h-right-btn">
  50. <text>立即绑定</text>
  51. </view>
  52. </view>
  53. </view>
  54. </u-popup>
  55. <!-- 密码正确 -->
  56. <u-popup :show="passwordErrShow" :round="10" mode="center" @close="close" @open="open">
  57. <view class="h-popo-content">
  58. <view class="h-img">
  59. <!-- <u-icon name="close" color="red" size="40"></u-icon> -->
  60. <u-icon name="/static/login/u01.png" color="red" size="50"></u-icon>
  61. </view>
  62. <view class="h-text">
  63. <text>密码错误</text>
  64. </view>
  65. <view class="h-btn-wrap">
  66. <view @click="passwordErrShow = false" class="h-right-btn">
  67. <text>确定</text>
  68. </view>
  69. </view>
  70. </view>
  71. </u-popup>
  72. </view>
  73. </template>
  74. <script>
  75. import {wechatRetrieveAccountPwdLogin} from '/src/api/login/login.js';
  76. export default {
  77. data() {
  78. return {
  79. passwordErrShow: false,
  80. show: false,
  81. userInfo: {
  82. phone: '',
  83. password: '',
  84. },
  85. rules: {
  86. password:{
  87. required: true,
  88. message: '请输入账号密码',
  89. trigger: ['blur', 'change'],
  90. },
  91. },
  92. }
  93. },
  94. onLoad(option) {
  95. // 判断Openid是否为空
  96. if(!this.$isDataEmpty(option)){
  97. this.userInfo.phone = option.data;
  98. }
  99. },
  100. onReady() {
  101. this.$refs.form1.setRules(this.rules)
  102. },
  103. methods: {
  104. // 提交账号密码验证
  105. submitAccountPasswordVerify(){
  106. this.$refs.form1.validate().then(res => {
  107. // 验证找回
  108. this.wechatRetrieveAccountPwdLogin();
  109. }).catch(errors => {
  110. uni.$u.toast('校验失败,请认真填写')
  111. })
  112. },
  113. // 去绑定微信
  114. gotoBindWechat(){
  115. this.show = false;
  116. uni.$u.route({
  117. url: '/pages/setting/setting-wechat',
  118. params: {
  119. name: 'lisa'
  120. }
  121. })
  122. },
  123. // 账号密码找回登录
  124. wechatRetrieveAccountPwdLogin(){
  125. let that = this;
  126. // 根据手机和密码找回账号,成功自动登录
  127. wechatRetrieveAccountPwdLogin(null,{data:this.userInfo}).then((res)=>{
  128. if(!this.$isDataEmpty(res.access_token)){
  129. let loginState = {
  130. status: 1,
  131. accessToken: ""
  132. }
  133. // 数据获取token
  134. loginState.accessToken = res.access_token;
  135. that.$store.commit('updateLoginState', loginState);
  136. that.$store.commit('updateLoginUserInfo', res.userInfo)
  137. that.show = true;
  138. } else {
  139. uni.showToast({
  140. title: "操作失败"
  141. })
  142. }
  143. }).catch(() =>{
  144. uni.showToast({
  145. title: "操作失败"
  146. })
  147. });
  148. },
  149. open() {
  150. },
  151. close() {
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="scss">
  157. page,body{
  158. background: #fff;
  159. }
  160. .container{
  161. background: #fff;
  162. height: 300px;
  163. .login-wrap {
  164. display: flex;
  165. justify-content: center;
  166. .login-form{
  167. width: 90%;
  168. }
  169. .account{
  170. display: flex;
  171. }
  172. .identifying-code{
  173. }
  174. }
  175. .op-btn-wrap{
  176. margin-top: 30px;
  177. display: flex;
  178. justify-content: center;
  179. align-items: center;
  180. .h-btn{
  181. text-align: center;
  182. width: 343px;
  183. height: 42px;
  184. background: #FFE05C;
  185. border-radius: 27px;
  186. line-height: 42px;
  187. }
  188. }
  189. }
  190. .h-popo-content{
  191. height: 160px;
  192. padding: 12px;
  193. width: 300px;
  194. text-align: center;
  195. font-size: 14px;
  196. font-family: PingFangSC-Semibold, PingFang SC;
  197. .h-img{
  198. display: flex;
  199. justify-content: center;
  200. }
  201. .h-text{
  202. margin-top: 12px;
  203. font-weight: 400;
  204. color: #666666;
  205. }
  206. .text{
  207. margin-top: 6px;
  208. font-weight: 400;
  209. color: #666666;
  210. }
  211. .h-btn-wrap{
  212. display: flex;
  213. justify-content: space-between;
  214. color: #333333;
  215. text-align: center;
  216. margin-top: 14px;
  217. .h-left-btn{
  218. height: 32px;
  219. line-height: 30px;
  220. background: #EEEEEE;
  221. width: 100px;
  222. text-align: center;
  223. border-radius: 16px;
  224. margin: 0 auto;
  225. }
  226. .h-right-btn{
  227. height: 32px;
  228. line-height: 30px;
  229. background: #FFE05C;
  230. width: 100px;
  231. border-radius: 16px;
  232. margin: 0 auto;
  233. }
  234. }
  235. }
  236. </style>