retrieve-account-password.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. export default {
  76. data() {
  77. return {
  78. passwordErrShow: false,
  79. show: false,
  80. userInfo: {
  81. phone: '',
  82. password: '',
  83. },
  84. rules: {
  85. password:{
  86. required: true,
  87. message: '请输入账号密码',
  88. trigger: ['blur', 'change'],
  89. },
  90. },
  91. }
  92. },
  93. onLoad(option) {
  94. // 判断Openid是否为空
  95. if(!this.$isDataEmpty(option)){
  96. this.userInfo.phone = option.data;
  97. }
  98. },
  99. onReady() {
  100. this.$refs.form1.setRules(this.rules)
  101. },
  102. methods: {
  103. // 提交账号密码验证
  104. submitAccountPasswordVerify(){
  105. this.$refs.form1.validate().then(res => {
  106. // 验证找回
  107. this.wechatRetrieveAccountPwdLogin();
  108. }).catch(errors => {
  109. uni.$u.toast('校验失败,请认真填写')
  110. })
  111. },
  112. // 去绑定微信
  113. gotoBindWechat(){
  114. this.show = false;
  115. uni.$u.route({
  116. url: '/pages/setting/setting-wechat',
  117. params: {
  118. name: 'lisa'
  119. }
  120. })
  121. },
  122. // 账号密码找回登录
  123. wechatRetrieveAccountPwdLogin(){
  124. let that = this;
  125. // 根据手机和密码找回账号,成功自动登录
  126. wechatRetrieveAccountPwdLogin(null,{data:this.userInfo}).then((res)=>{
  127. if(!this.$isDataEmpty(res.access_token)){
  128. let loginState = {
  129. status: 1,
  130. accessToken: ""
  131. }
  132. // 数据获取token
  133. loginState.accessToken = res.access_token;
  134. that.$store.commit('updateLoginState', loginState);
  135. that.$store.commit('updateLoginUserInfo', res.userInfo)
  136. that.show = true;
  137. } else {
  138. uni.showToast({
  139. title: "操作失败"
  140. })
  141. }
  142. }).catch(() =>{
  143. uni.showToast({
  144. title: "操作失败"
  145. })
  146. });
  147. },
  148. open() {
  149. },
  150. close() {
  151. }
  152. }
  153. }
  154. </script>
  155. <style lang="scss">
  156. page,body{
  157. background: #fff;
  158. }
  159. .container{
  160. background: #fff;
  161. height: 300px;
  162. .login-wrap {
  163. display: flex;
  164. justify-content: center;
  165. .login-form{
  166. width: 90%;
  167. }
  168. .account{
  169. display: flex;
  170. }
  171. .identifying-code{
  172. }
  173. }
  174. .op-btn-wrap{
  175. margin-top: 30px;
  176. display: flex;
  177. justify-content: center;
  178. align-items: center;
  179. .h-btn{
  180. text-align: center;
  181. width: 343px;
  182. height: 42px;
  183. background: #FFE05C;
  184. border-radius: 27px;
  185. line-height: 42px;
  186. }
  187. }
  188. }
  189. .h-popo-content{
  190. height: 160px;
  191. padding: 12px;
  192. width: 300px;
  193. text-align: center;
  194. font-size: 14px;
  195. font-family: PingFangSC-Semibold, PingFang SC;
  196. .h-img{
  197. display: flex;
  198. justify-content: center;
  199. }
  200. .h-text{
  201. margin-top: 12px;
  202. font-weight: 400;
  203. color: #666666;
  204. }
  205. .text{
  206. margin-top: 6px;
  207. font-weight: 400;
  208. color: #666666;
  209. }
  210. .h-btn-wrap{
  211. display: flex;
  212. justify-content: space-between;
  213. color: #333333;
  214. text-align: center;
  215. margin-top: 14px;
  216. .h-left-btn{
  217. height: 32px;
  218. line-height: 30px;
  219. background: #EEEEEE;
  220. width: 100px;
  221. text-align: center;
  222. border-radius: 16px;
  223. margin: 0 auto;
  224. }
  225. .h-right-btn{
  226. height: 32px;
  227. line-height: 30px;
  228. background: #FFE05C;
  229. width: 100px;
  230. border-radius: 16px;
  231. margin: 0 auto;
  232. }
  233. }
  234. }
  235. </style>