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.

242 lines
5.4 KiB

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