loginIndex.vue 6.9 KB

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