index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view class="appBox">
  3. <div class="shading">
  4. <image :src="logoUrl" v-if="logoUrl" />
  5. <image src="/static/images/logo2.png" v-else />
  6. </div>
  7. <mobileLogin :isUp="isUp" :isShow="isShow" :platform="platform" :isPos="isPos" :appleShow="appleShow" :authKey="authKey" @wechatPhone="wechatPhone"></mobileLogin>
  8. </view>
  9. </template>
  10. <script>
  11. const app = getApp();
  12. import sendVerifyCode from "@/mixins/SendVerifyCode";
  13. import Routine from '@/libs/routine';
  14. import {
  15. loginMobile,
  16. registerVerify,
  17. getCodeApi,
  18. getUserInfo,
  19. phoneSilenceAuth,
  20. phoneWxSilenceAuth
  21. } from "@/api/user";
  22. import {
  23. bindingPhone
  24. } from '@/api/api.js'
  25. import {
  26. getUserPhone
  27. } from '@/api/public';
  28. import mobileLogin from '@/components/login_mobile/index.vue'
  29. export default {
  30. name: 'login_mobile',
  31. data() {
  32. return {
  33. options: '',
  34. keyCode: '',
  35. account: '',
  36. codeNum: '',
  37. isUp: true,
  38. authKey: '',
  39. logoUrl: '',
  40. isShow: false,
  41. isPos: false,
  42. platform: '', // 手机平台
  43. appleShow: '' //是否是苹果登录
  44. }
  45. },
  46. components: {
  47. mobileLogin
  48. },
  49. mixins: [sendVerifyCode],
  50. mounted() {
  51. //this.getCode();
  52. },
  53. onLoad: function(options) {
  54. let that = this;
  55. // 获取系统信息
  56. uni.getSystemInfo({
  57. success(res) {
  58. that.platform = res.platform;
  59. }
  60. });
  61. const {
  62. code,
  63. state,
  64. scope,
  65. back_url,
  66. appleShow
  67. } = options;
  68. that.options = options
  69. if (options.authKey) that.authKey = options.authKey
  70. if (options.appleShow) that.appleShow = options.appleShow
  71. },
  72. methods: {
  73. wechatPhone() {
  74. this.$Cache.clear('snsapiKey');
  75. if (this.options.back_url) {
  76. let url = uni.getStorageSync('snRouter');
  77. url = url.indexOf('/pages/index/index') != -1 ? '/' : url;
  78. if (url.indexOf('/pages/users/wechat_login/index') !== -1) {
  79. url = '/';
  80. }
  81. if (!url) {
  82. url = '/pages/index/index';
  83. }
  84. this.isUp = false
  85. uni.showToast({
  86. title: '登录成功',
  87. icon: 'none'
  88. })
  89. setTimeout(res => {
  90. location.href = url
  91. }, 800)
  92. } else {
  93. uni.navigateBack()
  94. }
  95. },
  96. // 获取验证码
  97. async code() {
  98. let that = this;
  99. if (!that.account) return that.$util.Tips({
  100. title: '请填写手机号码'
  101. });
  102. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  103. title: '请输入正确的手机号码'
  104. });
  105. await registerVerify(that.account).then(res => {
  106. that.$util.Tips({
  107. title: res.msg
  108. });
  109. that.sendCode();
  110. }).catch(err => {
  111. return that.$util.Tips({
  112. title: err
  113. })
  114. })
  115. },
  116. // 获取验证码api
  117. getCode() {
  118. let that = this
  119. getCodeApi().then(res => {
  120. that.keyCode = res.data.key;
  121. }).catch(res => {
  122. that.$util.Tips({
  123. title: res
  124. });
  125. });
  126. },
  127. close() {
  128. this.$emit('close', false)
  129. },
  130. // #ifdef MP
  131. phoneSilenceAuth(code) {
  132. let self = this
  133. phoneSilenceAuth({
  134. code: code,
  135. spid: app.globalData.spid,
  136. spread: app.globalData.code,
  137. phone: this.account,
  138. captcha: this.codeNum
  139. }).then(res => {
  140. this.$store.commit('LOGIN', {
  141. token: res.data.token
  142. });
  143. this.$store.commit("SETUID", res.data.uid);
  144. this.getUserInfo();
  145. }).catch(error => {
  146. self.$util.Tips({
  147. title: error
  148. })
  149. })
  150. },
  151. // #endif
  152. /**
  153. * 获取个人用户信息
  154. */
  155. getUserInfo: function() {
  156. let that = this;
  157. getUserInfo().then(res => {
  158. uni.hideLoading();
  159. that.userInfo = res.data
  160. that.$store.commit("UPDATE_USERINFO", res.data);
  161. // #ifdef MP
  162. that.$util.Tips({
  163. title: '登录成功',
  164. icon: 'success'
  165. }, {
  166. tab: 3
  167. })
  168. that.close()
  169. // #endif
  170. // #ifdef H5
  171. that.$emit('wechatPhone', true)
  172. // #endif
  173. });
  174. },
  175. }
  176. }
  177. </script>
  178. <style>
  179. page {
  180. height: 100%;
  181. }
  182. </style>
  183. <style lang="scss" scoped>
  184. .appBox {
  185. background-color: #fff;
  186. height: 100%;
  187. display: flex;
  188. flex-direction: column;
  189. justify-content: center;
  190. overflow: hidden;
  191. }
  192. .shading {
  193. display: flex;
  194. align-items: center;
  195. justify-content: center;
  196. width: 100%;
  197. image {
  198. width: 180rpx;
  199. height: 180rpx;
  200. }
  201. }
  202. page {
  203. background-color: #fff !important;
  204. }
  205. .ChangePassword .phone {
  206. font-size: 32rpx;
  207. font-weight: bold;
  208. text-align: center;
  209. margin-top: 55rpx;
  210. }
  211. .ChangePassword .list {
  212. width: 580rpx;
  213. margin: 53rpx auto 0 auto;
  214. }
  215. .ChangePassword .list .item {
  216. width: 100%;
  217. height: 110rpx;
  218. border-bottom: 2rpx solid #f0f0f0;
  219. }
  220. .ChangePassword .list .item input {
  221. width: 100%;
  222. height: 100%;
  223. font-size: 32rpx;
  224. }
  225. .ChangePassword .list .item .placeholder {
  226. color: #b9b9bc;
  227. }
  228. .ChangePassword .list .item input.codeIput {
  229. width: 340rpx;
  230. }
  231. .ChangePassword .list .item .code {
  232. font-size: 32rpx;
  233. background-color: #fff;
  234. }
  235. .ChangePassword .list .item .code.on {
  236. color: #b9b9bc !important;
  237. }
  238. .ChangePassword .confirmBnt {
  239. font-size: 32rpx;
  240. width: 580rpx;
  241. height: 90rpx;
  242. border-radius: 45rpx;
  243. color: #fff;
  244. margin: 92rpx auto 0 auto;
  245. text-align: center;
  246. line-height: 90rpx;
  247. }
  248. </style>