浏览代码

上下班功能

seimin 3 年之前
父节点
当前提交
5eb2019dff
共有 4 个文件被更改,包括 316 次插入33 次删除
  1. 37 29
      index.html
  2. 59 4
      src/views/my.vue
  3. 219 0
      static/jssdk/jssdk.js
  4. 1 0
      static/jssdk/jweixin-1.2.0.js

+ 37 - 29
index.html

@@ -1,34 +1,42 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3
-  <head>
4
-    <meta charset="utf-8">
5
-    <link rel="stylesheet" href="./static/css/iconfont.css">
6
-    <script src="./static/js/JQ-3.3.1.js"></script>
7
-    <meta name="viewport"
8
-        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover">
9
-    <!-- <meta name="viewport" content="width=device-width,intial-scale=1,user-
3
+
4
+<head>
5
+  <meta charset="utf-8">
6
+  <link rel="stylesheet" href="./static/css/iconfont.css">
7
+  <script src="./static/js/JQ-3.3.1.js"></script>
8
+  <meta name="viewport"
9
+    content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover">
10
+  <!-- <meta name="viewport" content="width=device-width,intial-scale=1,user-
10 11
         scalable=no"> -->
11
-    <title>微信运维</title> 
12
-    <style>
13
-      html{
14
-        background-color: white;
15
-        height: 100vh;
16
-      }
17
-      body{
18
-        margin: 0;
19
-        padding: 0;
20
-        background-color: white
21
-      }
22
-      img{
23
-        vertical-align: middle
24
-      }
25
-      a{
26
-        text-decoration: none
27
-      }
28
-    </style>
29
-  </head>
30
-  <body>
31
-    <div id="app"></div>
32
-  </body>
12
+  <title>微信运维</title>
13
+  <style>
14
+    html {
15
+      background-color: white;
16
+      height: 100vh;
17
+    }
18
+
19
+    body {
20
+      margin: 0;
21
+      padding: 0;
22
+      background-color: white
23
+    }
24
+
25
+    img {
26
+      vertical-align: middle
27
+    }
28
+
29
+    a {
30
+      text-decoration: none
31
+    }
32
+  </style>
33
+  <!-- <script src="./static/jssdk/jweixin-1.2.0.js"></script> -->
34
+  <!-- <script src="./static/jssdk/jssdk.js"></script> -->
35
+</head>
36
+
37
+<body>
38
+  <div id="app"></div>
39
+</body>
40
+
33 41
 </html>
34 42
 <script src="./static/js/public.js"></script>

+ 59 - 4
src/views/my.vue

@@ -1,7 +1,9 @@
1 1
 <template>
2 2
   <div class="bgColor">
3 3
     <div class="head">
4
-      <div class="img"></div>
4
+      <div class="img" @click="goToWork(loginUser.online)">
5
+        {{ loginUser.online == 1 ? "下班" : "上班" }}
6
+      </div>
5 7
       <div class="name">{{ loginUser.name }}</div>
6 8
     </div>
7 9
     <div class="myMessage">
@@ -15,7 +17,9 @@
15 17
           <div>手机号</div>
16 18
           <div v-if="!loginUser.phone"></div>
17 19
           <div v-if="loginUser.phone">
18
-            <a :href="'tel:' + loginUser.phone"><i class="iconfont icon-shouji"></i>{{ loginUser.phone }}</a>
20
+            <a :href="'tel:' + loginUser.phone"
21
+              ><i class="iconfont icon-shouji"></i>{{ loginUser.phone }}</a
22
+            >
19 23
           </div>
20 24
         </li>
21 25
         <li>
@@ -111,6 +115,8 @@
111 115
   </div>
112 116
 </template>
113 117
 <script>
118
+// let sdk = new jssdk(3, "https://wx2.zuel.edu.cn"); // 域名更换为对应环境域名, 204 更换为对应环境wid
119
+// sdk.config(1); //1表示调试模式,生产环境传0
114 120
 import "./../../static/css/iconfont.js";
