loginIndex.vue 9.1 KB

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