forgotPassword.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <view class="app">
  3. <view class="top-view">
  4. <image class="bg" src="/static/img/login-bg.png"></image>
  5. <view class="inner">
  6. <view class="statusBar" :style="'height:' + statusBarHeight + 'px'"></view>
  7. <view class="inner-body fx-h fx-bc fx-ac">
  8. <view class="prv" @tap="utils.navigateBack()">
  9. <image src="/static/img/ic_back_white.png" class="icon-back"></image>
  10. </view>
  11. <view class="logo">
  12. <image src="/static/img/cbb_white.png"></image>
  13. </view>
  14. <view class="label-text">忘记密码</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="body">
  19. <view class="h120"></view>
  20. <view class="input-view">
  21. <view class="login-input fx-r">
  22. <view class="left fx-r fx-bc ">
  23. <view class="label">+86</view>
  24. <image class="loginv" src="/static/img/login-v.png"></image>
  25. </view>
  26. <input type="number" v-model="form.mobile" placeholder="请输入手机号" />
  27. </view>
  28. <view class="login-input yzm fx-r fx-bc">
  29. <view class="left fx-h fx-ac">
  30. <image class="icon" style="margin-left: 20rpx;" src="/static/img/login-password.png"></image>
  31. </view>
  32. <input type="text" v-model="form.verify" placeholder="请输入验证码" />
  33. <view class="line"></view>
  34. <view v-if="verifyCount <= 0" class="sbtn" @tap="getVcode">验证码</view>
  35. <view v-else class="no-sbtn">{{ verifyCount }} S</view>
  36. </view>
  37. <view class="login-input pass fx-r fx-bc">
  38. <view class="left fx-h fx-ac">
  39. <image class="icon" style="margin-left: 20rpx;" src="/static/img/login-password.png"></image>
  40. </view>
  41. <input type="text" v-model="form.password" password="*" placeholder="请输入密码" />
  42. <view class="fx-g1"></view>
  43. <image @tap="showPass = !showPass" :src="showPass ? '/static/img/mis_pass.png' : '/static/img/ck_pass.png' " class="miss-pass"></image>
  44. </view>
  45. <view class="btn ihover" @tap="tapSubmit">确认修改</view>
  46. <view id="captcha"></view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <style lang="scss">
  52. page{background: #fff;}
  53. .top-view{
  54. position: relative;
  55. width: 100vw;
  56. height: 62vw;
  57. .bg{width: 100vw;height: 62vw;}
  58. .inner{
  59. position: absolute;
  60. width: 100%;
  61. height: 100%;
  62. top: 0;
  63. left: 0;
  64. .inner-body{
  65. position:relative;
  66. .prv{
  67. position: absolute;
  68. left: 20rpx;
  69. top: 20rpx;
  70. .icon-back{
  71. width: 60rpx;
  72. height: 60rpx;
  73. }
  74. }
  75. .logo{
  76. width: 200rpx;
  77. height: 119rpx;
  78. margin-bottom: 40rpx;
  79. margin-top: 60rpx;
  80. image{width: 100%;height: 100%;}
  81. }
  82. .label-text{
  83. font-size: 42rpx;
  84. color: #FFFFFF;
  85. }
  86. }
  87. }
  88. }
  89. .body{
  90. position: relative;
  91. background: #fff;
  92. border-radius: 80rpx 80rpx 0px 0px;
  93. top: -120rpx;
  94. z-index: 9;
  95. height: 500px;
  96. .h120{height: 100rpx;}
  97. .input-view{
  98. padding: 0px 60rpx;
  99. .login-input{
  100. border-radius: 70rpx;
  101. border: 1px solid #E0E0E0;
  102. padding: 30rpx 46rpx;
  103. margin-bottom: 50rpx;
  104. .left{
  105. .label{
  106. font-size: 28rpx;
  107. color: #DB292B;
  108. font-weight: bold;
  109. }
  110. .loginv{width: 15rpx;height: 12rpx;margin-left: 14rpx;}
  111. .icon{width: 30rpx;height: 33rpx;}
  112. width: 90rpx;
  113. }
  114. input{
  115. width: calc(100% - 90rpx);
  116. }
  117. &.yzm{
  118. input{
  119. width: calc(100% - 90rpx - 22rpx - 80rpx);
  120. }
  121. .line{
  122. width: 1px;
  123. height: 36rpx;
  124. background: #eee;
  125. margin-right: 20rpx;
  126. }
  127. .sbtn{
  128. font-size: 12px;
  129. color: #DB292B;
  130. }
  131. .no-sbtn{
  132. font-size: 12px;
  133. color: #999999;
  134. }
  135. }
  136. &.pass{
  137. input{
  138. width: calc(100% - 180rpx);
  139. }
  140. .miss-pass{width: 60rpx;height: 60rpx}
  141. }
  142. }
  143. }
  144. .btn{
  145. background: #DB292B;
  146. border-radius: 60rpx;
  147. text-align: center;
  148. font-weight: bold;
  149. font-size: 28rpx;
  150. padding: 30rpx 0;
  151. color: #FAFAFA;
  152. }
  153. .agament{
  154. margin-top: 40rpx;
  155. image{width: 36rpx;height: 36rpx;margin-right: 20rpx;}
  156. color: #999999;
  157. font-size:24rpx;
  158. text{color: #DB292B;}
  159. }
  160. }
  161. .miss-pass{width: 30px;height: 30px;}
  162. .mb-view{font-size: 14px; margin-top: 30px;padding: 0px 5px;}
  163. .mb-view .link{color: #DB292B;}
  164. </style>
  165. <script>
  166. import maoScroll from '@/components/mao-scroll/mao-scroll.vue';
  167. import customerWiget from '@/components/ui-public/customer-wiget.vue';
  168. import { mapState, mapMutations } from 'vuex';
  169. export default {
  170. components: {
  171. maoScroll,
  172. customerWiget
  173. },
  174. computed: {
  175. getWebSocket(){
  176. // #ifdef APP-PLUS
  177. const webSocket = getApp().globalData.webSocket
  178. // #endif
  179. // #ifndef APP-PLUS
  180. const webSocket = this.webSocket
  181. // #endif
  182. return webSocket
  183. }
  184. },
  185. data() {
  186. return {
  187. statusBarHeight: 20,
  188. form:{
  189. mobile : "",
  190. password : "",
  191. verify : ""
  192. },
  193. isRead : false,
  194. verifyCount : 0,
  195. showPass : false,
  196. captchaIns : null,
  197. validate : ""
  198. }
  199. },
  200. onLoad() {
  201. this.initView();
  202. this.$nextTick(()=>{
  203. this.initNeCaptcha();
  204. });
  205. },
  206. methods: {
  207. ...mapMutations(['setSys','setUser']),
  208. initView: function() {
  209. uni.getSystemInfo({
  210. success: (res) => {
  211. this.statusBarHeight = res.statusBarHeight;
  212. }
  213. });
  214. },
  215. initNeCaptcha () {
  216. // #ifdef H5
  217. const options = {
  218. captchaId: 'c6af8490405544f8a169504b11c86fdc',
  219. element: '#captcha',
  220. protocol: 'https',
  221. onVerify: (err, data) => {
  222. if(data != null || data != "") {
  223. this.validate = data.validate;
  224. this.getVcode2();
  225. }
  226. }
  227. }
  228. options.mode = 'popup';
  229. initNECaptcha({ ...options }, ins => {
  230. this.captchaIns = ins
  231. })
  232. // #endif
  233. // #ifdef APP
  234. this.captchaIns = uni.requireNativePlugin('YD-Captcha')
  235. this.captchaIns.init({
  236. captcha_id: 'c6af8490405544f8a169504b11c86fdc',
  237. is_no_sense_mode: false
  238. });
  239. // #endif
  240. },
  241. /**
  242. * 注册
  243. */
  244. tapReg:function(){
  245. uni.navigateTo({ url:"./register" });
  246. },
  247. getVcode:function(){
  248. if (this.verifyCount > 0) return;
  249. if (!this.utils.isPoneAvailable(this.form.mobile)) {
  250. return uni.showToast({
  251. title: '请输入正确的手机号码!',
  252. mask: true,
  253. icon: 'none'
  254. });
  255. }
  256. // #ifdef H5
  257. this.captchaIns.popUp();
  258. // #endif
  259. // #ifdef APP
  260. this.captchaIns.showCaptcha((data)=>{
  261. var method = data.method;
  262. if(method == "onSuccess"){
  263. var data = data.data;
  264. this.validate = data.validate;
  265. this.getVcode2();
  266. }
  267. })
  268. // #endif
  269. },
  270. getVcode2: function() {
  271. uni.showLoading({
  272. title: "获取中..."
  273. });
  274. this
  275. .request
  276. .post("findYzm", { mobile: this.form.mobile,validate : this.validate})
  277. .then(res => {
  278. uni.hideLoading();
  279. if (res.code == 200) {
  280. if (res.data.status == 2) {
  281. this.utils.CountDowm(res.data.time, (e, s) => {
  282. this.verifyCount = e;
  283. });
  284. }
  285. if (res.data.status == 1) {
  286. this.utils.CountDowm(120, (e, s) => {
  287. this.verifyCount = e;
  288. });
  289. }
  290. } else {
  291. uni.showToast({
  292. title: res.msg,
  293. mask: true,
  294. icon: 'none'
  295. });
  296. }
  297. })
  298. .catch(err => {
  299. uni.showToast({
  300. title: '获取失败',
  301. mask: true,
  302. icon: 'none'
  303. });
  304. uni.hideLoading();
  305. });
  306. },
  307. /**
  308. * 提交数据
  309. */
  310. tapSubmit:function(){
  311. //手机号码
  312. if(this.form.mobile == ""){
  313. uni.showToast({
  314. title:"请输入手机号码",icon:"none",mask:true
  315. })
  316. return;
  317. }
  318. //手机验证号码
  319. //this.form.mobile
  320. if(!this.utils.isPoneAvailable(this.form.mobile) ){
  321. uni.showToast({
  322. title:"请输入正确的手机号码",icon:"none",mask:true
  323. })
  324. return;
  325. }
  326. if (this.form.password == '') {
  327. uni.showToast({
  328. title: '请输入密码',
  329. mask: true,
  330. icon: 'none'
  331. });
  332. return;
  333. }
  334. uni.showLoading({ title: '登录中..' });
  335. this.request
  336. .post("findPassword",this.form)
  337. .then(res=>{
  338. uni.hideLoading();
  339. if(res.code == 200) {
  340. this.setUser(res.data);
  341. this.getWebSocket.connect();
  342. uni.reLaunch({ url:"../index/index"});
  343. } else {
  344. uni.showToast({ title:res.msg,icon:"none",mask:true});
  345. }
  346. })
  347. .catch(res=>{
  348. uni.hideLoading();
  349. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  350. });
  351. }
  352. }
  353. }
  354. </script>