loginIndex.vue 9.7 KB

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