index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view class="container">
  3. <view class="t-b">{{ headline }}</view>
  4. <view class="t-b2">欢迎使用车旅程,为你提供便捷服务</view>
  5. <!-- 中间登录注册按钮 -->
  6. <view class="login-btn-wrap">
  7. <u-button
  8. shape="circle"
  9. type="primary"
  10. :loading="loading"
  11. :customStyle="buttonStyleTop"
  12. @tap="login"
  13. >
  14. 微信用户一键登录
  15. </u-button>
  16. <u-button
  17. shape="circle"
  18. :customStyle="buttonStyleButton"
  19. @tap="$Router.push('/pages/login/phoneLogin')"
  20. >
  21. 手机号登录/注册
  22. </u-button>
  23. </view>
  24. <br />
  25. <!-- 底部协议 -->
  26. <view class="agree">
  27. <u-checkbox-group v-model="checked">
  28. <u-checkbox shape="circle" name="1" />
  29. </u-checkbox-group>
  30. <view>我已阅读并同意</view>
  31. <view @click="clickAgreement('用户协议')" class="agreement">《用户协议》</view>
  32. <view @click="clickAgreement('隐私政策')" class="agreement">《隐私政策》</view>
  33. </view>
  34. <!-- 第三方 -->
  35. <view class="t-f"><text>————— 第三方账号登录 —————</text></view>
  36. <view class="t-e cl">
  37. <view class="t-g" @click="$Router.push('/pages/login/phoneLogin')">
  38. <image src="@/static//icon/phone.png" />
  39. </view>
  40. <view class="t-g">
  41. <image src="@/static//icon/qq.png" />
  42. </view>
  43. </view>
  44. <!-- 用户协议 -->
  45. <userAgreement v-if="show" :title="title" :show="show" @handleConfirm="handleConfirm" />
  46. <u-modal
  47. @confirm="confirmTips"
  48. :show="showTips"
  49. title="确认提示"
  50. content="我已阅读并同意《用户协议》和 《隐私政策》"
  51. ></u-modal>
  52. </view>
  53. </template>
  54. <script>
  55. import { getWxLoginCode } from '@/api/login.js';
  56. import userAgreement from '@/components/userAgreement/userAgreement.vue';
  57. export default {
  58. components: {
  59. userAgreement,
  60. },
  61. data() {
  62. return {
  63. showTips: false,
  64. isUserAgreement: false,
  65. loading: false,
  66. headline: '欢迎登录车旅程!',
  67. form: {
  68. client_id: 'chelvc_client',
  69. client_secret: 'qWBe6jD%GCuPPTkP',
  70. grant_type: 'wechat',
  71. token: '',
  72. },
  73. checked: [],
  74. title: '',
  75. show: false,
  76. showUserAgreementDialog: false,
  77. showPrivacyPolicyDialog: false,
  78. buttonStyleTop: {
  79. 'font-size': '28rpx',
  80. background: '#5677fc',
  81. color: '#fff',
  82. height: '90rpx',
  83. 'line-height': '90rpx',
  84. 'border-radius': '50rpx',
  85. 'box-shadow': '0 5px 7px 0 rgba(86, 119, 252, 0.2)',
  86. marginTop: '30rpx',
  87. },
  88. buttonStyleButton: {
  89. 'font-size': '28rpx',
  90. background: '#fff',
  91. color: '#333',
  92. height: '90rpx',
  93. 'line-height': '90rpx',
  94. 'border-radius': '50rpx',
  95. 'box-shadow': '0 5px 7px 0 rgba(235, 237, 245, 0.2)',
  96. marginTop: '30rpx',
  97. },
  98. };
  99. },
  100. methods: {
  101. confirmUserAgreement() {
  102. // 确认按钮点击事件处理
  103. if (!this.checked.length) {
  104. this.showUserAgreementDialog = true;
  105. } else {
  106. this.showPrivacyPolicyDialog = true;
  107. }
  108. // 在确认按钮点击后执行页面跳转的代码
  109. this.$Router.back();
  110. },
  111. //点击用户协议
  112. clickAgreement(title) {
  113. this.show = true; //打开弹框
  114. this.title = title; //赋值标题
  115. },
  116. //点击用户协议弹框内的确定
  117. handleConfirm() {
  118. this.show = false; //关闭弹框
  119. },
  120. confirmTips() {
  121. this.showTips = false;
  122. this.checked = ['1'];
  123. this.login();
  124. },
  125. //点击微信用户一键登录
  126. async login() {
  127. console.log('this.checked', this.checked);
  128. if (this.checked && this.checked.length == 0) {
  129. // uni.$u.toast('请阅读并同意《用户协议》和 《隐私政策》');
  130. this.showTips = true;
  131. return;
  132. }
  133. if (this.checked.length !== 0) {
  134. this.loading = true;
  135. this.form.token = await getWxLoginCode();
  136. this.$store
  137. .dispatch('LoginByWxCode', this.form)
  138. .then(() => {
  139. uni.setStorageSync('tabbar_type', true);
  140. this.$Router.pushTab('/pages/client/tabBar/home/index');
  141. this.loading = false;
  142. uni.$u.toast('登录成功');
  143. })
  144. .catch(() => {
  145. this.loading = false;
  146. uni.$u.toast('登录失败');
  147. });
  148. } else {
  149. this.show = !this.show;
  150. }
  151. },
  152. confirm() {
  153. if (!this.checked.length) {
  154. this.showUserAgreementDialog = true;
  155. } else {
  156. this.showPrivacyPolicyDialog = true;
  157. }
  158. },
  159. closeUserAgreementDialog() {
  160. this.showUserAgreementDialog = false;
  161. },
  162. closePrivacyPolicyDialog() {
  163. this.showPrivacyPolicyDialog = false;
  164. },
  165. },
  166. };
  167. </script>
  168. <style scoped lang="scss">
  169. .container {
  170. height: 100vh;
  171. padding: 0 70rpx;
  172. background-color: #f2f5f9;
  173. .t-b {
  174. text-align: left;
  175. font-size: 46rpx;
  176. color: #000;
  177. padding: 150rpx 0 30rpx 0;
  178. font-weight: bold;
  179. }
  180. .t-b2 {
  181. text-align: left;
  182. font-size: 32rpx;
  183. color: #aaaaaa;
  184. padding: 0rpx 0 80rpx 0;
  185. }
  186. .login-btn-wrap {
  187. margin-top: 50rpx;
  188. width: 100%;
  189. }
  190. }
  191. .agree {
  192. display: flex;
  193. justify-content: center;
  194. align-items: center;
  195. font-size: 27rpx;
  196. margin-top: 20rpx;
  197. .agreement {
  198. color: #3c9cff;
  199. cursor: pointer;
  200. }
  201. }
  202. .t-f {
  203. text-align: center;
  204. margin: 200rpx 0 0 0;
  205. color: #666;
  206. text {
  207. margin-left: 20rpx;
  208. color: #aaaaaa;
  209. font-size: 27rpx;
  210. }
  211. }
  212. .t-e {
  213. text-align: center;
  214. width: 250rpx;
  215. margin: 20rpx auto 0;
  216. .t-g {
  217. float: left;
  218. width: 50%;
  219. }
  220. image {
  221. width: 50rpx;
  222. height: 50rpx;
  223. }
  224. }
  225. </style>