authorize.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view>
  3. <view style="padding: 77rpx 77rpx 0rpx;box-sizing: border-box;">
  4. <!--pages/authorize/authorize.wxml-->
  5. <block>
  6. <view class="authorize-title">
  7. <view>您好,</view>
  8. <view>欢迎使用皮小电商家版</view>
  9. </view>
  10. <view style="margin-top: 50rpx;">
  11. <view class="input-box">
  12. <input v-model="userName" placeholder="请输入账号"/>
  13. </view>
  14. <view class="input-box ddflex">
  15. <input v-model="passWord" type="text" class="fflex" :password="!showPassword" placeholder="请输入密码" value="" />
  16. <view style="padding: 10rpx;">
  17. <image v-if="showPassword" @click="showPassword=false" style="width: 34rpx;height: 15rpx;margin-left: 10rpx;" src="../../static/pages/images/close-eyes.png"></image>
  18. <image v-else @click="showPassword=true" style="width: 31rpx;height: 23rpx;margin-left: 10rpx;" src="../../static/pages/images/open-eyes.png"></image>
  19. </view>
  20. </view>
  21. </view>
  22. <button class="login" @click="submitLogin()">授权登录</button>
  23. </block>
  24. </view>
  25. <view class="dflex" style="margin: 0 77rpx 0 47rpx;">
  26. <view v-if='agree' class="agree-icon" @click="agree=false">
  27. <image style="width: 100%;height: 100%;" src="../../static/pages/images/agree_h.png" ></image>
  28. </view>
  29. <view v-else class="agree-icon" @click="agree=true">
  30. <image style="width: 100%;height: 100%;" src="../../static/pages/images/agree.png" ></image>
  31. </view>
  32. <view hover-class="none" class="xieyi fflex">
  33. 已阅读并同意
  34. <text @click="jump('/mine/page/page?title=用户协议&isXieyi=true')">《皮小电用户服务协议》</text>
  35. <text @click="jump('/mine/page/page?title=隐私声明&isYinsi=true')">《皮小电隐私协议》</text>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. // pages/authorize/authorize.js
  42. const app = getApp();
  43. const req = require('../../utils/request.js');
  44. export default {
  45. data() {
  46. return {
  47. showPassword:false,
  48. agree:false,
  49. userName:'',
  50. passWord:''
  51. };
  52. },
  53. components: {},
  54. props: {},
  55. onLoad: function(options) {
  56. },
  57. onShow: function() {
  58. },
  59. onUnload: function() {
  60. },
  61. methods: {
  62. jump(url) {
  63. uni.navigateTo({
  64. url: url
  65. });
  66. },
  67. submitLogin(){
  68. if(!this.userName) return req.msg('请输入账号')
  69. if(!this.passWord) return req.msg('请输入密码')
  70. if(!this.agree) return req.msg('请阅读以下协议')
  71. let dataP = {
  72. account:this.userName,
  73. password:this.passWord
  74. }
  75. req.postRequest('/admin/v2/login',dataP,res=>{
  76. let params = res;
  77. req.setStorage('userInfo', params);
  78. req.setStorage('AUTH_TOKEN', params.token);
  79. console.log(params.token)
  80. req.msg('登陆成功')
  81. uni.$emit('reSetLogin',true)
  82. setTimeout(()=>{
  83. uni.navigateBack()
  84. },500)
  85. })
  86. }
  87. }
  88. };
  89. </script>
  90. <style>
  91. @import './authorize.css';
  92. </style>