yuexiu-xcx-login 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 petzold
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # nx-xcx-login
2
+
3
+ 农信小程序登录组件:
4
+
5
+ * 集成手机号登录(微信)
6
+ * 集成账号密码登录
7
+ * 集成快捷登录,手机号+验证码,未注册时创建用户
8
+
9
+ ## 前提条件
10
+ * 绑定至开放平台
11
+ * 报备wxAppId,secret
12
+
13
+ ## 使用
14
+ * 在小程序根目录上执行 npm init 或 yarn init
15
+ * 使用 npm install nx-xcx-login --save 安装小程序npm
16
+ * 安装utils库:npm install nx-xcx-utils
17
+ * 勾选 详情-》本地设置 下的使用npm模块
18
+ * 点击菜单 工具-》构建npm
19
+ * 在使用的页面的 json 文件 usingComponents 节点下添加 "nx-xcx-login": "nx-xcx-login"
20
+ * <nx-xcx-login title="标题" icon="../../images/login-logo.png" retUrl="{{retUrl}}"></nx-xcx-login>
21
+
22
+ ### 登录参数配置
23
+ * 相关文档 https://www.npmjs.com/package/nx-xcx-utils
24
+ * 在app.js里
25
+ ```js
26
+ import { configLogin } from 'nx-xcx-utils';
27
+
28
+ configLogin({
29
+ env: 1, //环境信息,根据此配置将请求信息推送至不同的采集站,1:测试 2:预生产 3:正式
30
+ loginPage: '登录页地址',
31
+ failPage: '授权失败地址,ex:授权取消',
32
+ systemId: 1,
33
+ channel: '短信通道',
34
+ theme: '主题配置'
35
+ });
36
+ ```
37
+ * 页面中配置登录拦截
38
+ ```js
39
+ import { logout, getLoginUser, logout, loginBehavior } from 'nx-xcx-utils';
40
+
41
+ behaviors: [loginBehavior] // 放置于data同级处,标识页面需要登录
42
+
43
+ // 获取登录用户
44
+ // 如果已经登录,直接从stoge里获取用户信息
45
+ // 如果用户未登录,先使用wx.login获取code,然后接口查询,如果用户已经绑定过,根据用户信息进行会话设置并返回,如果flag为false,则返回null,如果flag为true则reject
46
+ getLoginUser(flag: boolean = false): Promise<LoginUser>
47
+
48
+ getLoginUserSync(): LoginUser | null // 获取登录用户信息(同步方法),仅从stoge里获取
49
+
50
+ // 退出
51
+ // flag为false是仅清理stoge中用户信息,flag为true时除清理stoge中用户信息外还将解绑微信, webview中会话信息请自行清理
52
+ logout(flag: boolean = false): Promise<boolean>
53
+ ```
54
+ * theme 主题(可选),可用值及对应色值
55
+ theme_sc #ff0023
56
+ theme_zx #ff2c71
57
+ theme_egg #f5cf49
58
+ theme_black #262a2f
59
+ theme_gray #47525d
60
+ theme_blue #2d86fe
61
+ theme_green #22d7bb
62
+ theme_orange #ff9600
63
+
64
+ ### 参数说明
65
+ * title 授权页标题,请填写小程序所属产品名称
66
+ * icon 授权页图标,请使用小程序所属产品图标
67
+ * retUrl 授权取消时回退页面,应该配置为小程序登录前页面,由拦截器根据当前地址决定,做为动态参数传入登录页
68
+
69
+ ### 新增页面web-container,用于小程序内html内容的状态同步(小程序登录后,webview也登录)
70
+ * 请在app.json里先进行注册
71
+ * 使用wx.redirectTo或wx.reLaunch加载,参数如下
72
+
73
+ | 参数 | 说明 |
74
+ | ---- | ---- |
75
+ | url | 要到的目标页(请编码) |
76
+ | flag | true/false,是否需要处理登录 |
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,400 @@
1
+ module.exports =
2
+ /******/ (function(modules) { // webpackBootstrap
3
+ /******/ // The module cache
4
+ /******/ var installedModules = {};
5
+ /******/
6
+ /******/ // The require function
7
+ /******/ function __webpack_require__(moduleId) {
8
+ /******/
9
+ /******/ // Check if module is in cache
10
+ /******/ if(installedModules[moduleId]) {
11
+ /******/ return installedModules[moduleId].exports;
12
+ /******/ }
13
+ /******/ // Create a new module (and put it into the cache)
14
+ /******/ var module = installedModules[moduleId] = {
15
+ /******/ i: moduleId,
16
+ /******/ l: false,
17
+ /******/ exports: {}
18
+ /******/ };
19
+ /******/
20
+ /******/ // Execute the module function
21
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22
+ /******/
23
+ /******/ // Flag the module as loaded
24
+ /******/ module.l = true;
25
+ /******/
26
+ /******/ // Return the exports of the module
27
+ /******/ return module.exports;
28
+ /******/ }
29
+ /******/
30
+ /******/
31
+ /******/ // expose the modules object (__webpack_modules__)
32
+ /******/ __webpack_require__.m = modules;
33
+ /******/
34
+ /******/ // expose the module cache
35
+ /******/ __webpack_require__.c = installedModules;
36
+ /******/
37
+ /******/ // define getter function for harmony exports
38
+ /******/ __webpack_require__.d = function(exports, name, getter) {
39
+ /******/ if(!__webpack_require__.o(exports, name)) {
40
+ /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
41
+ /******/ }
42
+ /******/ };
43
+ /******/
44
+ /******/ // define __esModule on exports
45
+ /******/ __webpack_require__.r = function(exports) {
46
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
47
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48
+ /******/ }
49
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
50
+ /******/ };
51
+ /******/
52
+ /******/ // create a fake namespace object
53
+ /******/ // mode & 1: value is a module id, require it
54
+ /******/ // mode & 2: merge all properties of value into the ns
55
+ /******/ // mode & 4: return value when already ns object
56
+ /******/ // mode & 8|1: behave like require
57
+ /******/ __webpack_require__.t = function(value, mode) {
58
+ /******/ if(mode & 1) value = __webpack_require__(value);
59
+ /******/ if(mode & 8) return value;
60
+ /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
61
+ /******/ var ns = Object.create(null);
62
+ /******/ __webpack_require__.r(ns);
63
+ /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
64
+ /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
65
+ /******/ return ns;
66
+ /******/ };
67
+ /******/
68
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
69
+ /******/ __webpack_require__.n = function(module) {
70
+ /******/ var getter = module && module.__esModule ?
71
+ /******/ function getDefault() { return module['default']; } :
72
+ /******/ function getModuleExports() { return module; };
73
+ /******/ __webpack_require__.d(getter, 'a', getter);
74
+ /******/ return getter;
75
+ /******/ };
76
+ /******/
77
+ /******/ // Object.prototype.hasOwnProperty.call
78
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
79
+ /******/
80
+ /******/ // __webpack_public_path__
81
+ /******/ __webpack_require__.p = "";
82
+ /******/
83
+ /******/
84
+ /******/ // Load entry module and return exports
85
+ /******/ return __webpack_require__(__webpack_require__.s = 0);
86
+ /******/ })
87
+ /************************************************************************/
88
+ /******/ ([
89
+ /* 0 */
90
+ /***/ (function(module, exports, __webpack_require__) {
91
+
92
+ "use strict";
93
+
94
+
95
+ var _xcxLogin = __webpack_require__(1);
96
+
97
+ Component({
98
+ properties: {
99
+ retUrl: {
100
+ type: String,
101
+ value: ''
102
+ },
103
+ failPage: {
104
+ type: String,
105
+ value: ''
106
+ },
107
+ domain: {
108
+ type: String,
109
+ value: ''
110
+ },
111
+ env: {
112
+ type: Number,
113
+ value: 0
114
+ },
115
+ channel: {
116
+ type: String,
117
+ value: ''
118
+ }
119
+ },
120
+ data: {
121
+ mode: 1,
122
+ phone: '',
123
+ code: '',
124
+ seconds: 0,
125
+ userName: '',
126
+ password: '',
127
+ acceptXy: false,
128
+ ticket: '' // 短信票据
129
+ },
130
+ lifetimes: {
131
+ ready: function ready() {}
132
+ },
133
+ methods: {
134
+ switchTab: function switchTab(e) {
135
+ this.setData({ mode: Number.parseInt(e.currentTarget.dataset.mode, 10) });
136
+ },
137
+ sendSms: function sendSms() {
138
+ var _this = this;
139
+
140
+ var _data = this.data,
141
+ env = _data.env,
142
+ domain = _data.domain,
143
+ phone = _data.phone;
144
+
145
+ if (!/1[3-9]\d{9}$/.test(phone)) {
146
+ wx.showToast({ title: '手机号码不正确', icon: 'none' });
147
+ return;
148
+ }
149
+ var channel = this.properties.channel;
150
+
151
+ (0, _xcxLogin.sendSms)(env, domain, phone, channel).then(function (_ref) {
152
+ var code = _ref.code,
153
+ data = _ref.data,
154
+ msg = _ref.msg;
155
+
156
+ if (code === 0) {
157
+ _this.setData({ ticket: data });
158
+ } else {
159
+ wx.showToast({ title: msg, icon: 'none' });
160
+ }
161
+ });
162
+ },
163
+ loginCustomer: function loginCustomer() {
164
+ var _this2 = this;
165
+
166
+ var _data2 = this.data,
167
+ env = _data2.env,
168
+ domain = _data2.domain,
169
+ ticket = _data2.ticket,
170
+ code = _data2.code,
171
+ acceptXy = _data2.acceptXy;
172
+
173
+ if (!acceptXy) {
174
+ wx.showToast({ title: '请先接受协议', icon: 'none' });
175
+ return;
176
+ }
177
+ if (!ticket) {
178
+ wx.showToast({ title: '请先发送短信', icon: 'none' });
179
+ return;
180
+ }
181
+ if (!/^\d{6}$/.test(code)) {
182
+ wx.showToast({ title: '请填写验证码', icon: 'none' });
183
+ return;
184
+ }
185
+ (0, _xcxLogin.smsLogin)(env, domain, ticket, code).then(function (_ref2) {
186
+ var code = _ref2.code,
187
+ data = _ref2.data,
188
+ msg = _ref2.msg;
189
+
190
+ if (code === 0) {
191
+ wx.setStorage({
192
+ key: 'login-data',
193
+ data: data,
194
+ fail: function fail(_ref3) {
195
+ var errMsg = _ref3.errMsg;
196
+ return wx.showToast({ title: errMsg, icon: 'none' });
197
+ }
198
+ });
199
+ wx.reLaunch({ url: _this2.properties.retUrl });
200
+ } else {
201
+ wx.showToast({ title: msg, icon: 'none' });
202
+ }
203
+ });
204
+ },
205
+ loginStaff: function loginStaff() {
206
+ var _this3 = this;
207
+
208
+ var _data3 = this.data,
209
+ env = _data3.env,
210
+ domain = _data3.domain,
211
+ userName = _data3.userName,
212
+ password = _data3.password,
213
+ acceptXy = _data3.acceptXy;
214
+
215
+ if (!acceptXy) {
216
+ wx.showToast({ title: '请先接受协议', icon: 'none' });
217
+ return;
218
+ }
219
+ if (!userName) {
220
+ wx.showToast({ title: '请填写用户名', icon: 'none' });
221
+ return;
222
+ }
223
+ if (!password) {
224
+ wx.showToast({ title: '请填写密码', icon: 'none' });
225
+ return;
226
+ }
227
+ (0, _xcxLogin.accountLogin)(env, domain, userName, password).then(function (_ref4) {
228
+ var code = _ref4.code,
229
+ data = _ref4.data,
230
+ msg = _ref4.msg;
231
+
232
+ if (code === 0) {
233
+ wx.setStorage({
234
+ key: 'login-data',
235
+ data: data,
236
+ fail: function fail(_ref5) {
237
+ var errMsg = _ref5.errMsg;
238
+ return wx.showToast({ title: errMsg, icon: 'none' });
239
+ }
240
+ });
241
+ wx.reLaunch({ url: _this3.properties.retUrl });
242
+ } else {
243
+ wx.showToast({ title: msg, icon: 'none' });
244
+ }
245
+ });
246
+ }
247
+ }
248
+ });
249
+
250
+ /***/ }),
251
+ /* 1 */
252
+ /***/ (function(module, exports, __webpack_require__) {
253
+
254
+ "use strict";
255
+
256
+
257
+ exports.__esModule = true;
258
+ exports.sendSms = sendSms;
259
+ exports.smsLogin = smsLogin;
260
+ exports.accountLogin = accountLogin;
261
+ exports.login = login;
262
+
263
+ var _miniprogramSmCrypto = __webpack_require__(2);
264
+
265
+ var _requester = __webpack_require__(3);
266
+
267
+ function encryptPwd(env, domain, password) {
268
+ return (0, _requester.postForm)(env, 'yxnm-pt-iotcas', '.' + domain + '/gen-login-ticket', '').then(function (_ref) {
269
+ var data = _ref.data;
270
+ var _a, _b;return { password: '04' + _miniprogramSmCrypto.sm2.doEncrypt(password, (_a = data === null || data === void 0 ? void 0 : data.token) !== null && _a !== void 0 ? _a : ''), ticket: (_b = data === null || data === void 0 ? void 0 : data.ticket) !== null && _b !== void 0 ? _b : '' };
271
+ });
272
+ }
273
+ /**
274
+ * 发送短信
275
+ * @param env 环境
276
+ * @param phone 手机号
277
+ * @param channel 短信渠道
278
+ * @returns
279
+ */
280
+ function sendSms(env, domain, phone, channel) {
281
+ return (0, _requester.postForm)(env, 'yxnm-pt-iotcas', '.' + domain + '/send-sms', { phone: phone, channel: channel });
282
+ }
283
+ /**
284
+ * 小程序短信登录
285
+ * @param env 环境
286
+ * @param code 短信验证码
287
+ * @param ticket 短信票据
288
+ * @returns
289
+ */
290
+ function smsLogin(env, domain, ticket, code) {
291
+ return (0, _requester.postForm)(env, 'yxnm-pt-iotcas', '.' + domain + '/login', { code: code, ticket: ticket }, { 'X-Api-Version': '1' });
292
+ }
293
+ /**
294
+ * 小程序账户登录
295
+ * @param env 环境
296
+ * @param userName 用户名
297
+ * @param password 密码
298
+ * @returns
299
+ */
300
+ function accountLogin(env, domain, userName, password) {
301
+ return encryptPwd(env, domain, password).then(function (_ref2) {
302
+ var ticket = _ref2.ticket,
303
+ pwd = _ref2.password;
304
+ return (0, _requester.postForm)(env, 'yxnm-pt-iotcas', '.' + domain + '/login', { ticket: ticket, userName: userName, password: pwd }, { 'X-Api-Version': '2' });
305
+ });
306
+ }
307
+ function login(user) {
308
+ return new Promise(function (resolve, reject) {
309
+ wx.setStorage({
310
+ key: 'login-data',
311
+ data: user,
312
+ success: function success() {
313
+ return resolve(true);
314
+ },
315
+ fail: function fail(_ref3) {
316
+ var errMsg = _ref3.errMsg;
317
+ return reject(errMsg);
318
+ }
319
+ });
320
+ });
321
+ }
322
+
323
+ /***/ }),
324
+ /* 2 */
325
+ /***/ (function(module, exports) {
326
+
327
+ module.exports = require("miniprogram-sm-crypto");
328
+
329
+ /***/ }),
330
+ /* 3 */
331
+ /***/ (function(module, exports, __webpack_require__) {
332
+
333
+ "use strict";
334
+
335
+
336
+ exports.__esModule = true;
337
+ exports.postForm = postForm;
338
+ exports.postJson = postJson;
339
+ exports.get = get;
340
+
341
+ var _getUrl = __webpack_require__(4);
342
+
343
+ function req(env, prefix, stuffix, method, header, data) {
344
+ return new Promise(function (resolve, reject) {
345
+ wx.request({
346
+ url: (0, _getUrl.getUrl)(env, prefix, stuffix),
347
+ method: method,
348
+ header: header,
349
+ dataType: 'json',
350
+ data: data,
351
+ success: function success(_ref) {
352
+ var data = _ref.data;
353
+ return resolve(data);
354
+ },
355
+ fail: function fail(_ref2) {
356
+ var errMsg = _ref2.errMsg;
357
+ return reject(errMsg);
358
+ }
359
+ });
360
+ });
361
+ }
362
+ function post(env, prefix, stuffix, data, header) {
363
+ return req(env, prefix, stuffix, 'POST', header, data);
364
+ }
365
+ function postForm(env, prefix, stuffix, data, header) {
366
+ if (typeof data === 'string') {
367
+ return post(env, prefix, stuffix, data, Object.assign(Object.assign({}, header !== null && header !== void 0 ? header : {}), { 'content-type': 'application/x-www-form-urlencoded' }));
368
+ }
369
+ var body = Object.entries(data).map(function (_ref3) {
370
+ var key = _ref3[0],
371
+ value = _ref3[1];
372
+ return encodeURIComponent(key) + '=' + encodeURIComponent(value);
373
+ }).join('&');
374
+ return post(env, prefix, stuffix, body, Object.assign(Object.assign({}, header !== null && header !== void 0 ? header : {}), { 'content-type': 'application/x-www-form-urlencoded' }));
375
+ }
376
+ function postJson(env, prefix, stuffix, data, header) {
377
+ return post(env, prefix, stuffix, data, Object.assign(Object.assign({}, header !== null && header !== void 0 ? header : {}), { 'content-type': 'application/json' }));
378
+ }
379
+ function get(env, prefix, stuffix, header) {
380
+ return req(env, prefix, stuffix, 'GET', {}, '');
381
+ }
382
+
383
+ /***/ }),
384
+ /* 4 */
385
+ /***/ (function(module, exports, __webpack_require__) {
386
+
387
+ "use strict";
388
+
389
+
390
+ exports.__esModule = true;
391
+ exports.getUrl = getUrl;
392
+ var arr = ['prd', 'qas', 'dev', 'sit', 'uat', 'pre'];
393
+ function getUrl(env, prefix, stuffix) {
394
+ var sx = arr[env - 1];
395
+ return 'https://' + prefix + '-' + sx + stuffix;
396
+ }
397
+
398
+ /***/ })
399
+ /******/ ]);
400
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/index.ts","webpack:///./src/utils/xcx-login.ts","webpack:///external \"miniprogram-sm-crypto\"","webpack:///./src/utils/requester.ts","webpack:///./src/utils/get-url.ts"],"names":[],"mappings":";;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;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A+D,MAA/D,EAA8F;AAChG,WAAO,IAAO,GAAP,EAAY,MAAZ,EAAoB,OAApB,EAA6B,KAA7B,EAAoC,EAApC,EAAwC,EAAxC,CAAP;AACH,C;;;;;;;;;;QCnCe,M,GAAA,M;AADhB,IAAM,MAAM,CAAC,KAAD,EAAQ,KAAR,EAAe,KAAf,EAAsB,KAAtB,EAA6B,KAA7B,EAAoC,KAApC,CAAZ;AACM,SAAU,MAAV,CAAiB,GAAjB,EAA8B,MAA9B,EAA8C,OAA9C,EAA6D;AAC/D,QAAM,KAAK,IAAI,MAAM,CAAV,CAAX;AACA,wBAAkB,MAAlB,SAA4B,EAA5B,GAAiC,OAAjC;AACH,C","file":"index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","import { smsLogin, sendSms, accountLogin } from './utils/xcx-login';\n\nComponent({\n properties: {\n retUrl: {\n type: String,\n value: ''\n },\n failPage: {\n type: String, // 登录失败跳转页面\n value: ''\n },\n domain: {\n type: String, // 主域名\n value: ''\n },\n env: {\n type: Number, // 环境\n value: 0\n },\n channel: {\n type: String,\n value: ''\n }\n },\n data: {\n mode: 1, // 1. 客户登录 2: 员工登录\n phone: '', // 手机号\n code: '', // 验证码\n seconds: 0, // 倒计时\n userName: '', // 用户名\n password: '', // 密码\n acceptXy: false, // 是否接受协议\n ticket: '' // 短信票据\n },\n lifetimes: {\n ready(): void {\n }\n },\n methods: {\n switchTab(e) {\n this.setData({ mode: Number.parseInt(e.currentTarget.dataset.mode, 10) });\n },\n sendSms() {\n const { env, domain, phone } = this.data;\n if (!/1[3-9]\\d{9}$/.test(phone)) {\n wx.showToast({ title: '手机号码不正确', icon: 'none' });\n return;\n }\n const { channel } = this.properties;\n sendSms(env, domain, phone, channel).then(({ code, data, msg }) => {\n if (code === 0) {\n this.setData({ ticket: data });\n } else {\n wx.showToast({ title: msg, icon: 'none' });\n }\n });\n },\n loginCustomer() {\n const { env, domain, ticket, code, acceptXy } = this.data;\n if (!acceptXy) {\n wx.showToast({ title: '请先接受协议', icon: 'none' });\n return;\n }\n if (!ticket) {\n wx.showToast({ title: '请先发送短信', icon: 'none' });\n return;\n }\n if (!/^\\d{6}$/.test(code)) {\n wx.showToast({ title: '请填写验证码', icon: 'none' });\n return;\n }\n smsLogin(env, domain, ticket, code).then(({ code, data, msg }) => {\n if (code === 0) {\n wx.setStorage({\n key: 'login-data',\n data,\n fail: ({ errMsg }) => wx.showToast({ title: errMsg, icon: 'none' })\n });\n wx.reLaunch({ url: this.properties.retUrl });\n } else {\n wx.showToast({ title: msg, icon: 'none' });\n }\n });\n },\n loginStaff() {\n const { env, domain, userName, password, acceptXy } = this.data;\n if (!acceptXy) {\n wx.showToast({ title: '请先接受协议', icon: 'none' });\n return;\n }\n if (!userName) {\n wx.showToast({ title: '请填写用户名', icon: 'none' });\n return;\n }\n if (!password) {\n wx.showToast({ title: '请填写密码', icon: 'none' });\n return;\n }\n accountLogin(env, domain, userName, password).then(({ code, data, msg }) => {\n if (code === 0) {\n wx.setStorage({\n key: 'login-data',\n data,\n fail: ({ errMsg }) => wx.showToast({ title: errMsg, icon: 'none' })\n });\n wx.reLaunch({ url: this.properties.retUrl });\n } else {\n wx.showToast({ title: msg, icon: 'none' });\n }\n });\n }\n }\n})\n","import { sm2 } from 'miniprogram-sm-crypto';\r\nimport { ActionResult } from '../entity/action-result';\r\nimport { User } from '../entity/user';\r\nimport { postForm } from './requester';\r\n\r\nfunction encryptPwd(env: number, domain: string, password: string): Promise<{ password: string, ticket: string }> {\r\n return postForm<ActionResult<{ ticket: string, token: string }>>(env, 'yxnm-pt-iotcas', `.${domain}/gen-login-ticket`, '').then(({ data }) => ({ password: '04' + sm2.doEncrypt(password, data?.token ?? ''), ticket: data?.ticket ?? '' }));\r\n}\r\n\r\n/**\r\n * 发送短信\r\n * @param env 环境\r\n * @param phone 手机号\r\n * @param channel 短信渠道\r\n * @returns\r\n */\r\nexport function sendSms(env: number, domain: string, phone: string, channel: string): Promise<ActionResult<string>> {\r\n return postForm(env, 'yxnm-pt-iotcas', `.${domain}/send-sms`, { phone, channel });\r\n}\r\n\r\n/**\r\n * 小程序短信登录\r\n * @param env 环境\r\n * @param code 短信验证码\r\n * @param ticket 短信票据\r\n * @returns\r\n */\r\nexport function smsLogin(env: number, domain: string, ticket: string, code: string): Promise<ActionResult<User>> {\r\n return postForm(env, 'yxnm-pt-iotcas', `.${domain}/login`, { code, ticket }, { 'X-Api-Version': '1' });\r\n}\r\n\r\n/**\r\n * 小程序账户登录\r\n * @param env 环境\r\n * @param userName 用户名\r\n * @param password 密码\r\n * @returns\r\n */\r\nexport function accountLogin(env: number, domain: string, userName: string, password: string): Promise<ActionResult<User>> {\r\n return encryptPwd(env, domain, password).then(({ ticket, password: pwd }) => postForm(env, 'yxnm-pt-iotcas', `.${domain}/login`, { ticket, userName, password: pwd }, { 'X-Api-Version': '2' }));\r\n}\r\n\r\nexport function login(user: User): Promise<boolean> {\r\n return new Promise((resolve, reject) => {\r\n wx.setStorage({\r\n key: 'login-data',\r\n data: user,\r\n success: () => resolve(true),\r\n fail: ({ errMsg }) => reject(errMsg)\r\n });\r\n });\r\n}\r\n","module.exports = require(\"miniprogram-sm-crypto\");","import { getUrl } from './get-url';\r\n\r\ntype Method = 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'CONNECT';\r\n\r\nfunction req<T>(env: number, prefix: string, stuffix: string, method: Method, header: Record<string, string>, data: any): Promise<T> {\r\n return new Promise((resolve, reject) => {\r\n wx.request({\r\n url: getUrl(env, prefix, stuffix),\r\n method,\r\n header,\r\n dataType: 'json',\r\n data,\r\n success: ({ data }) => resolve(data as T),\r\n fail: ({ errMsg }) => reject(errMsg)\r\n })\r\n });\r\n}\r\n\r\nfunction post<T>(env: number, prefix: string, stuffix: string, data: any, header: Record<string, string>): Promise<T> {\r\n return req<T>(env, prefix, stuffix, 'POST', header, data);\r\n}\r\n\r\nexport function postForm<T>(env: number, prefix: string, stuffix: string, data: Record<string, any> | string, header?: Record<string, string>): Promise<T> {\r\n if (typeof data === 'string') {\r\n return post<T>(env, prefix, stuffix, data, {...(header ?? {}), 'content-type': 'application/x-www-form-urlencoded' });\r\n }\r\n const body = Object.entries(data).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join('&')\r\n return post<T>(env, prefix, stuffix, body, {...(header ?? {}), 'content-type': 'application/x-www-form-urlencoded' });\r\n}\r\n\r\nexport function postJson<T>(env: number, prefix: string, stuffix: string, data: any, header?: Record<string, string>): Promise<T> {\r\n return post<T>(env, prefix, stuffix, data, {...(header ?? {}), 'content-type': 'application/json' });\r\n}\r\n\r\nexport function get<T>(env: number, prefix: string, stuffix: string, header?: Record<string, string>): Promise<T> {\r\n return req<T>(env, prefix, stuffix, 'GET', {}, '');\r\n}\r\n","const arr = ['prd', 'qas', 'dev', 'sit', 'uat', 'pre'];\r\nexport function getUrl(env: number, prefix: string, stuffix: string): string {\r\n const sx = arr[env - 1];\r\n return `https://${prefix}-${sx}${stuffix}`;\r\n}\r\n"],"sourceRoot":""}
@@ -0,0 +1,5 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ }
5
+ }
@@ -0,0 +1,32 @@
1
+ <view class="container">
2
+ <text class="title">越秀生猪销售管理系统</text>
3
+ <view class="tab-bar">
4
+ <view class="tab-item {{mode === 1 ? 'active' : ''}}" bindtap="switchTab" data-mode="1">
5
+ 我是采购商
6
+ </view>
7
+ <view class="tab-item {{mode === 2 ? 'active' : ''}}" bindtap="switchTab" data-mode="2">
8
+ 我是内部员工
9
+ </view>
10
+ </view>
11
+ <view wx:if="{{mode === 1}}" class="form">
12
+ <input class="input" placeholder="请输入手机号" model:value="{{phone}}"/>
13
+ <view class="code-container">
14
+ <input class="input code-input" placeholder="请输入验证码" model:value="{{code}}"/>
15
+ <button class="code-btn {{(!seconds && login.isPhoneValid(phone)) ? '': 'disable'}}" bindtap="sendSms">
16
+ {{seconds ? '重新获取' + seconds : '获取验证码'}}
17
+ </button>
18
+ </view>
19
+ <button class="login-btn" bindtap="loginCustomer">立即登录</button>
20
+ </view>
21
+ <view wx:elif="{{mode === 2}}" class="form">
22
+ <input class="input" placeholder="请输入登录账号" model:value="{{userName}}"/>
23
+ <view class="code-container">
24
+ <input type="text" password model:value="{{password}}" class="input code-input" placeholder="请输入登录密码"/>
25
+ </view>
26
+ <button class="login-btn" bindtap="loginStaff">立即登录</button>
27
+ </view>
28
+ <view class="agreement">
29
+ <checkbox model:checked="{{acceptXy}}"/>
30
+ <text>我已阅读并同意《用户服务协议》和《隐私政策》</text>
31
+ </view>
32
+ </view>
@@ -0,0 +1,104 @@
1
+ .container {
2
+ padding: 40rpx 30rpx;
3
+ background-color: #fff;
4
+ height: 100vh;
5
+ display: flex;
6
+ flex-direction: column;
7
+ align-items: center;
8
+ }
9
+
10
+ .title {
11
+ font-size: 36rpx;
12
+ font-weight: bold;
13
+ margin-bottom: 40rpx;
14
+ color: #333;
15
+ }
16
+
17
+ .tab-bar {
18
+ width: 100%;
19
+ display: flex;
20
+ margin-bottom: 60rpx;
21
+ }
22
+
23
+ .tab-item {
24
+ flex: 1;
25
+ text-align: center;
26
+ font-size: 32rpx;
27
+ color: #666;
28
+ padding-bottom: 10rpx;
29
+ border-bottom: 2rpx solid #ddd;
30
+ }
31
+
32
+ .tab-item.active {
33
+ color: #007aff;
34
+ border-bottom: 4rpx solid #007aff;
35
+ }
36
+
37
+ .form {
38
+ width: 100%;
39
+ display: flex;
40
+ flex-direction: column;
41
+ align-items: center;
42
+ }
43
+
44
+ .input {
45
+ width: 100%;
46
+ height: 80rpx;
47
+ border-bottom: 1rpx solid #ddd;
48
+ margin-bottom: 40rpx;
49
+ padding: 0 10rpx;
50
+ box-sizing: border-box;
51
+ }
52
+
53
+ .code-container {
54
+ width: 100%;
55
+ display: flex;
56
+ align-items: center;
57
+ margin-bottom: 40rpx;
58
+ }
59
+
60
+ .code-input {
61
+ flex: 1;
62
+ border-bottom: 1rpx solid #ddd;
63
+ padding: 0 10rpx;
64
+ box-sizing: border-box;
65
+ }
66
+
67
+ .code-btn {
68
+ width: 200rpx;
69
+ height: 60rpx;
70
+ line-height: 60rpx;
71
+ background-color: #007aff;
72
+ color: #fff;
73
+ font-size: 28rpx;
74
+ border-radius: 10rpx;
75
+ margin-left: 20rpx;
76
+ text-align: center;
77
+ }
78
+
79
+ .code-btn[disabled] {
80
+ background-color: #ccc;
81
+ }
82
+
83
+ .login-btn {
84
+ width: 100%;
85
+ height: 90rpx;
86
+ background-color: #007aff;
87
+ color: #fff;
88
+ font-size: 32rpx;
89
+ border-radius: 45rpx;
90
+ line-height: 90rpx;
91
+ text-align: center;
92
+ margin-bottom: 40rpx;
93
+ }
94
+
95
+ .agreement {
96
+ display: flex;
97
+ align-items: center;
98
+ font-size: 24rpx;
99
+ color: #666;
100
+ }
101
+
102
+ .agreement text {
103
+ margin-left: 10rpx;
104
+ }
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "yuexiu-xcx-login",
3
+ "version": "1.0.0",
4
+ "description": "越秀小程序登录组件",
5
+ "main": "miniprogram_dist/index.js",
6
+ "scripts": {
7
+ "dev": "gulp dev --develop",
8
+ "watch": "gulp watch --develop --watch",
9
+ "build": "gulp",
10
+ "dist": "npm run build",
11
+ "clean-dev": "gulp clean --develop",
12
+ "clean": "gulp clean",
13
+ "test": "jest --bail",
14
+ "test-debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --bail",
15
+ "coverage": "jest ./test/* --coverage --bail",
16
+ "lint": "eslint \"src/**/*.ts\" --fix",
17
+ "lint-tools": "eslint \"tools/**/*.js\" --rule \"import/no-extraneous-dependencies: false\" --fix"
18
+ },
19
+ "miniprogram": "miniprogram_dist",
20
+ "jest": {
21
+ "testEnvironment": "jsdom",
22
+ "testURL": "https://jest.test",
23
+ "collectCoverageFrom": [
24
+ "miniprogram_dist/**/*.js"
25
+ ],
26
+ "moduleDirectories": [
27
+ "node_modules",
28
+ "miniprogram_dist"
29
+ ]
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": ""
34
+ },
35
+ "author": "petzold",
36
+ "license": "MIT",
37
+ "devDependencies": {
38
+ "@typescript-eslint/eslint-plugin": "^2.28.0",
39
+ "@typescript-eslint/parser": "^2.28.0",
40
+ "babel-core": "^6.26.3",
41
+ "babel-loader": "^7.1.5",
42
+ "babel-plugin-module-resolver": "^3.2.0",
43
+ "babel-preset-env": "^1.7.0",
44
+ "colors": "^1.3.1",
45
+ "eslint": "^5.14.1",
46
+ "eslint-config-airbnb-base": "13.1.0",
47
+ "eslint-loader": "^2.1.2",
48
+ "eslint-plugin-import": "^2.16.0",
49
+ "eslint-plugin-node": "^7.0.1",
50
+ "eslint-plugin-promise": "^3.8.0",
51
+ "gulp": "^4.0.0",
52
+ "gulp-clean": "^0.4.0",
53
+ "gulp-if": "^2.0.2",
54
+ "gulp-install": "^1.1.0",
55
+ "gulp-less": "^4.0.1",
56
+ "gulp-rename": "^1.4.0",
57
+ "gulp-sourcemaps": "^2.6.5",
58
+ "jest": "^23.5.0",
59
+ "miniprogram-api-typings": "^2.10.3-1",
60
+ "miniprogram-simulate": "^1.2.5",
61
+ "thread-loader": "^2.1.3",
62
+ "through2": "^2.0.3",
63
+ "ts-loader": "^7.0.0",
64
+ "typescript": "^3.8.3",
65
+ "vinyl": "^2.2.0",
66
+ "webpack": "^4.29.5",
67
+ "webpack-node-externals": "^1.7.2"
68
+ },
69
+ "dependencies": {
70
+ "miniprogram-sm-crypto": "^0.3.6"
71
+ }
72
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "setting": {
3
+ "es6": true,
4
+ "postcss": true,
5
+ "minified": true,
6
+ "uglifyFileName": false,
7
+ "enhance": true,
8
+ "packNpmRelationList": [],
9
+ "babelSetting": {
10
+ "ignore": [],
11
+ "disablePlugins": [],
12
+ "outputPath": ""
13
+ },
14
+ "useCompilerPlugins": false,
15
+ "minifyWXML": true
16
+ },
17
+ "compileType": "miniprogram",
18
+ "simulatorPluginLibVersion": {},
19
+ "packOptions": {
20
+ "ignore": [],
21
+ "include": []
22
+ },
23
+ "appid": "wx60929d89783207f5",
24
+ "editorSetting": {}
25
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "libVersion": "3.12.0",
3
+ "projectname": "yuexiu-xcx-login",
4
+ "setting": {
5
+ "urlCheck": true,
6
+ "coverView": true,
7
+ "lazyloadPlaceholderEnable": false,
8
+ "skylineRenderEnable": false,
9
+ "preloadBackgroundData": false,
10
+ "autoAudits": false,
11
+ "showShadowRootInWxmlPanel": true,
12
+ "compileHotReLoad": true
13
+ }
14
+ }