Bladeren bron

@CRMAIF_REQ_2549@迁移文件

yangdingli 3 jaren geleden
bovenliggende
commit
3cff12d6b6

+ 8 - 0
show-server/src/main/resources/server-data.xml

@ -44,4 +44,12 @@
44 44
45 45
	<!--自定义getVersion接口-->
46 46
	<action name="getVersion" class="com.ai.ipu.show.bean.LoginBean" method="getVersion" verify="false"></action>
47
48
	<!--video-->
49
	<!-- 普通登录 -->
50
	<action name="LoginBean.login" class="com.ai.video.bean.LoginBean" method="login" verify="false"></action>
51
	<!-- 模拟发送验证码 -->
52
	<action name="LoginBean.sendVerificationCode" class="com.ai.video.bean.LoginBean" method="sendVerificationCode" verify="false"></action>
53
	<action name="LoginBean.shortVideoToken" class="com.ai.video.bean.LoginBean" method="shortVideoToken" verify="false"></action>
54
	<!--video-end-->
47 55
</datas>

+ 1 - 0
show-server/src/main/resources/server-page.xml

@ -180,6 +180,7 @@
180 180
    <action name="ChooseFile" template="template/webapp/plugins/chooseFile.html"></action>
181 181
    <action name="showSliderVerify" template="template/webapp/plugins/showSliderVerify.html"></action>
182 182
183
    <action name="videoLogin" template="template/webapp/video/login.html"></action>
183 184
    <action name="videoSearch" template="template/webapp/video/video-search.html"></action>
184 185
    <action name="videoHistory" template="template/webapp/video/video-history.html"></action>
185 186
    <action name="videoAdd" template="template/webapp/video/video-add.html"></action>

+ 367 - 0
show-server/src/main/webapp/biz/js/common/carousel/CustomCarousel.js

