login.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <view>
  3. <navbar :scroll="scrollNum" :iSimmersive="true" title="" :onBack="onBack"></navbar>
  4. <view class="app" v-if="(platform.type=='app' || platform.type=='h5') && !platform.isWechat">
  5. <view class="top">
  6. <view>泰誉凡</view>
  7. <view>会员登录</view>
  8. </view>
  9. <view class="theform">
  10. <form @submit="onSubmit">
  11. <view class="fields-box">
  12. <view class="field-box iconfont">
  13. <input type="text" class="uni-input" name="phone" value="18026740326" placeholder="用户名/邮箱/手机号" />
  14. </view>
  15. <view class="field-box iconfont">
  16. <input type="password" class="uni-input" name="password" value="admin888" placeholder="密码" />
  17. </view>
  18. </view>
  19. <view class="btn">
  20. <button :disabled="isSubmit" form-type="submit">登录</button>
  21. </view>
  22. </form>
  23. <view class="tips-box clear">
  24. <view><navigator url="register" hover-class="none">用户注册</navigator></view>
  25. <view><navigator url="forget" hover-class="none">忘记密码</navigator></view>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- #ifdef H5 -->
  30. <view class="login-wrap" v-if="platform.type=='h5' && platform.isWechat">
  31. <view class="logo"><image v-if="static" :src="static+'app/a3mall.png'"></image></view>
  32. <view class="wechat-title">微信授权登录</view>
  33. <view class="wechat-desc">获得您的公开信息(昵称、头像等),以便为您提供更好的服务</view>
  34. <view class="wechat-login-btn" @click="onWechatLogin">授权登录</view>
  35. <view class="wechat-go-home" @click="onGoHome">暂不登录</view>
  36. </view>
  37. <!-- #endif -->
  38. <loading v-if="isSubmit" :layer="true"></loading>
  39. </view>
  40. </template>
  41. <script>
  42. import loading from '../../components/tool/loading';
  43. import { checkPhone } from '../../common/check';
  44. import navbar from "@/components/navbar/navbar";
  45. // #ifdef H5
  46. import { login } from '../../common/wechat';
  47. // #endif
  48. export default {
  49. components: {
  50. loading,navbar
  51. },
  52. data() {
  53. return {
  54. static: '',
  55. scrollNum: 0,
  56. isSubmit: false,
  57. platform: "app"
  58. }
  59. },
  60. onLoad() {
  61. this.static = this.$static;
  62. this.platform = this.$utils.platformAgent();
  63. },
  64. onShow() {
  65. // 微信公众号授权成功后回调处理
  66. if(this.platform.type == "h5" && this.platform.isWechat){
  67. if(this.$route.query.code != undefined && this.$route.query.code.length){
  68. this.isSubmit = true;
  69. this.$http.wxLogin({
  70. source: 1,
  71. code: this.$route.query.code,
  72. state: this.$route.query.state
  73. }).then(result=>{
  74. if(result.status){
  75. this.$store.commit("UPDATEUSERS",result.data);
  76. this.$utils.switchTab('ucenter/index');
  77. }else{
  78. this.$utils.msg(result.info);
  79. }
  80. this.isSubmit = false;
  81. }).catch(error=>{
  82. this.isSubmit = false;
  83. this.$utils.msg("请求失败,请稍后在试");
  84. });
  85. }
  86. }
  87. },
  88. onPageScroll(obj){
  89. this.scrollNum = obj.scrollTop;
  90. },
  91. methods: {
  92. onBack(){
  93. this.$utils.switchTab("index/index");
  94. },
  95. // #ifdef H5
  96. onWechatLogin(){
  97. login().catch(error=>{
  98. this.$utils.msg(error);
  99. });
  100. },
  101. // #endif
  102. onGoHome(){
  103. this.$utils.switchTab("index/index");
  104. },
  105. onSubmit(e){
  106. let formData = e.detail.value;
  107. this.isSubmit = true;
  108. if(formData.phone == ''){
  109. this.isSubmit = false;
  110. this.$utils.msg("请填写帐号!");
  111. return ;
  112. }else if(formData.password == ''){
  113. this.isSubmit = false;
  114. this.$utils.msg("请填写密码!");
  115. return ;
  116. }
  117. this.$http.sendLogin({
  118. username: formData.phone,
  119. password: formData.password
  120. }).then((result)=>{
  121. if(result.status){
  122. this.$store.commit("UPDATEUSERS",result.data);
  123. this.$utils.switchTab('ucenter/index');
  124. }else{
  125. this.$utils.msg(result.info);
  126. }
  127. this.isSubmit = false;
  128. }).catch((error)=>{
  129. this.isSubmit = false;
  130. this.$utils.msg("连接网络错误,请检查网络是否连接!");
  131. });
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .login-wrap {
  138. .logo {
  139. text-align: center;
  140. padding-top: 180rpx;
  141. image {
  142. width: 180rpx;
  143. height: 180rpx;
  144. }
  145. }
  146. .wechat-title {
  147. font-size: 35rpx;
  148. font-weight: 500;
  149. color: #333;
  150. margin-top: 64rpx;
  151. text-align: center;
  152. }
  153. .wechat-desc {
  154. font-size: 28rpx;
  155. font-weight: 500;
  156. color: #999;
  157. margin-top: 24rpx;
  158. text-align: center;
  159. padding: 10rpx 50rpx;
  160. }
  161. .wechat-login-btn {
  162. height: 80rpx; line-height: 80rpx;
  163. color: #fff; background-color: #33A7FF;
  164. text-align: center; border-radius: 50rpx;
  165. margin: 50rpx; font-size: 32rpx;
  166. }
  167. .wechat-go-home { text-align: center; font-size: 30rpx; color:#666; }
  168. }
  169. .top {
  170. background-color: transparent;
  171. width: 100%;
  172. height: 386rpx;
  173. position: relative;
  174. z-index: 1;
  175. background-image: url(~@/static/images/login-bg.png);
  176. background-repeat: no-repeat;
  177. background-size: 100%;
  178. view {
  179. z-index: 2;
  180. position: absolute;
  181. &:nth-child(1) {
  182. top: 90rpx;
  183. font-size: 72rpx;
  184. color: #fff;
  185. width: 100%;
  186. text-align: center;
  187. &::after {
  188. position: absolute;
  189. content: " ";
  190. background-color: #7a91dc;
  191. height: 1px;
  192. width: 210rpx;
  193. top: 120rpx;
  194. left: 50%;
  195. transform: translateX(-50%);
  196. }
  197. }
  198. &:nth-child(2) {
  199. top: 225rpx;
  200. font-size: 49rpx;
  201. color: #fff000;
  202. text-align: center;
  203. width: 100%;
  204. }
  205. }
  206. image {
  207. width: 100%;
  208. height: 386rpx;
  209. }
  210. }
  211. .theform {
  212. width: 590rpx;
  213. margin: 70rpx auto 0 auto;
  214. .fields-box{
  215. width: 100%;
  216. border: 1px solid #d2cdcd;
  217. overflow: hidden;
  218. border-radius: 10rpx;
  219. .field-box{
  220. width: 100%;
  221. height: 100rpx;
  222. position: relative;
  223. font-size: 40rpx;
  224. &:first-child {
  225. border-bottom:1px solid #d2cdcd;;
  226. }
  227. input {
  228. width: 100%; height: 100rpx; line-height: 100rpx;
  229. text-indent: 100rpx; font-size:29rpx; color: #888;
  230. }
  231. &:nth-child(1):before {
  232. content: "\e61b";
  233. color: #bfbfbf;
  234. position: absolute;
  235. left: 30rpx;
  236. top: 28rpx;
  237. }
  238. &:nth-child(2):before {
  239. content: "\e61a";
  240. color: #bfbfbf;
  241. position: absolute;
  242. left: 30rpx;
  243. top: 28rpx;
  244. }
  245. }
  246. }
  247. .btn{
  248. width: 100%;
  249. margin-top: 48rpx;
  250. button{
  251. color: #fff;
  252. background-color: #1b43c4;
  253. border: 1px solid #1b43c4;
  254. border-radius: 10rpx;
  255. font-size: 33rpx;
  256. height: 100rpx;
  257. line-height: 100rpx;
  258. text-align: center;
  259. }
  260. }
  261. .tips-box{
  262. width: 100%;
  263. font-size: 28rpx;
  264. color: #888;
  265. margin-top: 45rpx;
  266. view {
  267. width: 50%;
  268. float: left;
  269. &:last-child {
  270. text-align: right;
  271. }
  272. }
  273. }
  274. }
  275. </style>