forgotPassword.nvue 8.3 KB

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