115 121
 export default {
116 122
   data() {
@@ -125,6 +131,50 @@ export default {
125 131
     };
126 132
   },
127 133
   methods: {
134
+    //获取位置,经纬度
135
+    // getLocation() {
136
+    //   //第二个参数 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
137
+    //   sdk.getLocation(function(res) {
138
+    //     alert(res);
139
+    //   }, "wgs84");
140
+    // },
141
+    // 上下班
142
+    goToWork(online) {
143
+      // this.getLocation();
144
+      online = online == 1 ? 0 : 1;
145
+      const toast = this.$createToast({
146
+        time: 0,
147
+        mask: true,
148
+        txt: "正在加载中"
149
+      });
150
+      toast.show();
151
+      this.$http
152
+        .post("service/auth/online", { onlion: online, address: "" })
153
+        .then(res => {
154
+          toast.hide();
155
+          if (res.status == 200) {
156
+            this.loginUser.online = online;
157
+            localStorage.setItem("loginUser", JSON.stringify(this.loginUser));
158
+            const t = this.$createToast({
159
+              type: "txt",
160
+              txt: online == 1 ? "上班成功" : "下班成功"
161
+            });
162
+            t.show();
163
+            setTimeout(() => {
164
+              t.hide();
165
+            }, 1000);
166
+          } else {
167
+            const t = this.$createToast({
168
+              type: "txt",
169
+              txt: online == 1 ? "上班失败" : "下班失败"
170
+            });
171
+            t.show();
172
+            setTimeout(() => {
173
+              t.hide();
174
+            }, 1000);
175
+          }
176
+        });
177
+    },
128 178
     // 工作组
129 179
     getGroups() {
130 180
       var that = this;
@@ -211,8 +261,13 @@ export default {
211 261
   border-radius: 50%;
212 262
   margin: 0 auto;
213 263
   overflow: hidden;
214
-  background: url(./../../static/images/pig.jpg);
215
-  background-size: contain;
264
+  /* background: url(./../../static/images/pig.jpg); */
265
+  /* background-size: contain; */
266
+  background-color: #fff;
267
+  display: flex;
268
+  justify-content: center;
269
+  align-items: center;
270
+  font-size: 0.32rem;
216 271
 }
217 272
 
218 273
 .head .name {

+ 219 - 0
static/jssdk/jssdk.js

@@ -0,0 +1,219 @@
1
+function jssdk(wid, domain) {
2
+    this.wid = wid;
3
+    if (typeof domain == "undefined") {
4
+        domain = window.location.origin;
5
+    }
6
+    this.domain = domain;
7
+}
8
+
9
+// title,desc,link,imgUrl
10
+jssdk.prototype._shareQQ = function (shareData) {
11
+    wx.onMenuShareQQ(shareData);
12
+};
13
+
14
+// title,desc,link,imgUrl
15
+jssdk.prototype._shareWeibo = function (shareData) {
16
+    wx.onMenuShareWeibo(shareData);
17
+};
18
+
19
+// title,link,imgUrl
20
+jssdk.prototype._shareTimeline = function (shareData) {
21
+    wx.onMenuShareTimeline(shareData);
22
+};
23
+// title,desc,link,imgUrl
24
+// type 分享类型 music/video/link[default]
25
+// dataUrl type=music/video,则要提供数据链接,默认为空
26
+jssdk.prototype._shareAppMessage = function (shareData) {
27
+    wx.onMenuShareAppMessage(shareData);
28
+};
29
+//title 分享给朋友标题 desc 分享给朋友描述 imgUrl  分享图标 timetitle 分享到朋友圈标题
30
+jssdk.prototype.share = function (title, desc, imgUrl, timetitle, success) {
31
+    if (typeof success != "function") {
32
+        success = function () {
33
+        };
34
+    }
35
+    var link=arguments[5] ? arguments[5] : _sdk_config.getUrl(true); 
36
+    _sdk_config.config(this.wid, this.domain);
37
+    var that = this;
38
+    wx.ready(function () {
39
+        that._shareQQ({title: title, desc: desc, link: link, imgUrl: imgUrl, success: success});
40
+        that._shareWeibo({title: title, desc: desc, link: link, imgUrl: imgUrl, success: success});
41
+        that._shareTimeline({title: timetitle, link: link, imgUrl: imgUrl, success: success});
42
+        that._shareAppMessage({title: title, desc: desc, link: link, imgUrl: imgUrl, success: success});
43
+    });
44
+}
45
+
46
+jssdk.prototype.config = function (debug) {
47
+    _sdk_config.config(this.wid, this.domain, debug);
48
+}
49
+jssdk.prototype.previewImage = function (data) {
50
+    wx.previewImage(data);
51
+}
52
+
53
+jssdk.prototype.qrcode = function (callback) {
54
+    wx.scanQRCode({
55
+        needResult: 1,
56
+        scanType: ["qrCode","barCode"],
57
+        success: function (res) {
58
+            callback(res.resultStr);
59
+        }
60
+    });
61
+};
62
+
63
+jssdk.prototype.getLocation = function (callback) {
64
+    wx.ready(function(){
65
+        wx.getLocation({
66
+            type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
67
+            success: function (res) {
68
+                callback(res);
69
+            }
70
+        })
71
+    });
72
+}
73
+
74
+jssdk.prototype.chooseWXPay = function (option) {
75
+    wx.chooseWXPay(option);
76
+};
77
+
78
+// 控制分享接口
79
+jssdk.prototype.controlShareMenu = function(option){
80
+    _sdk_config.config(this.wid, this.domain);
81
+    var that = this;
82
+    wx.ready(function(){
83
+        if (option != 'hideAllNonBaseMenuItem') {
84
+            that._hideMenuItems(option);
85
+        } else {
86
+            wx.hideAllNonBaseMenuItem();    // 隐藏所有
87
+        }
88
+    });
89
+};
90
+// 选择隐藏
91
+jssdk.prototype._hideMenuItems = function(option){
92
+    var option = eval("("+option+")");
93
+    wx.hideMenuItems({
94
+        menuList: option
95
+    });
96
+};
97
+
98
+jssdk.prototype.chooseImage = function (option, callback) {
99
+    var def = {
100
+        count: 9,
101
+        sizeType: ['original', 'compressed'],
102
+        sourceType: ['album', 'camera'],
103
+        success: function(res) {
104
+            callback(res);
105
+        }
106
+    };
107
+    for(var i in option) {
108
+        def[i] = option[i];
109
+    }
110
+    wx.chooseImage(def);
111
+};
112
+
113
+jssdk.prototype.uploadImage = function (option, callback) {
114
+    var def = {
115
+        localId: '',
116
+        isShowProgressTips: 1,
117
+        success: function(res) {
118
+            callback(res);
119
+        }
120
+    };
121
+    for(var i in option) {
122
+        def[i] = option[i];
123
+    }
124
+    wx.uploadImage(def);
125
+};
126
+
127
+var _sdk_config = {
128
+    _config_state: [],
129
+    _url: "",
130
+    _apiList: [
131
+        'onMenuShareTimeline',
132
+        'onMenuShareAppMessage',
133
+        'onMenuShareQQ',
134
+        'onMenuShareWeibo',
135
+        'scanQRCode',
136
+        'chooseWXPay',
137
+        'previewImage',
138
+        'openLocation',
139
+        'getLocation',
140
+        'openEnterpriseChat',
141
+        'openEnterpriseContact',
142
+        'hideAllNonBaseMenuItem', // 添加
143
+        'hideMenuItems',
144
+        'chooseImage',
145
+        'uploadImage'
146
+    ],
147
+    addApiList: function (api) {
148
+        this._apiList.push(api);
149
+    },
150
+    config: function (wid, domain, debug, force) {
151
+        if (this._config_state[wid] && !force) {
152
+            return;
153
+        }
154
+        this._config_state[wid] = true;
155
+        var that = this;
156
+        $.ajax({
157
+            type: "get",
158
+            url: domain + '/uc/api/wx-jssdk/config',
159
+            dataType: "jsonp",
160
+            jsonp: "callback",
161
+            data: ({
162
+                wid: wid,
163
+                url: this.getUrl()
164
+            }),
165
+            success: function (data) {
166
+                var configData = {
167
+                    // beta: true,// 必须这么写,否则wx.invoke调用形式的jsapi会有问题
168
+                    debug: debug ? true : false,
169
+                    appId: data.appId,
170
+                    timestamp: data.timestamp,
171
+                    nonceStr: data.nonceStr,
172
+                    signature: data.signature,
173
+                    jsApiList: that._apiList
174
+                };
175
+                wx.config(configData);
176
+            }
177
+        });
178
+    },
179
+    getUrl: function (clear) {
180
+        if (!this._url) {
181
+            var l = window.location;
182
+            this._url = l.protocol + '//' + l.host + l.pathname + l.search;
183
+        }
184
+
185
+        if (typeof clear != "undefined") {
186
+            return this.delQueStr(this._url, ['code', 'CODE', 'state', 'STATE']);
187
+        }
188
+        return this._url;
189
+    },
190
+    delQueStr: function (url, strs) {
191
+        var str = "";
192
+
193
+        if (url.indexOf('?') != -1)
194
+            str = url.substr(url.indexOf('?') + 1);
195
+        else
196
+            return url;
197
+        for (var i = 0; i < strs.length; i++) {
198
+            var returnurl = "";
199
+            var ref = strs[i];
200
+            if (str.indexOf('&') != -1) {
201
+                var arr = str.split('&');
202
+                for (var ii in arr) {
203
+                    var nf = arr[ii].split('=');
204
+                    if (nf[0] != ref) {
205
+                        returnurl += arr[ii] + "&";
206
+                    }
207
+                }
208
+                url = url.substr(0, url.indexOf('?')) + "?" + returnurl.substr(0, returnurl.length - 1);
209
+            } else {
210
+                var arr = str.split('=');
211
+                if (arr[0] == ref)
212
+                    url = url.substr(0, url.indexOf('?'));
213
+                else
214
+                    url = url;
215
+            }
216
+        }
217
+        return url;
218
+    }
219
+};

文件差异内容过多而无法显示
+ 1 - 0
static/jssdk/jweixin-1.2.0.js