@ -0,0 +1,367 @@
1
// 临时用组件
2
define(["Hammer", "jquery", "ipuUI"], function (Hammer, $, ipuUI) {
3
  /**
4
   * @class
5
   * @uses Hammer.js
6
   * 通过hammer.js实现的banner功能组件,
7
   * 因为实现轮播,显示第一项后,再显示第一项,所以第一项有被复制到添加到最后
8
   *
9
   *        @example
10
   *        <!-- 组件html结构如下,li里的内容用户可自定义  -->
11
   *        <div class="ipu-carousel ipu-hammer-carousel">
12
   *          <ul class="ipu-carousel-wrapper">
13
   *            <li ><img src="../../biz/img/01.jpg" alt=""></li>
14
   *            <li ><img src="../../biz/img/02.jpg" alt=""></li>
15
   *            <li ><img src="../../biz/img/03.jpg" alt=""></li>
16
   *            <li ><img src="../../biz/img/04.jpg" alt=""></li>
17
   *          </ul>
18
   *        </div>
19
   *
20
   * @constructor  不能直接访问该类,调用 {@link ipu#customCarousel}生成实例
21
   * @param {String|JqueryObj} slt
22
   *      jquery选择器字符串或jquery对象,用来查找要被组件初始化化的dom
23
   * @param {Object} option 组件配置参数,默认配置见 {@link #cfg-defaultOption}
24
   */
25
  function CustomCarousel(slt, option) {
26
    this.option = $.extend({}, this.defaultOption, option);
27
    this.el = $(slt).get(0);
28
    this._init();
29
  }
30
31
  $.extend(CustomCarousel.prototype, {
32
    /**
33
     * 组件默认配置项
34
     *
35
     * @cfg {Object} defaultOption
36
     * @cfg {Number} defaultOption.index 初始化时显示第几项,用户未指定时,会查找子项内容上有ipu-current的项显示,默认显示第一项
37
     * @cfg {Number} defaultOption.showItemSize 一屏最多时出现的子项数量(循环的时候要复制的数量)
38
     * @cfg {Boolean} defaultOption.loop 是否循环切换,只有轮播切换时,才能自动轮播
39
     * @cfg {Boolean} defaultOption.autoPlay 是否自动轮播
40
     * @cfg {Number} defaultOption.duration 自动轮播时的间隔时间,单位ms
41
     * @cfg {Boolean} defaultOption.indicator 是否生成banner提示器,true右下角出现小点
42
     * @cfg {Function} defaultOption.callBack 轮播显示某项时的回调函数
43
     * @cfg {Number} defaultOption.callBack.index 当前显示的项索引
44
     * @cfg {Function} defaultOption.clickBack
45
     *          切换项时被点击时的回调函数,此处主要是为了处理复制项与第一项的点击事件进行处理,
46
     *          让用户不关注点击的是第一项或是复制项,回调作用域为组件对象
47
     * @cfg {Number} defaultOption.clickBack.index 点击的项索引
48
     */
49
    defaultOption: {
50
      index: null,
51
      showItemSize: 1,
52
      startIndex: 0,  // 起始位置,有时起始位置不为0;
53
      loop: true,
54
      autoPlay: false,
55
      duration: 3000,
56
      indicator: false,
57
      callBack: null,
58
      clickBack: null
59
    },
60
    _init: function () {
61
      this.wrapper = $(">.ipu-carousel-wrapper", this.el);
62
      this.carouselItems = $(">li", this.wrapper);
63
      this.itemSize = this.carouselItems.size();  // 子项数量
64
      this.showItemSize = this.option.showItemSize; // 一屏展示子项数量,默认显示1个,做循环显示时只需要复制一个子项
65
66
      if (this.showItemSize > this.itemSize + 1) {
67
        this.enable = false;
68
        return; // 不能正常工作,无法初始化此组件,需要做异常处理
69
      }
70
71
      this.enable = true;
72
      this.startIndex = Math.ceil(this.option.startIndex);   // 起始位置,表明0不会显示,因为没法显示0
73
      this.endIndex = this.startIndex + this.itemSize;       // 结束位置展现同起始位置,只是索引不同
74
      this.carouselItemWides = []; // 子项宽度尺寸
75
76
      /** @property {Number} 当前显示子项索引,从0开始 */
77
      this.currentIndex = 0; // 当前显示子项索引
78
      this.moveLen = 0;      // 当前滚动移动距离
79
80
      /** @type {Boolean} 循环展示时,第一项会被复制,显示项是第一项时,是否为第一项的复制项 */
81
      this.cloneItem = false; //这个参数用来标记是否复制项
82
83
      if (this.option.indicator) {
84
        this._addIndicator();
85
      }
86
87
      // 如果做循环展示,则要复制起始展示项到最后面
88
      if (this.option.loop) {
89
        var cloneItem = this.carouselItems.slice(0, this.showItemSize).clone().appendTo(this.wrapper).removeClass("ipu-current");  // 这里假设每个元素宽度都是相等的
90
        if (cloneItem.size() < this.showItemSize) {
91
          this.carouselItems.slice(0, 1).clone().appendTo(this.wrapper).removeClass("ipu-current");
92
        }
93
      }
94
95
      var that = this;
96
      if (this.option.clickBack) {
97
        $(">li", this.wrapper).each(function (i) {
98
          $(this).click(function () {
99
            that.option.clickBack.call(this, i % that.size);
100
          });
101
        })
102
      }
103
104
      this.hammer = new Hammer.Manager(this.el);
105
      this.hammer.add(new Hammer.Pan({direction: Hammer.DIRECTION_HORIZONTAL, threshold: 10}));
106
      this.hammer.on("panstart panmove panend pancancel", Hammer.bindFn(this._onPan, this));
107
108
      this._sizeCount();
109
      $(window).resize(function () { // 在窗口尺寸变化时,更新尺寸信息
110
        that.refresh();
111
      });
112
113
      if (this.option.index == null) {
114
        var activeIndex = this.carouselItems.filter(".ipu-current").index();
115
        this.currentIndex = activeIndex != -1 ? activeIndex : 0;
116
      }
117
118
      this._show(this.currentIndex, false);
119
    },
120
    /**
121
     * 停止自动滚动
122
     */
123
    stop: function () {
124
      this._pause();
125
      this.option.autoPlay = false;
126
    },
127
    _pause: function () {
128
      if (this.timeoutId) {
129
        clearTimeout(this.timeoutId);
130
        this.timeoutId = null;
131
      }
132
    },
133
    /**
134
     * 切换到上一项
135
     */
136
    prev: function () {
137
      var index;
138
      if (this.option.loop) {
139
        if (this.realIndex == this.startIndex) {
140
          this._show(this.endIndex, false);
141
          this.wrapper.width();
142
          index = this.endIndex - 1;
143
        } else {
144
          index = this.realIndex - 1;
145
        }
146
      } else {
147
        index = (this.currentIndex - 1 + this.itemSize) % this.itemSize;
148
      }
149
150
      this._show(index);
151
    },
152
    /**
153
     * 切换到下一项
154
     */
155
    next: function () {//下一张
156
      var index;
157
      if (this.option.loop) {
158
        if (this.realIndex == this.endIndex) {
159
          this._show(this.startIndex, false);
160
          this.wrapper.width();
161
          index = this.startIndex + 1;
162
        } else {
163
          index = this.realIndex + 1;
164
        }
165
      } else {
166
        index = (this.currentIndex + 1) % this.itemSize;
167
      }
168
169
      this._show(index);
170
    },
171
    /**
172
     * 切换显示指定项
173
     *
174
     * @param {Number} index 要切换到的项索引
175
     *
176
     */
177
    show: function (index) {  // 跳到指定索引处,这里是realIndex
178
      var index = index % this.itemSize;  // todo: 起始项与结束项相同,应该看离那项近,往那边移动?
179
      if (index < 0) {
180
        index = this.itemSize + index;
181
      }
182
      index = this.startIndex + index;
183
      this._show(index); // 默认追加动画
184
    },
185
    /**
186
     * 自动轮播
187
     */
188
    play: function () {
189
      this.option.autoPlay = true;
190
      this._play();
191
    },
192
    _play: function () {
193
      if (this.option.autoPlay && this.option.loop && !this.timeoutId) {
194
        var that = this;
195
        this.timeoutId = setTimeout(function () {
196
          that.timeoutId = null;//清空这个timeoutId,代表该次处理已经执行了
197
          that.next();
198
        }, that.option.duration);
199
      }
200
    },
201
    _addIndicator: function () {
202
      var html = "";
203
      for (var i = 0; i < this.itemSize; i++) {
204
        html += "<li></li>";
205
      }
206
      html = "<ul class='ipu-carousel-indicator'>" + html + "</ul>";
207
      this.indicator = $(html).appendTo(this.el);
208
      this.indicatorIndexs = $("li", this.indicator);
209
    },
210
    _sizeCount: function () {
211
      this.wrapperWidth = this.wrapper.outerWidth(true);
212
      this.itemWidth = this.carouselItems.eq(0).outerWidth(true);
213
      $(this.wrapper).removeClass("ipu-carousel-animate").width();
214
      this.carouselItemWides = [];
215
216
      var that = this;
217
      $(">li", this.wrapper).each(function (index, dom) {
218
        that.carouselItemWides[index] = $(this).position().left;
219
      });
220
      this.mostSize = this.itemSize * this.itemWidth;           // 宽度*数量
221
      this.startSize = that.carouselItemWides[this.startIndex]; // 起始位置
222
      this.endSize = that.carouselItemWides[this.endIndex];     // 宽度*数量
223
      // console.log(this.startSize + "--" + this.endSize);
224
    },
225
    /**
226
     * 宽度信息或尺寸信息发生变更时,进行刷新计算
227
     * 判断是否需要重新计算尺寸,若宽度尺寸发生变化,进行重新尺寸计算
228
     */
229
    refresh: function () {
230
      if (this.wrapperWidth != this.wrapper.outerWidth(true)) {
231
        this._sizeCount();
232
        this._show(this.realIndex, false); //新的位置
233
      }
234
    },
235
    _move: function (moveLen) { // 拖动时的处理
236
      this._pause();
237
      $(this.wrapper).removeClass("ipu-carousel-animate");
238
239
      if (this.option.loop) { // 循环时,起始位置
240
        moveLen = moveLen % this.mostSize;
241
        var move = (this.moveLen - moveLen);
242
        if (move < this.startSize) {
243
          move = move + this.mostSize;
244
        } else if (move > this.endSize) {
245
          move = move - this.mostSize
246
        }
247
      } else {
248
        var move = this.moveLen - moveLen;
249
        if (move < 0) {
250
          move = move / 2;
251
        } else if (move > this.endSize) {
252
          move = this.endSize + (move - this.endSize) / 2;
253
        }
254
      }
255
256
      this.displayMoveLen = move;
257
      move = -move + "px";
258
      $(this.wrapper).css("transform", "translate3d(" + move + ", 0, 0)");
259
    },
260
    _show: function (index, animate) { // index = realIndex
261
      if (animate !== false) { // 默认值为true
262
        animate = true;
263
      }
264
265
      // console.log(index); // 判断距离起始始和结束哪个位置更近
266
267
      this._pause();
268
      $(this.wrapper).toggleClass("ipu-carousel-animate", animate);
269
270
      if (index < this.startIndex) {  // 起始位置不一定位于0
271
        index = this.itemSize + index;
272
      } else if (index > this.endIndex) {
273
        index = index - this.itemSize;
274
      }
275
276
      if ((index == this.startIndex || index == this.endIndex) && this.displayMoveLen) { // 对于重复位置,需要根据最靠近移动
277
        var moveSize = Math.abs(this.displayMoveLen / this.itemWidth);
278
        if (Math.abs(this.startIndex - moveSize) > Math.abs(this.endIndex - moveSize)) {
279
          index = this.endIndex;
280
        } else {
281
          index = this.startIndex;
282
        }
283
      }
284
285
286
      this.realIndex = index;
287
      this.currentIndex = index % this.itemSize;
288
      this.cloneItem = index >= this.itemSize;
289
290
      this.moveLen = this.carouselItemWides[index];
291
      var move = -this.moveLen + "px";
292
293
      $(this.wrapper).css("transform", "translate3d(" + move + ", 0, 0)");
294
295
      var currentIndex = this.currentIndex;
296
      if (animate && this.option.callBack) {
297
        this.option.callBack(currentIndex, this.cloneItem);//返回当前索引,以及是滞最后一项参数
298
      }
299
300
      if (this.indicator) {
301
        this.indicatorIndexs.eq(currentIndex).addClass("ipu-current").siblings().removeClass("ipu-current");
302
      }
303
      // console.log(this.realIndex + " : " + this.currentIndex);
304
305
      if (this.displayMoveLen) {  // 这个值只在pancancel时使用,否则清0
306
        this.displayMoveLen = 0;
307
      }
308
309
      this._play();//处理自动播放
310
    },
311
    _onPan: function (ev) {
312
      var delta = ev.deltaX;  // 内容往左,deltaX为正值
313
314
      // pancancel与panend,有效的pan事件结束与无效的pan事件结束?
315
      if (ev.type == 'panend' || ev.type == 'pancancel') {
316
        var value = delta / this.itemWidth;
317
        var intValue = parseInt(Math.abs(value));               // 取整数
318
        var decimal = Math.abs(value) % 1;                      // 取小数
319
320
        if (decimal > 0.2) { // 滑动超过页面宽20%;
321
          intValue = intValue + 1;
322
        }
323
        if (delta > 0) {
324
          intValue = -intValue;
325
        }
326
        var index;
327
328
        // console.log("平移位置:" + intValue);
329
        if (this.option.loop) {
330
          intValue = intValue % this.itemSize;
331
          index = (this.realIndex + intValue);
332
333
          if (index < this.startIndex) {
334
            index = index + this.itemSize;
335
          } else if (index > this.endIndex) {
336
            index = index - this.itemSize;
337
          }
338
        } else { // 非循环时
339
          index = this.currentIndex + intValue;
340
          if (index < 0) {
341
            index = 0;
342
          } else if (index > this.itemSize - 1) {
343
            index = this.itemSize - 1;
344
          }
345
        }
346
347
        this._show(index);
348
      } else if (ev.type == 'panmove') {
349
        this._move(delta);
350
      }
351
    }
352
  });
353
354
  /**
355
   * @member ipuUI
356
   * 生成HammerCarousel实例,参数信息见{@link CustomCarousel#method-constructor}
357
   *
358
   * @param {String} slt
359
   * @param {Object} option
360
   * @returns {CustomCarousel}
361
   */
362
  ipuUI.customCarousel = function (slt, option) {
363
    return new CustomCarousel(slt, option);
364
  };
365
366
367
});

