login.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <gui-page :customHeader="true">
  3. <view slot="gHeader">
  4. <view class="gui-flex gui-nowrap gui-rows gui-align-items-center gui-padding">
  5. <!-- 使用组件实现返回按钮及返回首页按钮 -->
  6. <gui-header-leading :onlyBack="true"></gui-header-leading>
  7. <!-- 导航文本此处也可以是其他自定义内容 -->
  8. <text class="gui-h4 gui-ellipsis gui-text-center gui-header-content gui-primary-color">登录</text>
  9. <!-- 如果右侧有其他内容可以利用条件编译和定位来实现-->
  10. </view>
  11. </view>
  12. <view slot="gBody" class="register">
  13. <view class="content">
  14. <!-- 头部logo -->
  15. <view class="header" v-if="system_logo">
  16. <image :src="system_logo" @click="Dever.viewPic([system_logo], system_logo)"></image>
  17. </view>
  18. <!-- 主体 -->
  19. <view class="main">
  20. <wInput
  21. v-model="phoneData"
  22. type="text"
  23. maxlength="11"
  24. placeholder="手机号"
  25. ></wInput>
  26. <wInput
  27. v-model="passData"
  28. type="password"
  29. maxlength="11"
  30. placeholder="登录密码"
  31. isShowPass
  32. style="display: none;"
  33. ></wInput>
  34. <wInput
  35. v-model="verCode"
  36. type="number"
  37. maxlength="6"
  38. placeholder="验证码"
  39. isShowCode
  40. ref="runCode"
  41. @setCode="getVerCode()"
  42. ></wInput>
  43. </view>
  44. <wButton
  45. class="wbutton"
  46. text="登 录"
  47. :rotate="isRotate"
  48. @click.native="startLogin()"
  49. ></wButton>
  50. <view class="other_agree">
  51. <text
  52. @tap="isShowAgree"
  53. class="cuIcon"
  54. :class="showAgree?'cuIcon-radiobox':'cuIcon-round'"
  55. > 同意</text>
  56. <!-- 协议地址 -->
  57. <view @click="goView('agreement', '入记协议')">《入记协议》</view>
  58. </view>
  59. <!-- 其他登录 -->
  60. <view class="other_login cuIcon" style="display: none;">
  61. <view class="login_icon">
  62. <view class="cuIcon-weixin" @tap="login_weixin"></view>
  63. </view>
  64. </view>
  65. <!-- 底部信息 -->
  66. <view class="footer" style="display: none;">
  67. <navigator url="forget" open-type="navigate">找回密码</navigator>
  68. <text>|</text>
  69. <navigator url="register" open-type="navigate">注册账号</navigator>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </gui-page>
  75. </template>
  76. <script>
  77. var self;
  78. import wInput from '@/lib/watch-login/watch-input.vue' //input
  79. import wButton from '@/lib/watch-login/watch-button.vue' //button
  80. export default {
  81. data() {
  82. return {
  83. id : 0,
  84. code : '',
  85. info : {},
  86. system_logo : '',
  87. system_name : '',
  88. phoneData:'', // 用户/电话
  89. passData:'', //密码
  90. verCode:"", //验证码
  91. showAgree:true, //协议是否选择
  92. isRotate: false, //是否加载旋转
  93. }
  94. },
  95. components:{
  96. wInput,
  97. wButton,
  98. },
  99. onLoad(option) {
  100. self = this;
  101. self.id = option.id;
  102. self.code = option.code;
  103. self.getData();
  104. },
  105. methods: {
  106. getData : function() {
  107. if (self.id || self.code) {
  108. var data = {};
  109. if (self.id) {
  110. data.id = self.id;
  111. }
  112. if (self.code) {
  113. data.code = self.code;
  114. }
  115. self.Dever.get(self, 'app/collection/?l=api.getConfig', data, function(t) {
  116. uni.setNavigationBarTitle({
  117. title:t.info.name
  118. });
  119. self.system_logo = t.info.logo;
  120. self.system_name = t.info.name;
  121. self.info = t.info;
  122. });
  123. } else {
  124. self.system_logo = self.Dever.config.system_logo;
  125. }
  126. },
  127. goView : function(key, name) {
  128. var path = this.Dever.api_host + 'main/?l=page&key=' + key;
  129. this.Dever.location(path, 'webview', name);
  130. },
  131. isShowAgree(){
  132. //是否选择协议
  133. self.showAgree = !self.showAgree;
  134. },
  135. getVerCode(){
  136. //获取验证码
  137. if (self.phoneData.length != 11) {
  138. self.Dever.alert('手机号不正确');
  139. return false;
  140. }
  141. self.$refs.runCode.$emit('runCode');
  142. self.Dever.post('package/passport/?l=reg.getMCode', {noloading:1, mobile: self.phoneData}, function(t) {
  143. if (t.indexOf('::') != -1) {
  144. var temp = t.split('::');
  145. t = temp[0];
  146. self.verCode = temp[1];
  147. }
  148. self.Dever.alert(t);
  149. });
  150. },
  151. login_weixin : function() {
  152. this.Dever.alert('暂未开通');
  153. },
  154. startLogin() {
  155. if(self.isRotate){
  156. //判断是否加载中,避免重复点击请求
  157. return false;
  158. }
  159. if (self.showAgree == false) {
  160. self.Dever.alert('请先同意《入记协议》');
  161. return false;
  162. }
  163. if (self.phoneData.length !=11) {
  164. self.Dever.alert('手机号不正确');
  165. return false;
  166. }
  167. /*
  168. if (self.passData.length < 6) {
  169. self.Dever.alert('密码不正确');
  170. return false;
  171. }
  172. */
  173. if (self.verCode.length != 6) {
  174. self.Dever.alert('验证码不正确');
  175. return false;
  176. }
  177. var type = '';
  178. var type_id = '';
  179. if (self.id || self.code) {
  180. type = 'collection/info';
  181. type_id = self.info.id;
  182. }
  183. self.isRotate = true;
  184. self.Dever.post('package/passport/?l=app.login', {noloading:1, mobile: self.phoneData, mcode: self.verCode, source_type: self.Dever.source, system_source:self.Dever.source_id, type:type, type_id:type_id}, function(t) {
  185. self.isRotate = false;
  186. self.Dever.setToken(t.signature);
  187. self.Dever.jump();
  188. }, function(t) {
  189. self.Dever.alert(t.msg);
  190. self.isRotate = false;
  191. });
  192. }
  193. }
  194. }
  195. </script>
  196. <style>
  197. @import url("@/lib/watch-login/css/icon.css");
  198. @import url("@/lib/watch-login/css/main.css");
  199. .other_agree {
  200. display: flex;
  201. flex-direction: row;
  202. justify-content: center;
  203. align-items: center;
  204. margin-top: 50rpx;
  205. text-align: center;
  206. }
  207. .other_login {
  208. margin-top: 130rpx;
  209. }
  210. </style>