多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
2.8 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <view class="container flex-items-plus flex-column">
  3. <view class="login-logoBox">
  4. <image class="login-logo" src="http://36.138.125.206:8081/ceres-local-file/image/logo_http://36.138.125.206:8081/ceres-local-filepng"></image>
  5. </view>
  6. <view class="loginTitle-text flex-column-plus flex-items font-color-666 fs26">
  7. <label>{{ $t('client.logindesc')}}</label>
  8. <label>{{ $t('client.logindesc1')}}~</label>
  9. </view>
  10. <view>
  11. <button class="loginWxBut fs28 mar-top-100" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">{{ $t('client.loginbywxphone')}}</button>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. const NET = require('../../utils/request')
  17. const API = require('../../config/api')
  18. export default {
  19. data() {
  20. return {
  21. avatarUrl:''
  22. }
  23. },
  24. onLoad(options) {
  25. this.avatarUrl = uni.getStorageSync('avatarUrl')
  26. },
  27. onBackPress(options) {
  28. this.back();
  29. return true;
  30. },
  31. methods: {
  32. back(){
  33. uni.switchTab({
  34. url: 'login'
  35. });
  36. },
  37. getPhoneNumber(e){
  38. if(e.detail.errMsg === "getPhoneNumber:ok"){
  39. const that = this
  40. uni.login({
  41. provider: 'weixin',
  42. success: (res) => {
  43. that.code = res.code
  44. NET.request(API.GetSessionKey,{
  45. code:that.code,
  46. },'POST').then(res1 => {
  47. NET.request(API.SetWxPhone,{
  48. wechatOpenId:res1.data.wechatOpenId,
  49. sessionKey:res1.data.sessionKey,
  50. encryptedData:e.detail.encryptedData,
  51. iv:e.detail.iv,
  52. headImage:this.avatarUrl
  53. },'POST').then(res2 => {
  54. const item = res2.data
  55. uni.setStorageSync('storage_key', item);
  56. setTimeout(function(){
  57. uni.switchTab({
  58. url:'../../pages/tabbar/user/index',
  59. success() {
  60. uni.hideLoading()
  61. }
  62. })
  63. },1000)
  64. }).catch(res => {
  65. })
  66. }).catch(err => {
  67. })
  68. },
  69. fail: () => {
  70. uni.showToast({
  71. title: "微信登录授权失败",
  72. icon: "none"
  73. });
  74. }
  75. })
  76. }else{
  77. uni.showToast({
  78. title: "获取手机授权失败",
  79. icon: "none"
  80. });
  81. }
  82. },
  83. }
  84. }
  85. </script>
  86. <style lang="scss">
  87. .container {
  88. .login-logoBox {
  89. margin-top: 154upx;
  90. .login-logo {
  91. width: 518upx;
  92. height: 100upx;
  93. }
  94. }
  95. .loginTitle-text {
  96. margin-top: 222upx;
  97. }
  98. .loginWxBut {
  99. background-image: linear-gradient(135deg, #FFA100 10%, #FF7911 100%);
  100. color: #FFFFFF;
  101. height: 88upx;
  102. width: 600upx;
  103. text-align: center;
  104. line-height: 88upx;
  105. border-radius: 88upx;
  106. margin-top: 49upx;
  107. }
  108. .loginBut {
  109. background-color: #FFFFFF;
  110. color: #C5AA7B;
  111. height: 88upx;
  112. width: 600upx;
  113. text-align: center;
  114. line-height: 88upx;
  115. border-radius: 88upx;
  116. border: 2upx solid #C5AA7B;
  117. margin-top: 30upx;
  118. }
  119. .register-text {
  120. color: #47A7EE;
  121. }
  122. }
  123. </style>