+ 3 - 0
show-server/src/main/webapp/biz/js/common/require-config.js

@ -10,6 +10,9 @@ require.config({
10 10
		'LeftSwipe': 'biz/js/common/LeftSwipe',
11 11
		'WebTorrent': 'biz/js/common/webtorrent.min',
12 12
		'gesture': 'biz/lib/gesture/gesture.password',				 // 手势密码第三方库
13
		'customCarousel':'biz/js/common/carousel/customCarousel', // 自定义轮播组件
14
		'userManager':'biz/js/common/user/userManager', // 账号管理
15
		'vali':'biz/js/common/validate/common-validate',  // 自定义校验
13 16
	},
14 17
	shim:{
15 18
        'dragsort': { deps: ['jquery'] }

+ 207 - 0
show-server/src/main/webapp/biz/js/common/user/userManager.js

@ -0,0 +1,207 @@
1
/**
2
 * 用户管理类
3
 * currentUserAccount:当前登录用户名 字符串
4
 * userAccountList:本地存储所有登录用户的列表 DatasetList字符串形式 例如:userAccountList:[{userData},{userData}]
5
 * userData:DataMap字符串形式
6
 */
7
define(["common", "mobile", "ipuMobile", "jcl"], function (Common, Mobile, WadeMobile, Wade) {
8
9
  var userManager = {};
10
11
  // 本地缓存的key值定义
12
  userManager.currentUserAccount = "currentUserAccount";//当前登录的用户名
13
  userManager.userAccountList = "userAccountList";//当前登录多个用户的列表对应的key值
14
15
  userManager.userAccount = "userAccount";//用户名
16
  userManager.passwd = "password";//密码
17
  userManager.gesturePasswd = "gesturePasswd";//手势锁密码
18
  userManager.usingGesturePasswd = "usingGesturePasswd"; //是否启用手势锁
19
  userManager.hasRememberPasswd = "hasRememberPasswd";//是否记住密码。true:记住密码;false:不记录密码
20
  userManager.hasRememberPasswd_true = "true";
21
  userManager.hasRememberPasswd_false = "false";
22
23
  userManager.currentUserData = null;// 当前登录用户对象,全局变量
24
  userManager.currentUserGestureValue = null;// 当前登录用户手势锁值,全局变量
25
26
  // 获取当前登录的用户对象
27
  userManager.getCurrentUserData = function (callback) {
28
    Common.getLocal(function (data) {
29
      data = typeof (data) == "string" ? Wade.DataMap(data) : data;
30
      var currentUserAccount = null;
31
      if (data.get(userManager.currentUserAccount)) {
32
        currentUserAccount = data.get(userManager.currentUserAccount);
33
      }
34
      if (data.get(userManager.userAccountList)) {
35
        var userAccountList = data.get(userManager.userAccountList);
36
        userAccountList = typeof (userAccountList) == "string" ? Wade.DatasetList(userAccountList) : userAccountList;
37
        if (userAccountList.length > 0) {
38
          var obj;
39
          for (var i = 0; i < userAccountList.length; i++) {
40
            obj = userAccountList.get(i);
41
            obj = typeof (obj) == "string" ? Wade.DataMap(obj) : obj;
42
            var userAccount = obj.get(userManager.userAccount);
43
            if (userAccount == currentUserAccount) {
44
              console.log("获取到已有登录对象:" + obj.toString());
45
              userManager.currentUserData = obj;
46
              return callback(obj);
47
            }
48
          }
49
        }
50
      }
51
      console.log("未获取到已登录对象");
52
      return callback(null);
53
    }, [userManager.currentUserAccount, userManager.userAccountList]);
54
  };
55
56
  // 向本地添加用户数据
57
  userManager.addUserData = function (userData) {
58
    Common.getLocal(function (data) {
59
      var _currentUserAccount = userData.get(userManager.userAccount);
60
      var _hasRememberPasswd = userData.get(userManager.hasRememberPasswd);
61
      data = typeof (data) == "string" ? Wade.DataMap(data) : data;
62
      var has_update_data = false;//true:更新数据;false:新增数据;
63
      var _userAccountList = Wade.DatasetList();
64
      if (data.get(userManager.userAccountList)) {
65
        _userAccountList = data.get(userManager.userAccountList);
66
        _userAccountList = typeof (_userAccountList) == "string" ? Wade.DatasetList(_userAccountList) : _userAccountList;
67
        //更新数据
68
        if (_userAccountList.length > 0) {
69
          var obj;//循环对象
70
          for (var i = 0; i < _userAccountList.length; i++) {
71
            obj = _userAccountList.get(i);
72
            obj = typeof (obj) == "string" ? Wade.DataMap(obj) : obj;
73
            var userAccount = obj.get(userManager.userAccount);
74
            if (_currentUserAccount == userAccount) {
75
              has_update_data = true;
76
              //该用户数据已存在,更新数据
77
              obj.put(userManager.userAccount, userData.get(userManager.userAccount));
78
              obj.put(userManager.hasRememberPasswd, _hasRememberPasswd);
79
              if (_hasRememberPasswd == userManager.hasRememberPasswd_true) {
80
                //记录密码
81
                obj.put(userManager.passwd, userData.get(userManager.passwd));
82
              } else if (_hasRememberPasswd == userManager.hasRememberPasswd_false) {
83
                //不记录密码
84
                obj.removeKey(userManager.passwd);
85
              }
86
              console.log("更新用户对象:" + obj.toString());
87
              break;
88
            }
89
          }
90
        }
91
      }
92
      //新插入用户数据
93
      if (!has_update_data) {
94
        var obj = Wade.DataMap();
95
        obj.put(userManager.hasRememberPasswd, userData.get(userManager.hasRememberPasswd));
96
        obj.put(userManager.userAccount, _currentUserAccount);
97
        if (_hasRememberPasswd == userManager.hasRememberPasswd_true) {
98
          //记录密码
99
          obj.put(userManager.passwd, userData.get(userManager.passwd));
100
        } else if (_hasRememberPasswd == userManager.hasRememberPasswd_false) {
101
          //不记录密码
102
        }
103
        console.log("新增用户对象:" + obj.toString());
104
        _userAccountList.add(obj);
105
      }
106
107
      // 重新放置本地缓存数据
108
      Common.putLocal(userManager.userAccountList, _userAccountList.toString());
109
      // 强制更新当前登录用户值
110
      Common.putLocal(userManager.currentUserAccount, _currentUserAccount);
111
    }, [userManager.userAccountList]);
112
  };
113
114
  //启用手势锁管理
115
  userManager.addCurrentUsingGesturePasswd = function (usingGesturePasswd) {
116
    if(usingGesturePasswd){
117
      usingGesturePasswd = true;
118
    }else {
119
120
    }
121
    // Common.putLocal(userManager.usingGesturePasswd, usingGesturePasswd);
122
    Common.getLocal(function(data) {
123
      data = typeof(data)=="string"?Wade.DataMap(data):data;
124
      var currentUserAccount = null;
125
      if(data.get(userManager.currentUserAccount)){
126
        currentUserAccount = data.get(userManager.currentUserAccount);
127
      }
128
      if(data.get(userManager.userAccountList)){
129
        var userAccountList = data.get(userManager.userAccountList);
130
        userAccountList = typeof(userAccountList)=="string"?Wade.DatasetList(userAccountList):userAccountList;
131
        if(userAccountList.length>0){
132
          var obj;
133
          for(var i=0;i<userAccountList.length;i++){
134
            obj = userAccountList.get(i);
135
            obj = typeof(obj)=="string"?Wade.DataMap(obj):obj;
136
            var userAccount = obj.get(userManager.userAccount);
137
            if(userAccount == currentUserAccount){
138
              obj.put(userManager.usingGesturePasswd, usingGesturePasswd);
139
              if(usingGesturePasswd){
140
                // 开启手势密码
141
              }else{
142
                // 关闭手势密码,移除原有密码
143
                if(userManager.gesturePasswd){
144
                  obj.removeKey(userManager.gesturePasswd);
145
                }
146
              }
147
              break;
148
            }
149
          }
150
        }
151
        // 重新放置本地缓存数据
152
        Common.putLocal(userManager.userAccountList, userAccountList.toString());
153
      }
154
    }, [userManager.currentUserAccount,userManager.userAccountList]);
155
  }
156
157
  // 获取当前手势锁值
158
  userManager.getCurrentUserGestureValue = function(callback){
159
    if(userManager.currentUserGestureValue != null){
160
      return callback(userManager.currentUserGestureValue);
161
    }
162
    if(userManager.currentUserData != null){
163
      return callback(userManager.currentUserData.get(userManager.gesturePasswd));
164
    }
165
    userManager.getCurrentUserData(function(userData){
166
      if(userData==null){
167
        return callback(null);
168
      }
169
      return callback(userData.get(userManager.gesturePasswd));
170
    });
171
  };
172
173
  userManager.addCurrentUserGestureValue = function(value){
174
    Common.getLocal(function(data) {
175
      data = typeof(data)=="string"?Wade.DataMap(data):data;
176
      var currentUserAccount = null;
177
      if(data.get(userManager.currentUserAccount)){
178
        currentUserAccount = data.get(userManager.currentUserAccount);
179
      }
180
      if(data.get(userManager.userAccountList)){
181
        var userAccountList = data.get(userManager.userAccountList);
182
        userAccountList = typeof(userAccountList)=="string"?Wade.DatasetList(userAccountList):userAccountList;
183
        if(userAccountList.length>0){
184
          var obj;
185
          for(var i=0;i<userAccountList.length;i++){
186
            obj = userAccountList.get(i);
187
            obj = typeof(obj)=="string"?Wade.DataMap(obj):obj;
188
            var userAccount = obj.get(userManager.userAccount);
189
            if(userAccount == currentUserAccount){
190
              var lastGesturePasswd = obj.get(userManager.gesturePasswd);
191
              if(lastGesturePasswd){
192
                console.log("更新手势锁密码,旧密码是:"+lastGesturePasswd+",新手势锁密码是:"+value);
193
              }else{
194
                console.log("新增手势锁密码:"+value);
195
              }
196
              obj.put(userManager.gesturePasswd, value);
197
            }
198
          }
199
        }
200
        // 重新放置本地缓存数据
201
        Common.putLocal(userManager.userAccountList, userAccountList.toString());
202
      }
203
    }, [userManager.currentUserAccount,userManager.userAccountList]);
204
  };
205
206
  return userManager;
207
});

+ 62 - 0
show-server/src/main/webapp/biz/js/common/validate/common-validate.js

@ -0,0 +1,62 @@
1
/**
2
 * 常用校验
3
 */
4
define(['jquery', 'ipuUI'], function ($, ipuUI) {
5
  var Vali = new function () {
6
7
    // 是否为电话号码
8
    this.isPhoneNumber= function (number) {
9
      if (!number || typeof number == 'undefined' || number == '') {
10
        ipuUI.toast('请输入手机号');
11
        return false;
12
      }
13
      var mobileReg = /^((13+\d{9})|(145+\d{8})|(147+\d{8})|(15+\d{9})|(16+\d{9})|(17+\d{9})|(18+\d{9})|(19+\d{9}))$/;
14
      if(!mobileReg.test(number)){
15
        ipuUI.toast('手机号格式错误');
16
        return false;
17
      }
18
      return true;
19
    }
20
21
    // 校验空字符
22
    this.isNotNull = function (testValue, tipText) {
23
      if (testValue == "") {
24
        ipuUI.toast('请输入' + tipText + '!');
25
        return false;
26
      }
27
      return true;
28
    };
29
30
    // 校验自然数(0、正整数)
31
    this.isNaturalNumber = function (testValue, tipText) {
32
      var reg = /^(0|[1-9][0-9]*)$/;
33
      if (!reg.test(testValue)) {
34
        ipuUI.toast(tipText + '必须为数字');
35
        return false;
36
      }
37
      return true;
38
    };
39
40
    // 校验整数(正整数、0、负整数)
41
    this.isInteger = function (testValue, tipText) {
42
      var reg = /^(0|-?[1-9][0-9]*)$/;
43
      if (!reg.test(testValue)) {
44
        ipuUI.toast(tipText + '必须为整数');
45
        return false;
46
      }
47
      return true;
48
    };
49
50
    // 校验字符串长度
51
    this.valiLength = function (testValue, tipText, minLength, maxLength) {
52
      if (testValue < minLength || testValue > maxLength) {
53
        ipuUI.toast(tipText + '的长度必须在' + minLength + "-" + maxLength + "之间");
54
        return false;
55
      }
56
      return true;
57
    };
58
59
  }
60
61
  return Vali;
62
});

+ 206 - 0
show-server/src/main/webapp/biz/js/video/login.js

@ -0,0 +1,206 @@
1
require(['jquery', 'ipuUI', 'mobile', 'ipuMobile', 'jcl', 'common', 'userManager', 'vali'], function ($, ipuUI, Mobile, WadeMobile, Wade, Common, userManager, Vali) {
2
  $(function () {
3
4
    // 初始化登录页面
5
    showCurrentUserData();
6
7
    //记住密码
8
    $(".remember-pwd").click(function () {
9
      if ($(".remember-pwd").find(".app-icon").hasClass("icon-checkbox-blank-circle-outline")) {
10
        $(".remember-pwd").find(".app-icon").removeClass("icon-checkbox-blank-circle-outline");
11
        $(".remember-pwd").find(".app-icon").addClass("icon-checkbox-marked-circle");
12
      } else {
13
        $(".remember-pwd").find(".app-icon").addClass("icon-checkbox-blank-circle-outline");
14
        $(".remember-pwd").find(".app-icon").removeClass("icon-checkbox-marked-circle");
15
      }
16
    });
17
18
    // 获取焦点,变更底边框颜色
19
    $(".form-row").focusin(function () {
20
      $(this).addClass("form-row-focus");
21
    });
22
23
    // 丢失焦点,恢复底边框颜色
24
    $(".form-row").focusout(function () {
25
      $(this).removeClass("form-row-focus");
26
    });
27
28
    // 清空输入框
29
    $(".input-clear").click(function () {
30
      var row = $(this).parents(".form-row");
31
      $("input", row).val("");
32
      $(this).hide();
33
    });
34
35
    //显示隐藏清空按钮
36
    $(".form-row .form-input").on('keyup blur', checkInput);
37
38
    function checkInput() {
39
      if ($.trim($(this).val()) != "") {
40
        $(".input-clear", $(this).parents(".form-row")).show();
41
      } else {
42
        $(".input-clear", $(this).parents(".form-row")).hide();
43
      }
44
    }
45
46
    // 获取验证码,倒计时
47
    $(".send-code").click(function () {
48
      var params = Wade.DataMap();
49
      var phone="1353456788";
50
      params.put("phone",phone);
51
52
      if (!$(this).hasClass("time-count")) { // 非倒计时状态,获取验证码
53
        var total = 60; // 倒计总时长
54
        var sendBtn = $(this).addClass("time-count");
55
        var defaultText = sendBtn.text();
56
57
        // 向后台请求数据
58
        Common.callSvc("LoginBean.sendVerificationCode", params, function(result){
59
          result = typeof(result) == "string" ? Wade.DataMap(result) : result;
60
          if(result.get(Constant.RETURN_CODE_KEY) == Constant.RETURN_CODE_SUCCESS){
61
            ipuUI.toast(result.get(Constant.RETURN_MSG_KEY));
62
            // 登录按钮可用
63
            $(".ipu-btn").prop("disabled",false);
64
          }else{
65
            ipuUI.toast(result.get(Constant.RETURN_MSG_KEY));
66
            return;
67
          }
68
        });
69
70
        function updateTimeCount() {
71
          total--;
72
          if (total > 0) {
73
            sendBtn.text(total + "s");
74
            setTimeout(updateTimeCount, 1000);
75
          } else {
76
            sendBtn.text(defaultText).removeClass("time-count");
77
          }
78
        }
79
        updateTimeCount();
80
81
        // 验证码输入框可输入
82
        $("#4a_code").prop("disabled",false);
83
      }
84
    });
85
86
    // 点登录进入首页
87
    $(".ipu-btn").click(function () {
88
      var params = Wade.DataMap();
89
      var userAccount = $("#4a_name").val();
90
      var password = $("#4a_password").val();
91
      var verificationCode = $("#4a_code").val();
92
      // 校验用户名是否为空
93
      if(!Vali.isNotNull(userAccount,"用户名")){
94
        $("#4a_name").val("").focus();
95
        return;
96
      }
97
      // 校验密码是否为空
98
      if(!Vali.isNotNull(password,"密码")){
99
        $("#4a_password").val("").focus();
100
        return;
101
      }
102
      // 校验验证码是否为空
103
      if(!Vali.isNotNull(verificationCode,"验证码")){
104
        $("#4a_code").val("").focus();
105
        return;
106
      }
107
      params.put(userManager.userAccount, userAccount);
108
      params.put(userManager.passwd, password);
109
      params.put("verificationCode", verificationCode);
110
      params.put(userManager.hasRememberPasswd, $(".remember-pwd").find(".app-icon").hasClass("icon-checkbox-blank-circle-outline") ? userManager.hasRememberPasswd_false : userManager.hasRememberPasswd_true);
111
      // 加载请求等待样式
112
      ipuUI.showIndicator();
113
      // 向后台请求数据
114
      Common.callSvc("LoginBean.login", params, function (result) {
115
        result = typeof(result) == "string" ? Wade.DataMap(result) : result;
116
        if(result.get(Constant.RETURN_CODE_KEY) == Constant.RETURN_CODE_SUCCESS){
117
          // 用户数据本地保存
118
          userManager.addUserData(params);
119
          Common.putLocal(Constant.LAST_PASSWORD, password);
120
          // 保存主账号数据
121
          Common.put(Constant.SESSION_ID, result.get("SESSION_ID"));
122
          Common.put(Constant.STAFF_ID, result.get("USER_ID"));
123
          Common.put("userAccount", userAccount);
124
          // 传递至一下页面的参数
125
          var dataParam = Wade.DataMap();
126
          dataParam.put("userId", result.get("USER_ID"));
127
          dataParam.put("userAccount", userAccount);
128
          dataParam.put("userName", result.get("USER_NAME"));
129
          dataParam.put("email", result.get("USER_MAIL"));
130
          dataParam.put("lastPage", "Login");
131
          // 打开主页
132
          //Mobile.openTemplate("Index",dataParam);
133
          ipuUI.toast("登录成功!");
134
          Mobile.openTemplate("Login",dataParam);
135
          // 关闭请求等待样式
136
          ipuUI.hideIndicator();
137
        }else{
138
          ipuUI.toast(result.get(Constant.RETURN_MSG_KEY));
139
          ipuUI.hideIndicator();
140
        }
141
      });
142
143
    });
144
145
    // 手势密码登录
146
    $("#gesture-pass-login").click(function () {
147
      //判断是否设置过手势锁
148
      userManager.getCurrentUserData(function(userData){
149
        if(userData==null){
150
          return ;
151
        }
152
        var gestureValue = userData.get(userManager.gesturePasswd);
153
        var usingGesturePasswd = userData.get(userManager.usingGesturePasswd);
154
        if(usingGesturePasswd&&JSON.parse(usingGesturePasswd)){
155
          if(gestureValue){
156
            // 有手势锁样式
157
            var param = Wade.DataMap();
158
            var data = Wade.DataMap();
159
            data.put("loginFlag", "1");
160
            param.put("data", data);
161
            Mobile.openTemplate("GestureLockLogin", param);
162
          }else{
163
            // 没有手势锁样式
164
            ipuUI.toast("还未设置手势锁");
165
          }
166
        }else{
167
          // 没有手势锁样式
168
          ipuUI.toast("还未启用手势锁");
169
        }
170
      });
171
    });
172
173
    // 初始化登录用户数据
174
    function showCurrentUserData() {
175
      userManager.getCurrentUserData(function (userData) {
176
        if(userData==null){
177
          return;
178
        }
179
        var _hasRememberPasswd = userData.get(userManager.hasRememberPasswd);
180
        // 记录密码
181
        if (_hasRememberPasswd == userManager.hasRememberPasswd_true) {//记录密码
182
          $(".remember-pwd").find(".app-icon").removeClass("icon-checkbox-blank-circle-outline");
183
          $(".remember-pwd").find(".app-icon").addClass("icon-checkbox-marked-circle");
184
          if (userData.get(userManager.userAccount)) {
185
            $("#4a_name").val(userData.get(userManager.userAccount));
186
          }
187
          if (userData.get(userManager.passwd)) {
188
            // 聚焦到密码末尾
189
            $("#4a_password").val("").focus().val(userData.get(userManager.passwd));
190
          }
191
192
        } else if (_hasRememberPasswd == userManager.hasRememberPasswd_false) {//不记录密码
193
          // 不记录密码样式
194
          $(".remember-pwd").find(".app-icon").addClass("icon-checkbox-blank-circle-outline");
195
          $(".remember-pwd").find(".app-icon").removeClass("icon-checkbox-marked-circle");
196
          // 聚焦到用户名
197
          $("#4a_name").val("").focus();
198
          $("#4a_password").val("");
199
        }
200
201
      });
202
    }
203
204
205
  });
206
});

+ 85 - 0
show-server/src/main/webapp/template/webapp/video/login.html

@ -0,0 +1,85 @@
1
<!doctype html>
2
<html>
3
<head>
4
  <title>登录</title>
5
  {%>template/common/Head.html%}
6
  <script src="biz/js/video/login.js"></script>
7
</head>
8
<body class="pages-login">
9
<div class="ipu-flex-row ipu-flex-vertical">
10
    <div class="ipu-flex-col  login-head">
11
      <div class="login-head-content">
12
        <div class="app-info">
13
          <span class="app-logo"></span>
14
          <span class="app-name">超级客户端登录</span>
15
        </div>
16
      </div>
17
18
    </div>
19
    <div class="ipu-flex-col ipu-flex-col-auto ipu-flex-row ipu-flex-vertical">
20
      <div class="ipu-flex-col ipu-tab-body">
21
22
        <ul class="type-4a">
23
          <li class="login-type-4a">
24
            <div class="page-content">
25
              <div class="page-form">
26
27
                <div class="form-row-label">
28
                  NT账号
29
                </div>
30
                <div class="ipu-flex form-row">
31
                  <div class="ipu-flex-col-auto  form-input-wrap">
32
                    <input type="text" class="form-input" id="4a_name" placeholder="请输入您的用户名">
33
                  </div>
34
                  <div class="ipu-flex-col form-input-asset">
35
                    <div class="app-icon icon-close-circle input-clear"></div>
36
                  </div>
37
                </div>
38
39
                <div class="form-row-label">
40
                  密码
41
                </div>
42
                <div class="ipu-flex form-row">
43
                  <div class="ipu-flex-col-auto  form-input-wrap">
44
                    <input type="password" class="form-input" id="4a_password" placeholder="请输入您的密码">
45
                  </div>
46
                  <div class="ipu-flex-col form-input-asset">
47
                    <div class="app-icon icon-close-circle input-clear"></div>
48
                  </div>
49
                </div>
50
51
                <div class="form-row-label">
52
                  短信验证码
53
                </div>
54
                <div class="ipu-flex form-row">
55
                  <div class="ipu-flex-col-auto  form-input-wrap">
56
                    <input type="text" class="form-input" id="4a_code" placeholder="请输入您的短信验证码" disabled>
57
                  </div>
58
                  <div class="ipu-flex-col form-input-asset">
59
                    <div class="send-code">发送验证码</div>
60
                  </div>
61
                </div>
62
63
                <div class="login-assets">
64
                  <a  href="javascript:;" class="link-gesture-login" id="gesture-pass-login">手势密码登录</a>
65
                  <div class="remember-pwd">
66
                    <div class="ipu-flex">
67
                      <div class="app-icon icon-checkbox-blank-circle-outline"></div>
68
                      <div><p>记住密码</p></div>
69
                    </div>
70
                  </div>
71
                </div>
72
73
                <div class="form-btns">
74
                  <button class="ipu-btn common-btn" disabled>登录</button>
75
                </div>
76
              </div>
77
            </div>
78
          </li>
79
        </ul>
80
81
      </div>
82
    </div>
83
</div>
84
</body>
85
</html>