loginIndex.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <view class="container">
  3. <view class="login-title">
  4. <view>您好,</view>
  5. <view>欢迎来到河山恒康!</view>
  6. </view>
  7. <!-- <view class="logoimage"><image src="/static/logo.png" mode="aspectFill"></image></view> -->
  8. <view class="login-box">
  9. <!-- <view class="phone">187****8783</view>
  10. <view class="tips">认证服务由中国移动统一认证提供</view> -->
  11. <button class="login-btn x-c" style="margin-top: 74rpx;" :loading="btnLoading" :disabled="btnLoading"
  12. @click="show=true">
  13. <image class="es-icon-50 es-mr-10" src="/static/images/icon_wx.png"></image>
  14. <text>微信快捷登录</text>
  15. </button>
  16. <button class="login-btn other-login-btn" :loading="btnLoading" :disabled="btnLoading"
  17. @click="submit()">手机号一键登录</button>
  18. <button class="login-btn other-login-btn" :disabled="btnLoading" @tap="handleOtherLogin">其他方式登录</button>
  19. <view class="checkbox">
  20. <view class="checkbox-icon" @tap="handleAgree">
  21. <image src="../../static/image/login/radio_default.png" v-show="!agree"></image>
  22. <image src="../../static/image/login/radio_choose.png" v-show="agree"></image>
  23. </view>
  24. <view class="es-fs-36" @tap="handleAgree">我已阅读并同意<text @tap.stop="goToWeb(0)">《用户协议》</text><text @tap.stop="goToWeb(1)">《隐私政策》</text> 并使用本机号码登录</view>
  25. </view>
  26. </view>
  27. <u-popup :show="show" :safeAreaInsetBottom="false" mode="center" round="16rpx" @close="show=false">
  28. <view class="popupBox u-f-ajc">
  29. <view class="es-c-33 es-fs-32 es-fw ">
  30. 用户协议及隐私协议
  31. </view>
  32. <view class="es-mt-40 es-fs-24">
  33. 已阅读并同意<text class="colorFF5C03" @tap="goToWeb(0)"> 用户协议 </text>和<text class="colorFF5C03"
  34. @tap="goToWeb(1)">隐私政策</text>
  35. </view>
  36. <view class="es-mt-40 popupbox-btn es-c-white" @tap="wechatLogin">
  37. 同意并登录
  38. </view>
  39. <view class="es-mt-40 es-fs-24 es-c-99" @tap="show=false">
  40. 不同意
  41. </view>
  42. </view>
  43. </u-popup>
  44. </view>
  45. </template>
  46. <script>
  47. import {
  48. navBack
  49. } from "../../utils/common";
  50. import {
  51. login
  52. } from "@/api/user.js"
  53. import {
  54. quickWechatLogin
  55. } from "@/utils/login.js"
  56. export default {
  57. data() {
  58. return {
  59. btnLoading: false,
  60. agree: false,
  61. show: false,
  62. }
  63. },
  64. onLoad() {
  65. if (!this.$isLogin()) {
  66. let pages = getCurrentPages();
  67. let url = pages[pages.length - 3];
  68. if (pages.length > 2 && url && (url.route == "pages/auth/login" || url.route == "pages/auth/loginIndex" ||
  69. url.route == "pages/common/launch")) {
  70. uni.navigateBack({
  71. delta: 2
  72. });
  73. } else {
  74. // #ifdef APP-PLUS
  75. //this.submit()
  76. // #endif
  77. // #ifndef APP-PLUS
  78. if (String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger") {
  79. const pages = getCurrentPages();
  80. if (pages.length > 1) {
  81. const url = pages[pages.length - 2];
  82. const options = url.options //url中所带的参数
  83. //拼接url的参数
  84. if (options && JSON.stringify(options) != '{}') {
  85. let allurl = '/' + url.route + uni.$u.queryParams(options)
  86. uni.setStorageSync('beforLoginPage', allurl)
  87. } else {
  88. uni.setStorageSync('beforLoginPage', '/' + url.route);
  89. }
  90. uni.redirectTo({
  91. url: "/pages/auth/h5WxLogin"
  92. });
  93. } else {
  94. this.submit()
  95. }
  96. } else {
  97. uni.redirectTo({
  98. url: "/pages/auth/login"
  99. })
  100. }
  101. // #endif
  102. }
  103. }
  104. },
  105. onShow() {
  106. if (this.$isLogin()) {
  107. uni.reLaunch({
  108. url: '/pages_im/pages/conversation/conversationList/index',
  109. //url: '../course/video/living-app',
  110. animationType: 'none',
  111. animationDuration: 2000
  112. })
  113. }
  114. },
  115. methods: {
  116. wechatLogin() {
  117. this.agree=true;
  118. quickWechatLogin(false)
  119. },
  120. goToWeb(index) {
  121. uni.setStorageSync('url', index == 0 ? "https://userapp.his.cdwjyyh.com/web/userAgreement" :
  122. "https://userapp.his.cdwjyyh.com/web/privacyPolicy");
  123. uni.navigateTo({
  124. url: "/pages/index/h5"
  125. })
  126. },
  127. // 同意
  128. handleAgree() {
  129. this.agree = !this.agree
  130. },
  131. // login
  132. submit() {
  133. // if(!this.agree) {
  134. // this.$refs.popup.open('center')
  135. // return
  136. // }
  137. this.$showLoginPage()
  138. // uni.preLogin({
  139. // provider: 'univerify',
  140. // success() { //预登录成功
  141. // // 显示一键登录选项
  142. // uni.showToast({
  143. // title: "登录成功",
  144. // icon: "none"
  145. // })
  146. // uni.login({
  147. // provider: 'univerify',
  148. // univerifyStyle: { // 自定义登录框样式
  149. // fullScreen: true,
  150. // },
  151. // success(res) { // 登录成功 在该回调中请求后端接口,将access_token传给后端
  152. // console.log(res.authResult); // {openid:'登录授权唯一标识',access_token:'接口返回的 token'}
  153. // },
  154. // fail(res) { // 登录失败
  155. // console.log(res.errCode)
  156. // console.log(res.errMsg)
  157. // }
  158. // })
  159. // },
  160. // fail(res) { // 预登录失败
  161. // // 跳转到普通登录
  162. // uni.navigateTo({
  163. // url: "/pages/login/otherLogin"
  164. // })
  165. // // 根据错误信息判断失败原因,如有需要可将错误提交给统计服务器
  166. // console.log(res.errCode)
  167. // console.log(res.errMsg)
  168. // }
  169. // })
  170. },
  171. handleOtherLogin() {
  172. uni.redirectTo({
  173. url: "/pages/auth/login"
  174. })
  175. },
  176. // 关闭弹窗
  177. close(val) {
  178. this.$refs.popup.close()
  179. if (val == 'agree') {
  180. this.agree = true
  181. this.submit()
  182. }
  183. }
  184. }
  185. }
  186. </script>
  187. <style>
  188. page {
  189. background-color: #fff;
  190. }
  191. </style>
  192. <style scoped lang="scss">
  193. @mixin u-flex($flexD, $alignI, $justifyC) {
  194. display: flex;
  195. flex-direction: $flexD;
  196. align-items: $alignI;
  197. justify-content: $justifyC;
  198. }
  199. .container {
  200. height: 100vh;
  201. padding: 0 64rpx;
  202. padding-top: calc(var(--status-bar-height) + 88rpx);
  203. padding-bottom: calc(var(--window-bottom) + 20rpx);
  204. box-sizing: border-box;
  205. }
  206. .popupbox {
  207. font-family: PingFang SC, PingFang SC;
  208. font-weight: 400;
  209. font-size: 30rpx;
  210. color: #999999;
  211. line-height: 38rpx;
  212. background-color: #fff;
  213. width: 600rpx;
  214. padding: 60rpx 30rpx 10rpx 30rpx;
  215. border-radius: 15rpx;
  216. box-sizing: border-box;
  217. text {
  218. color: #2583EB;
  219. }
  220. .popupbox-footer {
  221. padding: 30rpx 0;
  222. @include u-flex(row, center, center);
  223. }
  224. .popupbox-btn {
  225. width: 200rpx;
  226. height: 68rpx;
  227. background: #fff;
  228. font-size: 28rpx;
  229. border-radius: 44rpx 44rpx 44rpx 44rpx;
  230. text-align: center;
  231. line-height: 66rpx;
  232. border: 1rpx solid #999;
  233. color: #999;
  234. }
  235. .agree-btn {
  236. background: linear-gradient(270deg, #2583EB 0%, #5a9ceb 100%);
  237. border: none;
  238. color: #fff;
  239. }
  240. }
  241. .login-title {
  242. font-family: PingFang SC, PingFang SC;
  243. font-weight: 600;
  244. font-size: 56rpx;
  245. color: #333333;
  246. line-height: 78rpx;
  247. padding-top: 40rpx;
  248. }
  249. .logoimage {
  250. @include u-flex(row, center, center);
  251. margin-top: 5vh;
  252. image {
  253. height: 100rpx;
  254. width: 100rpx;
  255. }
  256. }
  257. .login-box {
  258. margin-top: 16vh;
  259. font-family: PingFang SC, PingFang SC;
  260. font-weight: 400;
  261. font-size: 28rpx;
  262. color: #333333;
  263. text-align: center;
  264. .phone {
  265. font-weight: 500;
  266. font-size: 56rpx;
  267. }
  268. .tips {
  269. margin-top: 18rpx;
  270. color: #757575;
  271. }
  272. }
  273. .checkbox {
  274. margin-top: 36rpx;
  275. @include u-flex(row, flex-start, flex-start);
  276. font-family: PingFang SC, PingFang SC;
  277. font-weight: 400;
  278. font-size: 26rpx;
  279. color: #999999;
  280. line-height: 38rpx;
  281. text-align: left;
  282. text {
  283. color: #2583EB;
  284. }
  285. &-icon {
  286. flex-shrink: 0;
  287. margin-right: 12rpx;
  288. image {
  289. height: 40rpx;
  290. width: 40rpx;
  291. }
  292. }
  293. }
  294. .login-btn {
  295. min-width: 622rpx;
  296. height: 88rpx;
  297. margin-top: 40rpx;
  298. line-height: 88rpx;
  299. text-align: center;
  300. background: linear-gradient(270deg, #2583EB 0%, #FFAC64 100%);
  301. border-radius: 44rpx 44rpx 44rpx 44rpx;
  302. font-family: PingFang SC, PingFang SC;
  303. font-weight: 600;
  304. font-size: 32rpx;
  305. color: #FFFFFF !important;
  306. &::after {
  307. border: none;
  308. }
  309. }
  310. .other-login-btn {
  311. background: #fff;
  312. border: 2rpx solid #ECECEC;
  313. color: #333333 !important;
  314. }
  315. .popupBox {
  316. padding: 48rpx 24rpx;
  317. width: 500rpx;
  318. flex-direction: column;
  319. .colorFF5C03 {
  320. color: #2583EB;
  321. }
  322. .popupbox-btn {
  323. width: 100%;
  324. border-radius: 8rpx;
  325. text-align: center;
  326. height: 88rpx;
  327. line-height: 88rpx;
  328. background-color: #2583EB;
  329. }
  330. }
  331. </style>