loginIndex.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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: '../course/video/living-app',
  124. animationType: 'none',
  125. animationDuration: 2000
  126. })
  127. }
  128. // #ifdef APP-PLUS
  129. let curAgreePrivacy = this.$isAgreePrivacy();
  130. if (curAgreePrivacy) {
  131. this.getRegistrationID();
  132. }
  133. // #endif
  134. },
  135. methods: {
  136. getRegistrationID() {
  137. this.curRegistrationID = uni.getStorageSync('registrationID');
  138. if (!this.curRegistrationID) {
  139. uni.getPushClientId({
  140. success: (res) => {
  141. uni.setStorageSync('registrationID', res.cid);
  142. this.curRegistrationID = res.cid;
  143. }
  144. });
  145. }
  146. },
  147. checkWechatInstalled,
  148. quickClick(type) {
  149. this.quickLoginType = type;
  150. this.show = true;
  151. },
  152. quickLogin() {
  153. this.agree = true;
  154. if (this.quickLoginType == 1) {
  155. quickWechatLogin(false);
  156. }
  157. if (this.quickLoginType == 2) {
  158. quickAppleLogin(false);
  159. }
  160. },
  161. goToWeb(index) {
  162. uni.setStorageSync('url', index == 0 ? "https://userapp.his.cdwjyyh.com/web/userAgreement" :
  163. "https://userapp.his.cdwjyyh.com/web/privacyPolicy");
  164. uni.navigateTo({
  165. url: "/pages/index/h5"
  166. })
  167. },
  168. // 同意
  169. handleAgree() {
  170. this.agree = !this.agree
  171. },
  172. // login
  173. submit() {
  174. // if(!this.agree) {
  175. // this.$refs.popup.open('center')
  176. // return
  177. // }
  178. this.$showLoginPage()
  179. // uni.preLogin({
  180. // provider: 'univerify',
  181. // success() { //预登录成功
  182. // // 显示一键登录选项
  183. // uni.showToast({
  184. // title: "登录成功",
  185. // icon: "none"
  186. // })
  187. // uni.login({
  188. // provider: 'univerify',
  189. // univerifyStyle: { // 自定义登录框样式
  190. // fullScreen: true,
  191. // },
  192. // success(res) { // 登录成功 在该回调中请求后端接口,将access_token传给后端
  193. // console.log(res.authResult); // {openid:'登录授权唯一标识',access_token:'接口返回的 token'}
  194. // },
  195. // fail(res) { // 登录失败
  196. // console.log(res.errCode)
  197. // console.log(res.errMsg)
  198. // }
  199. // })
  200. // },
  201. // fail(res) { // 预登录失败
  202. // // 跳转到普通登录
  203. // uni.navigateTo({
  204. // url: "/pages/login/otherLogin"
  205. // })
  206. // // 根据错误信息判断失败原因,如有需要可将错误提交给统计服务器
  207. // console.log(res.errCode)
  208. // console.log(res.errMsg)
  209. // }
  210. // })
  211. },
  212. handleOtherLogin() {
  213. uni.redirectTo({
  214. url: "/pages/auth/login"
  215. })
  216. },
  217. // 关闭弹窗
  218. close(val) {
  219. this.$refs.popup.close()
  220. if (val == 'agree') {
  221. this.agree = true
  222. this.submit()
  223. }
  224. }
  225. }
  226. }
  227. </script>
  228. <style>
  229. page {
  230. background-color: #fff;
  231. }
  232. </style>
  233. <style scoped lang="scss">
  234. @mixin u-flex($flexD, $alignI, $justifyC) {
  235. display: flex;
  236. flex-direction: $flexD;
  237. align-items: $alignI;
  238. justify-content: $justifyC;
  239. }
  240. .container {
  241. height: 100vh;
  242. padding: 0 64rpx;
  243. padding-top: calc(var(--status-bar-height) + 88rpx);
  244. padding-bottom: calc(var(--window-bottom) + 20rpx);
  245. box-sizing: border-box;
  246. }
  247. .popupbox {
  248. font-family: PingFang SC, PingFang SC;
  249. font-weight: 400;
  250. font-size: 30rpx;
  251. color: #999999;
  252. line-height: 38rpx;
  253. background-color: #fff;
  254. width: 600rpx;
  255. padding: 60rpx 30rpx 10rpx 30rpx;
  256. border-radius: 15rpx;
  257. box-sizing: border-box;
  258. text {
  259. color: #FF5C03;
  260. }
  261. .popupbox-footer {
  262. padding: 30rpx 0;
  263. @include u-flex(row, center, center);
  264. }
  265. .popupbox-btn {
  266. width: 200rpx;
  267. height: 68rpx;
  268. background: #fff;
  269. font-size: 28rpx;
  270. border-radius: 44rpx 44rpx 44rpx 44rpx;
  271. text-align: center;
  272. line-height: 66rpx;
  273. border: 1rpx solid #999;
  274. color: #999;
  275. }
  276. .agree-btn {
  277. background: linear-gradient(270deg, #FF5C03 0%, #FFAC64 100%);
  278. border: none;
  279. color: #fff;
  280. }
  281. }
  282. .login-title {
  283. font-family: PingFang SC, PingFang SC;
  284. font-weight: 600;
  285. font-size: 56rpx;
  286. color: #333333;
  287. line-height: 78rpx;
  288. padding-top: 40rpx;
  289. }
  290. .logoimage {
  291. @include u-flex(row, center, center);
  292. margin-top: 5vh;
  293. image {
  294. height: 100rpx;
  295. width: 100rpx;
  296. }
  297. }
  298. .login-box {
  299. margin-top: 16vh;
  300. font-family: PingFang SC, PingFang SC;
  301. font-weight: 400;
  302. font-size: 28rpx;
  303. color: #333333;
  304. text-align: center;
  305. .phone {
  306. font-weight: 500;
  307. font-size: 56rpx;
  308. }
  309. .tips {
  310. margin-top: 18rpx;
  311. color: #757575;
  312. }
  313. }
  314. .checkbox {
  315. margin-top: 36rpx;
  316. @include u-flex(row, flex-start, flex-start);
  317. font-family: PingFang SC, PingFang SC;
  318. font-weight: 400;
  319. font-size: 26rpx;
  320. color: #999999;
  321. line-height: 38rpx;
  322. text-align: left;
  323. text {
  324. color: #FF5C03;
  325. }
  326. &-icon {
  327. flex-shrink: 0;
  328. margin-right: 12rpx;
  329. image {
  330. height: 40rpx;
  331. width: 40rpx;
  332. }
  333. }
  334. }
  335. .login-btn {
  336. min-width: 622rpx;
  337. height: 88rpx;
  338. margin-top: 40rpx;
  339. line-height: 88rpx;
  340. text-align: center;
  341. background: linear-gradient(270deg, #FF5C03 0%, #FFAC64 100%);
  342. border-radius: 44rpx 44rpx 44rpx 44rpx;
  343. font-family: PingFang SC, PingFang SC;
  344. font-weight: 600;
  345. font-size: 32rpx;
  346. color: #FFFFFF !important;
  347. &::after {
  348. border: none;
  349. }
  350. }
  351. .apple-login-btn {
  352. background: #fff;
  353. border: 2rpx solid #000000;
  354. color: #000 !important;
  355. }
  356. .other-login-btn {
  357. background: #fff;
  358. border: 2rpx solid #ECECEC;
  359. color: #333333 !important;
  360. }
  361. .popupBox {
  362. padding: 48rpx 24rpx;
  363. width: 500rpx;
  364. flex-direction: column;
  365. .colorFF5C03 {
  366. color: #FF5C03;
  367. }
  368. .popupbox-btn {
  369. width: 100%;
  370. border-radius: 8rpx;
  371. text-align: center;
  372. height: 88rpx;
  373. line-height: 88rpx;
  374. background-color: #FF5C03;
  375. }
  376. }
  377. </style>