index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view class="wrapper" :style="colorStyle">
  3. <view class="bag">
  4. <img :src="imgHost+'/statics/images/users/login-bg.jpg'" alt="" srcset="">
  5. </view>
  6. <!-- #ifdef MP -->
  7. <view class="title-bar" style="height: 43px;">
  8. <view class="icon" @click="back" v-if="!isHome">
  9. <image src="../static/left.png"></image>
  10. </view>
  11. <view class="icon" @click="home" v-else>
  12. <image src="../static/home.png"></image>
  13. </view>
  14. {{pageTitle}}
  15. </view>
  16. <!-- #endif -->
  17. <view class="page-msg">
  18. <view class="title">
  19. 找回密码
  20. </view>
  21. <view class="tip"></view>
  22. </view>
  23. <view class="page-form">
  24. <view class="item">
  25. <input type='number' placeholder='请输入手机号码' placeholder-class='placeholder' v-model="account"
  26. :maxlength="11"></input>
  27. </view>
  28. <view class="item acea-row row-between-wrapper">
  29. <input type='number' placeholder='请输入验证码' placeholder-class='placeholder' :maxlength="6"
  30. class="codeIput" v-model="captcha"></input>
  31. <view class="line">
  32. </view>
  33. <button class="code font-num" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
  34. {{ text }}
  35. </button>
  36. </view>
  37. <view class="item">
  38. <input type='password' placeholder='请输入密码' placeholder-class='placeholder' v-model="password"
  39. :maxlength="28"></input>
  40. </view>
  41. <view class="item">
  42. <input type='password' placeholder='请再次确认密码' placeholder-class='placeholder' v-model="passwordAgain"
  43. :maxlength="28"></input>
  44. </view>
  45. <view class="btn" @click="registerReset">
  46. 确认
  47. </view>
  48. <view class="text-center fs-32 text--w111-999 mt-32" @click="back">立即登录</view>
  49. </view>
  50. <Verify @success="success" :captchaType="'blockPuzzle'" :imgSize="{ width: '330px', height: '155px' }"
  51. ref="verify"></Verify>
  52. </view>
  53. </template>
  54. <script>
  55. import sendVerifyCode from "@/mixins/SendVerifyCode";
  56. import colors from '@/mixins/color.js';
  57. import Verify from '../components/verify/verify.vue';
  58. import {
  59. registerVerify,
  60. registerReset,
  61. getCodeApi
  62. } from "@/api/user";
  63. import { HTTP_REQUEST_URL } from '@/config/app';
  64. export default {
  65. name: "RetrievePassword",
  66. components: {
  67. Verify
  68. },
  69. data: function() {
  70. return {
  71. account: "",
  72. password: "",
  73. passwordAgain:'',
  74. captcha: "",
  75. keyCode: "",
  76. codeUrl: "",
  77. codeVal: "",
  78. isShowCode: false,
  79. imgHost: HTTP_REQUEST_URL,
  80. type:'register'
  81. };
  82. },
  83. mixins: [sendVerifyCode,colors],
  84. mounted: function() {
  85. // this.getCode();
  86. },
  87. methods: {
  88. back() {
  89. uni.navigateBack();
  90. },
  91. again() {
  92. this.codeUrl =
  93. VUE_APP_API_URL + "/captcha?" + this.keyCode + Date.parse(new Date());
  94. },
  95. async registerReset() {
  96. var that = this;
  97. if (!that.account) return that.$util.Tips({
  98. title: '请填写手机号码'
  99. });
  100. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  101. title: '请输入正确的手机号码'
  102. });
  103. if (!that.captcha) return that.$util.Tips({
  104. title: '请填写验证码'
  105. });
  106. if (!that.password) return that.$util.Tips({
  107. title: '请填写新密码'
  108. });
  109. if (that.password != that.passwordAgain) return that.$util.Tips({
  110. title: '两次密码不一致'
  111. });
  112. registerReset({
  113. account: that.account,
  114. captcha: that.captcha,
  115. password: that.password,
  116. code: that.codeVal
  117. })
  118. .then(res => {
  119. that.$util.Tips({
  120. title: res.msg
  121. }, {
  122. tab: 3
  123. })
  124. })
  125. .catch(res => {
  126. that.$util.Tips({
  127. title: res
  128. })
  129. });
  130. },
  131. success(data) {
  132. console.log(data,'data');
  133. this.$refs.verify.hide()
  134. getCodeApi()
  135. .then(res => {
  136. this.keyCode = res.data.key;
  137. this.getCode(data);
  138. })
  139. .catch(res => {
  140. this.$util.Tips({
  141. title: res
  142. });
  143. });
  144. },
  145. code(data) {
  146. let that = this;
  147. if (!that.account) return that.$util.Tips({
  148. title: '请填写手机号码'
  149. });
  150. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  151. title: '请输入正确的手机号码'
  152. });
  153. this.$refs.verify.show()
  154. },
  155. async getCode(data){
  156. console.log('data-------',data);
  157. let that = this;
  158. await registerVerify({
  159. phone: that.account,
  160. type: that.type,
  161. key: that.keyCode,
  162. captchaType: 'blockPuzzle',
  163. captchaVerification: data.captchaVerification,
  164. })
  165. .then(res => {
  166. that.$util.Tips({
  167. title: res.msg
  168. });
  169. that.sendCode();
  170. })
  171. .catch(res => {
  172. that.$util.Tips({
  173. title: res
  174. });
  175. });
  176. },
  177. }
  178. };
  179. </script>
  180. <style lang="scss" scoped>
  181. .wrapper {
  182. background-color: #fff;
  183. min-height: 100vh;
  184. position: relative;
  185. .bag {
  186. position: absolute;
  187. top: 0;
  188. left: 0;
  189. width: 100%;
  190. z-index: 0;
  191. /* #ifdef H5 */
  192. z-index: 0;
  193. /* #endif */
  194. img {
  195. width: 100%;
  196. height: 544rpx;
  197. }
  198. }
  199. .page-msg {
  200. padding-top: 160rpx;
  201. margin-left: 72rpx;
  202. z-index: 2;
  203. position: relative;
  204. .title {
  205. font-size: 48rpx;
  206. font-weight: 500;
  207. color: #333333;
  208. line-height: 68rpx;
  209. }
  210. .tip {
  211. font-size: 28rpx;
  212. font-weight: 400;
  213. color: #333333;
  214. line-height: 40rpx;
  215. }
  216. }
  217. .page-form {
  218. width: 606rpx;
  219. margin: 100rpx auto 0 auto;
  220. z-index: 2;
  221. position: relative;
  222. .item {
  223. width: 100%;
  224. height: 88rpx;
  225. background: #F5F5F5;
  226. border-radius: 45rpx;
  227. padding: 24rpx 48rpx;
  228. margin-bottom: 32rpx;
  229. input {
  230. width: 100%;
  231. height: 100%;
  232. font-size: 32rpx;
  233. }
  234. .placeholder {
  235. color: #BBBBBB;
  236. font-size: 28rpx;
  237. }
  238. input.codeIput {
  239. width: 300rpx;
  240. }
  241. .line {
  242. width: 2rpx;
  243. height: 28rpx;
  244. background: #CCCCCC;
  245. }
  246. .code {
  247. font-size: 28rpx;
  248. color: var(--view-theme);
  249. background-color: rgba(255, 255, 255, 0);
  250. }
  251. .code.on {
  252. color: #BBBBBB !important;
  253. }
  254. }
  255. .btn {
  256. width: 606rpx;
  257. height: 88rpx;
  258. background: var(--view-theme);
  259. border-radius: 200rpx 200rpx 200rpx 200rpx;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. font-size: 32rpx;
  264. font-family: PingFang SC-Regular, PingFang SC;
  265. font-weight: 400;
  266. color: #FFFFFF;
  267. line-height: 44rpx;
  268. margin-top: 48rpx;
  269. letter-spacing: 1px;
  270. }
  271. }
  272. }
  273. .title-bar {
  274. position: relative;
  275. display: flex;
  276. align-items: center;
  277. justify-content: center;
  278. font-size: 34rpx;
  279. font-weight: 500;
  280. color: #333333;
  281. line-height: 48rpx;
  282. }
  283. .icon {
  284. position: absolute;
  285. left: 30rpx;
  286. top: 0;
  287. display: flex;
  288. align-items: center;
  289. justify-content: center;
  290. width: 80rpx;
  291. height: 80rpx;
  292. image {
  293. width: 35rpx;
  294. height: 35rpx;
  295. }
  296. }
  297. </style>