login.vue 6.8 KB

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