forgotPassword.nvue 8.2 KB

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