loginIndex.vue 8.3 KB

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