loginIndex.vue 6.9 KB

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