login.vue 5.6 KB

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