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.

230 lines
5.3 KiB

8 months ago
  1. <template>
  2. <view class="content">
  3. <view style="height: 166rpx; width: 100%;"></view>
  4. <view class="a1">手机号快捷登录</view>
  5. <view class="a2">美好服务即刻享受</view>
  6. <view class="a3" @click="clickStaff">
  7. <img width="100%" src="/static/logo.png" alt="" />
  8. </view>
  9. <view class="a4">上门服务服务平台</view>
  10. <button class="a5" @click="clickLogin()">微信一键注册登录</button>
  11. <view class="a6">
  12. <view class="a7">&check;</view>
  13. 已同意<span
  14. @click="keyValue = 'policy';
  15. configPopupShow = true">隐私政策</span>
  16. <span @click="keyValue = 'service';configPopupShow = true">服务条款</span>
  17. </view>
  18. <configPopup
  19. :keyValue="keyValue"
  20. :show="configPopupShow"
  21. :list="config"
  22. @close="configPopupShow = false"/>
  23. </view>
  24. </template>
  25. <script>
  26. import configPopup from '@/components/configPopup'
  27. export default {
  28. components : {
  29. configPopup
  30. },
  31. data() {
  32. return {
  33. step: 2,
  34. openid: '',
  35. code: undefined,
  36. configPopupShow : false,
  37. keyValue : '',
  38. config : []
  39. }
  40. },
  41. onLoad() {
  42. // this.getConfig()
  43. this.code = this.GetQueryString('code');
  44. if (!this.code) {
  45. this.getwx_authorize();
  46. }
  47. // if (this.code) {
  48. // this.toWxLogin(this.code)
  49. // }
  50. },
  51. methods: {
  52. clickCancel() {
  53. uni.navigateTo({
  54. url: '/pages/login/mobile'
  55. })
  56. },
  57. clickStaff() {
  58. uni.navigateTo({
  59. url: '/pages/staff/center'
  60. })
  61. },
  62. clickLogin() {
  63. this.code = this.GetQueryString('code');
  64. if (this.code) {
  65. //直接去登录发起请求
  66. this.toWxLogin(this.code)
  67. } else {
  68. //获取code 静默授权
  69. this.getwx_authorize();
  70. }
  71. },
  72. loginOrRegister(encryptData) {
  73. console.log('encryptData', encryptData);
  74. uni.setStorageSync("userid", "1")
  75. uni.switchTab({
  76. url: '/pages/index/index'
  77. })
  78. this.$httpGet("/wxma/getMobile", {
  79. encryptedData: encryptData
  80. }, (res) => {
  81. uni.setStorageSync("userid", "1")
  82. })
  83. },
  84. getwx_authorize() {
  85. // let vid = uni.getStorageSync("ivcode");
  86. //授权的回调地址
  87. let redirect_uri = encodeURIComponent(import.meta.env.VITE_REDIRECT_URI + '/#/pages/login/login');
  88. //这是我们公众号的appid
  89. let appid = import.meta.env.VITE_APPID;
  90. //静默授权
  91. window.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appid+'&redirect_uri='+redirect_uri+'&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect'+'&t='+new Date().getTime();
  92. //修改授权参数
  93. // window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid +
  94. // '&redirect_uri=' + redirect_uri + '&response_type=code&scope=snsapi_userinfo&state=' + vid +
  95. // '&connect_redirect=1#wechat_redirect';
  96. },
  97. //获取url中参数的方法
  98. GetQueryString(name) {
  99. var url = window.location.href;
  100. try {
  101. var cs = url.split('?')[1]; //获取?之后的参数字符串
  102. var cs_arr = cs.split('&'); //参数字符串分割为数组
  103. for (var i = 0; i < cs_arr.length; i++) { //遍历数组,拿到json对象
  104. if (cs_arr[i].split('=')[0] == name) {
  105. return cs_arr[i].split('=')[1];
  106. }
  107. }
  108. return "";
  109. } catch {
  110. return "";
  111. }
  112. },
  113. //微信登录
  114. toWxLogin(code) {
  115. this.vid = uni.getStorageSync("ivcode");
  116. this.$api('wxLogin', { code }, res=>{
  117. if(res.code == 200){
  118. uni.setStorageSync("token", res.result.token)
  119. uni.setStorageSync("userInfo", JSON.stringify(res.result.userInfo))
  120. location.href = import.meta.env.VITE_REDIRECT_URI + '/#/pages/index/index'
  121. }else{
  122. location.href = import.meta.env.VITE_REDIRECT_URI + '/#/pages/login/login'
  123. }
  124. })
  125. },
  126. getConfig() {
  127. this.vid = uni.getStorageSync("ivcode");
  128. this.$api('getConfig', {} ,res => {
  129. if(res.code == 200){
  130. this.config = res.result
  131. }
  132. })
  133. },
  134. }
  135. }
  136. </script>
  137. <style scoped>
  138. .a1 {
  139. width: 336rpx;
  140. height: 66rpx;
  141. line-height: 66rpx;
  142. font-size: 48rpx;
  143. font-family: PingFang SC, PingFang SC-Heavy;
  144. font-weight: 800;
  145. text-align: center;
  146. color: #333333;
  147. width: 100%;
  148. margin-bottom: 20rpx;
  149. }
  150. .a2 {
  151. width: 100%;
  152. height: 40rpx;
  153. line-height: 40rpx;
  154. font-size: 28rpx;
  155. font-family: PingFang SC, PingFang SC-Regular;
  156. font-weight: 400;
  157. text-align: center;
  158. color: #333333;
  159. margin-bottom: 100rpx;
  160. }
  161. .a3 {
  162. width: 148rpx;
  163. height: 148rpx;
  164. background: #51d0b4;
  165. border-radius: 16px;
  166. margin: 0 auto;
  167. overflow: hidden;
  168. }
  169. .a4 {
  170. height: 40rpx;
  171. font-size: 28rpx;
  172. font-family: PingFang SC, PingFang SC-Regular;
  173. font-weight: 400;
  174. text-align: center;
  175. color: #333333;
  176. margin-top: 20rpx;
  177. margin-bottom: 80rpx;
  178. }
  179. .a5 {
  180. width: 568rpx;
  181. height: 90rpx;
  182. background: #51d0b4;
  183. border-radius: 16rpx;
  184. margin: 0 auto;
  185. line-height: 90rpx;
  186. font-size: 28rpx;
  187. font-family: PingFang SC, PingFang SC-Regular;
  188. font-weight: 400;
  189. text-align: center;
  190. color: #ffffff;
  191. }
  192. .a6 {
  193. height: 34rpx;
  194. font-size: 24rpx;
  195. font-family: PingFang SC, PingFang SC-Medium;
  196. font-weight: 500;
  197. text-align: center;
  198. color: #333333;
  199. margin-top: 40rpx;
  200. }
  201. .a6 span {
  202. color: #6FDFBE;
  203. }
  204. .a7 {
  205. background-color: #6FDFBE;
  206. width: 34rpx;
  207. height: 34rpx;
  208. line-height: 34rpx;
  209. color: #fff;
  210. border-radius: 50%;
  211. display: inline-block;
  212. }
  213. </style>