authorize.vue 2.6 KB

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